import{bq as e,br as t,aF as n,bs as s,bt as i,ag as r,ah as o,aC as a,bu as c,bv as l,bw as u,aV as h,bx as d,H as p,E as g,by as f,bz as m,bA as y,bd as _,aU as T,aN as v,bi as w,v as x,bB as S,bC as I,bD as k,bE as P}from"./index-B3cqKsI_.js";const A={pages:[{path:"pages/index/index",navigationStyle:"custom",style:{navigationBarTitleText:"首页",enablePullDownRefresh:!0}},{path:"pages/index/manage",navigationStyle:"custom",style:{navigationBarTitleText:"应用管理"}},{path:"pages/notice/index",navigationStyle:"custom",style:{navigationBarTitleText:"消息"}},{path:"pages/module/list",style:{navigationBarTitleText:"低代码应用"}},{path:"pages/module/details",style:{navigationBarTitleText:"低代码详情"}},{path:"pages/module/addForm",style:{navigationBarTitleText:"低代码添加"}},{path:"pages/module/oneOnOne",style:{navigationBarTitleText:"低代码一对一"}},{path:"pages/notice/work",navigationStyle:"custom",style:{navigationBarTitleText:"工作待办",enablePullDownRefresh:!0}},{path:"pages/notice/info",navigationStyle:"custom",style:{navigationBarTitleText:"待办详情"}},{path:"pages/forum/index",navigationStyle:"custom",style:{navigationBarTitleText:"学习",enablePullDownRefresh:!0}},{path:"pages/forum/default",navigationStyle:"custom",style:{navigationBarTitleText:"查看文章"}},{path:"pages/forum/search",navigationStyle:"custom",style:{navigationBarTitleText:"文章搜索"}},{path:"pages/forum/history",navigationStyle:"custom",style:{navigationBarTitleText:"阅读记录",enablePullDownRefresh:!0}},{path:"pages/workbench/index",navigationStyle:"custom",style:{navigationBarTitleText:"应用"}},{path:"pages/cloudfile/index",navigationStyle:"custom",style:{navigationBarTitleText:"云文件"}},{path:"pages/user/index",navigationStyle:"custom",style:{navigationBarTitleText:"通讯录"}},{path:"pages/user/userPhone",navigationStyle:"custom",style:{navigationBarTitleText:"手机号添加"}},{path:"pages/user/userId",navigationStyle:"custom",style:{navigationBarTitleText:"成员ID添加"}},{path:"pages/user/userRecord",navigationStyle:"custom",style:{navigationBarTitleText:"添加成员记录"}},{path:"pages/user/personal",navigationStyle:"custom",style:{navigationBarTitleText:"个人信息"}},{path:"pages/landing",style:{navigationBarTitleText:"LandingPage"}},{path:"pages/403",style:{navigationBarTitleText:"403"}}],subPackages:[{root:"pages/users",name:"users",pages:[{path:"login/index",style:{navigationBarTitleText:"登录"}},{path:"login/config",style:{navigationBarTitleText:"添加服务配置"}},{path:"login/enterprise",style:{navigationBarTitleText:"切换企业"}},{path:"login/service",style:{navigationBarTitleText:"服务协议"}},{path:"login/privacy",style:{navigationBarTitleText:"隐私协议"}},{path:"organization/index",style:{navigationBarTitleText:"组织架构"}},{path:"report/index",style:{navigationBarTitleText:"工作汇报"}},{path:"report/mine",style:{navigationBarTitleText:"汇报详情","app-plus":{softinputMode:"adjustResize"}}},{path:"report/check",style:{navigationBarTitleText:"查看汇报",enablePullDownRefresh:!0}},{path:"report/census",style:{navigationBarTitleText:"汇报统计"}},{path:"report/search",style:{navigationBarTitleText:"汇报搜索"}},{path:"notice/index",style:{navigationBarTitleText:"企业动态"}},{path:"noticeDefault/index",style:{navigationBarTitleText:"企业动态"}},{path:"assessment/index",style:{navigationBarTitleText:"绩效考核",enablePullDownRefresh:!0}},{path:"assessment/default",style:{navigationBarTitleText:"考核详情","app-plus":{softinputMode:"adjustResize"}}},{path:"schedule/index",style:{navigationBarTitleText:"我的日程"}},{path:"schedule/create",style:{navigationBarTitleText:"新建日程"}},{path:"schedule/detail",style:{navigationBarTitleText:"日程详情"}},{path:"center/index",style:{navigationBarTitleText:"个人中心"}},{path:"center/password",style:{navigationBarTitleText:"修改密码"}},{path:"center/phone",style:{navigationBarTitleText:"修改手机"}},{path:"examine/index",style:{navigationBarTitleText:"申请审批"}},{path:"examine/center",style:{navigationBarTitleText:"已提交",enablePullDownRefresh:!0}},{path:"examine/approve",style:{navigationBarTitleText:"我审批的",enablePullDownRefresh:!0}},{path:"examine/components/addSignature",style:{navigationBarTitleText:"加签",enablePullDownRefresh:!0}},{path:"examine/components/transfer",style:{navigationBarTitleText:"转审",enablePullDownRefresh:!0}},{path:"examine/default",style:{navigationBarTitleText:"添加审批","app-plus":{softinputMode:"adjustResize"}}},{path:"examine/defaults",style:{navigationBarTitleText:"审批详情"}},{path:"examine/mine",style:{navigationBarTitleText:"我的审批"}},{path:"examine/search",style:{navigationBarTitleText:"审批搜索"}},{path:"department/index",style:{navigationBarTitleText:"选择成员"}},{path:"memorandum/index",style:{navigationBarTitleText:"记事本",enablePullDownRefresh:!0}},{path:"memorandum/create",style:{navigationBarTitleText:"创建笔记"}},{path:"memorandum/details",style:{navigationBarTitleText:"记事本"}},{path:"memorandum/search",style:{navigationBarTitleText:"条件搜索"}},{path:"scanCode/index",style:{navigationBarTitleText:"扫码登录"}}]},{root:"pages/customer",name:"customer",pages:[{path:"list/index",style:{navigationBarTitleText:"客户",enablePullDownRefresh:!0}},{path:"list/addLiaison",style:{navigationBarTitleText:"添加联系人","app-plus":{softinputMode:"adjustResize"}}},{path:"list/addCustomer",style:{navigationBarTitleText:"添加客户","app-plus":{softinputMode:"adjustResize"}}},{path:"list/statistics",style:{navigationBarTitleText:"业绩统计","app-plus":{softinputMode:"adjustResize"}}},{path:"list/addFollow",style:{navigationBarTitleText:"添加跟进记录","app-plus":{softinputMode:"adjustResize"}}},{path:"list/shift",style:{navigationBarTitleText:"转移"}},{path:"list/search",style:{navigationBarTitleText:"客户-条件搜索"}},{path:"list/addSpend",style:{navigationBarTitleText:"添加支付"}},{path:"list/details",style:{navigationBarTitleText:"客户详情"}},{path:"list/contract",style:{navigationBarTitleText:"合同",enablePullDownRefresh:!0}},{path:"list/invoice",style:{navigationBarTitleText:"发票",enablePullDownRefresh:!0}},{path:"list/liaison",style:{navigationBarTitleText:"联系人",enablePullDownRefresh:!0}},{path:"list/file",style:{navigationBarTitleText:"资料",enablePullDownRefresh:!0}},{path:"contract/index",style:{navigationBarTitleText:"合同管理",enablePullDownRefresh:!0}},{path:"contract/details",style:{navigationBarTitleText:"合同详情",navigationBarBackgroundColor:"#fff"}},{path:"contract/addContract",style:{navigationBarTitleText:"添加合同","app-plus":{softinputMode:"adjustResize"}}},{path:"contract/collectionDetails",style:{navigationBarTitleText:"合同回款详情"}},{path:"contract/addPayment",style:{navigationBarTitleText:"添加付款","app-plus":{softinputMode:"adjustResize"}}},{path:"contract/addFile",style:{navigationBarTitleText:"添加合同资料","app-plus":{softinputMode:"adjustResize"}}},{path:"contract/addRemind",style:{navigationBarTitleText:"添加付款提醒","app-plus":{softinputMode:"adjustResize"}}},{path:"contract/search",style:{navigationBarTitleText:"合同-条件搜索"}},{path:"invoice/index",style:{navigationBarTitleText:"发票管理"}},{path:"invoice/details",style:{navigationBarTitleText:"发票详情"}},{path:"invoice/search",style:{navigationBarTitleText:"-发票-条件搜索"}},{path:"invoice/addInvoice",style:{navigationBarTitleText:"申请发票","app-plus":{softinputMode:"adjustResize"}}},{path:"invoice/checkPayment",style:{navigationBarTitleText:"选择付款单"}},{path:"turnover/index",style:{navigationBarTitleText:"业绩统计"}}]},{root:"pages/finance",name:"finance",pages:[{path:"invoice/index",style:{navigationBarTitleText:"开票管理",enablePullDownRefresh:!0}},{path:"invoice/details",style:{navigationBarTitleText:"发票详情"}},{path:"invoice/search",style:{navigationBarTitleText:"发票审核-搜索"}},{path:"payment/index",style:{navigationBarTitleText:"付款审核",enablePullDownRefresh:!0}},{path:"payment/search",style:{navigationBarTitleText:"付款搜索"}},{path:"payment/details",style:{navigationBarTitleText:"付款详情"}}]},{root:"pages/attendance",name:"attendance",pages:[{path:"index",style:{navigationBarTitleText:"打卡"}},{path:"apply",style:{navigationBarTitleText:"申请"}},{path:"statistics",style:{navigationBarTitleText:"统计"}},{path:"teamReport",navigationStyle:"custom",style:{navigationBarTitleText:"团队月报"}},{path:"personalReport",navigationStyle:"custom",style:{navigationBarTitleText:"个人月报"}},{path:"rules",navigationStyle:"custom",style:{navigationBarTitleText:"考勤规则"}},{path:"map",navigationStyle:"custom",style:{navigationBarTitleText:"考勤范围"}},{path:"detailed/userVacationList",navigationStyle:"custom",style:{navigationBarTitleText:"假期明细"}},{path:"detailed/userCheckList",navigationStyle:"custom",style:{navigationBarTitleText:"考勤明细"}},{path:"detailed/userOvertimeList",navigationStyle:"custom",style:{navigationBarTitleText:"加班明细"}},{path:"detailed/teamCheckList",navigationStyle:"custom",style:{navigationBarTitleText:"团队打卡明细"}},{path:"schedule",navigationStyle:"custom",style:{navigationBarTitleText:"排班管理"}},{path:"scheduleDetail",navigationStyle:"custom",style:{navigationBarTitleText:"排班详情"}},{path:"scheduleAdd",navigationStyle:"custom",style:{navigationBarTitleText:"新增排班"}},{path:"shift",navigationStyle:"custom",style:{navigationBarTitleText:"班次管理",onReachBottomDistance:200}},{path:"shiftAdd",navigationStyle:"custom",style:{navigationBarTitleText:"新建班次"}}]}],tabBar:{color:"#282828",selectedColor:"#308BF8",borderStyle:"#ebeef5",backgroundColor:"#ffffff",height:"54px",iconWidth:"21px",spacing:"6px",list:[{pagePath:"pages/index/index",iconPath:"static/image/bar-logo01.png",selectedIconPath:"static/image/bar-logo01-active.png",text:"首页"},{pagePath:"pages/notice/index",iconPath:"static/image/bar-logo02.png",selectedIconPath:"static/image/bar-logo02-active.png",text:"消息"},{pagePath:"pages/users/memorandum/index",iconPath:"static/image/bar-logo03.png",selectedIconPath:"static/image/bar-logo03-active.png",text:"记事本"},{pagePath:"pages/workbench/index",iconPath:"static/image/bar-logo04.png",selectedIconPath:"static/image/bar-logo04-active.png",text:"应用"}]},globalStyle:{navigationBarTextStyle:"black",navigationBarTitleText:"陀螺匠OA系统",navigationBarBackgroundColor:"#fff",backgroundColor:"#F8F8F8",titleNView:!1,"app-plus":{scrollIndicator:"none",bounce:"none"}}};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){var t=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),n={},s=n.lib={},i=s.Base={extend:function(e){var n=t(this);return e&&n.mixIn(e),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},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)}},r=s.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||a).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,i=e.sigBytes;if(this.clamp(),s%4)for(var r=0;r>>2]>>>24-r%4*8&255;t[s+r>>>2]|=o<<24-(s+r)%4*8}else for(r=0;r>>2]=n[r>>>2];return this.sigBytes+=i,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=[],i=function(t){var n=987654321,s=4294967295;return function(){var i=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;s.push((r>>>4).toString(16)),s.push((15&r).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 r.init(n,t/2)}},c=o.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],i=0;i>>2]>>>24-i%4*8&255;s.push(String.fromCharCode(r))}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 r.init(n,t)}},l=o.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},u=s.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new r.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,i=n.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,l=e.min(4*c,i);if(c){for(var u=0;u>>24)|4278255360&(i<<24|i>>>8)}var r=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],v=e[t+9],w=e[t+10],x=e[t+11],S=e[t+12],I=e[t+13],k=e[t+14],P=e[t+15],A=r[0],b=r[1],O=r[2],C=r[3];A=l(A,b,O,C,o,7,a[0]),C=l(C,A,b,O,c,12,a[1]),O=l(O,C,A,b,p,17,a[2]),b=l(b,O,C,A,g,22,a[3]),A=l(A,b,O,C,f,7,a[4]),C=l(C,A,b,O,m,12,a[5]),O=l(O,C,A,b,y,17,a[6]),b=l(b,O,C,A,_,22,a[7]),A=l(A,b,O,C,T,7,a[8]),C=l(C,A,b,O,v,12,a[9]),O=l(O,C,A,b,w,17,a[10]),b=l(b,O,C,A,x,22,a[11]),A=l(A,b,O,C,S,7,a[12]),C=l(C,A,b,O,I,12,a[13]),O=l(O,C,A,b,k,17,a[14]),A=u(A,b=l(b,O,C,A,P,22,a[15]),O,C,c,5,a[16]),C=u(C,A,b,O,y,9,a[17]),O=u(O,C,A,b,x,14,a[18]),b=u(b,O,C,A,o,20,a[19]),A=u(A,b,O,C,m,5,a[20]),C=u(C,A,b,O,w,9,a[21]),O=u(O,C,A,b,P,14,a[22]),b=u(b,O,C,A,f,20,a[23]),A=u(A,b,O,C,v,5,a[24]),C=u(C,A,b,O,k,9,a[25]),O=u(O,C,A,b,g,14,a[26]),b=u(b,O,C,A,T,20,a[27]),A=u(A,b,O,C,I,5,a[28]),C=u(C,A,b,O,p,9,a[29]),O=u(O,C,A,b,_,14,a[30]),A=h(A,b=u(b,O,C,A,S,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,k,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,w,23,a[39]),A=h(A,b,O,C,I,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,v,4,a[44]),C=h(C,A,b,O,S,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,k,15,a[50]),b=d(b,O,C,A,m,21,a[51]),A=d(A,b,O,C,S,6,a[52]),C=d(C,A,b,O,g,10,a[53]),O=d(O,C,A,b,w,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,I,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,v,21,a[63]),r[0]=r[0]+A|0,r[1]=r[1]+b|0,r[2]=r[2]+O|0,r[3]=r[3]+C|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var r=e.floor(s/4294967296),o=s;n[15+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[14+(i+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,l=0;l<4;l++){var u=c[l];c[l]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return a},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function l(e,t,n,s,i,r,o){var a=e+(t&n|~t&s)+i+o;return(a<>>32-r)+t}function u(e,t,n,s,i,r,o){var a=e+(t&s|n&~s)+i+o;return(a<>>32-r)+t}function h(e,t,n,s,i,r,o){var a=e+(t^n^s)+i+o;return(a<>>32-r)+t}function d(e,t,n,s,i,r,o){var a=e+(n^(t|~s))+i+o;return(a<>>32-r)+t}t.MD5=r._createHelper(c),t.HmacMD5=r._createHmacHelper(c)}(Math),n.MD5)})),b((function(e,t){var n,s,i;e.exports=(s=(n=C).lib.Base,i=n.enc.Utf8,void(n.algo.HMAC=s.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var r=this._oKey=t.clone(),o=this._iKey=t.clone(),a=r.words,c=o.words,l=0;l>>2]>>>24-r%4*8&255)<<16|(t[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|t[r+2>>>2]>>>24-(r+2)%4*8&255,a=0;a<4&&r+.75*a>>6*(3-a)&63));var c=s.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,n=this._map,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var r=0;r>>6-o%4*2;s[r>>>2]|=(a|c)<<24-r%4*8,r++}return i.create(s,r)}(e,t,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)}));const U="uni_id_token",D="uni_id_token_expired",B="FUNCTION",N="OBJECT",M="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){}}}const J="REJECTED",W="NOT_PENDING";class z{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}}class V{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{se.indexOf(n)>-1&&function(e,t,n){let s=ie[e][t];s||(s=ie[e][t]=[]),-1===s.indexOf(n)&&K(n)&&s.push(n)}(e,n,t[n])}))}function oe(e,t){ie[e]||(ie[e]={}),$(t)?Object.keys(t).forEach((n=>{se.indexOf(n)>-1&&function(e,t,n){const s=ie[e][t];if(!s)return;const i=s.indexOf(n);i>-1&&s.splice(i,1)}(e,n,t[n])})):delete ie[e]}function ae(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function ce(e,t){return ie[e]&&ie[e][t]||[]}function le(e){re("callObject",e)}const ue=ne("_globalUniCloudListener"),he="response",de="needLogin",pe="refreshToken",ge="clientdb",fe="cloudfunction",me="cloudobject";function ye(e){return ue[e]||(ue[e]=[]),ue[e]}function _e(e,t){const n=ye(e);n.includes(t)||n.push(t)}function Te(e,t){const n=ye(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function ve(e,t){const n=ye(e);for(let s=0;s{xe&&e(),function t(){if("function"==typeof n){const t=n();t&&t[0]&&(xe=!0,e())}xe||setTimeout((()=>{t()}),30)}()})),we)}function Ie(e){const t={};for(const n in e){const s=e[n];K(s)&&(t[n]=H(s))}return t}class ke 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 Pe={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 Ae(e){return e&&Ae(e.__v_raw)||e}function be(){return{token:Pe.getStorageSync(U)||Pe.getStorageSync("uniIdToken"),tokenExpired:Pe.getStorageSync(D)}}function Oe({token:e,tokenExpired:t}={}){e&&Pe.setStorageSync(U,e),t&&Pe.setStorageSync(D,t)}let Ce,Ee;function Re(){return Ce||(Ce=_()),Ce}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 Ue={};function De(){const e=k&&k()||"en";if(Ee)return{...Ue,...Ee,locale:e,LOCALE:e};const t=Re(),{deviceId:n,osName:s,uniPlatform:i,appId:r}=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 Ee={PLATFORM:i,OS:s,APPID:r,DEVICEID:n,...Le(),...t},{...Ue,...Ee,locale:e,LOCALE:e}}var Be=function(e,t){let n="";return Object.keys(e).sort().forEach((function(t){e[t]&&(n=n+"&"+t+"="+e[t])})),n=n.slice(1),E(n,t).toString()},Ne=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",i=e.data&&e.data.error&&e.data.error.message||e.errMsg||"request:fail";return s(new ke({code:n,message:i,requestId:t}))}const i=e.data;if(i.error)return s(new ke({code:i.error.code,message:i.error.message,requestId:t}));i.result=i.data,i.requestId=t,delete i.data,n(i)}}))}))},Me=function(e){return L.stringify(R.parse(e))},qe=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=Pe,this._getAccessTokenPromiseHub=new z({createPromise:()=>this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>{if(!e.result||!e.result.accessToken)throw new ke({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 Ne(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"]=Be(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"]=Be(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:i,onUploadProgress:r}){return new Promise(((o,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:i,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?o(e):a(new ke({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new ke({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof r&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{r({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:i,config:r}){if("string"!==j(t))throw new ke({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new ke({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new ke({code:"INVALID_PARAM",message:"cloudPath不合法"});const o=r&&r.envType||this.config.envType;if(s&&("/"!==t[0]&&(t="/"+t),t.indexOf("\\")>-1))throw new ke({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:l,accessKeyId:u,signature:h,host:d,ossPath:p,id:g,policy:f,ossCallbackUrl:m}=a,y={"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:u,Signature:h,host:d,id:g,key:p,policy:f,success_action_status:200};if(l&&(y["x-oss-security-token"]=l),m){const e=JSON.stringify({callbackUrl:m,callbackBody:JSON.stringify({fileId:g,spaceId:this.config.spaceId}),callbackBodyType:"application/json"});y.callback=Me(e)}const _={url:"https://"+a.host,formData:y,fileName:"file",name:"file",filePath:e,fileType:n};if(await this.uploadFileToOSS(Object.assign({},_,{onUploadProgress:i})),m)return{success:!0,filePath:e,fileID:c};if((await this.reportOSSUpload({id:g})).success)return{success:!0,filePath:e,fileID:c};throw new ke({code:"UPLOAD_FAILED",message:"文件上传失败"})}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new ke({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 ke({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}}},Fe={init(e){const t=new qe(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 je="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var $e,Ke;(Ke=$e||($e={})).local="local",Ke.none="none",Ke.session="session";var He=function(){},Je=b((function(e,t){var n;e.exports=(n=C,function(e){var t=n,s=t.lib,i=s.WordArray,r=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,i=0;i<64;)t(s)&&(i<8&&(a[i]=n(e.pow(s,.5))),c[i]=n(e.pow(s,1/3)),i++),s++}();var l=[],u=o.SHA256=r.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,s=n[0],i=n[1],r=n[2],o=n[3],a=n[4],u=n[5],h=n[6],d=n[7],p=0;p<64;p++){if(p<16)l[p]=0|e[t+p];else{var g=l[p-15],f=(g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3,m=l[p-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;l[p]=f+l[p-7]+y+l[p-16]}var _=s&i^s&r^i&r,T=(s<<30|s>>>2)^(s<<19|s>>>13)^(s<<10|s>>>22),v=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&u^~a&h)+c[p]+l[p];d=h,h=u,u=a,a=o+v|0,o=r,r=i,i=s,s=v+(T+_)|0}n[0]=n[0]+s|0,n[1]=n[1]+i|0,n[2]=n[2]+r|0,n[3]=n[3]+o|0,n[4]=n[4]+a|0,n[5]=n[5]+u|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,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(s/4294967296),n[15+(i+64>>>9<<4)]=s,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(u),t.HmacSHA256=r._createHmacHelper(u)}(Math),n.SHA256)})),We=Je,ze=b((function(e,t){e.exports=C.HmacSHA256}));const Ve=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new ke({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 Qe(e){return void 0===e}function Ye(e){return"[object Null]"===Object.prototype.toString.call(e)}function Ge(e=""){return e.replace(/([\s\S]+)\s+(请前往云开发AI小助手查看问题:.*)/,"$1")}function Xe(e=32){let t="";for(let n=0;n=0?JSON.parse(n).content:""}removeStore(e){this._storage.removeItem(e)}}const rt={},ot={};function at(e){return rt[e]}class ct{constructor(e,t){this.data=t||null,this.name=e}}class lt extends ct{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const ut=new class{constructor(){this._listeners={}}on(e,t){return n=e,s=t,(i=this._listeners)[n]=i[n]||[],i[n].push(s),this;var n,s,i}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 lt)return this;const n="string"==typeof e?new ct(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 ht(e,t){ut.on(e,t)}function dt(e,t={}){ut.fire(e,t)}function pt(e,t){ut.off(e,t)}const gt="loginStateChanged",ft="loginStateExpire",mt="loginTypeChanged",yt="anonymousConverted",_t="refreshAccessToken";var Tt;!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"}(Tt||(Tt={}));class vt{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 e=t();n(await e)}catch(i){s(i)}finally{this._fnPromiseMap.delete(e)}})),this._fnPromiseMap.set(e,n)),n}_runIdlePromise(){return Promise.resolve()}}class wt{constructor(e){this._singlePromise=new vt,this._cache=at(e.env),this._baseURL=`https://${e.env}.ap-shanghai.tcb-api.tencentcloudapi.com`,this._reqClass=new et.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=Xe(),this._cache.setStore(e,t)),this._deviceID=t,t}async _request(e,t,n={}){const s={"x-request-id":Xe(),"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,i=this._cache.getStore(e);if(i&&i!==Tt.ANONYMOUS)throw new ke({code:"INVALID_OPERATION",message:"非匿名登录不支持刷新 access token"});const r=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}=r;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 xt=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],St={"X-SDK-Version":"1.3.5"};function It(e,t,n){const s=e[t];e[t]=function(t){const i={},r={};n.forEach((n=>{const{data:s,headers:o}=n.call(e,t);Object.assign(i,s),Object.assign(r,o)}));const o=t.data;return o&&(()=>{var e;if(e=o,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...o,...i};else for(const t in i)o.append(t,i[t])})(),t.headers={...t.headers||{},...r},s.call(e,t)}}function kt(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...St,"x-seqid":e}}}class Pt{constructor(e={}){var t;this.config=e,this._reqClass=new et.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=at(this.config.env),this._localCache=(t=this.config.env,ot[t]),this.oauth=new wt(this.config),It(this._reqClass,"post",[kt]),It(this._reqClass,"upload",[kt]),It(this._reqClass,"download",[kt])}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:i}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let r=this._cache.getStore(n);if(!r)throw new ke({message:"未登录CloudBase"});const o={refresh_token:r},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)===Tt.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(i),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()}dt(ft),this._cache.removeStore(n)}throw new ke({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return dt(_t),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 ke({message:"refresh token不存在,登录状态异常"});let s=this._cache.getStore(e),i=this._cache.getStore(t),r=!0;return this._shouldRefreshAccessTokenHook&&!(await this._shouldRefreshAccessTokenHook(s,i))&&(r=!1),(!s||!i||i{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:i,country:r,city:o}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:i,country:r,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 Et{constructor(e){if(!e)throw new ke({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=at(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,i=this._cache.getStore(t),r=this._cache.getStore(n),o=this._cache.getStore(s);this.credential={refreshToken:i,accessToken:r,accessTokenExpire:o},this.user=new Ct(e)}get isAnonymousAuth(){return this.loginType===Tt.ANONYMOUS}get isCustomAuth(){return this.loginType===Tt.CUSTOM}get isWeixinAuth(){return this.loginType===Tt.WECHAT||this.loginType===Tt.WECHAT_OPEN||this.loginType===Tt.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class Rt extends Ot{async signIn(){this._cache.updatePersistence("local"),await this._request.oauth.getAccessToken(),dt(gt),dt(mt,{env:this.config.env,loginType:Tt.ANONYMOUS,persistence:"local"});const e=new Et(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),i=this._cache.getStore(n),r=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:i,ticket:e});if(r.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),dt(yt,{env:this.config.env}),dt(mt,{loginType:Tt.CUSTOM,persistence:"local"}),{credential:{refreshToken:r.refresh_token}};throw new ke({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Tt.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Lt extends Ot{async signIn(e){if("string"!=typeof e)throw new ke({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(),dt(gt),dt(mt,{env:this.config.env,loginType:Tt.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new Et(this.config.env);throw new ke({message:"自定义登录失败"})}}class Ut extends Ot{async signIn(e,t){if("string"!=typeof e)throw new ke({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:i,access_token:r,access_token_expire:o}=s;if(i)return this.setRefreshToken(i),r&&o?this.setAccessToken(r,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),dt(gt),dt(mt,{env:this.config.env,loginType:Tt.EMAIL,persistence:this.config.persistence}),new Et(this.config.env);throw s.code?new ke({code:s.code,message:`邮箱登录失败: ${s.message}`}):new ke({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 Dt extends Ot{async signIn(e,t){if("string"!=typeof e)throw new ke({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="");const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:Tt.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:i,access_token_expire:r,access_token:o}=s;if(i)return this.setRefreshToken(i),o&&r?this.setAccessToken(o,r):await this._request.refreshAccessToken(),await this.refreshUserInfo(),dt(gt),dt(mt,{env:this.config.env,loginType:Tt.USERNAME,persistence:this.config.persistence}),new Et(this.config.env);throw s.code?new ke({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new ke({message:"用户名密码登录失败"})}}class Bt{constructor(e){this.config=e,this._cache=at(e.env),this._request=bt(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),ht(mt,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 Rt(this.config)}customAuthProvider(){return new Lt(this.config)}emailAuthProvider(){return new Ut(this.config)}usernameAuthProvider(){return new Dt(this.config)}async signInAnonymously(){return new Rt(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new Ut(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new Dt(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new Rt(this.config)),ht(yt,this._onAnonymousConverted),await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Tt.ANONYMOUS)throw new ke({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const i=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),dt(gt),dt(mt,{env:this.config.env,loginType:Tt.NULL,persistence:this.config.persistence}),i}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){ht(gt,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){ht(ft,e.bind(this))}onAccessTokenRefreshed(e){ht(_t,e.bind(this))}onAnonymousConverted(e){ht(yt,e.bind(this))}onLoginTypeChanged(e){ht(mt,(()=>{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 Et(this.config.env)}async isUsernameRegistered(e){if("string"!=typeof e)throw new ke({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 Lt(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 Nt=function(e,t){t=t||Ve();const n=bt(this.config.env),{cloudPath:s,filePath:i,onUploadProgress:r,fileType:o="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:l,fileId:u,cosFileId:h},requestId:d}=e,p={key:s,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":l};n.upload({url:a,data:p,file:i,name:s,fileType:o,onUploadProgress:r}).then((e=>{201===e.statusCode?t(null,{fileID:u,requestId:d}):t(new ke({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Mt=function(e,t){t=t||Ve();const n=bt(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},qt=function({fileList:e},t){if(t=t||Ve(),!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 bt(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},Ft=function({fileList:e},t){t=t||Ve(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let i of e)"object"==typeof i?(i.hasOwnProperty("fileID")&&i.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:i.fileID,max_age:i.maxAge})):"string"==typeof i?n.push({fileid:i}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return bt(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},jt=async function({fileID:e},t){const n=(await Ft.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=bt(this.config.env);let i=n.download_url;if(i=encodeURI(i),!t)return s.download({url:i});t(await s.download({url:i}))},$t=function({name:e,data:t,query:n,parse:s,search:i,timeout:r},o){const a=o||Ve();let c;try{c=t?JSON.stringify(t):""}catch(u){return Promise.reject(u)}if(!e)return Promise.reject(new ke({code:"PARAM_ERROR",message:"函数名不能为空"}));const l={inQuery:n,parse:s,search:i,function_name:e,request_data:c};return bt(this.config.env).send("functions.invokeFunction",l,{timeout:r}).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 ke({message:"response data must be json"}))}}return a.promise})).catch((e=>{a(e)})),a.promise},Kt={timeout:15e3,persistence:"session"},Ht=6e5,Jt={};class Wt{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(et.adapter||(this.requestClient=new et.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Kt,...e},!0){case this.config.timeout>Ht:this.config.timeout=Ht;break;case this.config.timeout<100:this.config.timeout=100}return new Wt(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||et.adapter.primaryStorage||Kt.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;rt[t]=new it(e),ot[t]=new it({...e,persistence:"local"})}(this.config),n=this.config,At[n.env]=new Pt(n),this.authObj=new Bt(this.config),this.authObj}on(e,t){return ht.apply(this,[e,t])}off(e,t){return pt.apply(this,[e,t])}callFunction(e,t){return $t.apply(this,[e,t])}deleteFile(e,t){return qt.apply(this,[e,t])}getTempFileURL(e,t){return Ft.apply(this,[e,t])}downloadFile(e,t){return jt.apply(this,[e,t])}uploadFile(e,t){return Nt.apply(this,[e,t])}getUploadMetadata(e,t){return Mt.apply(this,[e,t])}registerExtension(e){Jt[e.name]=e}async invokeExtension(e,t){const n=Jt[e];if(!n)throw new ke({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&&(et.adapter=t),n&&(et.runtime=n)}}var zt=new Wt;function Vt(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),i="";for(var r in n)""===i?!s&&(t+="?"):i+="&",i+=r+"="+encodeURIComponent(n[r]);return/^http(s)?:\/\//.test(t+=i)?t:""+e+t}class Qt{get(e){const{url:t,data:n,headers:s,timeout:i}=e;return new Promise(((e,r)=>{Pe.request({url:Vt("https:",t),data:n,method:"GET",header:s,timeout:i,success(t){e(t)},fail(e){r(e)}})}))}post(e){const{url:t,data:n,headers:s,timeout:i}=e;return new Promise(((e,r)=>{Pe.request({url:Vt("https:",t),data:n,method:"POST",header:s,timeout:i,success(t){e(t)},fail(e){r(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:i,data:r,headers:o,fileType:a}=e,c=Pe.uploadFile({url:Vt("https:",s),name:"file",formData:Object.assign({},r),filePath:i,fileType:a,header:o,success(e){const n={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&r.success_action_status&&(n.statusCode=parseInt(r.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 Yt={setItem(e,t){Pe.setStorageSync(e,t)},getItem:e=>Pe.getStorageSync(e),removeItem(e){Pe.removeStorageSync(e)},clear(){Pe.clearStorageSync()}};var Gt={genAdapter:function(){return{root:{},reqClass:Qt,localStorage:Yt,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};zt.useAdapters(Gt);const Xt=zt,Zt=Xt.init;Xt.init=function(e){e.env=e.spaceId;const t=Zt.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:i}=Ie(e);if(!(t||s||i))return n.call(this,e);n.call(this,e).then((e=>{t&&t(e),i&&i(e)}),(e=>{s&&s(e),i&&i(e)}))}).bind(t)})),t},t.customAuth=t.auth,t};var en=Xt;async function tn(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{Pe.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(i){return!1}var s}const nn={"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 sn=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=Pe}async request(e,t=!0){return e=this.setupRequest(e),Promise.resolve().then((()=>Ne(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 ke({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"]=Be(t,this.config.clientSecret);const s=De();n["x-client-info"]=encodeURIComponent(JSON.stringify(s));const{token:i}=be();return n["x-client-token"]=i,{url:this.config.requestUrl,method:"POST",data:t,dataType:"json",header:JSON.parse(JSON.stringify(n))}}async setupLocalRequest(e){const t=De(),{token:n}=be(),s=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now(),clientInfo:t,token:n}),{address:i,servePort:r}=this.__dev__&&this.__dev__.debugInfo||{},{address:o}=await async function(e,t){let n;for(let s=0;s{const{url:r,formData:o,name:a}=t.result;return i=t.result.fileUrl,new Promise(((t,i)=>{const c=this.adapter.uploadFile({url:r,formData:o,name:a,filePath:e,fileType:n,success(e){e&&e.statusCode<400?t(e):i(new ke({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){i(new ke({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:i}):s(new ke({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 ke({code:"DELETE_FILE_FAILED",message:"删除文件失败"})}))}getTempFileURL({fileList:e,maxAge:t}={}){if(!Array.isArray(e)||0===e.length)throw new ke({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 ke({code:"GET_TEMP_FILE_URL_FAILED",message:"获取临时文件链接失败"})}))}},rn={init(e){const t=new sn(e),n={signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}},on=b((function(e,t){e.exports=C.enc.Hex}));function an(){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 cn(e="",t={}){const{data:n,functionName:s,method:i,headers:r,signHeaderKeys:o=[],config:a}=t,c=String(Date.now()),l=an(),u=Object.assign({},r,{"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":l,"x-alipay-callid":l,"x-trace-id":l}),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(""),i=We(e.body).toString(on),r=`${e.method.toUpperCase()}\n${e.path}\n${e.query}\n${s}\n${n}\n${i}\n`,o=We(r).toString(on),a=`${t}\n${e.timestamp}\n${o}\n`,c=ze(a,e.secretKey).toString(on);return`${t} Credential=${e.secretId}, SignedHeaders=${n}, Signature=${c}`}({path:d,query:p,method:i,headers:u,timestamp:c,body:JSON.stringify(n),secretId:a.accessKey,secretKey:a.secretKey,signedHeaders:h.sort()});return{url:`${a.endpoint}${e}`,headers:Object.assign({},u,{Authorization:g})}}function ln({url:e,data:t,method:n="POST",headers:s={},timeout:i}){return new Promise(((r,o)=>{Pe.request({url:e,method:n,data:"object"==typeof t?JSON.stringify(t):t,header:s,dataType:"json",timeout:i,complete:(e={})=>{const t=s["x-trace-id"]||"";if(!e.statusCode||e.statusCode>=400){const{message:n,errMsg:s,trace_id:i}=e.data||{};return o(new ke({code:"SYS_ERR",message:n||s||"request:fail",requestId:i||t}))}r({status:e.statusCode,data:e.data,headers:e.header,requestId:t})}})}))}function un(e,t){const{path:n,data:s,method:i="GET"}=e,{url:r,headers:o}=cn(n,{functionName:"",data:s,method:i,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 ln({url:r,data:s,method:i,headers:o}).then((e=>{const t=e.data||{};if(!t.success)throw new ke({code:e.errCode,message:e.errMsg,requestId:e.requestId});return t.data||{}})).catch((e=>{throw new ke({code:e.errCode,message:e.errMsg,requestId:e.requestId})}))}function hn(e=""){const t=e.trim().replace(/^cloud:\/\//,""),n=t.indexOf("/");if(n<=0)throw new ke({code:"INVALID_PARAM",message:"fileID不合法"});t.substring(0,n);const s=t.substring(n+1);return this.config.spaceId,s}function dn(e=""){return"cloud://".concat(this.config.spaceId,"/").concat(e.replace(/^\/+/,""))}class pn{constructor(e){this.config=e}signedURL(e,t={}){const n=`/ws/function/${e}`,s=this.config.wsEndpoint.replace(/^ws(s)?:\/\//,""),i=Object.assign({},t,{accessKeyId:this.config.accessKey,signatureNonce:an(),timestamp:""+Date.now()}),r=[n,["accessKeyId","authorization","signatureNonce","timestamp"].sort().map((function(e){return i[e]?"".concat(e,"=").concat(i[e]):null})).filter(Boolean).join("&"),`host:${s}`].join("\n"),o=["HMAC-SHA256",We(r).toString(on)].join("\n"),a=ze(o,this.config.secretKey).toString(on),c=Object.keys(i).map((e=>`${e}=${encodeURIComponent(i[e])}`)).join("&");return`${this.config.wsEndpoint}${n}?${c}&signature=${a}`}}var gn=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 pn(this.config)}callFunction(e){return function(e,t){const{name:n,data:s,async:i=!1,timeout:r}=e,o="POST",a={"x-to-function-name":n};i&&(a["x-function-invoke-type"]="async");const{url:c,headers:l}=cn("/functions/invokeFunction",{functionName:n,data:s,method:o,headers:a,signHeaderKeys:["x-to-function-name"],config:t});return ln({url:c,data:s,method:o,headers:l,timeout:r}).then((e=>{let t=0;if(i){const n=e.data||{};t="200"===n.errCode?0:n.errCode,e.data=n.data||{},e.errMsg=n.errMsg}if(0!==t)throw new ke({code:t,message:e.errMsg,requestId:e.requestId});return{errCode:t,success:0===t,requestId:e.requestId,result:e.data}})).catch((e=>{throw new ke({code:e.errCode,message:e.errMsg,requestId:e.requestId})}))}(e,this.config)}uploadFileToOSS({url:e,filePath:t,fileType:n,formData:s,onUploadProgress:i}){return new Promise(((r,o)=>{const a=Pe.uploadFile({url:e,filePath:t,fileType:n,formData:s,name:"file",success(e){e&&e.statusCode<400?r(e):o(new ke({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){o(new ke({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof i&&a&&"function"==typeof a.onProgressUpdate&&a.onProgressUpdate((e=>{i({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}async uploadFile({filePath:e,cloudPath:t="",fileType:n="image",onUploadProgress:s}){if("string"!==j(t))throw new ke({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new ke({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new ke({code:"INVALID_PARAM",message:"cloudPath不合法"});const i=await un({path:"/".concat(t.replace(/^\//,""),"?post_url")},this.config),{file_id:r,upload_url:o,form_data:a}=i,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:r})))}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 r of e){let e;"string"!==j(r)&&t({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});try{e=hn.call(this,r)}catch(i){e=r}s.push({file_id:e,expire:600})}un({path:"/?download_url",data:{file_list:s},method:"POST"},this.config).then((e=>{const{file_list:n=[]}=e;t({fileList:n.map((e=>({fileID:dn.call(this,e.file_id),tempFileURL:e.download_url})))})})).catch((e=>n(e)))}))}async connectWebSocket(e){const{name:t,query:n}=e;return Pe.connectSocket({url:this._websocket.signedURL(t,n),complete:()=>{}})}},fn={init:e=>{e.provider="alipay";const t=new gn(e);return t.auth=function(){return{signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!0)}}},t}};function mn({data:e}){let t;t=De();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=be();e&&(n.uniIdToken=e)}return n}const yn=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var _n=/[\\^$.*+?()[\]{}|]/g,Tn=RegExp(_n.source);function vn(e,t,n){return e.replace(new RegExp((s=t)&&Tn.test(s)?s.replace(_n,"\\$&"):s,"g"),n);var s}const wn="request",xn="response",Sn="both",In="_globalUniCloudStatus",kn={code:2e4,message:"System error"},Pn={code:20101,message:"Invalid client"};function An(e){const{errSubject:t,subject:n,errCode:s,errMsg:i,code:r,message:o,cause:a}=e||{};return new ke({subject:t||n||"uni-secure-network",code:s||r||kn.code,message:i||o,cause:a})}let bn;function On({secretType:e}={}){return e===wn||e===xn||e===Sn}function Cn({functionName:e,result:t,logPvd:n}){}function En(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=mn.call(e,{data:n.data});const i={aliyun:"aliyun",tencent:"tcb",tcb:"tcb",alipay:"alipay",dcloud:"dcloud"}[this.config.provider],r=On(n)||false;return t.call(this,n).then((e=>(e.errCode=0,!r&&Cn.call(this,{functionName:s,result:e,logPvd:i}),Promise.resolve(e))),(e=>(!r&&Cn.call(this,{functionName:s,result:e,logPvd:i}),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||{},l=Object.keys(c);if(0===l.length)return!0;const u=function(e,t){let n,s,i;for(let r=0;re.trim())).indexOf(t)>-1&&(s=o):i=o:n=o}return n||s||i}(l,n);if(!u)return!1;if((c[u]||[]).find(((e={})=>e.appId===s&&(e.platform||"").toLowerCase()===o.toLowerCase())))return!0;throw An(Pn)}({provider:s,spaceId:i,functionName:r})?new bn({secretType:t.secretType,uniCloudIns:e}).wrapVerifyClientCallFunction(n.bind(e))(t):o(t),Object.defineProperty(a,"result",{get:()=>({})}),a.then((e=>("undefined"!=typeof UTSJSONObject&&(e.result=new UTSJSONObject(e.result)),e)))}}bn=class{constructor(){throw An({message:`Platform ${G} is not supported by secure network`})}};const Rn=Symbol("CLIENT_DB_INTERNAL");function Ln(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=Rn,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 Un(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 Dn=["db.Geo","db.command","command.aggregate"];function Bn(e,t){return Dn.indexOf(`${e}.${t}`)>-1}function Nn(e){switch(j(e=Ae(e))){case"array":return e.map((e=>Nn(e)));case"object":return e._internalType===Rn||Object.keys(e).forEach((t=>{e[t]=Nn(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function Mn(e){return e&&e.content&&e.content.$method}class qn{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:Nn(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=Mn(e),n=Mn(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"===Mn(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=Mn(e),n=Mn(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}getNextStageFn(e){const t=this;return function(){return Fn({$method:e,$param:Nn(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:Nn(t)}),this._database._callCloudFunction({action:n,command:s})}}function Fn(e,t,n){return Ln(new qn(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),Bn(s,t)?Fn({$method:t},e,n):function(){return Fn({$method:t,$param:Nn(Array.from(arguments))},e,n)}}})}function jn({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())}}}class $n{constructor({uniClient:e={},isJQL:t=!1}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e._isDefault&&(this._dbCallBacks=ne("_globalUniCloudDatabaseCallback")),t||(this.auth=Un(this._authCallBacks)),this._isJQL=t,Object.assign(this,Un(this._dbCallBacks)),this.env=Ln({},{get:(e,t)=>({$env:t})}),this.Geo=Ln({},{get:(e,t)=>jn({path:["Geo"],method:t})}),this.serverDate=jn({path:[],method:"serverDate"}),this.RegExp=jn({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})}}function Kn(e,t={}){return Ln(new e(t),{get:(e,t)=>Bn("db",t)?Fn({$method:t},null,e):function(){return Fn({$method:t,$param:Nn(Array.from(arguments))},null,e)}})}class Hn extends $n{_parseResult(e){return this._isJQL?e.result:e}_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function i(e,t){if(n&&s)for(let n=0;nae(ce(o,"complete"),e))).then((()=>(i(null,e),ve(he,{type:ge,content:e}),Promise.reject(e))))}const c=ae(ce(o,"invoke")),l=this._uniClient;return c.then((()=>l.callFunction({name:"DCloud-clientDB",type:M,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:c,systemInfo:l=[]}=e.result;if(l)for(let i=0;in})}}return h=e,ae(ce(o,"success"),h).then((()=>ae(ce(o,"complete"),h))).then((()=>{i(h,null);const e=r._parseResult(h);return ve(he,{type:ge,content:e}),Promise.resolve(e)}));var h}),(e=>(/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message),a(new ke({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId})))))}}const Jn="token无效,跳转登录页面",Wn="token过期,跳转登录页面",zn={TOKEN_INVALID_TOKEN_EXPIRED:Wn,TOKEN_INVALID_INVALID_CLIENTID:Jn,TOKEN_INVALID:Jn,TOKEN_INVALID_WRONG_TOKEN:Jn,TOKEN_INVALID_ANONYMOUS_USER:Jn},Vn={"uni-id-token-expired":Wn,"uni-id-check-token-failed":Jn,"uni-id-token-not-exist":Jn,"uni-id-check-device-feature-failed":Jn};function Qn(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function Yn(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(Qn(t,e.path)):!1===e.needLogin&&s.push(Qn(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function Gn(e){return e.split("?")[0].replace(/^\//,"")}function Xn(){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 Zn(){return Gn(Xn())}function es(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=Gn(e);return n.some((e=>e.pagePath===s))}const ts=!!A.uniIdRouter,{loginPage:ns,routerNeedLogin:ss,resToLogin:is,needLoginPage:rs,notNeedLoginPage:os,loginPageInTabBar:as}=function({pages:e=[],subPackages:t=[],uniIdRouter:n={},tabBar:s={}}=A){const{loginPage:i,needLogin:r=[],resToLogin:o=!0}=n,{needLoginPage:a,notNeedLoginPage:c}=Yn(e),{needLoginPage:l,notNeedLoginPage:u}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:i=[]}=e,{needLoginPage:r,notNeedLoginPage:o}=Yn(i,s);t.push(...r),n.push(...o)})),{needLoginPage:t,notNeedLoginPage:n}}(t);return{loginPage:i,routerNeedLogin:r,resToLogin:o,needLoginPage:[...a,...l],notNeedLoginPage:[...c,...u],loginPageInTabBar:es(i,s)}}();if(rs.indexOf(ns)>-1)throw new Error(`Login page [${ns}] should not be "needLogin", please check your pages.json`);function cs(e){const t=Zn();if("/"===e.charAt(0))return e;const[n,s]=e.split("?"),i=n.replace(/^\//,"").split("/"),r=t.split("/");r.pop();for(let o=0;o-1?s+`&uniIdRedirectUrl=${encodeURIComponent(i)}`:s+`?uniIdRedirectUrl=${encodeURIComponent(i)}`:s);var s,i;as?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo");const r={navigateTo:T,redirectTo:v,switchTab:w,reLaunch:x};setTimeout((()=>{r[e]({url:n})}),0)}function hs({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},n=function(){const{token:e,tokenExpired:t}=be();let n;if(e){if(t-1)&&(rs.indexOf(t)>-1||ss.some((t=>{return n=e,new RegExp(t).test(n);var n})))}(e)&&n){if(n.uniIdRedirectUrl=e,ye(de).length>0)return setTimeout((()=>{ve(de,n)}),0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function ds(){!function(){const e=Xn(),{abortLoginPageJump:t,autoToLoginPage:n}=hs({url:e});t||n&&us({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 Vn}(n);break;case"clientdb":s=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in zn}(n)}s&&function(e={}){const t=ye(de);Se().then((()=>{const n=Xn();if(n&&ls({redirect:n}))return t.length>0?ve(de,Object.assign({uniIdRedirectUrl:n},e)):void(ns&&us({api:"navigateTo",redirect:n}))}))}(n)}))}function gs(e){var t;(t=e).onResponse=function(e){_e(he,e)},t.offResponse=function(e){Te(he,e)},function(e){e.onNeedLogin=function(e){_e(de,e)},e.offNeedLogin=function(e){Te(de,e)},ts&&(ne(In).needLoginInit||(ne(In).needLoginInit=!0,Se().then((()=>{ds.call(e)})),is&&ps.call(e)))}(e),function(e){e.onRefreshToken=function(e){_e(pe,e)},e.offRefreshToken=function(e){Te(pe,e)}}(e)}let fs;const ms="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ys=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function _s(){const e=be().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(fs(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(i){throw new Error("获取当前用户信息出错,详细错误信息为:"+i.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}fs="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!ys.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,i="",r=0;r>16&255):64===s?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return i}:atob;var Ts=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 r="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:r,tempFilePaths:[],tempFiles:[]}:function(e,t,n=5,s){(t=Object.assign({},t)).errMsg=r;const i=t.tempFiles,o=i.length;let a=0;return new Promise((r=>{for(;a=o)return void(!i.find((e=>!e.url&&!e.errMsg))&&r(t));const l=i[n];e.uploadFile({provider:l.provider,filePath:l.path,cloudPath:l.cloudPath,fileType:l.fileType,cloudPathAsRealPath:l.cloudPathAsRealPath,onUploadProgress(e){e.index=n,e.tempFile=l,e.tempFilePath=l.path,s&&s(e)}}).then((e=>{l.url=e.fileID,n{l.errMsg=e.errMsg||e.message,n{e({count:n,sizeType:s,sourceType:i,extension:r,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:i,sourceType:r=["album","camera"],extension:c}=e;return new Promise(((e,l)=>{t({camera:n,compressed:s,maxDuration:i,sourceType:r,extension:c,success(t){const{tempFilePath:n,duration:s,size:i,height:r,width:o}=t;e(a({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:i,type:t.tempFile&&t.tempFile.type||"",width:o,height:r,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){l({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 r=i;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(r=wx.chooseMessageFile),"function"!=typeof r)return s({errMsg:o+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});r({type:"all",count:t,extension:n,success(t){e(a(t))},fail(e){s({errMsg:e.errMsg.replace("chooseFile:fail",o)})}})}))}(s),s)}}})));const vs="manual";function ws(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===vs)return;let n=!1;const s=[];for(let i=2;i{this.mixinDatacomLoading=!1;const{data:s,count:i}=n.result;this.getcount&&(this.mixinDatacomPage.count=i),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 i=t.collection||this.collection;n=Array.isArray(i)?n.collection(...i):n.collection(i);const r=t.where||this.where;r&&Object.keys(r).length&&(n=n.where(r));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 l=t.groupField||this.groupField;l&&(n=n.groupField(l)),!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const u=t.orderby||this.orderby;u&&(n=n.orderBy(u));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 xs(e){return ne("_globalUniCloudSecureNetworkCache__{spaceId}".replace("{spaceId}",e.config.spaceId))}async function Ss({openid:e,callLoginByWeixin:t=!1}={}){throw xs(this),new Error(`[SecureNetwork] API \`initSecureNetworkByWeixin\` is not supported on platform \`${G}\``)}async function Is(e){const t=xs(this);return t.initPromise||(t.initPromise=Ss.call(this,e).then((e=>e)).catch((e=>{throw delete t.initPromise,e}))),t.initPromise}function ks(e){Ue=e}function Ps(e){const t={getSystemInfo:S,getPushClientId:I};return function(n){return new Promise(((s,i)=>{t[e]({...n,success(e){s(e)},fail(e){i(e)}})}))}}class As extends V{constructor(){super(),this._uniPushMessageCallback=this._receivePushMessage.bind(this),this._currentMessageId=-1,this._payloadQueue=[]}init(){return Promise.all([Ps("getSystemInfo")(),Ps("getPushClientId")()]).then((([{appId:e}={},{cid:t}={}]=[])=>{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:i}=t;this._payloadQueue.push({action:n,messageId:s,message:i}),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(){l(this._uniPushMessageCallback)}_destroy(){u(this._uniPushMessageCallback)}toJSON(){return{appId:this._appId,pushClientId:this._pushClientId,seqId:this._seqId}}close(){this._destroy(),this.emit("close")}}const bs={tcb:en,tencent:en,aliyun:Fe,private:rn,dcloud:rn,alipay:fn};let Os=new class{init(e){let t={};const n=bs[e.provider];if(!n)throw new Error("未提供正确的provider参数");var s;return t=n.init(e),function(e){e._initPromiseHub||(e._initPromiseHub=new z({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),En(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=Kn(Hn,{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=Kn(Hn,{uniClient:s,isJQL:!0});return this._databaseForJQL=t,t},function(e){e.getCurrentUserInfo=_s,e.chooseAndUploadFile=Ts.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return ws(e)}}),e.SSEChannel=As,e.initSecureNetworkByWeixin=function(e){return function({openid:t,callLoginByWeixin:n=!1}={}){return Is.call(e,{openid:t,callLoginByWeixin:n})}}(e),e.setCustomClientInfo=ks,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:i,loadingOptions:l,errorOptions:u,parseSystemError:h}=s,d=!i;return new Proxy({},{get(i,p){switch(p){case"toString":return"[object UniCloudObject]";case"toJSON":return{}}return function({fn:e,interceptorName:t,getCallbackArgs:n}={}){return async function(...s){const i=n?n({params:s}):{};let r,o;try{return await ae(ce(t,"invoke"),{...i}),r=await e(...s),await ae(ce(t,"success"),{...i,result:r}),r}catch(a){throw o=a,await ae(ce(t,"fail"),{...i,error:o}),o}finally{await ae(ce(t,"complete"),o?{...i,error:o}:{...i,result:r})}}}({fn:async function i(...g){let f;d&&r({title:l.title,mask:l.mask});const m={name:n,type:N,data:{method:p,params:g}};"object"==typeof s.secretMethods&&function(e,t){const n=t.data.method,s=e.secretMethods||{},i=s[n]||s["*"];i&&(t.secretType=i)}(s,m);let y=!1;try{f=await t.callFunction(m)}catch(e){y=!0,f={result:new ke(e)}}const{errSubject:_,errCode:T,errMsg:v,newToken:w}=f.result||{};if(d&&o(),w&&w.token&&w.tokenExpired&&(Oe(w),ve(pe,{...w})),T){let e=v;if(y&&h&&(e=(await h({objectName:n,methodName:p,params:g,errSubject:_,errCode:T,errMsg:v})).errMsg||v),d)if("toast"===u.type)a({title:e,icon:"none"});else{if("modal"!==u.type)throw new Error(`Invalid errorOptions.type: ${u.type}`);{const{confirm:t}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:i}={}){return new Promise(((r,o)=>{c({title:e,content:t,showCancel:n,cancelText:s,confirmText:i,success(e){r(e)},fail(){r({confirm:!1,cancel:!0})}})}))}({title:"提示",content:e,showCancel:u.retry,cancelText:"取消",confirmText:u.retry?"重试":"确定"});if(u.retry&&t)return i(...g)}}const t=new ke({subject:_,code:T,message:v,requestId:f.requestId});throw t.detail=f.result,ve(he,{type:me,content:t}),t}return ve(he,{type:me,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||B;s=e!==B}const i="callFunction"===t&&!s,r=this._initPromiseHub.exec();n=n||{};const{success:o,fail:a,complete:c}=Ie(n),l=r.then((()=>s?Promise.resolve():ae(ce(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):ae(ce(t,"success"),e).then((()=>ae(ce(t,"complete"),e))).then((()=>(i&&ve(he,{type:fe,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):ae(ce(t,"fail"),e).then((()=>ae(ce(t,"complete"),e))).then((()=>(ve(he,{type:fe,content:e}),Promise.reject(e))))));if(!(o||a||c))return l;l.then((e=>{o&&o(e),c&&c(e),i&&ve(he,{type:fe,content:e})}),(e=>{a&&a(e),c&&c(e),i&&ve(he,{type:fe,content:e})}))}}(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{const e=X;let t={};if(e&&1===e.length)t=e[0],Os=Os.init(t),Os._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=>{Os[e]=function(){return Promise.reject(new ke({code:"SYS_ERR",message:n}))}}))}Object.assign(Os,{get mixinDatacom(){return ws(Os)}}),gs(Os),Os.addInterceptor=re,Os.removeInterceptor=oe,Os.interceptObject=le;{const e=ee||(ee=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")()}(),ee);e.uniCloud=Os,e.UniCloudError=ke}})();var Cs=Os;export{Cs as e};