function _newArrowCheck(e,t){if(e!==t)throw new TypeError("Cannot instantiate an arrow function")}exports.__esModule=!0,exports.clearCustomer=clearCustomer,exports.createRequestId=createRequestId,exports.didMount=didMount,exports.didUnmount=didUnmount,exports.forceUpdate=forceUpdate,exports.formatAmount=formatAmount,exports.formatDate=formatDate,exports.formatTime=formatTime,exports.getCustomState=getCustomState,exports.handleQueryResponse=handleQueryResponse,exports.queryCustomerInfo=queryCustomerInfo,exports.renderBalance=renderBalance,exports.renderBalanceSummary=renderBalanceSummary,exports.renderJsx=renderJsx,exports.renderOrders=renderOrders,exports.searchCustomers=searchCustomers,exports.selectCustomer=selectCustomer,exports.setCustomState=setCustomState,exports.setQueryType=setQueryType,exports.updateKeyword=updateKeyword;var _customState={},APP_TYPE="APP_N9NPHVTQLPBPO8MR6WFG",CUSTOMER_FORM_UUID="FORM-NO966791YOK2XKW9DMSEGD5L1IN73UHW3ME6LR1",STORAGE_KEY="tyson.customer-info-query.selected-customer",requestSequence=0,FIELDS={customerNumber:"textField_l6em70k2",customerName:"textField_l6em70k4"};function didMount(){var t=null;try{t=JSON.parse(window.localStorage.getItem(STORAGE_KEY)||"null")}catch(e){t=null}this.setCustomState({keyword:t&&t.customerNumber?t.customerNumber+" - "+(t.customerName||""):"",searching:!1,customers:[],selectedCustomer:t&&t.customerNumber?t:null,queryType:"balance",querying:!1,result:null,error:"",searchVisible:!1})}function didUnmount(){this._customerSearchTimer&&clearTimeout(this._customerSearchTimer)}function setQueryType(e){this.setCustomState({queryType:e,result:null,error:""}),this.forceUpdate()}function updateKeyword(e){var t=this,r=e||"";t.setCustomState({keyword:r,searchVisible:!0,error:""}),t.forceUpdate(),t._customerSearchTimer&&clearTimeout(t._customerSearchTimer),r.trim().length<2?(t.setCustomState({customers:[],searching:!1}),t.forceUpdate()):t._customerSearchTimer=setTimeout(function(){t.searchCustomers(r.trim())},300)}function searchCustomers(e){var t=this,r=this,a={formUuid:CUSTOMER_FORM_UUID,appType:APP_TYPE,currentPage:1,pageSize:20},o=[{key:FIELDS.customerNumber,value:e,type:"TEXT",operator:"contains",componentName:"TextField"}],e=[{key:FIELDS.customerName,value:e,type:"TEXT",operator:"contains",componentName:"TextField"}],s=(r.setCustomState({searching:!0}),r.forceUpdate(),{}),n={};return Object.keys(a).forEach(function(e){_newArrowCheck(this,t),s[e]=a[e],n[e]=a[e]}.bind(this)),s.searchFieldJson=JSON.stringify(o),n.searchFieldJson=JSON.stringify(e),Promise.all([r.utils.yida.searchFormDatas(s),r.utils.yida.searchFormDatas(n)]).then(function(e){var t=this,a={},o=[];e.forEach(function(e){var r=this;_newArrowCheck(this,t),(e&&e.data||e&&e.content&&e.content.data||[]).forEach(function(e){_newArrowCheck(this,r);var e=e.formData||{},t=e[FIELDS.customerNumber];t&&!a[t]&&(a[t]=!0,o.push({customerNumber:t,customerName:e[FIELDS.customerName]||""}))}.bind(this))}.bind(this)),r.setCustomState({customers:o,searching:!1}),r.forceUpdate()}).catch(function(e){r.setCustomState({searching:!1,customers:[]}),r.utils.toast({title:e&&e.message?e.message:"客户查询失败",type:"error"}),r.forceUpdate()})}function selectCustomer(e){try{window.localStorage.setItem(STORAGE_KEY,JSON.stringify(e))}catch(e){}this.setCustomState({selectedCustomer:e,keyword:e.customerNumber+" - "+e.customerName,searchVisible:!1,customers:[],result:null,error:""}),this.forceUpdate()}function clearCustomer(){try{window.localStorage.removeItem(STORAGE_KEY)}catch(e){}this.setCustomState({keyword:"",selectedCustomer:null,customers:[],result:null,error:""}),this.forceUpdate()}function queryCustomerInfo(){var t=this,e=t.getCustomState(),r=e.selectedCustomer;if(r){var e="balance"===e.queryType?"customerBalance":"customerUnlockOrders",a=t.dataSourceMap&&t.dataSourceMap[e];if(a&&a.load){t.setCustomState({querying:!0,error:"",result:null}),t.forceUpdate();r={inputs:JSON.stringify({Headers:{"Content-Type":"application/json"},Query:{},Body:{requestID:t.createRequestId(),CUSTOMER_NUMBER:r.customerNumber,CUSTOMER_NAME:r.customerName}})};try{return Promise.resolve(a.load(r)).then(function(e){t.handleQueryResponse(e)}).catch(function(e){t.setCustomState({querying:!1,result:null,error:e&&e.message?e.message:"SAP查询失败"}),t.utils.toast({title:e&&e.message?e.message:"SAP查询失败",type:"error"}),t.forceUpdate()})}catch(e){t.setCustomState({querying:!1,result:null,error:e&&e.message?e.message:"SAP查询初始化失败"}),t.utils.toast({title:e&&e.message?e.message:"SAP查询初始化失败",type:"error"}),t.forceUpdate()}}else a="查询数据源不可用:"+e+";当前数据源:"+(t.dataSourceMap?Object.keys(t.dataSourceMap).join(", "):"未初始化"),t.setCustomState({error:a,result:null}),t.utils.toast({title:a,type:"error"}),t.forceUpdate()}else t.utils.toast({title:"请先选择客户",type:"warning"})}function handleQueryResponse(t){var e,r=this,t=t&&void 0!==t.Response?t.Response:t;if("string"==typeof(t=(t=t&&void 0!==t.content?t.content:t)&&void 0!==t.serviceReturnValue?t.serviceReturnValue:t))try{t=JSON.parse(t)}catch(e){var a=t.toLowerCase(),a=0<=a.indexOf("502 bad gateway")||0<=a.indexOf("503 service unavailable")||0<=a.indexOf("