import{aB as e,bz as t,bC as n,bD as s,bA as r,bE as i,bF as o,as as a,V as c,bG as u,bH as l,bI as h,bJ as d,H as p,T as g,a0 as f,bK as m,bL as y,a_ as _,aV as T,bp as w,X as v,bo as x,bM as I,bN as k,bO as S,bP as P}from"./index-Dhufwzns.js";const A={easycom:{autoscan:!0,custom:{"^s-(.*)":"@/sheep/components/s-$1/s-$1.vue","^su-(.*)":"@/sheep/ui/su-$1/su-$1.vue","^uni-(.*)":"@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"}},pages:[{path:"pages/index/FirstIndex",aliasPath:"/",style:{navigationBarTitleText:"常来此购商城",enablePullDownRefresh:!0},meta:{auth:!1,sync:!0,title:"首页",group:"商城"}},{path:"pages/index/FirstActivity",style:{navigationBarTitleText:"活动",enablePullDownRefresh:!0},meta:{auth:!1,sync:!0,title:"活动",group:"商城"}},{path:"pages/index/FirstMerchant",style:{navigationBarTitleText:"商家",enablePullDownRefresh:!0},meta:{auth:!1,sync:!0,title:"视频",group:"商城"}},{path:"pages/index/FirstVideo",style:{navigationBarTitleText:"视频",enablePullDownRefresh:!0},meta:{auth:!1,sync:!0,title:"视频",group:"商城"}},{path:"pages/index/FirstList",style:{navigationBarTitleText:"列表",enablePullDownRefresh:!0},meta:{auth:!1,sync:!0,title:"列表",group:"商城"}},{path:"pages/index/index",style:{navigationBarTitleText:"常来此购商城",enablePullDownRefresh:!0},meta:{auth:!1,sync:!0,title:"首页",group:"商城"}},{path:"pages/index/user",style:{navigationBarTitleText:"个人中心",enablePullDownRefresh:!0},meta:{sync:!0,title:"个人中心",group:"商城"}},{path:"pages/index/category",style:{navigationBarTitleText:"商品分类"},meta:{sync:!0,title:"商品分类",group:"商城"}},{path:"pages/index/cart",style:{navigationBarTitleText:"购物车"},meta:{sync:!0,title:"购物车",group:"商城"}},{path:"pages/index/login"},{path:"pages/index/search",style:{navigationBarTitleText:"搜索"},meta:{sync:!0,title:"搜索",group:"商城"}},{path:"pages/index/page",style:{navigationBarTitleText:""},meta:{auth:!1,sync:!0,title:"自定义页面",group:"商城"}}],subPackages:[{root:"pages/goods",pages:[{path:"index",style:{navigationBarTitleText:"商品详情"},meta:{sync:!0,title:"普通商品",group:"商品"}},{path:"groupon",style:{navigationBarTitleText:"拼团商品"},meta:{sync:!0,title:"拼团商品",group:"商品"}},{path:"seckill",style:{navigationBarTitleText:"秒杀商品"},meta:{sync:!0,title:"秒杀商品",group:"商品"}},{path:"list",style:{navigationBarTitleText:"商品列表"},meta:{sync:!0,title:"商品列表",group:"商品"}},{path:"comment/add",style:{navigationBarTitleText:"评价商品"},meta:{auth:!0}},{path:"comment/list",style:{navigationBarTitleText:"商品评价"}}]},{root:"pages/order",pages:[{path:"detail",style:{navigationBarTitleText:"订单详情"},meta:{auth:!0,title:"订单详情"}},{path:"confirm",style:{navigationBarTitleText:"确认订单"},meta:{auth:!0,title:"确认订单"}},{path:"list",style:{navigationBarTitleText:"我的订单",enablePullDownRefresh:!0},meta:{auth:!0,sync:!0,title:"用户订单",group:"订单中心"}},{path:"aftersale/apply",style:{navigationBarTitleText:"申请售后"},meta:{auth:!0,title:"申请售后"}},{path:"aftersale/return-delivery",style:{navigationBarTitleText:"退货物流"},meta:{auth:!0,title:"退货物流"}},{path:"aftersale/list",style:{navigationBarTitleText:"售后列表"},meta:{auth:!0,sync:!0,title:"售后订单",group:"订单中心"}},{path:"aftersale/detail",style:{navigationBarTitleText:"售后详情"},meta:{auth:!0,title:"售后详情"}},{path:"aftersale/log",style:{navigationBarTitleText:"售后进度"},meta:{auth:!0,title:"售后进度"}},{path:"express/log",style:{navigationBarTitleText:"物流轨迹"},meta:{auth:!0,title:"物流轨迹"}},{path:"otherlist",style:{navigationBarTitleText:"",enablePullDownRefresh:!1}}]},{root:"pages/user",pages:[{path:"info",style:{navigationBarTitleText:"用户信息"},meta:{auth:!0,sync:!0,title:"用户信息",group:"用户中心"}},{path:"setting",style:{navigationBarTitleText:"用户设置"},meta:{auth:!0,sync:!0,title:"用户设置",group:"用户中心"}},{path:"qrcode-share",style:{navigationBarTitleText:"我的二维码/分享页"},meta:{auth:!0,sync:!0,title:"我的二维码/分享页",group:"用户中心"}},{path:"goods-collect",style:{navigationBarTitleText:"我的收藏"},meta:{auth:!0,sync:!0,title:"商品收藏",group:"用户中心"}},{path:"goods-log",style:{navigationBarTitleText:"我的足迹"},meta:{auth:!0,sync:!0,title:"浏览记录",group:"用户中心"}},{path:"address/list",style:{navigationBarTitleText:"实体商品收货地址"},meta:{auth:!0,sync:!0,title:"地址管理",group:"用户中心"}},{path:"dummyAddress/list",style:{navigationBarTitleText:"虚拟商品收货地址"},meta:{auth:!0,sync:!0,title:"虚拟商品收货地址",group:"用户中心"}},{path:"invoice/edit",style:{navigationBarTitleText:"发票抬头编辑"},meta:{auth:!0,title:"发票抬头"}},{path:"invoice/list",style:{navigationBarTitleText:"发票抬头管理"},meta:{auth:!0,sync:!0,title:"发票抬头管理",group:"用户中心"}},{path:"address/edit",style:{navigationBarTitleText:"编辑地址"},meta:{auth:!0,title:"编辑地址"}},{path:"dummyAddress/edit",style:{navigationBarTitleText:"编辑地址"},meta:{auth:!0,title:"编辑地址"}},{path:"wallet/money",style:{navigationBarTitleText:"我的余额"},meta:{auth:!0,sync:!0,title:"用户余额",group:"用户中心"}},{path:"wallet/score",style:{navigationBarTitleText:"钱包"},meta:{auth:!0,sync:!0,title:"钱包",group:"用户中心"}},{path:"wallet/consumptionLog",style:{navigationBarTitleText:"消费分来源"},meta:{auth:!0,sync:!0,title:"消费分来源",group:"用户中心"}},{path:"wallet/topupConsumptionPoints",style:{navigationBarTitleText:"消费分充值"},meta:{auth:!0,sync:!0,title:"消费分充值",group:"用户中心"}},{path:"wallet/consumptionTransfersLog",style:{navigationBarTitleText:"消费分转账"},meta:{auth:!0,sync:!0,title:"消费分转账",group:"用户中心"}},{path:"wallet/consumptionTransfers",style:{navigationBarTitleText:"消费分转让"},meta:{auth:!0,sync:!0,title:"消费分转让",group:"用户中心"}},{path:"wallet/scoreToConsumption",style:{navigationBarTitleText:"佣金转消费分"},meta:{auth:!0,sync:!0,title:"佣金转消费分",group:"用户中心"}},{path:"wallet/withdraw",style:{navigationBarTitleText:"提现"},meta:{auth:!0,sync:!0,title:"提现",group:"提现"}},{path:"wallet/withdrawalLog",style:{navigationBarTitleText:"提现记录"},meta:{auth:!0,sync:!0,title:"提现记录",group:"提现记录"}},{path:"wallet/scoreToMoney",style:{navigationBarTitleText:"佣金兑换"},meta:{auth:!0,sync:!0,title:"佣金兑换",group:"用户中心"}},{path:"wallet/ScoreLog"},{path:"wallet/maxScoreLog"},{path:"wallet/team",style:{navigationBarTitleText:"团队"},meta:{auth:!0,sync:!0,title:"团队",group:"用户中心"}}]},{root:"pages/commission",pages:[{path:"index",style:{navigationBarTitleText:"分销"},meta:{auth:!0,sync:!0,title:"分销中心",group:"分销商城"}},{path:"wallet",style:{navigationBarTitleText:"我的佣金"},meta:{auth:!0,sync:!0,title:"用户佣金",group:"分销中心"}},{path:"goods",style:{navigationBarTitleText:"推广商品"},meta:{auth:!0,sync:!0,title:"推广商品",group:"分销商城"}},{path:"order",style:{navigationBarTitleText:"分销订单"},meta:{auth:!0,sync:!0,title:"分销订单",group:"分销商城"}},{path:"team",style:{navigationBarTitleText:"我的团队"},meta:{auth:!0,sync:!0,title:"我的团队",group:"分销商城"}},{path:"promoter",style:{navigationBarTitleText:"推广人排行榜"},meta:{auth:!0,sync:!0,title:"推广人排行榜",group:"分销商城"}},{path:"commission-ranking",style:{navigationBarTitleText:"佣金排行榜"},meta:{auth:!0,sync:!0,title:"佣金排行榜",group:"分销商城"}},{path:"withdraw",style:{navigationBarTitleText:"申请提现"},meta:{auth:!0,sync:!0,title:"申请提现",group:"分销商城"}}]},{root:"pages/app",pages:[{path:"sign",style:{navigationBarTitleText:"签到中心"},meta:{auth:!0,sync:!0,title:"签到中心",group:"应用"}}]},{root:"pages/shop",pages:[{path:"index",style:{navigationBarTitleText:"店铺首页"},meta:{auth:!0,sync:!0,title:"店铺首页",group:"应用"}},{path:"category",style:{navigationBarTitleText:"店铺分类"},meta:{auth:!0,sync:!0,title:"店铺分类",group:"应用"}},{path:"allproduct",style:{navigationBarTitleText:"所有商品"},meta:{auth:!0,sync:!0,title:"所有商品",group:"应用"}}]},{root:"pages/public",pages:[{path:"setting",style:{navigationBarTitleText:"系统设置"},meta:{sync:!0,title:"系统设置",group:"通用"}},{path:"richtext",style:{navigationBarTitleText:"富文本"},meta:{sync:!0,title:"富文本",group:"通用"}},{path:"faq",style:{navigationBarTitleText:"常见问题"},meta:{sync:!0,title:"常见问题",group:"通用"}},{path:"error",style:{navigationBarTitleText:"错误页面"}},{path:"webview",style:{navigationBarTitleText:""}},{path:"merchant",style:{navigationBarTitleText:"",enablePullDownRefresh:!1}},{path:"merchantApplyList",style:{navigationBarTitleText:"",enablePullDownRefresh:!1}}]},{root:"pages/coupon",pages:[{path:"list",style:{navigationBarTitleText:"领券中心"},meta:{sync:!0,title:"领券中心",group:"优惠券"}},{path:"detail",style:{navigationBarTitleText:"优惠券"},meta:{auth:!1,sync:!0,title:"优惠券详情",group:"优惠券"}}]},{root:"pages/chat",pages:[{path:"index",style:{navigationBarTitleText:"客服"},meta:{auth:!0,sync:!0,title:"客服",group:"客服"}},{path:"speechtotext",style:{navigationBarTitleText:"语音转文字",enablePullDownRefresh:!1},meta:{auth:!0,sync:!0,title:"语音转文字",group:"语音转文字"}}]},{root:"pages/pay",pages:[{path:"index",style:{navigationBarTitleText:"收银台"}},{path:"result",style:{navigationBarTitleText:"富友支付结果"}},{path:"resultYuan",style:{navigationBarTitleText:"支付结果"}},{path:"recharge",style:{navigationBarTitleText:"充值余额"},meta:{auth:!0,sync:!0,title:"充值余额",group:"支付"}},{path:"recharge-log",style:{navigationBarTitleText:"充值记录"},meta:{auth:!0,sync:!0,title:"充值记录",group:"支付"}}]},{root:"pages/activity",pages:[{path:"groupon/detail",style:{navigationBarTitleText:"拼团详情"}},{path:"groupon/order",style:{navigationBarTitleText:"我的拼团",enablePullDownRefresh:!0},meta:{auth:!0,sync:!0,title:"拼团订单",group:"营销活动"}},{path:"index",style:{navigationBarTitleText:"营销商品"},meta:{sync:!0,title:"营销商品",group:"营销活动"}},{path:"groupon/list",style:{navigationBarTitleText:"拼团活动"},meta:{sync:!0,title:"拼团活动",group:"营销活动"}},{path:"seckill/list",style:{navigationBarTitleText:"秒杀活动"},meta:{sync:!0,title:"秒杀活动",group:"营销活动"}},{path:"bargain/list",style:{navigationBarTitleText:"砍价列表"},meta:{sync:!0,title:"砍价列表",group:"营销活动"}},{path:"bargain/detail",style:{navigationBarTitleText:"砍价详情"},meta:{sync:!0,title:"砍价详情",group:"营销活动"}}]}],globalStyle:{navigationBarTextStyle:"black",navigationBarTitleText:"常来此购",navigationBarBackgroundColor:"#FFFFFF",backgroundColor:"#FFFFFF",navigationStyle:"custom"},tabBar:{list:[{pagePath:"pages/index/index"},{pagePath:"pages/index/cart"},{pagePath:"pages/index/user"}]},condition:{current:0,list:[{name:"",path:"",query:""}]},usingComponents:{richtext:"@/pages/public/richtext"}};function b(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var O=b((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},r=s.lib={},i=r.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,r=e.sigBytes;if(this.clamp(),s%4)for(var i=0;i>>2]>>>24-i%4*8&255;t[s+i>>>2]|=o<<24-(s+i)%4*8}else for(i=0;i>>2]=n[i>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],r=function(t){var n=987654321,s=4294967295;return function(){var r=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return r/=4294967296,(r+=.5)*(e.random()>.5?1:-1)}},i=0;i>>2]>>>24-r%4*8&255;s.push((i>>>4).toString(16)),s.push((15&i).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new o.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r>>2]>>>24-r%4*8&255;s.push(String.fromCharCode(i))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new o.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,s=n.words,r=n.sigBytes,i=this.blockSize,a=r/(4*i),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,u=e.min(4*c,r);if(c){for(var l=0;l>>24)|4278255360&(r<<24|r>>>8)}var i=this._hash.words,o=e[t+0],c=e[t+1],p=e[t+2],g=e[t+3],f=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],T=e[t+8],w=e[t+9],v=e[t+10],x=e[t+11],I=e[t+12],k=e[t+13],S=e[t+14],P=e[t+15],A=i[0],b=i[1],O=i[2],C=i[3];A=u(A,b,O,C,o,7,a[0]),C=u(C,A,b,O,c,12,a[1]),O=u(O,C,A,b,p,17,a[2]),b=u(b,O,C,A,g,22,a[3]),A=u(A,b,O,C,f,7,a[4]),C=u(C,A,b,O,m,12,a[5]),O=u(O,C,A,b,y,17,a[6]),b=u(b,O,C,A,_,22,a[7]),A=u(A,b,O,C,T,7,a[8]),C=u(C,A,b,O,w,12,a[9]),O=u(O,C,A,b,v,17,a[10]),b=u(b,O,C,A,x,22,a[11]),A=u(A,b,O,C,I,7,a[12]),C=u(C,A,b,O,k,12,a[13]),O=u(O,C,A,b,S,17,a[14]),A=l(A,b=u(b,O,C,A,P,22,a[15]),O,C,c,5,a[16]),C=l(C,A,b,O,y,9,a[17]),O=l(O,C,A,b,x,14,a[18]),b=l(b,O,C,A,o,20,a[19]),A=l(A,b,O,C,m,5,a[20]),C=l(C,A,b,O,v,9,a[21]),O=l(O,C,A,b,P,14,a[22]),b=l(b,O,C,A,f,20,a[23]),A=l(A,b,O,C,w,5,a[24]),C=l(C,A,b,O,S,9,a[25]),O=l(O,C,A,b,g,14,a[26]),b=l(b,O,C,A,T,20,a[27]),A=l(A,b,O,C,k,5,a[28]),C=l(C,A,b,O,p,9,a[29]),O=l(O,C,A,b,_,14,a[30]),A=h(A,b=l(b,O,C,A,I,20,a[31]),O,C,m,4,a[32]),C=h(C,A,b,O,T,11,a[33]),O=h(O,C,A,b,x,16,a[34]),b=h(b,O,C,A,S,23,a[35]),A=h(A,b,O,C,c,4,a[36]),C=h(C,A,b,O,f,11,a[37]),O=h(O,C,A,b,_,16,a[38]),b=h(b,O,C,A,v,23,a[39]),A=h(A,b,O,C,k,4,a[40]),C=h(C,A,b,O,o,11,a[41]),O=h(O,C,A,b,g,16,a[42]),b=h(b,O,C,A,y,23,a[43]),A=h(A,b,O,C,w,4,a[44]),C=h(C,A,b,O,I,11,a[45]),O=h(O,C,A,b,P,16,a[46]),A=d(A,b=h(b,O,C,A,p,23,a[47]),O,C,o,6,a[48]),C=d(C,A,b,O,_,10,a[49]),O=d(O,C,A,b,S,15,a[50]),b=d(b,O,C,A,m,21,a[51]),A=d(A,b,O,C,I,6,a[52]),C=d(C,A,b,O,g,10,a[53]),O=d(O,C,A,b,v,15,a[54]),b=d(b,O,C,A,c,21,a[55]),A=d(A,b,O,C,T,6,a[56]),C=d(C,A,b,O,P,10,a[57]),O=d(O,C,A,b,y,15,a[58]),b=d(b,O,C,A,k,21,a[59]),A=d(A,b,O,C,f,6,a[60]),C=d(C,A,b,O,x,10,a[61]),O=d(O,C,A,b,p,15,a[62]),b=d(b,O,C,A,w,21,a[63]),i[0]=i[0]+A|0,i[1]=i[1]+b|0,i[2]=i[2]+O|0,i[3]=i[3]+C|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;n[r>>>5]|=128<<24-r%32;var i=e.floor(s/4294967296),o=s;n[15+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,r,i,o){var a=e+(t&n|~t&s)+r+o;return(a<>>32-i)+t}function l(e,t,n,s,r,i,o){var a=e+(t&s|n&~s)+r+o;return(a<>>32-i)+t}function h(e,t,n,s,r,i,o){var a=e+(t^n^s)+r+o;return(a<>>32-i)+t}function d(e,t,n,s,r,i,o){var a=e+(n^(t|~s))+r+o;return(a<>>32-i)+t}t.MD5=i._createHelper(c),t.HmacMD5=i._createHmacHelper(c)}(Math),n.MD5)})),b((function(e,t){var n,s,r;e.exports=(s=(n=C).lib.Base,r=n.enc.Utf8,void(n.algo.HMAC=s.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),a=i.words,c=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a>>6*(3-a)&63));var c=s.charAt(64);if(c)for(;r.length%4;)r.push(c);return r.join("")},parse:function(e){var t=e.length,n=this._map,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var i=0;i>>6-o%4*2;s[i>>>2]|=(a|c)<<24-i%4*8,i++}return r.create(s,i)}(e,t,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)}));const U="uni_id_token",D="uni_id_token_expired",N="FUNCTION",M="OBJECT",B="CLIENT_DB",q="pending",F="rejected";function j(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function $(e){return"object"===j(e)}function K(e){return"function"==typeof e}function H(e){return function(){try{return e.apply(e,arguments)}catch(t){console.error(t)}}}const J="REJECTED",W="NOT_PENDING";class V{constructor({createPromise:e,retryRule:t=J}={}){this.createPromise=e,this.status=null,this.promise=null,this.retryRule=t}get needRetry(){if(!this.status)return!0;switch(this.retryRule){case J:return this.status===F;case W:return this.status!==q}}exec(){return this.needRetry?(this.status=q,this.promise=this.createPromise().then((e=>(this.status="fulfilled",Promise.resolve(e))),(e=>(this.status=F,Promise.reject(e)))),this.promise):this.promise}}function z(e){return e&&"string"==typeof e?JSON.parse(e):e}const Q=z([]);z("");const Y=z("[]")||[];let G="";try{G="__UNI__7806143"}catch(Fe){}let X,Z={};function ee(e,t={}){var n,s;return n=Z,s=e,Object.prototype.hasOwnProperty.call(n,s)||(Z[e]=t),Z[e]}const te=["invoke","success","fail","complete"],ne=ee("_globalUniCloudInterceptor");function se(e,t){ne[e]||(ne[e]={}),$(t)&&Object.keys(t).forEach((n=>{te.indexOf(n)>-1&&function(e,t,n){let s=ne[e][t];s||(s=ne[e][t]=[]),-1===s.indexOf(n)&&K(n)&&s.push(n)}(e,n,t[n])}))}function re(e,t){ne[e]||(ne[e]={}),$(t)?Object.keys(t).forEach((n=>{te.indexOf(n)>-1&&function(e,t,n){const s=ne[e][t];if(!s)return;const r=s.indexOf(n);r>-1&&s.splice(r,1)}(e,n,t[n])})):delete ne[e]}function ie(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function oe(e,t){return ne[e]&&ne[e][t]||[]}function ae(e){se("callObject",e)}const ce=ee("_globalUniCloudListener"),ue="response",le="needLogin",he="refreshToken",de="clientdb",pe="cloudfunction",ge="cloudobject";function fe(e){return ce[e]||(ce[e]=[]),ce[e]}function me(e,t){const n=fe(e);n.includes(t)||n.push(t)}function ye(e,t){const n=fe(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function _e(e,t){const n=fe(e);for(let s=0;s{we&&e(),function t(){if("function"==typeof n){const t=n();t&&t[0]&&(we=!0,e())}we||setTimeout((()=>{t()}),30)}()})),Te)}function xe(e){const t={};for(const n in e){const s=e[n];K(s)&&(t[n]=H(s))}return t}class Ie extends Error{constructor(e){super(e.message),this.errMsg=e.message||e.errMsg||"unknown system error",this.code=this.errCode=e.code||e.errCode||"SYSTEM_ERROR",this.errSubject=this.subject=e.subject||e.errSubject,this.cause=e.cause,this.requestId=e.requestId}toJson(e=0){if(!(e>=10))return e++,{errCode:this.errCode,errMsg:this.errMsg,errSubject:this.errSubject,cause:this.cause&&this.cause.toJson?this.cause.toJson(e):this.cause}}}var ke={request:e=>h(e),uploadFile:e=>d(e),setStorageSync:(e,t)=>p(e,t),getStorageSync:e=>g(e),removeStorageSync:e=>f(e),clearStorageSync:()=>m(),connectSocket:e=>y(e)};function Se(e){return e&&Se(e.__v_raw)||e}function Pe(){return{token:ke.getStorageSync(U)||ke.getStorageSync("uniIdToken"),tokenExpired:ke.getStorageSync(D)}}function Ae({token:e,tokenExpired:t}={}){e&&ke.setStorageSync(U,e),t&&ke.setStorageSync(D,t)}let be,Oe;function Ce(){return be||(be=_()),be}function Le(){let e,t;try{if(P){if(P.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=P();e=s,t=n}}catch(n){}return{channel:e,scene:t}}let Ee={};function Re(){const e=S&&S()||"en";if(Oe)return{...Ee,...Oe,locale:e,LOCALE:e};const t=Ce(),{deviceId:n,osName:s,uniPlatform:r,appId:i}=t,o=["appId","appLanguage","appName","appVersion","appVersionCode","appWgtVersion","browserName","browserVersion","deviceBrand","deviceId","deviceModel","deviceType","osName","osVersion","romName","romVersion","ua","hostName","hostVersion","uniPlatform","uniRuntimeVersion","uniRuntimeVersionCode","uniCompilerVersion","uniCompilerVersionCode"];for(const a in t)Object.hasOwnProperty.call(t,a)&&-1===o.indexOf(a)&&delete t[a];return Oe={PLATFORM:r,OS:s,APPID:i,DEVICEID:n,...Le(),...t},{...Ee,...Oe,locale:e,LOCALE:e}}var Ue=function(e,t){let n="";return Object.keys(e).sort().forEach((function(t){e[t]&&(n=n+"&"+t+"="+e[t])})),n=n.slice(1),L(n,t).toString()},De=function(e,t){return new Promise(((n,s)=>{t(Object.assign(e,{complete(e){e||(e={});const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400){const n=e.data&&e.data.error&&e.data.error.code||"SYS_ERR",r=e.data&&e.data.error&&e.data.error.message||e.errMsg||"request:fail";return s(new Ie({code:n,message:r,requestId:t}))}const r=e.data;if(r.error)return s(new Ie({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,n(r)}}))}))},Ne=function(e){return R.stringify(E.parse(e))},Me={init(e){const t=new class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`${t} required`)})),this.config=Object.assign({},{endpoint:0===e.spaceId.indexOf("mp-")?"https://api.next.bspapp.com":"https://api.bspapp.com"},e),this.config.provider="aliyun",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.config.accessTokenKey="access_token_"+this.config.spaceId,this.adapter=ke,this._getAccessTokenPromiseHub=new V({createPromise:()=>this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>{if(!e.result||!e.result.accessToken)throw new Ie({code:"AUTH_FAILED",message:"获取accessToken失败"});this.setAccessToken(e.result.accessToken)})),retryRule:W})}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return De(e,this.adapter.request)}requestAuth(e){return this.requestWrapped(e)}request(e,t){return Promise.resolve().then((()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch((t=>new Promise(((e,n)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?n(t):e()})).then((()=>this.getAccessToken())).then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)})))):this.getAccessToken().then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)}))))}rebuildRequest(e){const t=Object.assign({},e);return t.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=Ue(t.data,this.config.clientSecret),t}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=Ue(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){return this._getAccessTokenPromiseHub.exec()}async authorize(){await this.getAccessToken()}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request({...this.setupRequest(t),timeout:e.timeout})}getOSSUploadOptionsFromPath(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:i}){return new Promise(((o,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?o(e):a(new Ie({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new Ie({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof i&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{i({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}async uploadFile({filePath:e,cloudPath:t,fileType:n="image",cloudPathAsRealPath:s=!1,onUploadProgress:r,config:i}){if("string"!==j(t))throw new Ie({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new Ie({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new Ie({code:"INVALID_PARAM",message:"cloudPath不合法"});const o=i&&i.envType||this.config.envType;if(s&&("/"!==t[0]&&(t="/"+t),t.indexOf("\\")>-1))throw new Ie({code:"INVALID_PARAM",message:"使用cloudPath作为路径时,cloudPath不可包含“\\”"});const a=(await this.getOSSUploadOptionsFromPath({env:o,filename:s?t.split("/").pop():t,fileId:s?t:void 0})).result,c="https://"+a.cdnDomain+"/"+a.ossPath,{securityToken:u,accessKeyId:l,signature:h,host:d,ossPath:p,id:g,policy:f,ossCallbackUrl:m}=a,y={"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:l,Signature:h,host:d,id:g,key:p,policy:f,success_action_status:200};if(u&&(y["x-oss-security-token"]=u),m){const e=JSON.stringify({callbackUrl:m,callbackBody:JSON.stringify({fileId:g,spaceId:this.config.spaceId}),callbackBodyType:"application/json"});y.callback=Ne(e)}const _={url:"https://"+a.host,formData:y,fileName:"file",name:"file",filePath:e,fileType:n};if(await this.uploadFileToOSS(Object.assign({},_,{onUploadProgress:r})),m)return{success:!0,filePath:e,fileID:c};if((await this.reportOSSUpload({id:g})).success)return{success:!0,filePath:e,fileID:c};throw new Ie({code:"UPLOAD_FAILED",message:"文件上传失败"})}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new Ie({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}async getFileInfo({fileList:e}={}){if(!Array.isArray(e)||0===e.length)throw new Ie({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});const t={method:"serverless.file.resource.info",params:JSON.stringify({id:e.map((e=>e.split("?")[0])).join(",")})};return{fileList:(await this.request(this.setupRequest(t))).result}}}(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};const Be="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var qe,Fe;(Fe=qe||(qe={})).local="local",Fe.none="none",Fe.session="session";var je=function(){},$e=b((function(e,t){var n;e.exports=(n=C,function(e){var t=n,s=t.lib,r=s.WordArray,i=s.Hasher,o=t.algo,a=[],c=[];!function(){function t(t){for(var n=e.sqrt(t),s=2;s<=n;s++)if(!(t%s))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var s=2,r=0;r<64;)t(s)&&(r<8&&(a[r]=n(e.pow(s,.5))),c[r]=n(e.pow(s,1/3)),r++),s++}();var u=[],l=o.SHA256=i.extend({_doReset:function(){this._hash=new r.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,s=n[0],r=n[1],i=n[2],o=n[3],a=n[4],l=n[5],h=n[6],d=n[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var g=u[p-15],f=(g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3,m=u[p-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[p]=f+u[p-7]+y+u[p-16]}var _=s&r^s&i^r&i,T=(s<<30|s>>>2)^(s<<19|s>>>13)^(s<<10|s>>>22),w=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+c[p]+u[p];d=h,h=l,l=a,a=o+w|0,o=i,i=r,r=s,s=w+(T+_)|0}n[0]=n[0]+s|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+o|0,n[4]=n[4]+a|0,n[5]=n[5]+l|0,n[6]=n[6]+h|0,n[7]=n[7]+d|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=e.floor(s/4294967296),n[15+(r+64>>>9<<4)]=s,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(l),t.HmacSHA256=i._createHmacHelper(l)}(Math),n.SHA256)})),Ke=$e,He=b((function(e,t){e.exports=C.HmacSHA256}));const Je=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new Ie({message:'Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.'})};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}const t=new Promise(((t,n)=>{e=(e,s)=>e?n(e):t(s)}));return e.promise=t,e};function We(e){return void 0===e}function Ve(e){return"[object Null]"===Object.prototype.toString.call(e)}function ze(e=""){return e.replace(/([\s\S]+)\s+(请前往云开发AI小助手查看问题:.*)/,"$1")}function Qe(e=32){let t="";for(let n=0;n=0?JSON.parse(n).content:""}removeStore(e){this._storage.removeItem(e)}}const nt={},st={};function rt(e){return nt[e]}class it{constructor(e,t){this.data=t||null,this.name=e}}class ot extends it{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const at=new class{constructor(){this._listeners={}}on(e,t){return n=e,s=t,(r=this._listeners)[n]=r[n]||[],r[n].push(s),this;var n,s,r}off(e,t){return function(e,t,n){if(n&&n[e]){const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof ot)return console.error(e.error),this;const n="string"==typeof e?new it(e,t||{}):e,s=n.name;if(this._listens(s)){n.target=this;const e=this._listeners[s]?[...this._listeners[s]]:[];for(const t of e)t.call(this,n)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function ct(e,t){at.on(e,t)}function ut(e,t={}){at.fire(e,t)}function lt(e,t){at.off(e,t)}const ht="loginStateChanged",dt="loginStateExpire",pt="loginTypeChanged",gt="anonymousConverted",ft="refreshAccessToken";var mt;!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL"}(mt||(mt={}));class yt{constructor(){this._fnPromiseMap=new Map}async run(e,t){let n=this._fnPromiseMap.get(e);return n||(n=new Promise((async(n,s)=>{try{await this._runIdlePromise();const s=t();n(await s)}catch(r){s(r)}finally{this._fnPromiseMap.delete(e)}})),this._fnPromiseMap.set(e,n)),n}_runIdlePromise(){return Promise.resolve()}}class _t{constructor(e){this._singlePromise=new yt,this._cache=rt(e.env),this._baseURL=`https://${e.env}.ap-shanghai.tcb-api.tencentcloudapi.com`,this._reqClass=new Ge.adapter.reqClass({timeout:e.timeout,timeoutMsg:`请求在${e.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]})}_getDeviceId(){if(this._deviceID)return this._deviceID;const{deviceIdKey:e}=this._cache.keys;let t=this._cache.getStore(e);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=Qe(),this._cache.setStore(e,t)),this._deviceID=t,t}async _request(e,t,n={}){const s={"x-request-id":Qe(),"x-device-id":this._getDeviceId()};if(n.withAccessToken){const{tokenTypeKey:e}=this._cache.keys,t=await this.getAccessToken(),n=this._cache.getStore(e);s.authorization=`${n} ${t}`}return this._reqClass["get"===n.method?"get":"post"]({url:`${this._baseURL}${e}`,data:t,headers:s})}async _fetchAccessToken(){const{loginTypeKey:e,accessTokenKey:t,accessTokenExpireKey:n,tokenTypeKey:s}=this._cache.keys,r=this._cache.getStore(e);if(r&&r!==mt.ANONYMOUS)throw new Ie({code:"INVALID_OPERATION",message:"非匿名登录不支持刷新 access token"});const i=await this._singlePromise.run("fetchAccessToken",(async()=>(await this._request("/auth/v1/signin/anonymously",{},{method:"post"})).data)),{access_token:o,expires_in:a,token_type:c}=i;return this._cache.setStore(s,c),this._cache.setStore(t,o),this._cache.setStore(n,Date.now()+1e3*a),o}isAccessTokenExpired(e,t){let n=!0;return e&&t&&(n=t(await this._request("/auth/v1/user/me",{},{withAccessToken:!0,method:"get"})).data))}}const Tt=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],wt={"X-SDK-Version":"1.3.5"};function vt(e,t,n){const s=e[t];e[t]=function(t){const r={},i={};n.forEach((n=>{const{data:s,headers:o}=n.call(e,t);Object.assign(r,s),Object.assign(i,o)}));const o=t.data;return o&&(()=>{var e;if(e=o,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...o,...r};else for(const t in r)o.append(t,r[t])})(),t.headers={...t.headers||{},...i},s.call(e,t)}}function xt(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...wt,"x-seqid":e}}}class It{constructor(e={}){var t;this.config=e,this._reqClass=new Ge.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=rt(this.config.env),this._localCache=(t=this.config.env,st[t]),this.oauth=new _t(this.config),vt(this._reqClass,"post",[xt]),vt(this._reqClass,"upload",[xt]),vt(this._reqClass,"download",[xt])}async post(e){return await this._reqClass.post(e)}async upload(e){return await this._reqClass.upload(e)}async download(e){return await this._reqClass.download(e)}async refreshAccessToken(){let e,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=await this._refreshAccessTokenPromise}catch(n){t=n}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:r}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let i=this._cache.getStore(n);if(!i)throw new Ie({message:"未登录CloudBase"});const o={refresh_token:i},a=await this.request("auth.fetchAccessTokenWithRefreshToken",o);if(a.data.code){const{code:e}=a.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(s)===mt.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(r),t=this._cache.getStore(n),s=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(s.refresh_token),this._refreshAccessToken()}ut(dt),this._cache.removeStore(n)}throw new Ie({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return ut(ft),this._cache.setStore(e,a.data.access_token),this._cache.setStore(t,a.data.access_token_expire+Date.now()),{accessToken:a.data.access_token,accessTokenExpire:a.data.access_token_expire};a.data.refresh_token&&(this._cache.removeStore(n),this._cache.setStore(n,a.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n}=this._cache.keys;if(!this._cache.getStore(n))throw new Ie({message:"refresh token不存在,登录状态异常"});let s=this._cache.getStore(e),r=this._cache.getStore(t),i=!0;return this._shouldRefreshAccessTokenHook&&!(await this._shouldRefreshAccessTokenHook(s,r))&&(i=!1),(!s||!r||r{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:n,hasPrimaryUid:t}}setPrimaryUid(e){return this._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){return this._request.send("auth.unlink",{platform:e})}async update(e){const{nickName:t,gender:n,avatarUrl:s,province:r,country:i,city:o}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:r,country:i,city:o});this.setLocalUserInfo(a)}async refresh(){const e=await this._request.oauth.getUserInfo();return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach((e=>{this[e]=t[e]})),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class bt{constructor(e){if(!e)throw new Ie({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=rt(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,r=this._cache.getStore(t),i=this._cache.getStore(n),o=this._cache.getStore(s);this.credential={refreshToken:r,accessToken:i,accessTokenExpire:o},this.user=new At(e)}get isAnonymousAuth(){return this.loginType===mt.ANONYMOUS}get isCustomAuth(){return this.loginType===mt.CUSTOM}get isWeixinAuth(){return this.loginType===mt.WECHAT||this.loginType===mt.WECHAT_OPEN||this.loginType===mt.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class Ot extends Pt{async signIn(){this._cache.updatePersistence("local"),await this._request.oauth.getAccessToken(),ut(ht),ut(pt,{env:this.config.env,loginType:mt.ANONYMOUS,persistence:"local"});const e=new bt(this.config.env);return await e.user.refresh(),e}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),r=this._cache.getStore(n),i=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:r,ticket:e});if(i.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(i.refresh_token),await this._request.refreshAccessToken(),ut(gt,{env:this.config.env}),ut(pt,{loginType:mt.CUSTOM,persistence:"local"}),{credential:{refreshToken:i.refresh_token}};throw new Ie({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,mt.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Ct extends Pt{async signIn(e){if("string"!=typeof e)throw new Ie({code:"PARAM_ERROR",message:"ticket must be a string"});const{refreshTokenKey:t}=this._cache.keys,n=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(n.refresh_token)return this.setRefreshToken(n.refresh_token),await this._request.refreshAccessToken(),ut(ht),ut(pt,{env:this.config.env,loginType:mt.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new bt(this.config.env);throw new Ie({message:"自定义登录失败"})}}class Lt extends Pt{async signIn(e,t){if("string"!=typeof e)throw new Ie({code:"PARAM_ERROR",message:"email must be a string"});const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token:i,access_token_expire:o}=s;if(r)return this.setRefreshToken(r),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),ut(ht),ut(pt,{env:this.config.env,loginType:mt.EMAIL,persistence:this.config.persistence}),new bt(this.config.env);throw s.code?new Ie({code:s.code,message:`邮箱登录失败: ${s.message}`}):new Ie({message:"邮箱登录失败"})}async activate(e){return this._request.send("auth.activateEndUserMail",{token:e})}async resetPasswordWithToken(e,t){return this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}class Et extends Pt{async signIn(e,t){if("string"!=typeof e)throw new Ie({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:mt.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token_expire:i,access_token:o}=s;if(r)return this.setRefreshToken(r),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),ut(ht),ut(pt,{env:this.config.env,loginType:mt.USERNAME,persistence:this.config.persistence}),new bt(this.config.env);throw s.code?new Ie({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new Ie({message:"用户名密码登录失败"})}}class Rt{constructor(e){this.config=e,this._cache=rt(e.env),this._request=St(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),ct(pt,this._onLoginTypeChanged)}get currentUser(){const e=this.hasLoginState();return e&&e.user||null}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){return new Ot(this.config)}customAuthProvider(){return new Ct(this.config)}emailAuthProvider(){return new Lt(this.config)}usernameAuthProvider(){return new Et(this.config)}async signInAnonymously(){return new Ot(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new Lt(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new Et(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new Ot(this.config)),ct(gt,this._onAnonymousConverted),await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===mt.ANONYMOUS)throw new Ie({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const r=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),ut(ht),ut(pt,{env:this.config.env,loginType:mt.NULL,persistence:this.config.persistence}),r}async signUpWithEmailAndPassword(e,t){return this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}async sendPasswordResetEmail(e){return this._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){ct(ht,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){ct(dt,e.bind(this))}onAccessTokenRefreshed(e){ct(ft,e.bind(this))}onAnonymousConverted(e){ct(gt,e.bind(this))}onLoginTypeChanged(e){ct(pt,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{accessTokenKey:e,accessTokenExpireKey:t}=this._cache.keys,n=this._cache.getStore(e),s=this._cache.getStore(t);return this._request.oauth.isAccessTokenExpired(n,s)?null:new bt(this.config.env)}async isUsernameRegistered(e){if("string"!=typeof e)throw new Ie({code:"PARAM_ERROR",message:"username must be a string"});const{data:t}=await this._request.send("auth.isUsernameRegistered",{username:e});return t&&t.isRegistered}getLoginState(){return Promise.resolve(this.hasLoginState())}async signInWithTicket(e){return new Ct(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){return this._request.send("auth.getUserInfo",{}).then((e=>e.code?e:{...e.data,requestId:e.seqId}))}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,n=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+n}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:n,env:s}=e.data;s===this.config.env&&(this._cache.updatePersistence(n),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const Ut=function(e,t){t=t||Je();const n=St(this.config.env),{cloudPath:s,filePath:r,onUploadProgress:i,fileType:o="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:l,cosFileId:h},requestId:d}=e,p={key:s,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:p,file:r,name:s,fileType:o,onUploadProgress:i}).then((e=>{201===e.statusCode?t(null,{fileID:l,requestId:d}):t(new Ie({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Dt=function(e,t){t=t||Je();const n=St(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},Nt=function({fileList:e},t){if(t=t||Je(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let s of e)if(!s||"string"!=typeof s)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return St(this.config.env).send("storage.batchDeleteFile",n).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Mt=function({fileList:e},t){t=t||Je(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let r of e)"object"==typeof r?(r.hasOwnProperty("fileID")&&r.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:r.fileID,max_age:r.maxAge})):"string"==typeof r?n.push({fileid:r}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return St(this.config.env).send("storage.batchGetDownloadUrl",s).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Bt=async function({fileID:e},t){const n=(await Mt.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=St(this.config.env);let r=n.download_url;if(r=encodeURI(r),!t)return s.download({url:r});t(await s.download({url:r}))},qt=function({name:e,data:t,query:n,parse:s,search:r,timeout:i},o){const a=o||Je();let c;try{c=t?JSON.stringify(t):""}catch(l){return Promise.reject(l)}if(!e)return Promise.reject(new Ie({code:"PARAM_ERROR",message:"函数名不能为空"}));const u={inQuery:n,parse:s,search:r,function_name:e,request_data:c};return St(this.config.env).send("functions.invokeFunction",u,{timeout:i}).then((e=>{if(e.code)a(null,e);else{let n=e.data.response_data;if(s)a(null,{result:n,requestId:e.requestId});else try{n=JSON.parse(e.data.response_data),a(null,{result:n,requestId:e.requestId})}catch(t){a(new Ie({message:"response data must be json"}))}}return a.promise})).catch((e=>{a(e)})),a.promise},Ft={timeout:15e3,persistence:"session"},jt={};class $t{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(Ge.adapter||(this.requestClient=new Ge.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Ft,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new $t(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||Ge.adapter.primaryStorage||Ft.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;nt[t]=new tt(e),st[t]=new tt({...e,persistence:"local"})}(this.config),n=this.config,kt[n.env]=new It(n),this.authObj=new Rt(this.config),this.authObj}on(e,t){return ct.apply(this,[e,t])}off(e,t){return lt.apply(this,[e,t])}callFunction(e,t){return qt.apply(this,[e,t])}deleteFile(e,t){return Nt.apply(this,[e,t])}getTempFileURL(e,t){return Mt.apply(this,[e,t])}downloadFile(e,t){return Bt.apply(this,[e,t])}uploadFile(e,t){return Ut.apply(this,[e,t])}getUploadMetadata(e,t){return Dt.apply(this,[e,t])}registerExtension(e){jt[e.name]=e}async invokeExtension(e,t){const n=jt[e];if(!n)throw new Ie({message:`扩展${e} 必须先注册`});return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=function(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const s of t){const{isMatch:e,genAdapter:t,runtime:n}=s;if(e())return{adapter:t(),runtime:n}}}(e)||{};t&&(Ge.adapter=t),n&&(Ge.runtime=n)}}var Kt=new $t;function Ht(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),r="";for(var i in n)""===r?!s&&(t+="?"):r+="&",r+=i+"="+encodeURIComponent(n[i]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}class Jt{get(e){const{url:t,data:n,headers:s,timeout:r}=e;return new Promise(((e,i)=>{ke.request({url:Ht("https:",t),data:n,method:"GET",header:s,timeout:r,success(t){e(t)},fail(e){i(e)}})}))}post(e){const{url:t,data:n,headers:s,timeout:r}=e;return new Promise(((e,i)=>{ke.request({url:Ht("https:",t),data:n,method:"POST",header:s,timeout:r,success(t){e(t)},fail(e){i(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:r,data:i,headers:o,fileType:a}=e,c=ke.uploadFile({url:Ht("https:",s),name:"file",formData:Object.assign({},i),filePath:r,fileType:a,header:o,success(e){const n={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(n.statusCode=parseInt(i.success_action_status,10)),t(n)},fail(e){n(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})}))}))}}const Wt={setItem(e,t){ke.setStorageSync(e,t)},getItem:e=>ke.getStorageSync(e),removeItem(e){ke.removeStorageSync(e)},clear(){ke.clearStorageSync()}};var Vt={genAdapter:function(){return{root:{},reqClass:Jt,localStorage:Wt,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Kt.useAdapters(Vt);const zt=Kt,Qt=zt.init;zt.init=function(e){e.env=e.spaceId;const t=Qt.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const n=t.auth;return t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{var n;t[e]=(n=t[e],function(e){e=e||{};const{success:t,fail:s,complete:r}=xe(e);if(!(t||s||r))return n.call(this,e);n.call(this,e).then((e=>{t&&t(e),r&&r(e)}),(e=>{s&&s(e),r&&r(e)}))}).bind(t)})),t},t.customAuth=t.auth,t};var Yt=zt;async function Gt(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{ke.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(r){return!1}var s}const Xt={"serverless.file.resource.generateProximalSign":"storage/generate-proximal-sign","serverless.file.resource.report":"storage/report","serverless.file.resource.delete":"storage/delete","serverless.file.resource.getTempFileURL":"storage/get-temp-file-url"};var Zt={init(e){const t=new class{constructor(e){if(["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`${t} required`)})),!e.endpoint)throw new Error("集群空间未配置ApiEndpoint,配置后需要重新关联服务空间后生效");this.config=Object.assign({},e),this.config.provider="dcloud",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.adapter=ke}async request(e,t=!0){return e=this.setupRequest(e),Promise.resolve().then((()=>De(e,this.adapter.request)))}requestLocal(e){return new Promise(((t,n)=>{this.adapter.request(Object.assign(e,{complete(e){if(e||(e={}),!e.statusCode||e.statusCode>=400){const t=e.data&&e.data.code||"SYS_ERR",s=e.data&&e.data.message||"request:fail";return n(new Ie({code:t,message:s}))}t({success:!0,result:e.data})}}))}))}setupRequest(e){const t=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),n={"Content-Type":"application/json"};n["x-serverless-sign"]=Ue(t,this.config.clientSecret);const s=Re();n["x-client-info"]=encodeURIComponent(JSON.stringify(s));const{token:r}=Pe();return n["x-client-token"]=r,{url:this.config.requestUrl,method:"POST",data:t,dataType:"json",header:JSON.parse(JSON.stringify(n))}}async setupLocalRequest(e){const t=Re(),{token:n}=Pe(),s=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now(),clientInfo:t,token:n}),{address:r,servePort:i}=this.__dev__&&this.__dev__.debugInfo||{},{address:o}=await async function(e,t){let n;for(let s=0;s{const{url:i,formData:o,name:a}=t.result;return r=t.result.fileUrl,new Promise(((t,r)=>{const c=this.adapter.uploadFile({url:i,formData:o,name:a,filePath:e,fileType:n,success(e){e&&e.statusCode<400?t(e):r(new Ie({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){r(new Ie({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof s&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{s({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))})).then((()=>this.reportUploadFile({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:r}):s(new Ie({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(t).then((e=>{if(e.success)return e.result;throw new Ie({code:"DELETE_FILE_FAILED",message:"删除文件失败"})}))}getTempFileURL({fileList:e,maxAge:t}={}){if(!Array.isArray(e)||0===e.length)throw new Ie({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});const n={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e,maxAge:t})};return this.request(n).then((e=>{if(e.success)return{fileList:e.result.fileList.map((e=>({fileID:e.fileID,tempFileURL:e.tempFileURL})))};throw new Ie({code:"GET_TEMP_FILE_URL_FAILED",message:"获取临时文件链接失败"})}))}}(e),n={signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}},en=b((function(e,t){e.exports=C.enc.Hex}));function tn(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function nn(e="",t={}){const{data:n,functionName:s,method:r,headers:i,signHeaderKeys:o=[],config:a}=t,c=String(Date.now()),u=tn(),l=Object.assign({},i,{"x-from-app-id":a.spaceAppId,"x-from-env-id":a.spaceId,"x-to-env-id":a.spaceId,"x-from-instance-id":c,"x-from-function-name":s,"x-client-timestamp":c,"x-alipay-source":"client","x-request-id":u,"x-alipay-callid":u,"x-trace-id":u}),h=["x-from-app-id","x-from-env-id","x-to-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp"].concat(o),[d="",p=""]=e.split("?")||[],g=function(e){const t="HMAC-SHA256",n=e.signedHeaders.join(";"),s=e.signedHeaders.map((t=>`${t.toLowerCase()}:${e.headers[t]}\n`)).join(""),r=Ke(e.body).toString(en),i=`${e.method.toUpperCase()}\n${e.path}\n${e.query}\n${s}\n${n}\n${r}\n`,o=Ke(i).toString(en),a=`${t}\n${e.timestamp}\n${o}\n`,c=He(a,e.secretKey).toString(en);return`${t} Credential=${e.secretId}, SignedHeaders=${n}, Signature=${c}`}({path:d,query:p,method:r,headers:l,timestamp:c,body:JSON.stringify(n),secretId:a.accessKey,secretKey:a.secretKey,signedHeaders:h.sort()});return{url:`${a.endpoint}${e}`,headers:Object.assign({},l,{Authorization:g})}}function sn({url:e,data:t,method:n="POST",headers:s={},timeout:r}){return new Promise(((i,o)=>{ke.request({url:e,method:n,data:"object"==typeof t?JSON.stringify(t):t,header:s,dataType:"json",timeout:r,complete:(e={})=>{const t=s["x-trace-id"]||"";if(!e.statusCode||e.statusCode>=400){const{message:n,errMsg:s,trace_id:r}=e.data||{};return o(new Ie({code:"SYS_ERR",message:n||s||"request:fail",requestId:r||t}))}i({status:e.statusCode,data:e.data,headers:e.header,requestId:t})}})}))}function rn(e,t){const{path:n,data:s,method:r="GET"}=e,{url:i,headers:o}=nn(n,{functionName:"",data:s,method:r,headers:{"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":Date.now()+6e4},signHeaderKeys:["x-data-api-type","x-expire-timestamp"],config:t});return sn({url:i,data:s,method:r,headers:o}).then((e=>{const t=e.data||{};if(!t.success)throw new Ie({code:e.errCode,message:e.errMsg,requestId:e.requestId});return t.data||{}})).catch((e=>{throw new Ie({code:e.errCode,message:e.errMsg,requestId:e.requestId})}))}function on(e=""){const t=e.trim().replace(/^cloud:\/\//,""),n=t.indexOf("/");if(n<=0)throw new Ie({code:"INVALID_PARAM",message:"fileID不合法"});const s=t.substring(0,n),r=t.substring(n+1);return s!==this.config.spaceId&&console.warn("file ".concat(e," does not belong to env ").concat(this.config.spaceId)),r}function an(e=""){return"cloud://".concat(this.config.spaceId,"/").concat(e.replace(/^\/+/,""))}class cn{constructor(e){this.config=e}signedURL(e,t={}){const n=`/ws/function/${e}`,s=this.config.wsEndpoint.replace(/^ws(s)?:\/\//,""),r=Object.assign({},t,{accessKeyId:this.config.accessKey,signatureNonce:tn(),timestamp:""+Date.now()}),i=[n,["accessKeyId","authorization","signatureNonce","timestamp"].sort().map((function(e){return r[e]?"".concat(e,"=").concat(r[e]):null})).filter(Boolean).join("&"),`host:${s}`].join("\n"),o=["HMAC-SHA256",Ke(i).toString(en)].join("\n"),a=He(o,this.config.secretKey).toString(en),c=Object.keys(r).map((e=>`${e}=${encodeURIComponent(r[e])}`)).join("&");return`${this.config.wsEndpoint}${n}?${c}&signature=${a}`}}var un={init:e=>{e.provider="alipay";const t=new class{constructor(e){if(["spaceId","spaceAppId","accessKey","secretKey"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`${t} required`)})),e.endpoint){if("string"!=typeof e.endpoint)throw new Error("endpoint must be string");if(!/^https:\/\//.test(e.endpoint))throw new Error("endpoint must start with https://");e.endpoint=e.endpoint.replace(/\/$/,"")}this.config=Object.assign({},e,{endpoint:e.endpoint||`https://${e.spaceId}.api-hz.cloudbasefunction.cn`,wsEndpoint:e.wsEndpoint||`wss://${e.spaceId}.api-hz.cloudbasefunction.cn`}),this._websocket=new cn(this.config)}callFunction(e){return function(e,t){const{name:n,data:s,async:r=!1,timeout:i}=e,o="POST",a={"x-to-function-name":n};r&&(a["x-function-invoke-type"]="async");const{url:c,headers:u}=nn("/functions/invokeFunction",{functionName:n,data:s,method:o,headers:a,signHeaderKeys:["x-to-function-name"],config:t});return sn({url:c,data:s,method:o,headers:u,timeout:i}).then((e=>{let t=0;if(r){const n=e.data||{};t="200"===n.errCode?0:n.errCode,e.data=n.data||{},e.errMsg=n.errMsg}if(0!==t)throw new Ie({code:t,message:e.errMsg,requestId:e.requestId});return{errCode:t,success:0===t,requestId:e.requestId,result:e.data}})).catch((e=>{throw new Ie({code:e.errCode,message:e.errMsg,requestId:e.requestId})}))}(e,this.config)}uploadFileToOSS({url:e,filePath:t,fileType:n,formData:s,onUploadProgress:r}){return new Promise(((i,o)=>{const a=ke.uploadFile({url:e,filePath:t,fileType:n,formData:s,name:"file",success(e){e&&e.statusCode<400?i(e):o(new Ie({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){o(new Ie({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof r&&a&&"function"==typeof a.onProgressUpdate&&a.onProgressUpdate((e=>{r({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}async uploadFile({filePath:e,cloudPath:t="",fileType:n="image",onUploadProgress:s}){if("string"!==j(t))throw new Ie({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new Ie({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new Ie({code:"INVALID_PARAM",message:"cloudPath不合法"});const r=await rn({path:"/".concat(t.replace(/^\//,""),"?post_url")},this.config),{file_id:i,upload_url:o,form_data:a}=r,c=a&&a.reduce(((e,t)=>(e[t.key]=t.value,e)),{});return this.uploadFileToOSS({url:o,filePath:e,fileType:n,formData:c,onUploadProgress:s}).then((()=>({fileID:i})))}async getTempFileURL({fileList:e}){return new Promise(((t,n)=>{(!e||e.length<0)&&t({code:"INVALID_PARAM",message:"fileList不能为空数组"}),e.length>50&&t({code:"INVALID_PARAM",message:"fileList数组长度不能超过50"});const s=[];for(const i of e){let e;"string"!==j(i)&&t({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});try{e=on.call(this,i)}catch(r){console.warn(r.errCode,r.errMsg),e=i}s.push({file_id:e,expire:600})}rn({path:"/?download_url",data:{file_list:s},method:"POST"},this.config).then((e=>{const{file_list:n=[]}=e;t({fileList:n.map((e=>({fileID:an.call(this,e.file_id),tempFileURL:e.download_url})))})})).catch((e=>n(e)))}))}async connectWebSocket(e){const{name:t,query:n}=e;return ke.connectSocket({url:this._websocket.signedURL(t,n),complete:()=>{}})}}(e);return t.auth=function(){return{signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!0)}}},t}};function ln({data:e}){let t;t=Re();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=Pe();e&&(n.uniIdToken=e)}return n}const hn=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var dn=/[\\^$.*+?()[\]{}|]/g,pn=RegExp(dn.source);function gn(e,t,n){return e.replace(new RegExp((s=t)&&pn.test(s)?s.replace(dn,"\\$&"):s,"g"),n);var s}const fn="request",mn="response",yn="both",_n="_globalUniCloudStatus",Tn={code:2e4,message:"System error"},wn={code:20101,message:"Invalid client"};function vn(e){const{errSubject:t,subject:n,errCode:s,errMsg:r,code:i,message:o,cause:a}=e||{};return new Ie({subject:t||n||"uni-secure-network",code:s||i||Tn.code,message:r||o,cause:a})}let xn;function In({secretType:e}={}){return e===fn||e===mn||e===yn}function kn({functionName:e,result:t,logPvd:n}){}function Sn(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=ln.call(e,{data:n.data});const r={aliyun:"aliyun",tencent:"tcb",tcb:"tcb",alipay:"alipay",dcloud:"dcloud"}[this.config.provider],i=In(n)||false;return t.call(this,n).then((e=>(e.errCode=0,!i&&kn.call(this,{functionName:s,result:e,logPvd:r}),Promise.resolve(e))),(e=>(!i&&kn.call(this,{functionName:s,result:e,logPvd:r}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;sn.provider===e&&n.spaceId===t));return s&&s.config}({provider:e,spaceId:t});if(!a||!a.accessControl||!a.accessControl.enable)return!1;const c=a.accessControl.function||{},u=Object.keys(c);if(0===u.length)return!0;const l=function(e,t){let n,s,r;for(let i=0;ie.trim())).indexOf(t)>-1&&(s=o):r=o:n=o}return n||s||r}(u,n);if(!l)return!1;if((c[l]||[]).find(((e={})=>e.appId===s&&(e.platform||"").toLowerCase()===o.toLowerCase())))return!0;throw console.error(`此应用[appId: ${s}, platform: ${o}]不在云端配置的允许访问的应用列表内,参考:https://uniapp.dcloud.net.cn/uniCloud/secure-network.html#verify-client`),vn(wn)}({provider:s,spaceId:r,functionName:i})?new xn({secretType:t.secretType,uniCloudIns:e}).wrapVerifyClientCallFunction(n.bind(e))(t):o(t),Object.defineProperty(a,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),a.then((e=>("undefined"!=typeof UTSJSONObject&&(e.result=new UTSJSONObject(e.result)),e)))}}xn=class{constructor(){throw vn({message:"Platform web is not supported by secure network"})}};const Pn=Symbol("CLIENT_DB_INTERNAL");function An(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=Pn,e.inspect=null,e.__v_raw=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;if("symbol"==typeof n)return e[n];if(n in e||"string"!=typeof n){const t=e[n];return"function"==typeof t?t.bind(e):t}return t.get(e,n,s)}})}function bn(e){return{on:(t,n)=>{e[t]=e[t]||[],e[t].indexOf(n)>-1||e[t].push(n)},off:(t,n)=>{e[t]=e[t]||[];const s=e[t].indexOf(n);-1!==s&&e[t].splice(s,1)}}}const On=["db.Geo","db.command","command.aggregate"];function Cn(e,t){return On.indexOf(`${e}.${t}`)>-1}function Ln(e){switch(j(e=Se(e))){case"array":return e.map((e=>Ln(e)));case"object":return e._internalType===Pn||Object.keys(e).forEach((t=>{e[t]=Ln(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function En(e){return e&&e.content&&e.content.$method}class Rn{constructor(e,t,n){this.content=e,this.prevStage=t||null,this.udb=null,this._database=n}toJSON(){let e=this;const t=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map((e=>({$method:e.$method,$param:Ln(e.$param)})))}}toString(){return JSON.stringify(this.toJSON())}getAction(){const e=this.toJSON().$db.find((e=>"action"===e.$method));return e&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}get isAggregate(){let e=this;for(;e;){const t=En(e),n=En(e.prevStage);if("aggregate"===t&&"collection"===n||"pipeline"===t)return!0;e=e.prevStage}return!1}get isCommand(){let e=this;for(;e;){if("command"===En(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=En(e),n=En(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}getNextStageFn(e){const t=this;return function(){return Un({$method:e,$param:Ln(Array.from(arguments))},t,t._database)}}get count(){return this.isAggregate?this.getNextStageFn("count"):function(){return this._send("count",Array.from(arguments))}}get remove(){return this.isCommand?this.getNextStageFn("remove"):function(){return this._send("remove",Array.from(arguments))}}get(){return this._send("get",Array.from(arguments))}get add(){return this.isCommand?this.getNextStageFn("add"):function(){return this._send("add",Array.from(arguments))}}update(){return this._send("update",Array.from(arguments))}end(){return this._send("end",Array.from(arguments))}get set(){return this.isCommand?this.getNextStageFn("set"):function(){throw new Error("JQL禁止使用set方法")}}_send(e,t){const n=this.getAction(),s=this.getCommand();return s.$db.push({$method:e,$param:Ln(t)}),this._database._callCloudFunction({action:n,command:s})}}function Un(e,t,n){return An(new Rn(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),Cn(s,t)?Un({$method:t},e,n):function(){return Un({$method:t,$param:Ln(Array.from(arguments))},e,n)}}})}function Dn({path:e,method:t}){return class{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map((e=>({$method:e}))),{$method:t,$param:this.param}]}}toString(){return JSON.stringify(this.toJSON())}}}function Nn(e,t={}){return An(new e(t),{get:(e,t)=>Cn("db",t)?Un({$method:t},null,e):function(){return Un({$method:t,$param:Ln(Array.from(arguments))},null,e)}})}class Mn extends class{constructor({uniClient:e={},isJQL:t=!1}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e._isDefault&&(this._dbCallBacks=ee("_globalUniCloudDatabaseCallback")),t||(this.auth=bn(this._authCallBacks)),this._isJQL=t,Object.assign(this,bn(this._dbCallBacks)),this.env=An({},{get:(e,t)=>({$env:t})}),this.Geo=An({},{get:(e,t)=>Dn({path:["Geo"],method:t})}),this.serverDate=Dn({path:[],method:"serverDate"}),this.RegExp=Dn({path:[],method:"RegExp"})}getCloudEnv(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}}_callback(e,t){const n=this._dbCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}_callbackAuth(e,t){const n=this._authCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}multiSend(){const e=Array.from(arguments),t=e.map((e=>{const t=e.getAction(),n=e.getCommand();if("getTemp"!==n.$db[n.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:n}}));return this._callCloudFunction({multiCommand:t,queryList:e})}}{_parseResult(e){return this._isJQL?e.result:e}_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function r(e,t){if(n&&s)for(let n=0;nie(oe(o,"complete"),e))).then((()=>(r(null,e),_e(ue,{type:de,content:e}),Promise.reject(e))))}const c=ie(oe(o,"invoke")),u=this._uniClient;return c.then((()=>u.callFunction({name:"DCloud-clientDB",type:B,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:c,systemInfo:u=[]}=e.result;if(u)for(let r=0;r(console.warn(n),s)})}}return h=e,ie(oe(o,"success"),h).then((()=>ie(oe(o,"complete"),h))).then((()=>{r(h,null);const e=i._parseResult(h);return _e(ue,{type:de,content:e}),Promise.resolve(e)}));var h}),(e=>(/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB"),a(new Ie({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId})))))}}const Bn="token无效,跳转登录页面",qn="token过期,跳转登录页面",Fn={TOKEN_INVALID_TOKEN_EXPIRED:qn,TOKEN_INVALID_INVALID_CLIENTID:Bn,TOKEN_INVALID:Bn,TOKEN_INVALID_WRONG_TOKEN:Bn,TOKEN_INVALID_ANONYMOUS_USER:Bn},jn={"uni-id-token-expired":qn,"uni-id-check-token-failed":Bn,"uni-id-token-not-exist":Bn,"uni-id-check-device-feature-failed":Bn};function $n(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function Kn(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push($n(t,e.path)):!1===e.needLogin&&s.push($n(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function Hn(e){return e.split("?")[0].replace(/^\//,"")}function Jn(){return function(e){let t=e&&e.$page&&e.$page.fullPath||"";return t?("/"!==t.charAt(0)&&(t="/"+t),t):t}(function(){const e=n();return e[e.length-1]}())}function Wn(){return Hn(Jn())}function Vn(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=Hn(e);return n.some((e=>e.pagePath===s))}const zn=!!A.uniIdRouter,{loginPage:Qn,routerNeedLogin:Yn,resToLogin:Gn,needLoginPage:Xn,notNeedLoginPage:Zn,loginPageInTabBar:es}=function({pages:e=[],subPackages:t=[],uniIdRouter:n={},tabBar:s={}}=A){const{loginPage:r,needLogin:i=[],resToLogin:o=!0}=n,{needLoginPage:a,notNeedLoginPage:c}=Kn(e),{needLoginPage:u,notNeedLoginPage:l}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:r=[]}=e,{needLoginPage:i,notNeedLoginPage:o}=Kn(r,s);t.push(...i),n.push(...o)})),{needLoginPage:t,notNeedLoginPage:n}}(t);return{loginPage:r,routerNeedLogin:i,resToLogin:o,needLoginPage:[...a,...u],notNeedLoginPage:[...c,...l],loginPageInTabBar:Vn(r,s)}}();if(Xn.indexOf(Qn)>-1)throw new Error(`Login page [${Qn}] should not be "needLogin", please check your pages.json`);function ts(e){const t=Wn();if("/"===e.charAt(0))return e;const[n,s]=e.split("?"),r=n.replace(/^\//,"").split("/"),i=t.split("/");i.pop();for(let o=0;o-1?s+`&uniIdRedirectUrl=${encodeURIComponent(r)}`:s+`?uniIdRedirectUrl=${encodeURIComponent(r)}`:s);var s,r;es?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo");const i={navigateTo:T,redirectTo:w,switchTab:v,reLaunch:x};setTimeout((()=>{i[e]({url:n})}),0)}function rs({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},n=function(){const{token:e,tokenExpired:t}=Pe();let n;if(e){if(t-1)&&(Xn.indexOf(t)>-1||Yn.some((t=>{return n=e,new RegExp(t).test(n);var n})))}(e)&&n){if(n.uniIdRedirectUrl=e,fe(le).length>0)return setTimeout((()=>{_e(le,n)}),0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function is(){!function(){const e=Jn(),{abortLoginPageJump:t,autoToLoginPage:n}=rs({url:e});t||n&&ss({api:"redirectTo",redirect:e})}();const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t{const{type:t,content:n}=e;let s=!1;switch(t){case"cloudobject":s=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in jn}(n);break;case"clientdb":s=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in Fn}(n)}s&&function(e={}){const t=fe(le);ve().then((()=>{const n=Jn();if(n&&ns({redirect:n}))return t.length>0?_e(le,Object.assign({uniIdRedirectUrl:n},e)):void(Qn&&ss({api:"navigateTo",redirect:n}))}))}(n)}))}function as(e){var t;(t=e).onResponse=function(e){me(ue,e)},t.offResponse=function(e){ye(ue,e)},function(e){e.onNeedLogin=function(e){me(le,e)},e.offNeedLogin=function(e){ye(le,e)},zn&&(ee(_n).needLoginInit||(ee(_n).needLoginInit=!0,ve().then((()=>{is.call(e)})),Gn&&os.call(e)))}(e),function(e){e.onRefreshToken=function(e){me(he,e)},e.offRefreshToken=function(e){ye(he,e)}}(e)}let cs;const us="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ls=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function hs(){const e=Pe().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let n;try{n=JSON.parse((s=t[1],decodeURIComponent(cs(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(r){throw new Error("获取当前用户信息出错,详细错误信息为:"+r.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}cs="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!ls.test(e))throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var n,s,r="",i=0;i>16&255):64===s?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return r}:atob;var ds=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(b((function(n,s){Object.defineProperty(s,"__esModule",{value:!0});const i="chooseAndUploadFile:ok",o="chooseAndUploadFile:fail";function a(e,t){return e.tempFiles.forEach(((e,n)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+n+e.name.substring(e.name.lastIndexOf("."))})),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map((e=>e.path))),e}function c(e,t,{onChooseFile:n,onUploadProgress:s}){return t.then((e=>{if(n){const t=n(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:i,tempFilePaths:[],tempFiles:[]}:function(e,t,n=5,s){(t=Object.assign({},t)).errMsg=i;const r=t.tempFiles,o=r.length;let a=0;return new Promise((i=>{for(;a=o)return void(!r.find((e=>!e.url&&!e.errMsg))&&i(t));const u=r[n];e.uploadFile({provider:u.provider,filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,cloudPathAsRealPath:u.cloudPathAsRealPath,onUploadProgress(e){e.index=n,e.tempFile=u,e.tempFilePath=u.path,s&&s(e)}}).then((e=>{u.url=e.fileID,n{u.errMsg=e.errMsg||e.message,n{e({count:n,sizeType:s,sourceType:r,extension:i,success(e){t(a(e,"image"))},fail(e){c({errMsg:e.errMsg.replace("chooseImage:fail",o)})}})}))}(s),s):"video"===s.type?c(n,function(e){const{camera:n,compressed:s,maxDuration:r,sourceType:i=["album","camera"],extension:c}=e;return new Promise(((e,u)=>{t({camera:n,compressed:s,maxDuration:r,sourceType:i,extension:c,success(t){const{tempFilePath:n,duration:s,size:r,height:i,width:o}=t;e(a({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:r,type:t.tempFile&&t.tempFile.type||"",width:o,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){u({errMsg:e.errMsg.replace("chooseVideo:fail",o)})}})}))}(s),s):c(n,function(e){const{count:t,extension:n}=e;return new Promise(((e,s)=>{let i=r;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return s({errMsg:o+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(a(t))},fail(e){s({errMsg:e.errMsg.replace("chooseFile:fail",o)})}})}))}(s),s)}}})));const ps="manual";function gs(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},spaceInfo:{type:Object,default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{},mixinDatacomError:null}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach((t=>{e.push(this[t])})),e}),((e,t)=>{if(this.loadtime===ps)return;let n=!1;const s=[];for(let r=2;r{this.mixinDatacomLoading=!1;const{data:s,count:r}=n.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=s.length{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,this.mixinDatacomError=e,n&&n(e)})))},mixinDatacomGet(t={}){let n;t=t||{},n="undefined"!=typeof __uniX&&__uniX?e.databaseForJQL(this.spaceInfo):e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const r=t.collection||this.collection;n=Array.isArray(r)?n.collection(...r):n.collection(r);const i=t.where||this.where;i&&Object.keys(i).length&&(n=n.where(i));const o=t.field||this.field;o&&(n=n.field(o));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u)),!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const l=t.orderby||this.orderby;l&&(n=n.orderBy(l));const h=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,p=void 0!==t.getcount?t.getcount:this.getcount,g=void 0!==t.gettree?t.gettree:this.gettree,f=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:p},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return g&&(m.getTree=y),f&&(m.getTreePath=y),n=n.skip(d*(h-1)).limit(d).get(m),n}}}}function fs(e){return ee("_globalUniCloudSecureNetworkCache__{spaceId}".replace("{spaceId}",e.config.spaceId))}async function ms({openid:e,callLoginByWeixin:t=!1}={}){throw fs(this),new Error("[SecureNetwork] API `initSecureNetworkByWeixin` is not supported on platform `web`")}async function ys(e){const t=fs(this);return t.initPromise||(t.initPromise=ms.call(this,e).then((e=>e)).catch((e=>{throw delete t.initPromise,e}))),t.initPromise}function _s(e){Ee=e}function Ts(e){const t={getSystemInfo:I,getPushClientId:k};return function(n){return new Promise(((s,r)=>{t[e]({...n,success(e){s(e)},fail(e){r(e)}})}))}}class ws extends class{constructor(){this._callback={}}addListener(e,t){this._callback[e]||(this._callback[e]=[]),this._callback[e].push(t)}on(e,t){return this.addListener(e,t)}removeListener(e,t){if(!t)throw new Error('The "listener" argument must be of type function. Received undefined');const n=this._callback[e];if(!n)return;const s=function(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]===t)return n;return-1}(n,t);n.splice(s,1)}off(e,t){return this.removeListener(e,t)}removeAllListener(e){delete this._callback[e]}emit(e,...t){const n=this._callback[e];if(n)for(let s=0;s{if(!e)throw new Error("Invalid appId, please check the manifest.json file");if(!t)throw new Error("Invalid push client id");this._appId=e,this._pushClientId=t,this._seqId=Date.now()+"-"+Math.floor(9e5*Math.random()+1e5),this.emit("open"),this._initMessageListener()}),(e=>{throw this.emit("error",e),this.close(),e}))}async open(){return this.init()}_isUniCloudSSE(e){if("receive"!==e.type)return!1;const t=e&&e.data&&e.data.payload;return!(!t||"UNI_CLOUD_SSE"!==t.channel||t.seqId!==this._seqId)}_receivePushMessage(e){if(!this._isUniCloudSSE(e))return;const t=e&&e.data&&e.data.payload,{action:n,messageId:s,message:r}=t;this._payloadQueue.push({action:n,messageId:s,message:r}),this._consumMessage()}_consumMessage(){for(;;){const e=this._payloadQueue.find((e=>e.messageId===this._currentMessageId+1));if(!e)break;this._currentMessageId++,this._parseMessagePayload(e)}}_parseMessagePayload(e){const{action:t,messageId:n,message:s}=e;"end"===t?this._end({messageId:n,message:s}):"message"===t&&this._appendMessage({messageId:n,message:s})}_appendMessage({messageId:e,message:t}={}){this.emit("message",t)}_end({messageId:e,message:t}={}){this.emit("end",t),this.close()}_initMessageListener(){u(this._uniPushMessageCallback)}_destroy(){l(this._uniPushMessageCallback)}toJSON(){return{appId:this._appId,pushClientId:this._pushClientId,seqId:this._seqId}}close(){this._destroy(),this.emit("close")}}const vs={tcb:Yt,tencent:Yt,aliyun:Me,private:Zt,dcloud:Zt,alipay:un};let xs=new class{init(e){let t={};const n=vs[e.provider];if(!n)throw new Error("未提供正确的provider参数");var s;return t=n.init(e),function(e){e._initPromiseHub||(e._initPromiseHub=new V({createPromise:function(){let t=Promise.resolve();t=new Promise((e=>{setTimeout((()=>{e()}),1)}));const n=e.auth();return t.then((()=>n.getLoginState())).then((e=>e?Promise.resolve():n.signInAnonymously()))}}))}(t),Sn(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),(s=t).database=function(e){if(e&&Object.keys(e).length>0)return s.init(e).database();if(this._database)return this._database;const t=Nn(Mn,{uniClient:s});return this._database=t,t},s.databaseForJQL=function(e){if(e&&Object.keys(e).length>0)return s.init(e).databaseForJQL();if(this._databaseForJQL)return this._databaseForJQL;const t=Nn(Mn,{uniClient:s,isJQL:!0});return this._databaseForJQL=t,t},function(e){e.getCurrentUserInfo=hs,e.chooseAndUploadFile=ds.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return gs(e)}}),e.SSEChannel=ws,e.initSecureNetworkByWeixin=function(e){return function({openid:t,callLoginByWeixin:n=!1}={}){return ys.call(e,{openid:t,callLoginByWeixin:n})}}(e),e.setCustomClientInfo=_s,e.importObject=function(t){return function(n,s={}){s=function(e,t={}){return e.customUI=t.customUI||e.customUI,e.parseSystemError=t.parseSystemError||e.parseSystemError,Object.assign(e.loadingOptions,t.loadingOptions),Object.assign(e.errorOptions,t.errorOptions),"object"==typeof t.secretMethods&&(e.secretMethods=t.secretMethods),e}({customUI:!1,loadingOptions:{title:"加载中...",mask:!0},errorOptions:{type:"modal",retry:!1}},s);const{customUI:r,loadingOptions:u,errorOptions:l,parseSystemError:h}=s,d=!r;return new Proxy({},{get(r,p){switch(p){case"toString":return"[object UniCloudObject]";case"toJSON":return{}}return function({fn:e,interceptorName:t,getCallbackArgs:n}={}){return async function(...s){const r=n?n({params:s}):{};let i,o;try{return await ie(oe(t,"invoke"),{...r}),i=await e(...s),await ie(oe(t,"success"),{...r,result:i}),i}catch(a){throw o=a,await ie(oe(t,"fail"),{...r,error:o}),o}finally{await ie(oe(t,"complete"),o?{...r,error:o}:{...r,result:i})}}}({fn:async function r(...g){let f;d&&i({title:u.title,mask:u.mask});const m={name:n,type:M,data:{method:p,params:g}};"object"==typeof s.secretMethods&&function(e,t){const n=t.data.method,s=e.secretMethods||{},r=s[n]||s["*"];r&&(t.secretType=r)}(s,m);let y=!1;try{f=await t.callFunction(m)}catch(e){y=!0,f={result:new Ie(e)}}const{errSubject:_,errCode:T,errMsg:w,newToken:v}=f.result||{};if(d&&o(),v&&v.token&&v.tokenExpired&&(Ae(v),_e(he,{...v})),T){let e=w;if(y&&h&&(e=(await h({objectName:n,methodName:p,params:g,errSubject:_,errCode:T,errMsg:w})).errMsg||w),d)if("toast"===l.type)a({title:e,icon:"none"});else{if("modal"!==l.type)throw new Error(`Invalid errorOptions.type: ${l.type}`);{const{confirm:t}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:r}={}){return new Promise(((i,o)=>{c({title:e,content:t,showCancel:n,cancelText:s,confirmText:r,success(e){i(e)},fail(){i({confirm:!1,cancel:!0})}})}))}({title:"提示",content:e,showCancel:l.retry,cancelText:"取消",confirmText:l.retry?"重试":"确定"});if(l.retry&&t)return r(...g)}}const t=new Ie({subject:_,code:T,message:w,requestId:f.requestId});throw t.detail=f.result,_e(ue,{type:ge,content:t}),t}return _e(ue,{type:ge,content:f.result}),f.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:n,methodName:p,params:e}}})}})}}(e)}(t),["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return n.apply(t,Array.from(arguments))},t[e]=function(e,t){return function(n){let s=!1;if("callFunction"===t){const e=n&&n.type||N;s=e!==N}const r="callFunction"===t&&!s,i=this._initPromiseHub.exec();n=n||{};const{success:o,fail:a,complete:c}=xe(n),u=i.then((()=>s?Promise.resolve():ie(oe(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):ie(oe(t,"success"),e).then((()=>ie(oe(t,"complete"),e))).then((()=>(r&&_e(ue,{type:pe,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):ie(oe(t,"fail"),e).then((()=>ie(oe(t,"complete"),e))).then((()=>(_e(ue,{type:pe,content:e}),Promise.reject(e))))));if(!(o||a||c))return u;u.then((e=>{o&&o(e),c&&c(e),r&&_e(ue,{type:pe,content:e})}),(e=>{a&&a(e),c&&c(e),r&&_e(ue,{type:pe,content:e})}))}}(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{const e=Y;let t={};if(e&&1===e.length)t=e[0],xs=xs.init(t),xs._isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":"应用未关联服务空间,请在uniCloud目录右键关联服务空间",t.forEach((e=>{xs[e]=function(){return console.error(n),Promise.reject(new Ie({code:"SYS_ERR",message:n}))}}))}Object.assign(xs,{get mixinDatacom(){return gs(xs)}}),as(xs),xs.addInterceptor=se,xs.removeInterceptor=re,xs.interceptObject=ae;{const e=X||(X=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;function e(){return this}return void 0!==e()?e():new Function("return this")()}(),X);e.uniCloud=xs,e.UniCloudError=Ie}})();var Is=xs;export{Is as e};