var__assign=function(){return__assign=Object.assign||function(t){for(vars,i=1,n=arguments.length;i<n;i++)for(varpins=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);returnt},__assign.apply(this,arguments)};function__spreadArrays(){for(vars=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;varr=Array(s),k=0;for(i=0;i<il;i++)for(vara=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];returnr}varCALL_METHOD_ERROR,hasOwnProperty=Object.prototype.hasOwnProperty,isUndef=function(v){returnnull==v},isArray=Array.isArray,cacheStringFunction=function(fn){varcache=Object.create(null);returnfunction(str){returncache[str]||(cache[str]=fn(str))}},hyphenateRE=/\B([A-Z])/g,hyphenate=cacheStringFunction((function(str){returnstr.replace(hyphenateRE,"-$1").toLowerCase()})),camelizeRE=/-(\w)/g,camelize=cacheStringFunction((function(str){returnstr.replace(camelizeRE,(function(_,c){returnc?c.toUpperCase():""}))})),capitalize=cacheStringFunction((function(str){returnstr.charAt(0).toUpperCase()+str.slice(1)})),PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongetPaths(path,data){if(isArray(path))returnpath;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];varval,key,res=[];returnpath.replace(PATH_RE,(function(match,p1,offset,string){returnres.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}functiongetDataByPath(data,path){vardataPath,paths=getPaths(path,data);for(dataPath=paths.shift();!isUndef(dataPath);){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}returndata}functiongetPageId(page){returnpage.__wxWebviewId__?page.__wxWebviewId__:page.privateProperties?page.privateProperties.slaveId:page.$page?page.$page.id:void0}functiongetPagePath(page){returnpage.route||page.uri}functiongetPageQuery(page){returnpage.options||page.$page&&page.$page.options||{}}functionparsePage(page){return{id:getPageId(page),path:getPagePath(page),query:getPageQuery(page)}}functiongetPageVm(id){varpage=function(id){returngetCurrentPages().find((function(page){returngetPageId(page)===id}))}(id);returnpage&&page.$vm}functionmatchNodeId(vm,nodeId){returnfunction(vm){if(vm._$weex)returnvm._uid;if(vm._$id)returnvm._$id;if(vm.uid)returnvm.uid;varparent_1=function(vm){for(varparent=vm.$parent;parent;){if(parent._$id)returnparent;parent=parent.$parent}}(vm);if(!vm.$parent)return"-1";varvnode=vm.$vnode,context=vnode.context;returncontext&&context!==parent_1&&context._$id?context._$id+";"+parent_1._$id+","+vnode.data.attrs._i:parent_1._$id+","+vnode.data.attrs._i}(vm)===nodeId}functionfindComponentVm(vm,nodeId,isVue3){var_a,_b,_c,_d,_e,_f,_g,_h,_j,_k,_l,_m,res;if(void0===isVue3&&(isVue3=!1),isVue3)if(vm.component&&matchNodeId(vm.component,nodeId))res=vm.component;else{varchildren=[];vm.childreninstanceofArray?children=vm.children:(null===(_b=null===(_a=vm.component)||void0===_a?void0:_a.subTree)||void0===_b?void0:_b.children)&&(null===(_d=null===(_c=vm.component)||void0===_c?void0:_c.subTree)||void0===_d?void0:_d.children)instanceofArray?children=vm.component.subTree.children:(null===(_h=null===(_g=null===(_f=null===(_e=vm.component)||void0===_e?void0:_e.subTree)||void0===_f?void0:_f.component)||void0===_g?void0:_g.subTree)||void0===_h?void0:_h.children)&&(null===(_m=null===(_l=null===(_k=null===(_j=vm.component)||void0===_j?void0:_j.subTree)||void0===_k?void0:_k.component)||void0===_l?void0:_l.subTree)||void0===_m?void0:_m.children)instanceofArray&&(children=vm.component.subTree.component.subTree.children),children.find((function(child){returnres=findComponentVm(child,nodeId,!0)}))}elsevm&&(matchNodeId(vm,nodeId)?res=vm:vm.$children.find((function(child){returnres=findComponentVm(child,nodeId)})));returnres}functiongetComponentVm(pageId,nodeId){varpageVm=getPageVm(pageId);if(pageVm)returnisVue3(pageVm)?findComponentVm(pageVm.$.subTree,nodeId,!0):findComponentVm(pageVm,nodeId)}functiongetData(vm,path){vardata,vmData=vm.$data||vm.data;returnvm.exposed?vmData=__assign(__assign({},vmData),vm.exposed):vm.$&&vm.$.exposed&&(vmData=__assign(__assign({},vmData),vm.$.exposed)),vm&&(data=path?getDataByPath(vmData,path):Object.assign({},vmData)),Promise.resolve({data:data})}functionsetData(vm,data){if(vm){var_isVue3_1=isVue3(vm);Object.keys(data).forEach((function(name){_isVue3_1?(vm.$data||vm.data)[name]=data[name]:vm[name]=data[name]}))}returnPromise.resolve()}functioncallMethod(vm,method,args){returnisVue3(vm)&&(vm=vm.$vm||vm.ctx),newPromise((function(resolve,reject){var_a,_b;if(!vm)returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);if(!vm[method]&&!(null===(_b=vm.$.exposed)||void0===_b?void0:_b[method]))returnreject(CALL_METHOD_ERROR.METHOD_NOT_EXISTS);varobj,ret=vm[method]?vm[method].apply(vm,args):(_a=vm.$.exposed)[method].apply(_a,args);!(obj=ret)||"object"!=typeofobj&&"function"!=typeofobj||"function"!=typeofobj.then?resolve({result:ret}):ret.then((function(res){resolve({result:res})}))}))}functionisVue3(vm){return!vm.$children}!function(CALL_METHOD_ERROR){CALL_METHOD_ERROR.VM_NOT_EXISTS="VM_NOT_EXISTS",CALL_METHOD_ERROR.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(CALL_METHOD_ERROR||(CALL_METHOD_ERROR={}));varpostMessageId=1,postMessageCallbacks={};varsocketInstanceMap=newMap,firstSocketTaskEmitter=function(options){returnnewPromise((function(resolve,reject){varsocketInstanceData=socketInstanceMap.values().next().value;if(socketInstanceData){varmethod_1=options.method;if("onOpen"===method_1)returnhandleOnOpen(socketInstanceData,resolve);if(method_1.startsWith("on"))returnsocketInstanceData.instance[method_1]((function(data){resolve(data)}));"sendMessage"===method_1&&(method_1="send"),socketInstanceData.instance[method_1](__assign(__assign({},options),{success:function(result){resolve({result:result}),"close"===method_1&&socketInstanceMap.delete(socketInstanceMap.keys().next().value)},fail:function(error){reject(error)}}))}elsereject({errMsg:"socketTask not exists."})}))};functionhandleOnOpen(socketInstanceData,resolve){if(socketInstanceData.isOpend)resolve({data:socketInstanceData.openData});else{vartimer_1=setInterval((function(){socketInstanceData.isOpend&&(clearInterval(timer_1),resolve(socketInstanceData.openData))}),200);setTimeout((function(){clearInterval(timer_1)}),2e3)}}varSYNC_APIS=["stopRecord","getRecorderManager","pauseVoice","stopVoice","pauseBackgroundAudio","stopBackgroundAudio","getBackgroundAudioManager","createAudioContext","createInnerAudioContext","createVideoContext","createCameraContext","createMapContext","canIUse","startAccelerometer","stopAccelerometer","startCompass","stopCompass","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","createAnimation","pageScrollTo","createSelectorQuery","createCanvasContext","createContext","drawCanvas","hideKeyboard","stopPullDownRefresh","arrayBufferToBase64","base64ToArrayBuffer"],onApisEventMap=newMap,ON_APIS=["onCompassChange","onThemeChange","onUserCaptureScreen","onWindowResize","onMemoryWarning","onAccelerometerChange","onKeyboardHeightChange","onNetworkStatusChange","onPushMessage","onLocationChange","onGetWifiList","onWifiConnected","onWifiConnectedWithPartialInfo","onSocketOpen","onSocketError","onSocketMessage","onSocketClose"],originUni={},SYNC_API_RE=/^\$|Sync$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting|initUTS|requireUTS|registerUTS/,MOCK_API_BLACKLIST_RE=/^on|^off/;functionisSyncApi(method){returnSYNC_API_RE.test(method)||-1!==SYNC_APIS.indexOf(method)}varApp={getPageStack:function(){returnPromise.resolve({pageStack:getCurrentPages().map((function(page){returnparsePage(page)}))})},getCurrentPage:function(){varpages=getCurrentPages(),len=pages.length;returnnewPromise((function(resolve,reject){len?resolve(parsePage(pages[len-1])):reject(Error("getCurrentPages().length=0"))}))},callUniMethod:function(params,send){varmethod=params.method,args=params.args;returnnewPromise((function(resolve,reject){if("connectSocket"!==method){varid,url;if(ON_APIS.includes(method)){onApisEventMap.has(method)||onApisEventMap.set(method,newMap);varuuid_1=args[0],callback_1=function(data){send({id:uuid_1,result:{method:method,data:data}})};returnmethod.startsWith("onSocket")?firstSocketTaskEmitter({method:method.replace("Socket","")}).then((function(res){returncallback_1(res)})).catch((function(err){returncallback_1(err)})):(onApisEventMap.get(method).set(uuid_1,callback_1),uni[method](callback_1)),resolve({result:null})}if(method.startsWith("off")&&ON_APIS.includes(method.replace("off","on"))){varonMethod=method.replace("off","on");if(onApisEventMap.has(onMethod)){varuuid=args[0];if(void0!==uuid){varcallback=onApisEventMap.get(onMethod).get(uuid);uni[method](callback),onApisEventMap.get(onMethod).delete(uuid)}else{onApisEventMap.get(onMethod).forEach((function(callback){uni[method](callback)})),onApisEventMap.delete(onMethod)}}returnresolve({result:null})}if(method.indexOf("Socket")>0)returnfirstSocketTaskEmitter(__assign({method:method.replace("Socket","")},args[0])).then((function(res){returnresolve(res)})).catch((function(err){returnreject(err)}));if(!uni[method])returnreject(Error("uni."+method+" not exists"));if(isSyncApi(method))returnresolve({result:uni[method].apply(uni,args)});varparams=[Object.assign({},args[0]||{},{success:function(result){setTimeout((function(){resolve({result:result})}),"pageScrollTo"===method?350:0)},fail:function(res){reject(Error(res.errMsg.replace(method+":fail ","")))}})];uni[method].apply(uni,params)}else(id=args[0].id,url=args[0].url,newPromise((function(resolve,reject){varsocketTask=uni.connectSocket({url:url,success:function(){resolve({result:{errMsg:"connectSocket:ok"}})},fail:function(){reject({result:{errMsg:"connectSocket:fail"}})}});socketInstanceMap.set(id,{instance:socketTask,isOpend:!1}),socketTask.onOpen((function(data){socketInstanceMap.get(id).isOpend=!0,socketInstanceMap.get(id).openData=data}))}))).then((function(res){returnresolve(res)})).catch((function(err){returnreject(err)}))}))},mockUniMethod:function(params){varmethod=params.method;if(!uni[method])throwError("uni."+method+" not exists");if(!function(method){return!MOCK_API_BLACKLIST_RE.test(method)}(method))throwError("You can't mock uni."+method);varmockFn,result=params.result,functionDeclaration=params.functionDeclaration;returnisUndef(result)&&isUndef(functionDeclaration)?(originUni[method]&&(uni[method]=originUni[method],deleteoriginUni[method]),Promise.resolve()):(mockFn=isUndef(functionDeclaration)?isSyncApi(method)?function(){returnresult}:function(params){setTimeout((function(){result.errMsg&&-1!==result.errMsg.indexOf(":fail")?params.fail&¶ms.fail(result):params.success&¶ms.success(result),params.complete&¶ms.complete(result)}),4)}:function(){for(varargs=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];returnnewFunction("return "+functionDeclaration)().apply(mockFn,args.concat(params.args))},mockFn.origin=originUni[method]||uni[method],originUni[method]||(originUni[method]=uni[method]),uni[method]=mockFn,Promise.resolve())},captureScreenshot:function(params){returnnewPromise((function(resolve,reject){varpages=getCurrentPages(),len=pages.length;if(len){varpage=pages[len-1];if(page)if("undefined"!=typeofUniElement)page.$viewToTempFilePath({id:params.id,offsetX:null!==params.offsetX?params.offsetX:"0",offsetY:null!==params.offsetY?params.offsetY:"0",wholeContent:1==params.fullPage,path:params.path||"screenshot",overwrite:!0,success:function(res){nativeFileManager.readFile({encoding:"base64",filePath:res.tempFilePath,success:function(readFileRes){resolve({data:readFileRes.data})},fail:function(err){reject(Error("captureScreenshot fail: "+(err.message||err.errMsg)))}})},fail:function(err){reject(Error("captureScreenshot fail: "+(err.message||err.errMsg)))}});else{varwebview=page.$getAppWebview(),bitmap_1=newplus.nativeObj.Bitmap("captureScreenshot","captureScreenshot.png");webview.draw(bitmap_1,(function(res){vardata=bitmap_1.toBase64Data().replace("data:image/png;base64,","").replace("data:image/(null);base64,","");bitmap_1.clear(),resolve({data:data})}),(function(err){reject(Error("captureScreenshot fail: "+err.message))}),{wholeContent:!!params.fullPage})}}elsereject(Error("getCurrentPage fail."))}))},socketEmitter:function(params){returnnewPromise((function(resolve,reject){(function(params){returnnewPromise((function(resolve,reject){if(socketInstanceMap.has(params.id)){varsocketInstanceData=socketInstanceMap.get(params.id),socketTask=socketInstanceData.instance,method_2=params.method,id_1=params.id;if("onOpen"==method_2)returnhandleOnOpen(socketInstanceData,resolve);if(method_2.startsWith("on"))returnsocketTask[method_2]((function(data){resolve({method:"Socket."+method_2,id:id_1,data:data})}));socketTask[method_2](__assign(__assign({},params),{success:function(result){resolve(result),"close"===method_2&&socketInstanceMap.delete(params.id)},fail:function(error){reject(error)}}))}elsereject({errMsg:"socketTask not exists."})}))})(params).then((function(res){returnresolve(res)})).catch((function(err){returnreject(err)}))}))}},App$1=App,Page$1={getData:function(params){returngetData(getPageVm(params.pageId),params.path)},setData:function(params){returnsetData(getPageVm(params.pageId),params.data)},callMethod:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="page."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getPageVm(params.pageId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))},callMethodWithCallback:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="callMethodWithCallback:fail, Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="callMethodWithCallback:fail, page."+params.method+" not exists",_a),callback=params.args[params.args.length-1];callMethod(getPageVm(params.pageId),params.method,params.args).catch((function(type){callback({errMsg:err[type]})}))}};functiongetNodeId(params){returnparams.nodeId||params.elementId}varElement$1={getData:function(params){returngetData(getComponentVm(params.pageId,getNodeId(params)),params.path)},setData:function(params){returnsetData(getComponentVm(params.pageId,getNodeId(params)),params.data)},callMethod:function(params){var_a,nodeId=getNodeId(params),err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Component["+params.pageId+":"+nodeId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="component."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getComponentVm(params.pageId,nodeId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};functiongetDocument(pageId){varpage=getCurrentPages().find((function(page){returnpage.$page.id===pageId}));if(!page)throwError("page["+pageId+"] not found");varweex=page.$vm._$weex;returnweex.document.__$weex__||(weex.document.__$weex__=weex),weex.document}varTAGS={},U_TAGS={};["text","image","input","textarea","video","web-view","slider"].forEach((function(tag){TAGS[tag]=!0,U_TAGS["u-"+tag]=!0}));varBUILITIN=["movable-view","picker","ad","button","checkbox-group","checkbox","form","icon","label","movable-area","navigator","picker-view-column","picker-view","progress","radio-group","radio","rich-text","u-slider","swiper-item","swiper","switch"],BUILITIN_ALIAS=BUILITIN.map((function(tag){returncapitalize(camelize(tag))}));functiontransTagName(el){vartagName=el.type;if(U_TAGS[tagName])returntagName.replace("u-","");varcomponentName=el.__vue__&&el.__vue__.$options.name;return"USlider"===componentName?"slider":componentName&&-1!==BUILITIN_ALIAS.indexOf(componentName)?hyphenate(componentName):tagName}functiontransEl(el){varelem={elementId:el.nodeId,tagName:transTagName(el),nvue:!0},vm=el.__vue__;returnvm&&!vm.$options.isReserved&&(elem.nodeId=vm._uid),"video"===elem.tagName&&(elem.videoId=elem.nodeId),elem}functionquerySelectorByFn(node,match,result){for(varchildren=node.children,i=0;i<children.length;i++){varchildNode=children[i];if(match(childNode)){if(!result)returnchildNode;result.push(childNode)}if(result)querySelectorByFn(childNode,match,result);else{varres=querySelectorByFn(childNode,match,result);if(res)returnres}}returnresult}functionquerySelector(context,selector,result){varmatchSelector,match;if(0===selector.indexOf("#")?(matchSelector=selector.substr(1),match=function(node){returnnode.attr&&node.attr.id===matchSelector}):0===selector.indexOf(".")&&(matchSelector=selector.substr(1),match=function(node){returnnode.classList&&-1!==node.classList.indexOf(matchSelector)}),match){varret_1=querySelectorByFn(context,match,result);if(!ret_1)throwError("Node("+selector+") not exists");returnret_1}if("body"===selector)returnObject.assign({},context,{type:"page"});0===selector.indexOf("uni-")&&(selector=selector.replace("uni-",""));vartagName=TAGS[selector]?"u-"+selector:selector,aliasTagName=-1!==BUILITIN.indexOf(tagName)?capitalize(camelize(tagName)):"",ret=querySelectorByFn(context,(function(node){returnnode.type===tagName||aliasTagName&&node.__vue__&&node.__vue__.$options.name===aliasTagName}),result);if(!ret)throwError("Node("+selector+") not exists");returnret}varDOM_PROPERTIES=[{test:function(names){return2===names.length&&-1!==names.indexOf("document.documentElement.scrollWidth")&&-1!==names.indexOf("document.documentElement.scrollHeight")},call:function(node){varweex=node.__$weex__||node.ownerDocument.__$weex__;returnnewPromise((function(resolve){"scroll-view"===node.type&&1===node.children.length&&(node=node.children[0]),weex.requireModule("dom").getComponentRect(node.ref,(function(res){res.result?resolve([res.size.width,res.size.height]):resolve([0,0])}))}))}},{test:function(names){return1===names.length&&"document.documentElement.scrollTop"===names[0]},call:function(node){varweex=node.__$weex__||node.ownerDocument.__$weex__;returnnewPromise((function(resolve){"scroll-view"===node.type&&1===node.children.length&&(node=node.children[0]),weex.requireModule("dom").getComponentRect(node.ref,(function(res){resolve([res.size&&Math.abs(res.size.top)||0])}))}))}},{test:function(names){return2===names.length&&-1!==names.indexOf("offsetWidth")&&-1!==names.indexOf("offsetHeight")},call:function(node){varweex=node.__$weex__||node.ownerDocument.__$weex__;returnnewPromise((function(resolve){weex.requireModule("dom").getComponentRect(node.ref,(function(res){res.result?resolve([res.size.width,res.size.height]):resolve([0,0])}))}))}},{test:function(names,node){return1===names.length&&"innerText"===names[0]},call:function(node){returnPromise.resolve([toText(node,[]).join("")])}}];functiontoText(node,res){return"u-text"===node.type?res.push(node.attr.value):node.pureChildren.map((function(child){returntoText(child,res)})),res}functionformatHTML(html){returnhtml.replace(/\n/g,"").replace(/<u-/g,"<").replace(/<\/u-/g,"</")}functiontoHTML(node,type){return"outer"===type?"body"===node.role&&"scroll-view"===node.type?"<page>"+formatHTML(toHTML(node,"inner"))+"</page>":formatHTML(node.toString()):formatHTML(node.pureChildren.map((function(child){returnchild.toString()})).join(""))}varFUNCTIONS={input:{input:function(el,value){el.setValue(value)}},textarea:{input:function(el,value){el.setValue(value)}},"scroll-view":{scrollTo:function(el,x,y){el.scrollTo(y)},scrollTop:function(el){return0},scrollLeft:function(el){return0},scrollWidth:function(el){return0},scrollHeight:function(el){return0}},swiper:{swipeTo:function(el,index){el.__vue__.current=index}},"movable-view":{moveTo:function(el,x,y){varvm=el.__vue__;vm.x=x,vm.y=y}},switch:{tap:function(el){varvm=el.__vue__;vm.checked=!vm.checked}},slider:{slideTo:function(el,value){el.__vue__.value=value}}};functiongetRoot(pageId){returngetDocument(pageId).body}varNativeAdapter={getWindow:function(pageId){returngetRoot(pageId)},getDocument:function(pageId){returngetRoot(pageId)},getEl:function(elementId,pageId){varelement=getDocument(pageId).getRef(elementId);if(!element)throwError("element destroyed");returnelement},getOffset:function(node){varweex=node.__$weex__||node.ownerDocument.__$weex__;returnnewPromise((function(resolve){weex.requireModule("dom").getComponentRect(node.ref,(function(res){res.result?resolve({left:res.size.left,top:res.size.top}):resolve({left:0,top:0})}))}))},querySelector:function(context,selector){returnPromise.resolve(transEl(querySelector(context,selector)))},querySelectorAll:function(context,selector){returnPromise.resolve({elements:querySelector(context,selector,[]).map((function(el){returntransEl(el)}))})},queryProperties:function(context,names){varoptions=DOM_PROPERTIES.find((function(options){returnoptions.test(names,context)}));returnoptions?options.call(context).then((function(properties){return{properties:properties}})):Promise.resolve({properties:names.map((function(name){returngetDataByPath(context,name)}))})},queryAttributes:function(context,names){varattr=context.attr;returnPromise.resolve({attributes:names.map((function(name){return"class"===name?(context.classList||[]).join(""):String(attr[name]||attr[camelize(name)]||"")}))})},queryStyles:function(context,names){varstyle=context.style;returnPromise.resolve({styles:names.map((function(name){returnstyle[name]}))})},queryHTML:function(context,type){returnPromise.resolve({html:toHTML(context,type)})},dispatchTapEvent:function(el){returnel.fireEvent("click",{timeStamp:Date.now(),target:el,currentTarget:el},!0),Promise.resolve()},dispatchLongpressEvent:function(el){returnel.fireEvent("longpress",{timeStamp:Date.now(),target:el,currentTarget:el},!0),Promise.resolve()},dispatchTouchEvent:function(el,type,eventInitDict){returneventInitDict||(eventInitDict={}),eventInitDict.touches||(eventInitDict.touches=[]),eventInitDict.changedTouches||(eventInitDict.changedTouches=[]),eventInitDict.touches.length||eventInitDict.touches.push({identifier:Date.now(),target:el}),el.fireEvent(type,Object.assign({timeStamp:Date.now(),target:el,currentTarget:el},eventInitDict),!0),Promise.resolve()},callFunction:function(el,functionName,args){varfn=getDataByPath(FUNCTIONS,functionName);returnfn?Promise.resolve({result:fn.apply(null,__spreadArrays([el],args))}):Promise.reject(Error(functionName+" not exists"))},triggerEvent:function(el,type,detail){varvm=el.__vue__;returnvm?vm.$trigger&&vm.$trigger(type,{},detail):el.fireEvent(type,{timeStamp:Date.now(),target:el,currentTarget:el},!1,{params:[{detail:detail}]}),Promise.resolve()}};functioninitNativeApi(){returnObject.assign({},function(adapter){return{"Page.getElement":function(params){returnadapter.querySelector(adapter.getDocument(params.pageId),params.selector)},"Page.getElements":function(params){returnadapter.querySelectorAll(adapter.getDocument(params.pageId),params.selector)},"Page.getWindowProperties":function(params){returnadapter.queryProperties(adapter.getWindow(params.pageId),params.names)}}}(NativeAdapter),function(adapter){vargetEl=function(params){returnadapter.getEl(params.elementId,params.pageId)};return{"Element.getElement":function(params){returnadapter.querySelector(getEl(params),params.selector)},"Element.getElements":function(params){returnadapter.querySelectorAll(getEl(params),params.selector)},"Element.getDOMProperties":function(params){returnadapter.queryProperties(getEl(params),params.names)},"Element.getProperties":function(params){varel=getEl(params),ctx=el.__vue__||el.attr||{};returnel.__vueParentComponent&&(ctx=Object.assign({},ctx,el.__vueParentComponent.attrs,el.__vueParentComponent.props)),adapter.queryProperties(ctx,params.names)},"Element.getOffset":function(params){returnadapter.getOffset(getEl(params))},"Element.getAttributes":function(params){returnadapter.queryAttributes(getEl(params),params.names)},"Element.getStyles":function(params){returnadapter.queryStyles(getEl(params),params.names)},"Element.getHTML":function(params){returnadapter.queryHTML(getEl(params),params.type)},"Element.tap":function(params){returnadapter.dispatchTapEvent(getEl(params))},"Element.longpress":function(params){returnadapter.dispatchLongpressEvent(getEl(params))},"Element.touchstart":function(params){returnadapter.dispatchTouchEvent(getEl(params),"touchstart",params)},"Element.touchmove":function(params){returnadapter.dispatchTouchEvent(getEl(params),"touchmove",params)},"Element.touchend":function(params){returnadapter.dispatchTouchEvent(getEl(params),"touchend",params)},"Element.callFunction":function(params){returnadapter.callFunction(getEl(params),params.functionName,params.args)},"Element.triggerEvent":function(params){returnadapter.triggerEvent(getEl(params),params.type,params.detail)}}}(NativeAdapter))}varE=function(){};E.prototype={on:function(name,callback,ctx){vare=this.e||(this.e={});return(e[name]||(e[name]=[])).push({fn:callback,ctx:ctx}),this},once:function(name,callback,ctx){varself=this;functionlistener(){self.off(name,listener),callback.apply(ctx,arguments)}returnlistener._=callback,this.on(name,listener,ctx)},emit:function(name){for(vardata=[].slice.call(arguments,1),evtArr=((this.e||(this.e={}))[name]||[]).slice(),i=0,len=evtArr.length;i<len;i++)evtArr[i].fn.apply(evtArr[i].ctx,data);returnthis},off:function(name,callback){vare=this.e||(this.e={}),evts=e[name],liveEvents=[];if(evts&&callback){for(vari=evts.length-1;i>=0;i--)if(evts[i].fn===callback||evts[i].fn._===callback){evts.splice(i,1);break}liveEvents=evts}returnliveEvents.length?e[name]=liveEvents:deletee[name],this}};varEmitter=E;functioninitBridge(subscribeNamespace){varemitter=newEmitter;return{subscribe:function(event,callback,once){void0===once&&(once=!1),emitter[once?"once":"on"](subscribeNamespace+"."+event,callback)},subscribeHandler:function(event,args,pageId){emitter.emit(subscribeNamespace+"."+event,args,pageId)}}}varextend=Object.assign,UniXServiceJSBridge=extend(initBridge("service"),{publishHandler:function(event,args,pageId){UniViewJSBridge.subscribeHandler(event,args,pageId)}}),UniXViewJSBridge=extend(initBridge("view"),{publishHandler:function(event,args,pageId){UniServiceJSBridge.subscribeHandler(event,args,pageId)}});if("undefined"==typeofUniServiceJSBridge&&"undefined"==typeofUniViewJSBridge){var__global__="undefined"==typeofglobalThis?Function("return this")():globalThis;__global__.UniServiceJSBridge=UniXServiceJSBridge,__global__.UniViewJSBridge=UniXViewJSBridge}varApi={};Object.keys(App$1).forEach((function(method){Api["App."+method]=App$1[method]})),Object.keys(Page$1).forEach((function(method){Api["Page."+method]=Page$1[method]})),Object.keys(Element$1).forEach((function(method){Api["Element."+method]=Element$1[method]}));varNVueApi,fallback,socketTask,wsEndpoint=process.env.UNI_AUTOMATOR_WS_ENDPOINT;functionsend(data){socketTask.send({data:JSON.stringify(data)})}functiononMessage(res){var_a=JSON.parse(res.data),id=_a.id,method=_a.method,params=_a.params,data={id:id},fn=Api[method];if(!fn){if(fallback){varresult=fallback(id,method,params,data);if(!0===result)return;fn=result}if(!fn)returndata.error={message:method+" unimplemented"},send(data)}try{fn(params,send).then((function(res){res&&(data.result=res)})).catch((function(err){data.error={message:err.message}})).finally((function(){send(data)}))}catch(err){data.error={message:err.message},send(data)}}fallback=function(id,method,params,data){varpageId=params.pageId,page=function(pageId){varpages=getCurrentPages();if(!pageId)returnpages[pages.length-1];returnpages.find((function(page){returnpage.$page.id===pageId}))}(pageId);returnpage?!page.$page.meta.isNVue?(UniServiceJSBridge.publishHandler("sendAutoMessage",{id:id,method:method,params:params},pageId),!0):(NVueApi||(NVueApi=initNativeApi()),NVueApi[method]):(data.error={message:"page["+pageId+"] not exists"},send(data),!0)},UniServiceJSBridge.subscribe("onAutoMessageReceive",(function(res){send(res)})),setTimeout((function(){if("undefined"!=typeofwindow&&(window.__uniapp_x_||window.__uniapp_x_postMessage))!function(data,callback){var_a,id=0;callback&&(id=postMessageId++,postMessageCallbacks[id]=callback);varmessage={data:{id:id,type:"automator",data:data}};console.log("postMessageToUniXWebView",message),(null===(_a=null===window||void0===window?void0:window.__uniapp_x_)||void0===_a?void0:_a.postMessage)?window.__uniapp_x_.postMessage(JSON.stringify(message)):(null===window||void0===window?void0:window.__uniapp_x_postMessage)&&window.__uniapp_x_postMessage({data:message})}({action:"ready"});else{if(wsEndpoint&&wsEndpoint.endsWith(":0000"))return;void0===options&&(options={}),(socketTask=uni.connectSocket({url:options.wsEndpoint||wsEndpoint,complete:function(){}})).onMessage(onMessage),socketTask.onOpen((function(res){options.success&&options.success(),console.log("已开启自动化测试...")})),socketTask.onError((function(res){console.log("automator.onError",res)})),socketTask.onClose((function(){options.fail&&options.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))}varoptions}),500);export{send};
var__assign=function(){return__assign=Object.assign||function(t){for(vars,i=1,n=arguments.length;i<n;i++)for(varpins=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);returnt},__assign.apply(this,arguments)};function__spreadArrays(){for(vars=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;varr=Array(s),k=0;for(i=0;i<il;i++)for(vara=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];returnr}varCALL_METHOD_ERROR,hasOwnProperty=Object.prototype.hasOwnProperty,isUndef=function(v){returnnull==v},isArray=Array.isArray,cacheStringFunction=function(fn){varcache=Object.create(null);returnfunction(str){returncache[str]||(cache[str]=fn(str))}},hyphenateRE=/\B([A-Z])/g,hyphenate=cacheStringFunction((function(str){returnstr.replace(hyphenateRE,"-$1").toLowerCase()})),camelizeRE=/-(\w)/g,camelize=cacheStringFunction((function(str){returnstr.replace(camelizeRE,(function(_,c){returnc?c.toUpperCase():""}))})),capitalize=cacheStringFunction((function(str){returnstr.charAt(0).toUpperCase()+str.slice(1)})),PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongetPaths(path,data){if(isArray(path))returnpath;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];varval,key,res=[];returnpath.replace(PATH_RE,(function(match,p1,offset,string){returnres.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}functiongetDataByPath(data,path){vardataPath,paths=getPaths(path,data);for(dataPath=paths.shift();!isUndef(dataPath);){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}returndata}functiongetPageId(page){returnpage.__wxWebviewId__?page.__wxWebviewId__:page.privateProperties?page.privateProperties.slaveId:page.$page?page.$page.id:void0}functiongetPagePath(page){returnpage.route||page.uri}functiongetPageQuery(page){returnpage.options||page.$page&&page.$page.options||{}}functionparsePage(page){return{id:getPageId(page),path:getPagePath(page),query:getPageQuery(page)}}functiongetPageVm(id){varpage=function(id){returngetCurrentPages().find((function(page){returngetPageId(page)===id}))}(id);returnpage&&page.$vm}functionmatchNodeId(vm,nodeId){returnfunction(vm){if(vm._$weex)returnvm._uid;if(vm._$id)returnvm._$id;if(vm.uid)returnvm.uid;varparent_1=function(vm){for(varparent=vm.$parent;parent;){if(parent._$id)returnparent;parent=parent.$parent}}(vm);if(!vm.$parent)return"-1";varvnode=vm.$vnode,context=vnode.context;returncontext&&context!==parent_1&&context._$id?context._$id+";"+parent_1._$id+","+vnode.data.attrs._i:parent_1._$id+","+vnode.data.attrs._i}(vm)===nodeId}functionfindComponentVm(vm,nodeId,isVue3){var_a,_b,_c,_d,_e,_f,_g,_h,_j,_k,_l,_m,res;if(void0===isVue3&&(isVue3=!1),isVue3)if(vm.component&&matchNodeId(vm.component,nodeId))res=vm.component;else{varchildren=[];vm.childreninstanceofArray?children=vm.children:(null===(_b=null===(_a=vm.component)||void0===_a?void0:_a.subTree)||void0===_b?void0:_b.children)&&(null===(_d=null===(_c=vm.component)||void0===_c?void0:_c.subTree)||void0===_d?void0:_d.children)instanceofArray?children=vm.component.subTree.children:(null===(_h=null===(_g=null===(_f=null===(_e=vm.component)||void0===_e?void0:_e.subTree)||void0===_f?void0:_f.component)||void0===_g?void0:_g.subTree)||void0===_h?void0:_h.children)&&(null===(_m=null===(_l=null===(_k=null===(_j=vm.component)||void0===_j?void0:_j.subTree)||void0===_k?void0:_k.component)||void0===_l?void0:_l.subTree)||void0===_m?void0:_m.children)instanceofArray&&(children=vm.component.subTree.component.subTree.children),children.find((function(child){returnres=findComponentVm(child,nodeId,!0)}))}elsevm&&(matchNodeId(vm,nodeId)?res=vm:vm.$children.find((function(child){returnres=findComponentVm(child,nodeId)})));returnres}functiongetComponentVm(pageId,nodeId){varpageVm=getPageVm(pageId);if(pageVm)returnisVue3(pageVm)?findComponentVm(pageVm.$.subTree,nodeId,!0):findComponentVm(pageVm,nodeId)}functiongetData(vm,path){vardata,vmData=vm.$data||vm.data;returnvm.exposed?vmData=__assign(__assign({},vmData),vm.exposed):vm.$&&vm.$.exposed&&(vmData=__assign(__assign({},vmData),vm.$.exposed)),vm&&(data=path?getDataByPath(vmData,path):Object.assign({},vmData)),Promise.resolve({data:data})}functionsetData(vm,data){if(vm){var_isVue3_1=isVue3(vm);Object.keys(data).forEach((function(name){_isVue3_1?(vm.$data||vm.data)[name]=data[name]:vm[name]=data[name]}))}returnPromise.resolve()}functioncallMethod(vm,method,args){returnisVue3(vm)&&(vm=vm.$vm||vm.ctx),newPromise((function(resolve,reject){var_a,_b;if(!vm)returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);if(!vm[method]&&!(null===(_b=vm.$.exposed)||void0===_b?void0:_b[method]))returnreject(CALL_METHOD_ERROR.METHOD_NOT_EXISTS);varobj,ret=vm[method]?vm[method].apply(vm,args):(_a=vm.$.exposed)[method].apply(_a,args);!(obj=ret)||"object"!=typeofobj&&"function"!=typeofobj||"function"!=typeofobj.then?resolve({result:ret}):ret.then((function(res){resolve({result:res})}))}))}functionisVue3(vm){return!vm.$children}!function(CALL_METHOD_ERROR){CALL_METHOD_ERROR.VM_NOT_EXISTS="VM_NOT_EXISTS",CALL_METHOD_ERROR.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(CALL_METHOD_ERROR||(CALL_METHOD_ERROR={}));varpostMessageId=1,postMessageCallbacks={};varsocketInstanceMap=newMap,firstSocketTaskEmitter=function(options){returnnewPromise((function(resolve,reject){varsocketInstanceData=socketInstanceMap.values().next().value;if(socketInstanceData){varmethod_1=options.method;if("onOpen"===method_1)returnhandleOnOpen(socketInstanceData,resolve);if(method_1.startsWith("on"))returnsocketInstanceData.instance[method_1]((function(data){resolve(data)}));"sendMessage"===method_1&&(method_1="send"),socketInstanceData.instance[method_1](__assign(__assign({},options),{success:function(result){resolve({result:result}),"close"===method_1&&socketInstanceMap.delete(socketInstanceMap.keys().next().value)},fail:function(error){reject(error)}}))}elsereject({errMsg:"socketTask not exists."})}))};functionhandleOnOpen(socketInstanceData,resolve){if(socketInstanceData.isOpend)resolve({data:socketInstanceData.openData});else{vartimer_1=setInterval((function(){socketInstanceData.isOpend&&(clearInterval(timer_1),resolve(socketInstanceData.openData))}),200);setTimeout((function(){clearInterval(timer_1)}),2e3)}}varSYNC_APIS=["stopRecord","getRecorderManager","pauseVoice","stopVoice","pauseBackgroundAudio","stopBackgroundAudio","getBackgroundAudioManager","createAudioContext","createInnerAudioContext","createVideoContext","createCameraContext","createMapContext","canIUse","startAccelerometer","stopAccelerometer","startCompass","stopCompass","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","createAnimation","pageScrollTo","createSelectorQuery","createCanvasContext","createContext","drawCanvas","hideKeyboard","stopPullDownRefresh","arrayBufferToBase64","base64ToArrayBuffer"],onApisEventMap=newMap,ON_APIS=["onCompassChange","onThemeChange","onUserCaptureScreen","onWindowResize","onMemoryWarning","onAccelerometerChange","onKeyboardHeightChange","onNetworkStatusChange","onPushMessage","onLocationChange","onGetWifiList","onWifiConnected","onWifiConnectedWithPartialInfo","onSocketOpen","onSocketError","onSocketMessage","onSocketClose"],originUni={},SYNC_API_RE=/^\$|Sync$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting|initUTS|requireUTS|registerUTS/,MOCK_API_BLACKLIST_RE=/^on|^off/;functionisSyncApi(method){returnSYNC_API_RE.test(method)||-1!==SYNC_APIS.indexOf(method)}varApp={getPageStack:function(){returnPromise.resolve({pageStack:getCurrentPages().map((function(page){returnparsePage(page)}))})},getCurrentPage:function(){varpages=getCurrentPages(),len=pages.length;returnnewPromise((function(resolve,reject){len?resolve(parsePage(pages[len-1])):reject(Error("getCurrentPages().length=0"))}))},callUniMethod:function(params,send){varmethod=params.method,args=params.args;returnnewPromise((function(resolve,reject){if("connectSocket"!==method){varid,url;if(ON_APIS.includes(method)){onApisEventMap.has(method)||onApisEventMap.set(method,newMap);varuuid_1=args[0],callback_1=function(data){send({id:uuid_1,result:{method:method,data:data}})};returnmethod.startsWith("onSocket")?firstSocketTaskEmitter({method:method.replace("Socket","")}).then((function(res){returncallback_1(res)})).catch((function(err){returncallback_1(err)})):(onApisEventMap.get(method).set(uuid_1,callback_1),uni[method](callback_1)),resolve({result:null})}if(method.startsWith("off")&&ON_APIS.includes(method.replace("off","on"))){varonMethod=method.replace("off","on");if(onApisEventMap.has(onMethod)){varuuid=args[0];if(void0!==uuid){varcallback=onApisEventMap.get(onMethod).get(uuid);uni[method](callback),onApisEventMap.get(onMethod).delete(uuid)}else{onApisEventMap.get(onMethod).forEach((function(callback){uni[method](callback)})),onApisEventMap.delete(onMethod)}}returnresolve({result:null})}if(method.indexOf("Socket")>0)returnfirstSocketTaskEmitter(__assign({method:method.replace("Socket","")},args[0])).then((function(res){returnresolve(res)})).catch((function(err){returnreject(err)}));if(!uni[method])returnreject(Error("uni."+method+" not exists"));if(isSyncApi(method))returnresolve({result:uni[method].apply(uni,args)});varparams=[Object.assign({},args[0]||{},{success:function(result){setTimeout((function(){resolve({result:result})}),"pageScrollTo"===method?350:0)},fail:function(res){reject(Error(res.errMsg.replace(method+":fail ","")))}})];uni[method].apply(uni,params)}else(id=args[0].id,url=args[0].url,newPromise((function(resolve,reject){varsocketTask=uni.connectSocket({url:url,success:function(){resolve({result:{errMsg:"connectSocket:ok"}})},fail:function(){reject({result:{errMsg:"connectSocket:fail"}})}});socketInstanceMap.set(id,{instance:socketTask,isOpend:!1}),socketTask.onOpen((function(data){socketInstanceMap.get(id).isOpend=!0,socketInstanceMap.get(id).openData=data}))}))).then((function(res){returnresolve(res)})).catch((function(err){returnreject(err)}))}))},mockUniMethod:function(params){varmethod=params.method;if(!uni[method])throwError("uni."+method+" not exists");if(!function(method){return!MOCK_API_BLACKLIST_RE.test(method)}(method))throwError("You can't mock uni."+method);varmockFn,result=params.result,functionDeclaration=params.functionDeclaration;returnisUndef(result)&&isUndef(functionDeclaration)?(originUni[method]&&(uni[method]=originUni[method],deleteoriginUni[method]),Promise.resolve()):(mockFn=isUndef(functionDeclaration)?isSyncApi(method)?function(){returnresult}:function(params){setTimeout((function(){result.errMsg&&-1!==result.errMsg.indexOf(":fail")?params.fail&¶ms.fail(result):params.success&¶ms.success(result),params.complete&¶ms.complete(result)}),4)}:function(){for(varargs=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];returnnewFunction("return "+functionDeclaration)().apply(mockFn,args.concat(params.args))},mockFn.origin=originUni[method]||uni[method],originUni[method]||(originUni[method]=uni[method]),uni[method]=mockFn,Promise.resolve())},captureScreenshot:function(params){returnnewPromise((function(resolve,reject){varpages=getCurrentPages(),len=pages.length;if(len){varpage=pages[len-1];if(page)if("undefined"!=typeofUniElement)page.$viewToTempFilePath({id:params.id,offsetX:null!==params.offsetX?params.offsetX:"0",offsetY:null!==params.offsetY?params.offsetY:"0",wholeContent:1==params.fullPage,path:params.path||"screenshot",overwrite:!0,success:function(res){nativeFileManager.readFile({encoding:"base64",filePath:res.tempFilePath,success:function(readFileRes){resolve({data:readFileRes.data})},fail:function(err){reject(Error("captureScreenshot fail: "+(err.message||err.errMsg)))}})},fail:function(err){reject(Error("captureScreenshot fail: "+(err.message||err.errMsg)))}});else{varwebview=page.$getAppWebview(),bitmap_1=newplus.nativeObj.Bitmap("captureScreenshot","captureScreenshot.png");webview.draw(bitmap_1,(function(res){vardata=bitmap_1.toBase64Data().replace("data:image/png;base64,","").replace("data:image/(null);base64,","");bitmap_1.clear(),resolve({data:data})}),(function(err){reject(Error("captureScreenshot fail: "+err.message))}),{wholeContent:!!params.fullPage})}}elsereject(Error("getCurrentPage fail."))}))},socketEmitter:function(params){returnnewPromise((function(resolve,reject){(function(params){returnnewPromise((function(resolve,reject){if(socketInstanceMap.has(params.id)){varsocketInstanceData=socketInstanceMap.get(params.id),socketTask=socketInstanceData.instance,method_2=params.method,id_1=params.id;if("onOpen"==method_2)returnhandleOnOpen(socketInstanceData,resolve);if(method_2.startsWith("on"))returnsocketTask[method_2]((function(data){resolve({method:"Socket."+method_2,id:id_1,data:data})}));socketTask[method_2](__assign(__assign({},params),{success:function(result){resolve(result),"close"===method_2&&socketInstanceMap.delete(params.id)},fail:function(error){reject(error)}}))}elsereject({errMsg:"socketTask not exists."})}))})(params).then((function(res){returnresolve(res)})).catch((function(err){returnreject(err)}))}))}},App$1=App,Page$1={getData:function(params){returngetData(getPageVm(params.pageId),params.path)},setData:function(params){returnsetData(getPageVm(params.pageId),params.data)},callMethod:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="page."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getPageVm(params.pageId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))},callMethodWithCallback:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="callMethodWithCallback:fail, Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="callMethodWithCallback:fail, page."+params.method+" not exists",_a),callback=params.args[params.args.length-1];callMethod(getPageVm(params.pageId),params.method,params.args).catch((function(type){callback({errMsg:err[type]})}))}};functiongetNodeId(params){returnparams.nodeId||params.elementId}varElement$1={getData:function(params){returngetData(getComponentVm(params.pageId,getNodeId(params)),params.path)},setData:function(params){returnsetData(getComponentVm(params.pageId,getNodeId(params)),params.data)},callMethod:function(params){var_a,nodeId=getNodeId(params),err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Component["+params.pageId+":"+nodeId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="component."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getComponentVm(params.pageId,nodeId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};functiongetDocument(pageId){varpage=getCurrentPages().find((function(page){returnpage.$page.id===pageId}));if(!page)throwError("page["+pageId+"] not found");varweex=page.$vm._$weex;returnweex.document.__$weex__||(weex.document.__$weex__=weex),weex.document}varTAGS={},U_TAGS={};["text","image","input","textarea","video","web-view","slider"].forEach((function(tag){TAGS[tag]=!0,U_TAGS["u-"+tag]=!0}));varBUILITIN=["movable-view","picker","ad","button","checkbox-group","checkbox","form","icon","label","movable-area","navigator","picker-view-column","picker-view","progress","radio-group","radio","rich-text","u-slider","swiper-item","swiper","switch"],BUILITIN_ALIAS=BUILITIN.map((function(tag){returncapitalize(camelize(tag))}));functiontransTagName(el){vartagName=el.type;if(U_TAGS[tagName])returntagName.replace("u-","");varcomponentName=el.__vue__&&el.__vue__.$options.name;return"USlider"===componentName?"slider":componentName&&-1!==BUILITIN_ALIAS.indexOf(componentName)?hyphenate(componentName):tagName}functiontransEl(el){varelem={elementId:el.nodeId,tagName:transTagName(el),nvue:!0},vm=el.__vue__;returnvm&&!vm.$options.isReserved&&(elem.nodeId=vm._uid),"video"===elem.tagName&&(elem.videoId=elem.nodeId),elem}functionquerySelectorByFn(node,match,result){for(varchildren=node.children,i=0;i<children.length;i++){varchildNode=children[i];if(match(childNode)){if(!result)returnchildNode;result.push(childNode)}if(result)querySelectorByFn(childNode,match,result);else{varres=querySelectorByFn(childNode,match,result);if(res)returnres}}returnresult}functionquerySelector(context,selector,result){varmatchSelector,match;if(0===selector.indexOf("#")?(matchSelector=selector.substr(1),match=function(node){returnnode.attr&&node.attr.id===matchSelector}):0===selector.indexOf(".")&&(matchSelector=selector.substr(1),match=function(node){returnnode.classList&&-1!==node.classList.indexOf(matchSelector)}),match){varret_1=querySelectorByFn(context,match,result);if(!ret_1)throwError("Node("+selector+") not exists");returnret_1}if("body"===selector)returnObject.assign({},context,{type:"page"});0===selector.indexOf("uni-")&&(selector=selector.replace("uni-",""));vartagName=TAGS[selector]?"u-"+selector:selector,aliasTagName=-1!==BUILITIN.indexOf(tagName)?capitalize(camelize(tagName)):"",ret=querySelectorByFn(context,(function(node){returnnode.type===tagName||aliasTagName&&node.__vue__&&node.__vue__.$options.name===aliasTagName}),result);if(!ret)throwError("Node("+selector+") not exists");returnret}varDOM_PROPERTIES=[{test:function(names){return2===names.length&&-1!==names.indexOf("document.documentElement.scrollWidth")&&-1!==names.indexOf("document.documentElement.scrollHeight")},call:function(node){varweex=node.__$weex__||node.ownerDocument.__$weex__;returnnewPromise((function(resolve){"scroll-view"===node.type&&1===node.children.length&&(node=node.children[0]),weex.requireModule("dom").getComponentRect(node.ref,(function(res){res.result?resolve([res.size.width,res.size.height]):resolve([0,0])}))}))}},{test:function(names){return1===names.length&&"document.documentElement.scrollTop"===names[0]},call:function(node){varweex=node.__$weex__||node.ownerDocument.__$weex__;returnnewPromise((function(resolve){"scroll-view"===node.type&&1===node.children.length&&(node=node.children[0]),weex.requireModule("dom").getComponentRect(node.ref,(function(res){resolve([res.size&&Math.abs(res.size.top)||0])}))}))}},{test:function(names){return2===names.length&&-1!==names.indexOf("offsetWidth")&&-1!==names.indexOf("offsetHeight")},call:function(node){varweex=node.__$weex__||node.ownerDocument.__$weex__;returnnewPromise((function(resolve){weex.requireModule("dom").getComponentRect(node.ref,(function(res){res.result?resolve([res.size.width,res.size.height]):resolve([0,0])}))}))}},{test:function(names,node){return1===names.length&&"innerText"===names[0]},call:function(node){returnPromise.resolve([toText(node,[]).join("")])}}];functiontoText(node,res){return"u-text"===node.type?res.push(node.attr.value):node.pureChildren.map((function(child){returntoText(child,res)})),res}functionformatHTML(html){returnhtml.replace(/\n/g,"").replace(/<u-/g,"<").replace(/<\/u-/g,"</")}functiontoHTML(node,type){return"outer"===type?"body"===node.role&&"scroll-view"===node.type?"<page>"+formatHTML(toHTML(node,"inner"))+"</page>":formatHTML(node.toString()):formatHTML(node.pureChildren.map((function(child){returnchild.toString()})).join(""))}varFUNCTIONS={input:{input:function(el,value){el.setValue(value)}},textarea:{input:function(el,value){el.setValue(value)}},"scroll-view":{scrollTo:function(el,x,y){el.scrollTo(y)},scrollTop:function(el){return0},scrollLeft:function(el){return0},scrollWidth:function(el){return0},scrollHeight:function(el){return0}},swiper:{swipeTo:function(el,index){el.__vue__.current=index}},"movable-view":{moveTo:function(el,x,y){varvm=el.__vue__;vm.x=x,vm.y=y}},switch:{tap:function(el){varvm=el.__vue__;vm.checked=!vm.checked}},slider:{slideTo:function(el,value){el.__vue__.value=value}}};functiongetRoot(pageId){returngetDocument(pageId).body}varNativeAdapter={getWindow:function(pageId){returngetRoot(pageId)},getDocument:function(pageId){returngetRoot(pageId)},getEl:function(elementId,pageId){varelement=getDocument(pageId).getRef(elementId);if(!element)throwError("element destroyed");returnelement},getOffset:function(node){varweex=node.__$weex__||node.ownerDocument.__$weex__;returnnewPromise((function(resolve){weex.requireModule("dom").getComponentRect(node.ref,(function(res){res.result?resolve({left:res.size.left,top:res.size.top}):resolve({left:0,top:0})}))}))},querySelector:function(context,selector){returnPromise.resolve(transEl(querySelector(context,selector)))},querySelectorAll:function(context,selector){returnPromise.resolve({elements:querySelector(context,selector,[]).map((function(el){returntransEl(el)}))})},queryProperties:function(context,names){varoptions=DOM_PROPERTIES.find((function(options){returnoptions.test(names,context)}));returnoptions?options.call(context).then((function(properties){return{properties:properties}})):Promise.resolve({properties:names.map((function(name){returngetDataByPath(context,name)}))})},queryAttributes:function(context,names){varattr=context.attr;returnPromise.resolve({attributes:names.map((function(name){return"class"===name?(context.classList||[]).join(""):String(attr[name]||attr[camelize(name)]||"")}))})},queryStyles:function(context,names){varstyle=context.style;returnPromise.resolve({styles:names.map((function(name){returnstyle[name]}))})},queryHTML:function(context,type){returnPromise.resolve({html:toHTML(context,type)})},dispatchTapEvent:function(el){returnel.fireEvent("click",{timeStamp:Date.now(),target:el,currentTarget:el},!0),Promise.resolve()},dispatchLongpressEvent:function(el){returnel.fireEvent("longpress",{timeStamp:Date.now(),target:el,currentTarget:el},!0),Promise.resolve()},dispatchTouchEvent:function(el,type,eventInitDict){returneventInitDict||(eventInitDict={}),eventInitDict.touches||(eventInitDict.touches=[]),eventInitDict.changedTouches||(eventInitDict.changedTouches=[]),eventInitDict.touches.length||eventInitDict.touches.push({identifier:Date.now(),target:el}),el.fireEvent(type,Object.assign({timeStamp:Date.now(),target:el,currentTarget:el},eventInitDict),!0),Promise.resolve()},callFunction:function(el,functionName,args){varfn=getDataByPath(FUNCTIONS,functionName);returnfn?Promise.resolve({result:fn.apply(null,__spreadArrays([el],args))}):Promise.reject(Error(functionName+" not exists"))},triggerEvent:function(el,type,detail){varvm=el.__vue__;returnvm?vm.$trigger&&vm.$trigger(type,{},detail):el.fireEvent(type,{timeStamp:Date.now(),target:el,currentTarget:el},!1,{params:[{detail:detail}]}),Promise.resolve()}};functioninitNativeApi(){returnObject.assign({},function(adapter){return{"Page.getElement":function(params){returnadapter.querySelector(adapter.getDocument(params.pageId),params.selector)},"Page.getElements":function(params){returnadapter.querySelectorAll(adapter.getDocument(params.pageId),params.selector)},"Page.getWindowProperties":function(params){returnadapter.queryProperties(adapter.getWindow(params.pageId),params.names)}}}(NativeAdapter),function(adapter){vargetEl=function(params){returnadapter.getEl(params.elementId,params.pageId)};return{"Element.getElement":function(params){returnadapter.querySelector(getEl(params),params.selector)},"Element.getElements":function(params){returnadapter.querySelectorAll(getEl(params),params.selector)},"Element.getDOMProperties":function(params){returnadapter.queryProperties(getEl(params),params.names)},"Element.getProperties":function(params){varel=getEl(params),ctx=el.__vue__||el.attr||{};returnel.__vueParentComponent&&(ctx=Object.assign({},ctx,el.__vueParentComponent.attrs,el.__vueParentComponent.props)),adapter.queryProperties(ctx,params.names)},"Element.getOffset":function(params){returnadapter.getOffset(getEl(params))},"Element.getAttributes":function(params){returnadapter.queryAttributes(getEl(params),params.names)},"Element.getStyles":function(params){returnadapter.queryStyles(getEl(params),params.names)},"Element.getHTML":function(params){returnadapter.queryHTML(getEl(params),params.type)},"Element.tap":function(params){returnadapter.dispatchTapEvent(getEl(params))},"Element.longpress":function(params){returnadapter.dispatchLongpressEvent(getEl(params))},"Element.touchstart":function(params){returnadapter.dispatchTouchEvent(getEl(params),"touchstart",params)},"Element.touchmove":function(params){returnadapter.dispatchTouchEvent(getEl(params),"touchmove",params)},"Element.touchend":function(params){returnadapter.dispatchTouchEvent(getEl(params),"touchend",params)},"Element.callFunction":function(params){returnadapter.callFunction(getEl(params),params.functionName,params.args)},"Element.triggerEvent":function(params){returnadapter.triggerEvent(getEl(params),params.type,params.detail)}}}(NativeAdapter))}varE=function(){};E.prototype={on:function(name,callback,ctx){vare=this.e||(this.e={});return(e[name]||(e[name]=[])).push({fn:callback,ctx:ctx}),this},once:function(name,callback,ctx){varself=this;functionlistener(){self.off(name,listener),callback.apply(ctx,arguments)}returnlistener._=callback,this.on(name,listener,ctx)},emit:function(name){for(vardata=[].slice.call(arguments,1),evtArr=((this.e||(this.e={}))[name]||[]).slice(),i=0,len=evtArr.length;i<len;i++)evtArr[i].fn.apply(evtArr[i].ctx,data);returnthis},off:function(name,callback){vare=this.e||(this.e={}),evts=e[name],liveEvents=[];if(evts&&callback){for(vari=evts.length-1;i>=0;i--)if(evts[i].fn===callback||evts[i].fn._===callback){evts.splice(i,1);break}liveEvents=evts}returnliveEvents.length?e[name]=liveEvents:deletee[name],this}};varEmitter=E;functioninitBridge(subscribeNamespace){varemitter=newEmitter;return{subscribe:function(event,callback,once){void0===once&&(once=!1),emitter[once?"once":"on"](subscribeNamespace+"."+event,callback)},subscribeHandler:function(event,args,pageId){emitter.emit(subscribeNamespace+"."+event,args,pageId)}}}varextend=Object.assign,UniXServiceJSBridge=extend(initBridge("service"),{publishHandler:function(event,args,pageId){UniViewJSBridge.subscribeHandler(event,args,pageId)}}),UniXViewJSBridge=extend(initBridge("view"),{publishHandler:function(event,args,pageId){UniServiceJSBridge.subscribeHandler(event,args,pageId)}});if("undefined"==typeofUniServiceJSBridge&&"undefined"==typeofUniViewJSBridge){var__global__="undefined"==typeofglobalThis?Function("return this")():globalThis;__global__.UniServiceJSBridge=UniXServiceJSBridge,__global__.UniViewJSBridge=UniXViewJSBridge}varApi={};Object.keys(App$1).forEach((function(method){Api["App."+method]=App$1[method]})),Object.keys(Page$1).forEach((function(method){Api["Page."+method]=Page$1[method]})),Object.keys(Element$1).forEach((function(method){Api["Element."+method]=Element$1[method]}));varNVueApi,fallback,socketTask,wsEndpoint=process.env.UNI_AUTOMATOR_WS_ENDPOINT;functionsend(data){setTimeout((function(){socketTask.send({data:JSON.stringify(data)})}),0)}functiononMessage(res){var_a=JSON.parse(res.data),id=_a.id,method=_a.method,params=_a.params,data={id:id},fn=Api[method];if(!fn){if(fallback){varresult=fallback(id,method,params,data);if(!0===result)return;fn=result}if(!fn)returndata.error={message:method+" unimplemented"},send(data)}try{fn(params,send).then((function(res){res&&(data.result=res)})).catch((function(err){data.error={message:err.message}})).finally((function(){send(data)}))}catch(err){data.error={message:err.message},send(data)}}fallback=function(id,method,params,data){varpageId=params.pageId,page=function(pageId){varpages=getCurrentPages();if(!pageId)returnpages[pages.length-1];returnpages.find((function(page){returnpage.$page.id===pageId}))}(pageId);returnpage?!page.$page.meta.isNVue?(UniServiceJSBridge.publishHandler("sendAutoMessage",{id:id,method:method,params:params},pageId),!0):(NVueApi||(NVueApi=initNativeApi()),NVueApi[method]):(data.error={message:"page["+pageId+"] not exists"},send(data),!0)},UniServiceJSBridge.subscribe("onAutoMessageReceive",(function(res){send(res)})),setTimeout((function(){if("undefined"!=typeofwindow&&(window.__uniapp_x_||window.__uniapp_x_postMessage))!function(data,callback){var_a,id=0;callback&&(id=postMessageId++,postMessageCallbacks[id]=callback);varmessage={data:{id:id,type:"automator",data:data}};console.log("postMessageToUniXWebView",message),(null===(_a=null===window||void0===window?void0:window.__uniapp_x_)||void0===_a?void0:_a.postMessage)?window.__uniapp_x_.postMessage(JSON.stringify(message)):(null===window||void0===window?void0:window.__uniapp_x_postMessage)&&window.__uniapp_x_postMessage({data:message})}({action:"ready"});else{if(wsEndpoint&&wsEndpoint.endsWith(":0000"))return;void0===options&&(options={}),(socketTask=uni.connectSocket({url:options.wsEndpoint||wsEndpoint,complete:function(){}})).onMessage(onMessage),socketTask.onOpen((function(res){options.success&&options.success(),console.log("已开启自动化测试...")})),socketTask.onError((function(res){console.log("automator.onError",res)})),socketTask.onClose((function(){options.fail&&options.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))}varoptions}),500);export{send};