UNPKG

tina-weapp

Version:
2 lines (1 loc) 27 kB
const t=Object.prototype.toString,e="[object Object]";function n(n){return t.call(n)===e}function o(...t){const e={};return t.forEach((t=>{t&&Object.keys(t).forEach((r=>{const s=t[r];n(s)?n(e[r])?e[r]=o(e[r],s):e[r]=o(s):e[r]=s}))})),e}const r=Object.create(null);function s(t,e){return void 0!==e?e:t}function i(t,e){return n(e)?o(t,e):void 0!==e?e:n(t)?o(t):void 0!==t?t:void 0}function a(t){return function(t){t.headers=function(t){const e=function(t,e){return t?(t=o(t.common||{},t[e]||{},t),["delete","get","head","options","post","put","patch","common"].forEach((e=>{delete t[e]})),t):t}(t.headers,t.method),{auth:n,authKey:r,authURL:s,url:i}=t;if(s.exclusive&&s.exclusive.includes(i))return e;if(s.inclusive&&!s.inclusive.includes(i))return e;if(n&&r&&"string"==typeof r&&void 0===e[r]&&void 0===e[r.toLowerCase()]){const o=typeof t.auth;let s="";"string"===o?s=n:"function"===o&&(s=n()),s&&"string"==typeof s&&(e[r]=s)}return e}(t),t.url=function(t="",e){return t+e}(t.baseURL,t.url),t.method=(t.method||"GET").toUpperCase()}(t),function(t){return new Promise(((e,n)=>{const{url:o,method:r,data:s,params:i,timeout:a,headers:c,dataType:u="json",responseType:l="text",cancelToken:h}=t,f=wx.request({url:o,method:r,data:"GET"===r?i:s,header:c,timeout:a,dataType:u,responseType:l,success:t=>e(t),fail:t=>n(t),complete:()=>{}});h&&h.promise.then((t=>{f.abort(),n(t)}))}))}(t).then((e=>function(t,e){return t.config=e,t}(e,t)))}["url","params","key"].forEach((t=>{r[t]=s})),["headers"].forEach((t=>{r[t]=i}));class c{constructor(){this.interceptors=[]}use(t,e){return this.interceptors.push({resolved:t,rejected:e}),this.interceptors.length-1}forEach(t){this.interceptors.forEach((e=>{null!==e&&t(e)}))}eject(t){this.interceptors[t]&&(this.interceptors[t]=null)}}class u{constructor(t){this.defaults=t,this.interceptors={request:new c,response:new c}}request(t,e={}){"string"==typeof t?e.url=t:e=t;const n=e;(e=function(t,e={}){const n={};for(const t in e)o(t);for(const n in t)e[n]||o(n);function o(o){const i=r[o]||s;n[o]=i(t[o],e[o])}return n}(this.defaults,e)).originConfig=n;const o=[{resolved:a,rejected:void 0}];this.interceptors.request.forEach((t=>o.unshift(t))),this.interceptors.response.forEach((t=>o.push(t)));let i=Promise.resolve(e);for(;o.length;){const{resolved:t,rejected:e}=o.shift();i=i.then(t,e)}return i}get(t,e){return this._requestMethodWithoutData("get",t,e)}delete(t,e){return this._requestMethodWithoutData("delete",t,e)}head(t,e){return this._requestMethodWithoutData("head",t,e)}options(t,e){return this._requestMethodWithoutData("options",t,e)}post(t,e,n){return this._requestMethodWithData("post",t,e,n)}put(t,e,n){return this._requestMethodWithData("put",t,e,n)}patch(t,e,n){return this._requestMethodWithData("patch",t,e,n)}_requestMethodWithoutData(t,e,n){return this.request(Object.assign(n||{},{method:t,url:e}))}_requestMethodWithData(t,e,n,o){return this.request(Object.assign(o||{},{method:t,url:e,data:n}))}}const l={method:"GET",timeout:0,headers:{common:{Accept:"application/json, text/plain, */*"}},baseURL:"",auth:null,authKey:"Authorization",authURL:{inclusive:null,exclusive:null}};["delete","get","head","options"].forEach((t=>{l.headers[t]={}}));["post","put","patch"].forEach((t=>{l.headers[t]={"Content-Type":"application/json;charset=utf-8"}}));class h{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function");let e=null;this.promise=new Promise((t=>{e=t})),t((t=>{this.reason||(this.reason=t?`Cancel: ${t}`:"Canceled",e(this.reason))}))}}h.source=function(){let t;return{token:new h((function(e){t=e})),cancel:t}};const f={};function p(t){return t.map((t=>t.operationName)).join("_")}function d(t){return t[0].operationType}function m(t){return{name:p(t),type:d(t)}}function g(t,e){const{name:n}=m(t);n&&f[n]&&(f[n].response=e,function(t){const{request:e,response:n,type:o,name:r}=t;console.log(`%c ${o} : ${r} `,`background-color:${"query"===o?"#00ff00":"#ffc400"};color:#000`),console.log("请求",e.variables),console.log("响应",n)}(f[n]))}const y={};function w(t){const e=new u(t),n=u.prototype.request.bind(e);return function(t,e){for(const n in e)t[n]=e[n];["request","get","delete","head","options","post","put","patch","_requestMethodWithData","_requestMethodWithoutData"].forEach((n=>{t[n]=e[n]}))}(n,e),n}const b=w(l);function v(){}b.create=function(t){return w(o(l,t))},b.CancelToken=h,b.graphQL=class{constructor(t={}){this.client=new u(o(l,t)),this.config=t,"undefined"!==t.custom?this.isCustomQueryStatement=!!t.custom:this.isCustomQueryStatement=!1}query(t,e={}){return this.dispatchRequest(t,e,"query","query")}mutate(t,e={}){return t.query=t.mutation,this.dispatchRequest(t,e,"mutation","mutate")}dispatchRequest(t,e,n,o){let{query:r,variables:s={},responseNode:i,custom:a}=t;if(!(r=function(t){if(!t)return!1;if("string"==typeof t)return[t];if(Array.isArray(t))return t.some((t=>"string"!=typeof t))?(console.error('query为数组时需要是 "string[]" 类型'),!1):t;return console.error("query只支持 string 和 string[] 类型"),!1}(r)))return Promise.reject();let c,u="",l={},h=null;if(c="boolean"==typeof a?a:this.isCustomQueryStatement,c)u=r;else{const t=r.join("/")+i||"";if(y[t])u=y[t];else try{h=function(t,e,n,o){e||(e={});const r=1===t.length,s=[];return t.forEach((t=>{const i=function(t,e,n,o,r){t=t.trim();const s=/\(([^)]*)\)/,i={};let a=t.match(s);if(!a&&(a=(t+="()").match(s),!a))throw new Error(`${t}语法错误`);const c=a[1],u=a.index,l=t.substr(0,u);if(!l)throw new Error(`缺少操作名称: ${t}`);i.operationName=l,i.variables=[],i.variablesMap={},c&&c.split(",").forEach((e=>{let[n,o]=e.split(":");if(n=n.trim(),o=o.trim(),!o)throw new Error(`变量"${n}"缺少类型: ${t}`);i.variables.push({key:n,type:o}),i.variablesMap[n]=o}));"string"==typeof e&&(e={[l]:e});return i.variablesStore=r?o:o[l]||{},i.responseNode=e[l]||"",i.operationType=n,i}(t,e,n,o,r);s.push(i)})),s}(r,i,n,s),u=function(t){let e="";const n=t[0].operationType,o=t.map((t=>t.operationName)).join("_"),r=i(t),s=r.length>0?`(${r.join(",")})`:"";function i(t){const e=[];return t.forEach((t=>{const{operationName:n,variables:o}=t;e.push(...o.map((({key:t,type:e})=>`$${n}_${t}:${e}`)))})),e}function a(t){let e="";return t.forEach((t=>{const{operationName:n,variables:o,responseNode:r}=t,s=o&&o.length>0;if(e+=n,s){const t=o.map((({key:t})=>`${t}:$${n}_${t}`)).join(",");e+=`(${t})`}r&&(e+=`{${r}}`),e+="↵"})),e}return e+=`${n} ${o}${s}{\n ${a(t)}\n }`,e}(h),l=function(t){const e={};t&&t.length>0&&t.forEach((t=>{const{operationName:n,variablesStore:o}=t;Object.keys(o).forEach((t=>{e[`${n}_${t}`]=o[t]}))}));return e}(h),this.config.logger&&function(t,e){const{name:n,type:o}=m(t);f[n]={request:{variables:e},response:{},type:o,name:n}}(h,l)}catch(e){return y[t]="",console.error(e),Promise.reject()}}return e=Object.assign({},e,{isGql:!0,gql:h}),this.client.post(this.config.url,{query:u,variables:l},e).then((t=>(this.config.logger&&g(h,t),Promise.resolve(t))),(t=>(this.config.logger&&function(t,e){const{name:n,type:o}=m(t);console.log(`%c ${o} : ${n} %c Error `,`background-color:${"query"===o?"#00ff00":"#ffc400"};color:#000`,"background-color:#ff0000;color:#fff"),console.log("AST",t),console.log("err",e)}(h,t),Promise.reject(t))))}};let _=new RegExp("[^"+/a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/.source+".$_\\d]");function k(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){var n,o,r,s=Array.isArray(t),i=Array.isArray(e);if(s&&i){if((o=t.length)!=e.length)return!1;for(n=o;0!=n--;)if(!k(t[n],e[n]))return!1;return!0}if(s!=i)return!1;var a=t instanceof Date,c=e instanceof Date;if(a!=c)return!1;if(a&&c)return t.getTime()==e.getTime();var u=t instanceof RegExp,l=e instanceof RegExp;if(u!=l)return!1;if(u&&l)return t.toString()==e.toString();var h=Object.keys(t);if((o=h.length)!==Object.keys(e).length)return!1;for(n=o;0!=n--;)if(!Object.prototype.hasOwnProperty.call(e,h[n]))return!1;for(n=o;0!=n--;)if(!k(t[r=h[n]],e[r]))return!1;return!0}return t!=t&&e!=e}function $(t,e){let n=new Map;t.map((t=>n.set(t,(n.get(t)||0)+1))),e.map((t=>n.set(t,(n.get(t)||0)-1)));for(let t of n.values())if(0!==t)return!1;return!0}function j(t){return"[object Object]"===Object.prototype.toString.call(t)}function x(t){return"[object Object]"===Object.prototype.toString.call(t)||Array.isArray(t)}function O(t){return null!==t&&"object"==typeof t}function D(t,e){Object.keys(t).forEach((n=>e(t[n],n)))}function E(t,e){D(t._children,e)}function T(t,e,n){return O(t)&&t.type&&(n=e,e=t,t=t.type),{type:t,payload:e,options:n}}class S{constructor(t){this.root=null,this.register([],t)}register(t,e){let n={_rawModule:e,_children:{},state:e.state};if(this.root){const e=t[t.length-1],o=(t,e)=>t._children[e],r=t.slice(0,-1).reduce(o,this.root);r._children[e]=n,r._children&&E(r,((t,e)=>{const n=r.state;r.state=("function"==typeof n?n():n)||{};const o=t.state;t.state=("function"==typeof o?o():o)||{},r.state[e]=t.state}))}else this.root=n;const o=e.modules;o&&Object.keys(o).forEach((e=>{const n=o[e];this.register(t.concat(e),n)}))}}let M=0;class q{constructor(){this.subs=[],this.id=M++}addSub(t){this.subs.push(t)}removeSub(t){!function(t,e){if(t.length){const n=t.indexOf(e);if(n>-1)t.splice(n,1)}}(this.subs,t)}depend(){q.target&&q.target.addDep(this)}notify(){const t=this.subs.slice();for(let e=0,n=t.length;e<n;e++)t[e].update()}}q.target=null;const A=[];function C(t){L(t)}function L(t){x(t)&&(Array.isArray(t)?t.map((t=>{j(t)?W(t):L(t)})):W(t))}function W(t){const e=new q;Object.keys(t).forEach((n=>{let o=t[n];"__webviewId__"!==n&&Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>(q.target&&e.depend(),o),set(t){o!=t&&(L(t),o=t,e.notify())}}),L(o)}))}class F{constructor(t={}){this._init=!1,this._actions={},this._mutations={},this._wrappedGetters={},this._makeLocalGettersCache={},this._modulesNamespaceMap={},this._modules=new S(t);const e=this._states=this._modules.root.state;this._rawState=JSON.parse(JSON.stringify(e));const n=this,{dispatch:o,commit:r}=this;this.dispatch=function(t,e){return o.call(n,t,e)},this.commit=function(t,e,o){return r.call(n,t,e,o)},N(this,e,[],this._modules.root),function(t,e){let{getters:n}=t._modules.root._rawModule;n=n||{},t.getters={},t._getters={},t._makeLocalGettersCache=Object.create(null);const o=t._wrappedGetters;D(o,((r,s)=>{n[s]&&Object.defineProperty(t._getters,s,{get:()=>n[s](e),enumerable:!0}),Object.defineProperty(t.getters,s,{get:()=>o[s](e),enumerable:!0})}))}(this,e)}commit(t,e){O(t)&&t.type&&(e=t,t=t.type);const n=this._mutations[t];n?n.forEach((t=>t(e))):console.error(`[weux] unknown mutation type: ${t}`)}dispatch(t,e){O(t)&&t.type&&(e=t,t=t.type);const n=this._actions[t];if(n)return n.length>1?Promise.all(n.map((t=>t(e)))):n[0](e);console.error(`[weux] unknown action type: ${t}`)}get state(){return this._init||(C(this._states),this._init=!0),this._states}set state(t){console.error("use store commit to explicit replace store state.")}}function N(t,e,n,o){const r=function(t,e){let n=t;return e.reduce(((t,e)=>(n=n._children[e],t+(n._rawModule.namespaced?e+"/":""))),"")}(t._modules.root,n);o._rawModule.namespaced&&(t._modulesNamespaceMap[r]=o);const s=o.context=function(t,e,n){const o=""===e,r={dispatch:o?t.dispatch:(n,o,r)=>{const s=T(n,o,r),{payload:i,options:a}=s;let{type:c}=s;if(a&&a.root||(c=e+c,t._actions[c]))return t.dispatch(c,i);console.error(`[weux] unknown local action type: ${s.type}, global type: ${c}`)},commit:o?t.commit:(n,o,r)=>{const s=T(n,o,r),{payload:i,options:a}=s;let{type:c}=s;a&&a.root||(c=e+c,t._mutations[c])?t.commit(c,i,a):console.error(`[weux] unknown local mutation type: ${s.type}, global type: ${c}`)}};return Object.defineProperties(r,{getters:{get:o?()=>t.getters:()=>function(t,e){if(!t._makeLocalGettersCache[e]){const n={},o=e.length;t.getters&&(Object.keys(t.getters).forEach((r=>{if(r.slice(0,o)!==e)return;const s=r.slice(o);Object.defineProperty(n,s,{get:()=>t.getters[r],enumerable:!0})})),t._makeLocalGettersCache[e]=n)}return t._makeLocalGettersCache[e]}(t,e)},state:{get:()=>function(t,e){return e.reduce(((t,e)=>t[e]),t)}(t.state,n)}}),r}(t,r,n);!function(t,e){t._rawModule.mutations&&D(t._rawModule.mutations,e)}(o,((e,n)=>{!function(t,e,n,o){(t._mutations[e]||(t._mutations[e]=[])).push((function(e){n.call(t,o.state,e)}))}(t,r+n,e,s)})),function(t,e){t._rawModule.actions&&D(t._rawModule.actions,e)}(o,((e,n)=>{const o=e.root?n:r+n,i=e.handler||e;!function(t,e,n,o){(t._actions[e]||(t._actions[e]=[])).push((function(e){let r=n.call(t,{dispatch:o.dispatch,commit:o.commit,getters:o.getters,state:o.state,rootGetters:t.getters,rootState:t.state},e);var s;return(s=r)&&"function"==typeof s.then||(r=Promise.resolve(r)),r}))}(t,o,i,s)})),function(t,e){t._rawModule.getters&&D(t._rawModule.getters,e)}(o,((e,n)=>{!function(t,e,n,o){if(t._wrappedGetters[e])return void console.error(`[weux] duplicate getter key: ${e}`);t._wrappedGetters[e]=function(){return n(o.state,o.getters,t.state,t.getters)}}(t,r+n,e,s)})),o._children&&E(o,((o,r)=>{N(t,e,n.concat(r),o)}))}const P=J(((t,e)=>{const n={};return R(e)||console.error("[weux] mapState: mapper parameter must be either an Array or an Object"),z(e).forEach((({key:e,val:o})=>{n[e]=function(){let e=this.$store.state,n=this.$store.getters;if(t){const o=H(this.$store,"mapState",t);if(!o)return;e=o.context.state,n=o.context.getters}return"function"==typeof o?o.call(this,e,n):e[o]}})),n})),G=J(((t,e)=>{const n={};return R(e)||console.error("[weux] mapMutations: mapper parameter must be either an Array or an Object"),z(e).forEach((({key:e,val:o})=>{n[e]=function(...e){let n=this.$store.commit;if(t){const e=H(this.$store,"mapMutations",t);if(!e)return;n=e.context.commit}return"function"==typeof o?o.apply(this,[n].concat(e)):n.apply(this.$store,[o].concat(e))}})),n})),B=J(((t,e)=>{const n={};return R(e)||console.error("[weux] mapGetters: mapper parameter must be either an Array or an Object"),z(e).forEach((({key:e,val:o})=>{o=t+o,n[e]=function(){if(!t||H(this.$store,"mapGetters",t)){if(o in this.$store.getters)return this.$store.getters[o];console.error(`[weux] unknown getter: ${o}`)}}})),n})),I=J(((t,e)=>{const n={};return R(e)||console.error("[weux] mapActions: mapper parameter must be either an Array or an Object"),z(e).forEach((({key:e,val:o})=>{n[e]=function(...e){let n=this.$store.dispatch;if(t){const e=H(this.$store,"mapActions",t);if(!e)return;n=e.context.dispatch}return"function"==typeof o?o.apply(this,[n].concat(e)):n.apply(this.$store,[o].concat(e))}})),n})),U=t=>({mapState:P.bind(null,t),mapGetters:B.bind(null,t),mapMutations:G.bind(null,t),mapActions:I.bind(null,t)});function z(t){return R(t)?Array.isArray(t)?t.map((t=>({key:t,val:t}))):Object.keys(t).map((e=>({key:e,val:t[e]}))):[]}function R(t){return Array.isArray(t)||null!==(e=t)&&"object"==typeof e;var e}function J(t){return(e,n)=>("string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n))}function H(t,e,n){const o=t._modulesNamespaceMap[n];return o||console.error(`[weux] module namespace not found in ${e}(): ${n}`),o}const Q=[];let K={},Y={},Z=!1,V=0;const X=function(){let t=!1;return(e,n)=>{t||(t=!0,Promise.resolve().then((()=>{t=!1,"function"==typeof e&&e()})).catch((e=>{t=!1,"function"==typeof n&&n(),console.error("Something wrong in weapp asyncLock func execution, please check.",void 0,e)})))}}();function tt(){for(Z=!0,Q.sort(((t,e)=>t.id-e.id)),V=0;V<Q.length;V++){const t=Q[V],e=t.id;if(e!==1/0&&(delete K[e],Y[e]=(Y[e]||0)+1,Y[e]>100)){let e=t.vm&&t.vm.is;console.error("You may have a dead circular update in watcher with expression, please check!",e);break}t.run()}et()}function et(){Z=!1,V=Q.length=0,K={},Y={}}let nt=!1,ot=!1;const rt=[];let st=[];function it(t){nt||(wx.nextTick((()=>{at().map((e=>{const n=e._computedMap;if(n&&Object.keys(n).length)try{"updateComputed"==t?(e._rawData=JSON.parse(e._rawStr),e._rawStr=null):e._rawBackup&&(e._rawData=e._rawBackup,e._rawBackup=null),e.setData(n,(()=>{e._computedMap={}}))}catch(t){throw t}})),nt=!1})),nt=!0)}function at(){const t=getCurrentPages(),e=t[t.length-1];let n=[];return rt.map((t=>{t.map((o=>{e.is==o.is&&(n=t)}))})),n}let ct=!1;const ut=new Map;function lt(t,e){for(let n in e){let o=e[n];if(Array.isArray(o))for(let e=0;e<o.length;e++)ht(t,n,o[e]);else ht(t,n,o)}}function ht(t,e,n,o){O(n)&&(o=n,n=n.handler),"string"==typeof n&&(n=t[n]?t[n]:v),ft(t,e,n,o)}function ft(t,e,n,o){if(O(n))return ht(t,e,n,o);let r;n=n||v,(o=o||{}).user=!0,r=mt&&mt.default?mt.default:mt;const s=new r(t,e,n,o);return o.immediate&&n.call(t,s.value),function(){s.teardown()}}function pt(t,e,n){const o=at().map((t=>t.is)),r=t.vm.is,s=t.cb.name,i=t.fn===s?t.fn:`${t.fn}${a=s,a.toLowerCase().replace(/bound/g,"").replace(/^\s+/g,"").replace(/(?:^)\w/g,(t=>t.toUpperCase()))}`;var a;if(o.includes(r))if(ut.size)if(ut.has(r)){let o=ut.get(r);o.includes(i)||(o.push(i),t.cb.call(t.vm,e,n))}else{const o=[];o.push(i),ut.set(r,o),t.cb.call(t.vm,e,n)}else{const o=[];o.push(i),ut.set(r,o),t.cb.call(t.vm,e,n)}ct||(wx.nextTick((()=>{ut.clear(),ct=!1})),ct=!0)}let dt=0;class mt{constructor(t,e,n,o){this.vm=t,this.fn=e,this.cb=n,this.id=++dt,this.deps=[],this.newDeps=[],this.depIds=new Set,this.newDepIds=new Set,this.active=!0,o?(this.user=!!o.user,this.lazy=!!o.lazy,this.sync=!!o.sync):this.user=this.lazy=this.sync=!1,"function"==typeof e?this.getter=e:(this.getter=function(t){if(!_.test(t)){var e=t.split(".");return function(t){if(t&&t.data){let{data:o}=t;for(var n=0;n<e.length;n++)o=o[e[n]];return o}return t}}}(e),this.getter||(this.getter=v,console.warn(`Failed watching path: ${getter} Watcher only accepts simple dot-delimited paths.For full control, use a function instead.`))),this.dirty=this.lazy,this.value=this.lazy?void 0:this.getWatcher()}evaluate(){this.value=this.getWatcher(),this.dirty=!1}getWatcher(){var t;let e;t=this,q.target&&A.push(q.target),q.target=t;try{e=this.getter.call(this.vm,this.vm)}catch(t){throw t}finally{A.pop(),q.target=A[A.length-1],this.cleanupDeps()}return e}update(){if(this.lazy){this.dirty=!0;let t=this.value,e=this.getter.call(this.vm,this.vm);k(t,e)||(this.value=e,"function"==typeof this.cb&&this.cb.call(this.vm))}else this.sync?this.run():function(t){if(t.id||"function"!=typeof t||(t={id:1/0,run:t}),!K[t.id]||t.id===1/0)if(K[t.id]=!0,Z){let e=Q.length-1;for(;e>V&&t.id<Q[e].id;)e--;Q.splice(e+1,0,t)}else Q.push(t),X(tt,et)}(this)}run(){if(this.active){const t=this.getWatcher();if(t!==this.value||O(t)){const e=this.value;if(this.value=t,this.user)try{pt(this,t,e)}catch(t){console.error(t,this.vm.is,`callback for watcher "${this.getter}"`)}else pt(this,t,e)}}}addDep(t){const e=t.id;this.newDepIds.has(e)||(this.newDepIds.add(e),this.newDeps.push(t),this.depIds.has(e)||t.addSub(this))}cleanupDeps(){let t=this.deps.length;for(;t--;){const e=this.deps[t];this.newDepIds.has(e.id)||e.removeSub(this)}let e=this.depIds;this.depIds=this.newDepIds,this.newDepIds=e,this.newDepIds.clear(),e=this.deps,this.deps=this.newDeps,this.newDeps=e,this.newDeps.length=0}depend(){if(q.target){let t=this.deps.length;for(;t--;)this.deps[t].depend()}}teardown(){if(this.active){let t=this.deps.length;for(;t--;)this.deps[t].removeSub(this);this.active=!1}}}const gt={enumerable:!0,configurable:!0,get:v,set:v};function yt(t,e,n){!function(t){st.push(t),ot||(wx.nextTick((()=>{if(rt.length){const t=getCurrentPages(),e=t[t.length-1].is;rt.map(((t,n)=>{t.map((t=>t.is)).includes(e)&&rt.splice(n,1)}))}rt.push(st),st=[],ot=!1})),ot=!0)}(t);const o={},r=t._computedWatchers={};t._computedMap={};for(const s in n){const i=n[s],a="function"==typeof i?i.bind(t):i.get;if(s in e){console.error(`The computed property "${s}" is already defined in data`);continue}wt(t,e,s,i);const c=r[s]=new mt(t,a||v,(()=>{t._computedMap[s]=c.value,it()}),{lazy:!0});o[s]=e[s]}try{t.setData(o)}catch(t){throw t}}function wt(t,e,n,o){"function"==typeof o?(gt.get=bt(t,n),gt.set=v):(gt.get=o.get?bt(t,n):v,gt.set=o.set?o.set.bind(t):v),Object.defineProperty(e,n,gt)}function bt(t,e){return()=>{const n=t._computedWatchers&&t._computedWatchers[e];if(n)return n.dirty&&n.evaluate(),q.target&&n.depend(),n.value}}function vt(t,e,n){C(e),yt(t,e,n)}function _t(...t){let e=t[0],n="navigateTo",o={};if(2==t.length&&(j(t[1])&&(o=t[1]),"string"==typeof t[1]&&(n=t[1])),3==t.length&&(n=t[1],o=j(t[2])?t[2]:{}),"navigateBack"==n)try{wx.navigateBack(o)}catch(t){console.error(t)}else{if(!e)throw Error("The url should be string and not empty");if(["navigateTo","reLaunch","redirectTo"].includes(n)){if(Object.keys(o).length)for(const[t,n]of Object.entries(o))e.indexOf("?")>0?e+=`&${t}=${n}`:e+=`?${t}=${n}`;!function(t,e){"navigateTo"==e?wx.navigateTo({url:t}):"reLaunch"==e?wx.reLaunch({url:t}):wx.redirectTo({url:t})}(e,n)}else try{let t=e.indexOf("?"),n=t>0?e.substring(0,t):e;wx.switchTab({url:n})}catch(t){console.error(t)}}}function kt(t){let{url:e,routeType:n,delta:o}=t.currentTarget.dataset,r=n||"navigateTo",s=o||1;if("navigateBack"==n){getCurrentPages().length>1?_t(e="empty",r,{delta:Number(s)}):console.warn("navigateBack the navigate type must be navigateTo")}else _t(e,r)}function $t(t,e){let n=getApp().globalData;if(0===arguments.length)return n;if(jt(t)){const o=t.replace(/\[(\d+?)\]/g,".$1").split(".");if(1===arguments.length)return e=o.reduce(((t,e)=>t[e]),n);if(2===arguments.length)return o.reduce(((t,n,r)=>(r==o.length-1&&(t[n]=e),t[n])),n),n}}function jt(t){return"[object String]"===Object.prototype.toString.call(t)}let xt,Ot,Dt={};function Et(t){if(t.$store){const{_computedWatchers:e,$store:{_rawState:n}}=t;Object.keys(e).forEach((t=>{const o=e[t].value;x(o)&&(xt=o,Tt(n),Dt[t]=Ot)})),t._rawData={...t._rawData,...Dt},Dt={}}}function Tt(t){for(let e in t){let n=t[e];if(x(n)){if(Array.isArray(n)){if(k(xt,n))return void(Ot=n);for(const t of n)if(j(t)){if(Tt(t),k(xt,t)){Ot=t;break}}else Tt(t)}else Tt(n);if(j(n)&&k(xt,n)){Ot=n;break}}}}var St=new class{constructor(){this.eventTask={}}on(t,e){this.eventTask[t]||(this.eventTask[t]=[]),"function"==typeof e&&this.eventTask[t].push(e)}emit(t,...e){let n=this.eventTask[t];n&&n.length>0&&n.forEach((t=>t(...e)))}off(t,e){let n=this.eventTask[t];if(n&&n.length>0){let t=n.indexOf(e);-1!=t&&n.splice(t,1)}}once(t,e){"function"==typeof e&&this.on(t,(function(...n){this.off(t,e),e(...n)}))}};const Mt="[object Array]",qt="[object Object]";let At=[],Ct=[];function Lt(t,e,n){const o=function(t,e){const n={};return Wt(t,e),Ft(t,e,"",n),n}(e=JSON.parse(JSON.stringify(e)),t._rawData),r=function(t){const e={};return Object.keys(t).forEach((n=>{n.split(".").length>1?null===t[n]?e[n]="":e[n]=t[n]:null!==t[n]&&(e[n]=t[n])})),e}(o);let s=!(null===(i=r)||"object"!=typeof i||!Object.keys(i).length);var i;n=n||v;let{_setDataBackup:{setData:a}}=t;s&&(a.call(t,r,n),At.push(r),Ct.push(t),wx.nextTick((()=>{At.length&&(At.map(((t,e)=>{let n=Ct[e];Object.keys(t).forEach((e=>{!function(t,e,n){const o=e.replace(/\[(\d+?)\]/g,".$1").split(".");o.reduce(((t,e,r)=>(r==o.length-1&&(t[e]=n),t[e])),t._rawData)}(n,e,t[e])}))})),At=[],Ct=[])})))}function Wt(t,e){if(t===e)return;const n=Pt(t),o=Pt(e);if(n==qt&&o==qt)for(let n in e){const o=t[n];void 0===o?t[n]=null:Wt(o,e[n])}else n==Mt&&o==Mt&&t.length>=e.length&&e.forEach(((e,n)=>{Wt(t[n],e)}))}function Ft(t,e,n,o){if(t===e)return;const r=Pt(t),s=Pt(e);if(r==qt)if(s!=qt||Object.keys(t).length<Object.keys(e).length&&""!=n)Nt(o,n,t);else for(let r in t){const s=t[r],i=e[r],a=Pt(s),c=Pt(i);if(a!=Mt&&a!=qt)s!=e[r]&&Nt(o,(""==n?"":n+".")+r,s);else if(a==Mt)if(c!=Mt)Nt(o,(""==n?"":n+".")+r,s);else if(s.length<i.length)Nt(o,(""==n?"":n+".")+r,s);else{if($(s,i))return;s.forEach(((t,e)=>{Ft(t,i[e],(""==n?"":n+".")+r+"["+e+"]",o)}))}else if(a==qt)if(c!=qt||Object.keys(s).length<Object.keys(i).length)Nt(o,(""==n?"":n+".")+r,s);else for(let t in s)Ft(s[t],i[t],(""==n?"":n+".")+r+"."+t,o)}else r==Mt?s!=Mt||t.length<e.length?Nt(o,n,t):t.forEach(((t,r)=>{Ft(t,e[r],n+"["+r+"]",o)})):Nt(o,n,t)}function Nt(t,e,n){"[object Function]"!=Pt(n)&&(t[e]=n)}function Pt(t){return Object.prototype.toString.call(t)}function Gt(t,e){const{proxyData:n}=getApp(),o=new WeakMap;if(n&&n.store&&(t.$store=n.store),n&&n.api&&(t.$api=n.api),n&&n.axios){const{axios:e}=n;e.CancelToken=b.CancelToken,e.graphQL=b.graphQL,t.$axios=e}else t.$axios=b;t.$bus=St,"component"==e&&(t.$route=_t,t.$global=$t,t.routeTo=function(t){return kt(t)}),t.$watch=function(e,n,o){return ft(t,e,n,o)};const{setData:r,data:s}=t;t._setDataBackup={setData:r},t._rawData=JSON.parse(JSON.stringify(s)),o.set(t._rawData,"rawData"),o.set(t.$store||{},"store"),o.set(t.$bus||{},"bus"),o.set(t.$api||{},"api"),t.setData=function(e,n){Lt(t,e,n)}}const Bt=Page;Page=function(t={}){t.$global=$t,t.$route=_t;const e={onLoad:t.onLoad,onShow:t.onShow,onHide:t.onHide,onUnload:t.onUnload};return t.onLoad=function(t){Gt(this);const{data:n,computed:o}=this;vt(this,n,o),wx.nextTick((()=>{Et(this)})),e.onLoad&&e.onLoad.call(this,t)},t.onShow=function(){lt(this,this.watch),it("updateComputed"),e.onShow&&e.onShow.call(this)},t.onHide=function(){at().map((t=>{t._rawBackup=t._rawData,t._rawStr=JSON.stringify(t._rawData)})),e.onHide&&e.onHide.call(this)},t.onUnload=function(){const t=this._computedWatchers;t&&Object.keys(t).length&&Object.keys(t).forEach((e=>t[e].teardown())),this._rawData=null,this._computedWatchers=null,this.$store=null,this.$bus=null,e.onUnload&&e.onUnload.call(this)},t.routeTo=function(t){return kt(t)},Bt(t)};const It=Behavior({lifetimes:{attached:function(){Gt(this,"component")}}}),Ut=Component;function zt(t){const e=t._computedWatchers;e&&Object.keys(e).length&&Object.keys(e).forEach((t=>e[t].teardown()))}Component=function(t={}){t.behaviors=[It];const e={attached:t.lifetimes&&t.lifetimes.attached?t.lifetimes.attached:v,detached:t.lifetimes&&t.lifetimes.detached?t.lifetimes.detached:v,configAttached:t.attached?t.attached:v,configDetached:t.detached?t.detached:v},n={show:t.pageLifetimes&&t.pageLifetimes.show?t.pageLifetimes.show:v};return t.lifetimes?t.lifetimes={attached:function(){vt(this,this.data,t.computed),wx.nextTick((()=>{Et(this)})),e.attached.call(this)},detached:function(){zt(this),e.detached.call(this)}}:t.attached&&"function"==typeof t.attached?(t.attached=function(){vt(this,this.data,t.computed),wx.nextTick((()=>{Et(this)})),e.configAttached.call(this)},t.detached=function(){zt(this),ifeTimesBackup.configDetached.call(this)}):t.lifetimes={attached:function(){vt(this,this.data,t.computed),wx.nextTick((()=>{Et(this)})),e.attached.call(this)},detached:function(){zt(this),e.detached.call(this)}},t.pageLifetimes={show:function(){lt(this,t.watch),n.show&&n.show.call(this)}},Ut(t)};var Rt={axios:b,Store:F,mapState:P,mapMutations:G,mapActions:I,mapGetters:B,createNamespacedHelpers:U};export{F as Store,b as axios,U as createNamespacedHelpers,Rt as default,I as mapActions,B as mapGetters,G as mapMutations,P as mapState};