"use strict";vare=require("@dcloudio/uni-i18n");"undefined"!=typeofglobalThis?globalThis:"undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself&&self;functiont(e){returne&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}functions(e,t,s){returne(s={path:t,exports:{},require:function(e,t){returnfunction(){thrownewError("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&s.path)}},s.exports),s.exports}varn=s((function(e,t){vars;e.exports=(s=s||function(e,t){vars=Object.create||function(){functione(){}returnfunction(t){vars;returne.prototype=t,s=newe,e.prototype=null,s}}(),n={},r=n.lib={},o=r.Base={extend:function(e){vart=s(this);returne&&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(){vare=this.extend();returne.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(vartine)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){returnthis.init.prototype.extend(this)}},i=r.WordArray=o.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){vart=this.words,s=e.words,n=this.sigBytes,r=e.sigBytes;if(this.clamp(),n%4)for(varo=0;o<r;o++){vari=s[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=i<<24-(n+o)%4*8}elsefor(o=0;o<r;o+=4)t[n+o>>>2]=s[o>>>2];returnthis.sigBytes+=r,this},clamp:function(){vart=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-s%4*8,t.length=e.ceil(s/4)},clone:function(){vare=o.clone.call(this);returne.words=this.words.slice(0),e},random:function(t){for(vars,n=[],r=function(t){t=t;vars=987654321,n=4294967295;returnfunction(){varr=((s=36969*(65535&s)+(s>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;returnr/=4294967296,(r+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){vara=r(4294967296*(s||e.random()));s=987654071*a(),n.push(4294967296*a()|0)}returnnewi.init(n,t)}}),a=n.enc={},c=a.Hex={stringify:function(e){for(vart=e.words,s=e.sigBytes,n=[],r=0;r<s;r++){varo=t[r>>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}returnn.join("")},parse:function(e){for(vart=e.length,s=[],n=0;n<t;n+=2)s[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;returnnewi.init(s,t/2)}},u=a.Latin1={stringify:function(e){for(vart=e.words,s=e.sigBytes,n=[],r=0;r<s;r++){varo=t[r>>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(o))}returnn.join("")},parse:function(e){for(vart=e.length,s=[],n=0;n<t;n++)s[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;returnnewi.init(s,t)}},h=a.Utf8={stringify:function(e){try{returndecodeURIComponent(escape(u.stringify(e)))}catch(e){thrownewError("Malformed UTF-8 data")}},parse:function(e){returnu.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=newi.init,this._nDataBytes=0},_append:function(e){"string"==typeofe&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){vars=this._data,n=s.words,r=s.sigBytes,o=this.blockSize,a=r/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,r);if(c){for(varh=0;h<c;h+=o)this._doProcessBlock(n,h);varl=n.splice(0,c);s.sigBytes-=u}returnnewi.init(l,u)},clone:function(){vare=o.clone.call(this);returne._data=this._data.clone(),e},_minBufferSize:0}),d=(r.Hasher=l.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){returnthis._append(e),this._process(),this},finalize:function(e){returne&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){returnfunction(t,s){returnnewe.init(s).finalize(t)}},_createHmacHelper:function(e){returnfunction(t,s){returnnewd.HMAC.init(e,s).finalize(t)}}}),n.algo={});returnn}(Math),s)})),r=(s((function(e,t){vars;e.exports=(s=n,function(e){vart=s,n=t.lib,r=n.WordArray,o=n.Hasher,i=t.algo,a=[];!function(){for(vart=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();varc=i.MD5=o.extend({_doReset:function(){this._hash=newr.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(vars=0;s<16;s++){varn=t+s,r=e[n];e[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}varo=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],v=e[t+9],S=e[t+10],k=e[t+11],T=e[t+12],P=e[t+13],I=e[t+14],A=e[t+15],E=o[0],O=o[1],U=o[2],b=o[3];E=u(E,O,U,b,i,7,a[0]),b=u(b,E,O,U,c,12,a[1]),U=u(U,b,E,O,f,17,a[2]),O=u(O,U,b,E,p,22,a[3]),E=u(E,O,U,b,g,7,a[4]),b=u(b,E,O,U,m,12,a[5]),U=u(U,b,E,O,y,17,a[6]),O=u(O,U,b,E,_,22,a[7]),E=u(E,O,U,b,w,7,a[8]),b=u(b,E,O,U,v,12,a[9]),U=u(U,b,E,O,S,17,a[10]),O=u(O,U,b,E,k,22,a[11]),E=u(E,O,U,b,T,7,a[12]),b=u(b,E,O,U,P,12,a[13]),U=u(U,b,E,O,I,17,a[14]),E=h(E,O=u(O,U,b,E,A,22,a[15]),U,b,c,5,a[16]),b=h(b,E,O,U,y,9,a[17]),U=h(U,b,E,O,k,14,a[18]),O=h(O,U,b,E,i,20,a[19]),E=h(E,O,U,b,m,5,a[20]),b=h(b,E,O,U,S,9,a[21]),U=h(U,b,E,O,A,14,a[22]),O=h(O,U,b,E,g,20,a[23]),E=h(E,O,U,b,v,5,a[24]),b=h(b,E,O,U,I,9,a[25]),U=h(U,b,E,O,p,14,a[26]),O=h(O,U,b,E,w,20,a[27]),E=h(E,O,U,b,P,5,a[28]),b=h(b,E,O,U,f,9,a[29]),U=h(U,b,E,O,_,14,a[30]),E=l(E,O=h(O,U,b,E,T,20,a[31]),U,b,m,4,a[32]),b=l(b,E,O,U,w,11,a[33]),U=l(U,b,E,O,k,16,a[34]),O=l(O,U,b,E,I,23,a[35]),E=l(E,O,U,b,c,4,a[36]),b=l(b,E,O,U,g,11,a[37]),U=l(U,b,E,O,_,16,a[38]),O=l(O,U,b,E,S,23,a[39]),E=l(E,O,U,b,P,4,a[40]),b=l(b,E,O,U,i,11,a[41]),U=l(U,b,E,O,p,16,a[42]),O=l(O,U,b,E,y,23,a[43]),E=l(E,O,U,b,v,4,a[44]),b=l(b,E,O,U,T,11,a[45]),U=l(U,b,E,O,A,16,a[46]),E=d(E,O=l(O,U,b,E,f,23,a[47]),U,b,i,6,a[48]),b=d(b,E,O,U,_,10,a[49]),U=d(U,b,E,O,I,15,a[50]),O=d(O,U,b,E,m,21,a[51]),E=d(E,O,U,b,T,6,a[52]),b=d(b,E,O,U,p,10,a[53]),U=d(U,b,E,O,S,15,a[54]),O=d(O,U,b,E,c,21,a[55]),E=d(E,O,U,b,w,6,a[56]),b=d(b,E,O,U,A,10,a[57]),U=d(U,b,E,O,y,15,a[58]),O=d(O,U,b,E,P,21,a[59]),E=d(E,O,U,b,g,6,a[60]),b=d(b,E,O,U,k,10,a[61]),U=d(U,b,E,O,f,15,a[62]),O=d(O,U,b,E,v,21,a[63]),o[0]=o[0]+E|0,o[1]=o[1]+O|0,o[2]=o[2]+U|0,o[3]=o[3]+b|0},_doFinalize:function(){vart=this._data,s=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;s[r>>>5]|=128<<24-r%32;varo=e.floor(n/4294967296),i=n;s[15+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(s.length+1),this._process();for(vara=this._hash,c=a.words,u=0;u<4;u++){varh=c[u];c[u]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}returna},clone:function(){vare=o.clone.call(this);returne._hash=this._hash.clone(),e}});functionu(e,t,s,n,r,o,i){vara=e+(t&s|~t&n)+r+i;return(a<<o|a>>>32-o)+t}functionh(e,t,s,n,r,o,i){vara=e+(t&n|s&~n)+r+i;return(a<<o|a>>>32-o)+t}functionl(e,t,s,n,r,o,i){vara=e+(t^s^n)+r+i;return(a<<o|a>>>32-o)+t}functiond(e,t,s,n,r,o,i){vara=e+(s^(t|~n))+r+i;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),s.MD5)})),s((function(e,t){vars,r,o;e.exports=(r=(s=n).lib.Base,o=s.enc.Utf8,void(s.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=newe.init,"string"==typeoft&&(t=o.parse(t));vars=e.blockSize,n=4*s;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(varr=this._oKey=t.clone(),i=this._iKey=t.clone(),a=r.words,c=i.words,u=0;u<s;u++)a[u]^=1549556828,c[u]^=909522486;r.sigBytes=i.sigBytes=n,this.reset()},reset:function(){vare=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){returnthis._hasher.update(e),this},finalize:function(e){vart=this._hasher,s=t.finalize(e);returnt.reset(),t.finalize(this._oKey.clone().concat(s))}})))})),s((function(e,t){e.exports=n.HmacMD5})));functiono(e){returnObject.prototype.toString.call(e).slice(8,-1).toLowerCase()}functioni(e){return"object"===o(e)}classaextendsError{constructor(e,t){super(e),this.code=t}}constc=["invoke","success","fail","complete"],u={};functionh(e,t){u[e]||(u[e]={}),i(t)&&Object.keys(t).forEach(s=>{c.indexOf(s)>-1&&function(e,t,s){letn=u[e][t];n||(n=u[e][t]=[]),-1===n.indexOf(s)&&"function"==typeofs&&n.push(s)}(e,s,t[s])})}functionl(e,t){u[e]||(u[e]={}),i(t)?Object.keys(t).forEach(s=>{c.indexOf(s)>-1&&function(e,t,s){constn=u[e][t];if(!n)return;constr=n.indexOf(s);r>-1&&n.splice(r,1)}(e,s,t[s])}):deleteu[e]}functiond(e,t){returne&&0!==e.length?e.reduce((e,s)=>e.then(()=>s(t)),Promise.resolve()):Promise.resolve()}functionf(e,t){returnu[e]&&u[e][t]||[]}functionp(e,t){returnt?function(s){constn="callFunction"===t&&"DCloud-clientDB"===(s&&s.name);letr;r=this.isReady?Promise.resolve():this.initUniCloud,s=s||{};consto=r.then(()=>n?Promise.resolve():d(f(t,"invoke"),s)).then(()=>e.call(this,s)).then(e=>n?Promise.resolve(e):d(f(t,"success"),e).then(()=>d(f(t,"complete"),e)).then(()=>Promise.resolve(e)),e=>n?Promise.reject(e):d(f(t,"fail"),e).then(()=>d(f(t,"complete"),e)).then(()=>Promise.reject(e)));if(!(s.success||s.fail||s.complete))returno;o.then(e=>{s.success&&s.success(e),s.complete&&s.complete(e)}).catch(e=>{s.fail&&s.fail(e),s.complete&&s.complete(e)})}:function(t){if(!((t=t||{}).success||t.fail||t.complete))returne.call(this,t);e.call(this,t).then(e=>{t.success&&t.success(e),t.complete&&t.complete(e)},e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)})}}classgextendsError{constructor(e){super(e.message),this.errMsg=e.message||"",Object.defineProperties(this,{code:{get:()=>e.code},requestId:{get:()=>e.requestId},message:{get(){returnthis.errMsg},set(e){this.errMsg=e}}})}}const{t:m,setLocale:y,getLocale:_}=e.initVueI18n({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},fr:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},es:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"}},"zh-Hans");functionw(e){returne&&"string"==typeofe?JSON.parse(e):e}constv="development"===process.env.NODE_ENV,S=process.env.VUE_APP_PLATFORM||process.env.UNI_PLATFORM,k=w(process.env.UNICLOUD_DEBUG),T=w(process.env.UNI_CLOUD_PROVIDER),P=process.env.RUN_BY_HBUILDERX;letI,A,E;try{I=require("uni-stat-config").default||require("uni-stat-config")}catch(e){I={appid:""}}functionO(e=8){lett="";for(;t.length<e;)t+=Math.random().toString(32).substring(2);returnt.substring(0,e)}functionU(){const{deviceId:e}=uni.getSystemInfoSync();return{PLATFORM:S,OS:E,APPID:I.appid,LOCALE:_(),DEVICEID:e,CLIENT_SDK_VERSION:"1.0.4"}}functionb(){if("n"===D()){try{A=plus.runtime.getDCloudId()}catch(e){A=""}returnA}returnA||(A=O(32),uni.setStorage({key:"__DC_CLOUD_UUID",data:A})),A}functionD(){return{"app-plus":"n",h5:"h5","mp-weixin":"wx",[["y","a","p","mp-ali"].reverse().join("")]:"ali","mp-baidu":"bd","mp-toutiao":"tt","mp-qq":"qq","quickapp-native":"qn"}[S]}varC={sign:function(e,t){lets="";returnObject.keys(e).sort().forEach((function(t){e[t]&&(s=s+"&"+t+"="+e[t])})),s=s.slice(1),r(s,t).toString()},wrappedRequest:function(e,t){returnnewPromise((s,n)=>{t(Object.assign(e,{complete(e){e||(e={}),v&&"h5"===S&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");constt=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)returnn(newg({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));constr=e.data;if(r.error)returnn(newg({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,deleter.data,s(r)}}))})}};constx={request:e=>uni.request(e),uploadFile:e=>uni.uploadFile(e),setStorageSync:(e,t)=>uni.setStorageSync(e,t),getStorageSync:e=>uni.getStorageSync(e),removeStorageSync:e=>uni.removeStorageSync(e),clearStorageSync:()=>uni.clearStorageSync()};classq{constructor(e){["spaceId","clientSecret"].forEach(t=>{if(!Object.prototype.hasOwnProperty.call(e,t))thrownewError(m("uniCloud.init.paramRequired",{param:t}))}),this.config=Object.assign({},{endpoint:"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=x,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}gethasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){returnC.wrappedRequest(e,this.adapter.request)}requestAuth(e){returnthis.requestWrapped(e)}request(e,t){returnPromise.resolve().then(()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch(t=>newPromise((e,s)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?s(t):e()}).then(()=>this.getAccessToken()).then(()=>{constt=this.rebuildRequest(e);returnthis.request(t,!0)})):this.getAccessToken().then(()=>{constt=this.rebuildRequest(e);returnthis.request(t,!0)}))}rebuildRequest(e){constt=Object.assign({},e);returnt.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=C.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){consts=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),n={"Content-Type":"application/json"};return"auth"!==t&&(s.token=this.accessToken,n["x-basement-token"]=this.accessToken),n["x-serverless-sign"]=C.sign(s,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:s,dataType:"json",header:n}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)returnthis._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";returnthis._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then(e=>newPromise((t,s)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",s(newg({code:"AUTH_FAILED",message:"获取accessToken失败"})))}),e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e))),this._getAccessTokenPromise}authorize(){this.getAccessToken()}callFunction(e){constt={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};returnthis.request(this.setupRequest(t))}getOSSUploadOptionsFromPath(e){constt={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};returnthis.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:s,filePath:n,fileType:r,onUploadProgress:o}){returnnewPromise((i,a)=>{constc=this.adapter.uploadFile({url:e,formData:t,name:s,filePath:n,fileType:r,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(newg({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(newg({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeofo&&c&&"function"==typeofc.onProgressUpdate&&c.onProgressUpdate(e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})})})}reportOSSUpload(e){constt={method:"serverless.file.resource.report",params:JSON.stringify(e)};returnthis.request(this.setupRequest(t))}uploadFile({filePath:e,cloudPath:t,fileType:s="image",onUploadProgress:n,config:r}){if(!t)thrownewg({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});consto=r&&r.envType||this.config.envType;leti,a;returnthis.getOSSUploadOptionsFromPath({env:o,filename:t}).then(t=>{constr=t.result;i=r.id,a="https://"+r.cdnDomain+"/"+r.ossPath;consto={url:"https://"+r.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:r.accessKeyId,Signature:r.signature,host:r.host,id:i,key:r.ossPath,policy:r.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:s};returnthis.uploadFileToOSS(Object.assign({},o,{onUploadProgress:n}))}).then(()=>this.reportOSSUpload({id:i})).then(t=>newPromise((s,n)=>{t.success?s({success:!0,filePath:e,fileID:a}):n(newg({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))}deleteFile({fileList:e}){constt={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};returnthis.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){returnnewPromise((t,s)=>{Array.isArray(e)&&0!==e.length||s(newg({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map(e=>({fileID:e,tempFileURL:e}))})})}}constR={init(e){constt=newq(e),s={signInAnonymously:function(){returnt.authorize()},getLoginState:function(){returnPromise.resolve(!1)}};returnt.auth=function(){returns},t.customAuth=t.auth,t}},F="undefined"!=typeoflocation&&"http:"===location.protocol?"http:":"https:",L="undefined"!=typeofprocess&&"e2e"===process.env.NODE_ENV&&"pre"===process.env.END_POINT?"//tcb-pre.tencentcloudapi.com/web":"//tcb-api.tencentcloudapi.com/web";varN;!function(e){e.local="local",e.none="none",e.session="session"}(N||(N={}));varM=function(){};constj=()=>{lete;if(!Promise){e=()=>{},e.promise={};constt=()=>{thrownewError('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};returnObject.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}constt=newPromise((t,s)=>{e=(e,n)=>e?s(e):t(n)});returne.promise=t,e};function$(e){returnvoid0===e}functionK(e){return"[object Null]"===Object.prototype.toString.call(e)}varB;functionH(e){constt=(s=e,"[object Array]"===Object.prototype.toString.call(s)?e:[e]);vars;for(consteoft){const{isMatch:t,genAdapter:s,runtime:n}=e;if(t())return{adapter:s(),runtime:n}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(B||(B={}));constW={adapter:null,runtime:void0},z=["anonymousUuidKey"];classVextendsM{constructor(){super(),W.adapter.root.tcbObject||(W.adapter.root.tcbObject={})}setItem(e,t){W.adapter.root.tcbObject[e]=t}getItem(e){returnW.adapter.root.tcbObject[e]}removeItem(e){deleteW.adapter.root.tcbObject[e]}clear(){deleteW.adapter.root.tcbObject}}functionJ(e,t){switch(e){case"local":returnt.localStorage||newV;case"none":returnnewV;default:returnt.sessionStorage||newV}}classY{constructor(e){if(!this._storage){this._persistence=W.adapter.primaryStorage||e.persistence,this._storage=J(this._persistence,W.adapter);constt="access_token_"+e.env,s="access_token_expire_"+e.env,n="refresh_token_"+e.env,r="anonymous_uuid_"+e.env,o="login_type_"+e.env,i="user_info_"+e.env;this.keys={accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:n,anonymousUuidKey:r,loginTypeKey:o,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;constt="local"===this._persistence;this._persistence=e;consts=J(e,W.adapter);for(consteinthis.keys){constn=this.keys[e];if(t&&z.includes(e))continue;constr=this._storage.getItem(n);$(r)||K(r)||(s.setItem(n,r),this._storage.removeItem(n))}this._storage=s}setStore(e,t,s){if(!this._storage)return;constn={version:s||"localCachev1",content:t},r=JSON.stringify(n);try{this._storage.setItem(e,r)}catch(e){throwe}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";consts=this._storage.getItem(e);if(!s)return"";if(s.indexOf(t)>=0){returnJSON.parse(s).content}return""}removeStore(e){this._storage.removeItem(e)}}constX={},G={};functionQ(e){returnX[e]}classZ{constructor(e,t){this.data=t||null,this.name=e}}classeeextendsZ{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}constte=newclass{constructor(){this._listeners={}}on(e,t){returnfunction(e,t,s){s[e]=s[e]||[],s[e].push(t)}(e,t,this._listeners),this}off(e,t){returnfunction(e,t,s){if(s&&s[e]){constn=s[e].indexOf(t);-1!==n&&s[e].splice(n,1)}}(e,t,this._listeners),this}fire(e,t){if(einstanceofee)returnconsole.error(e.error),this;consts="string"==typeofe?newZ(e,t||{}):e;constn=s.name;if(this._listens(n)){s.target=this;conste=this._listeners[n]?[...this._listeners[n]]:[];for(consttofe)t.call(this,s)}returnthis}_listens(e){returnthis._listeners[e]&&this._listeners[e].length>0}};functionse(e,t){te.on(e,t)}functionne(e,t={}){te.fire(e,t)}functionre(e,t){te.off(e,t)}constoe="loginStateChanged",ie="loginStateExpire",ae="loginTypeChanged",ce="anonymousConverted",ue="refreshAccessToken";varhe;!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"}(he||(he={}));constle=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],de={"X-SDK-Version":"1.3.5"};functionfe(e,t,s){constn=e[t];e[t]=function(t){constr={},o={};s.forEach(s=>{const{data:n,headers:i}=s.call(e,t);Object.assign(r,n),Object.assign(o,i)});consti=t.data;returni&&(()=>{vare;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...r};elsefor(consteinr)i.append(e,r[e])})(),t.headers={...t.headers||{},...o},n.call(e,t)}}functionpe(){conste=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...de,"x-seqid":e}}}classge{constructor(e={}){vart;this.config=e,this._reqClass=newW.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=Q(this.config.env),this._localCache=(t=this.config.env,G[t]),fe(this._reqClass,"post",[pe]),fe(this._reqClass,"upload",[pe]),fe(this._reqClass,"download",[pe])}asyncpost(e){returnawaitthis._reqClass.post(e)}asyncupload(e){returnawaitthis._reqClass.upload(e)}asyncdownload(e){returnawaitthis._reqClass.download(e)}asyncrefreshAccessToken(){lete,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=awaitthis._refreshAccessTokenPromise}catch(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throwt;returne}async_refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:s,loginTypeKey:n,anonymousUuidKey:r}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);leto=this._cache.getStore(s);if(!o)thrownewError("未登录CloudBase");consti={refresh_token:o},a=awaitthis.request("auth.fetchAccessTokenWithRefreshToken",i);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(n)===he.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){conste=this._cache.getStore(r),t=this._cache.getStore(s),n=awaitthis.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});returnthis.setRefreshToken(n.refresh_token),this._refreshAccessToken()}ne(ie),this._cache.removeStore(s)}thrownewError("刷新access token失败:"+a.data.code)}if(a.data.access_token)returnne(ue),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(s),this._cache.setStore(s,a.data.refresh_token),this._refreshAccessToken())}asyncgetAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:s}=this._cache.keys;if(!this._cache.getStore(s))thrownewError("refresh token不存在,登录状态异常");letn=this._cache.getStore(e),r=this._cache.getStore(t),o=!0;returnthis._shouldRefreshAccessTokenHook&&!awaitthis._shouldRefreshAccessTokenHook(n,r)&&(o=!1),(!n||!r||r<Date.now())&&o?this.refreshAccessToken():{accessToken:n,accessTokenExpire:r}}asyncrequest(e,t,s){constn="x-tcb-trace_"+this.config.env;letr="application/x-www-form-urlencoded";consto={action:e,env:this.config.env,dataVersion:"2019-08-16",...t};if(-1===le.indexOf(e)){const{refreshTokenKey:e}=this._cache.keys;this._cache.getStore(e)&&(o.access_token=(awaitthis.getAccessToken()).accessToken)}leti;if("storage.uploadFile"===e){i=newFormData;for(leteini)i.hasOwnProperty(e)&&void0!==i[e]&&i.append(e,o[e]);r="multipart/form-data"}else{r="application/json;charset=UTF-8",i={};for(leteino)void0!==o[e]&&(i[e]=o[e])}leta={headers:{"content-type":r}};s&&s.onUploadProgress&&(a.onUploadProgress=s.onUploadProgress);constc=this._localCache.getStore(n);c&&(a.headers["X-TCB-Trace"]=c);const{parse:u,inQuery:h,search:l}=t;letd={env:this.config.env};u&&(d.parse=!0),h&&(d={...h,...d});letf=function(e,t,s={}){constn=/\?/.test(t);letr="";for(leteins)""===r?!n&&(t+="?"):r+="&",r+=`${e}=${encodeURIComponent(s[e])}`;return/^http(s)?\:\/\//.test(t+=r)?t:`${e}${t}`}(F,L,d);l&&(f+=l);constp=awaitthis.post({url:f,data:i,...a}),g=p.header&&p.header["x-tcb-trace"];if(g&&this._localCache.setStore(n,g),200!==Number(p.status)&&200!==Number(p.statusCode)||!p.data)thrownewError("network request error");returnp}asyncsend(e,t={}){consts=awaitthis.request(e,t,{onUploadProgress:t.onUploadProgress});if("ACCESS_TOKEN_EXPIRED"===s.data.code&&-1===le.indexOf(e)){awaitthis.refreshAccessToken();consts=awaitthis.request(e,t,{onUploadProgress:t.onUploadProgress});if(s.data.code)thrownewError(`[${s.data.code}] ${s.data.message}`);returns.data}if(s.data.code)thrownewError(`[${s.data.code}] ${s.data.message}`);returns.data}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(n,e)}}constme={};functionye(e){returnme[e]}class_e{constructor(e){this.config=e,this._cache=Q(e.env),this._request=ye(e.env)}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(n,e)}setAccessToken(e,t){const{accessTokenKey:s,accessTokenExpireKey:n}=this._cache.keys;this._cache.setStore(s,e),this._cache.setStore(n,t)}asyncrefreshUserInfo(){const{data:e}=awaitthis._request.send("auth.getUserInfo",{});returnthis.setLocalUserInfo(e),e}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e)}}classwe{constructor(e){if(!e)thrownewError("envId is not defined");this._envId=e,this._cache=Q(this._envId),this._request=ye(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeofe)thrownewError("ticket must be string");returnthis._request.send("auth.linkWithTicket",{ticket:e})}linkWithRedirect(e){e.signInWithRedirect()}updatePassword(e,t){returnthis._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})}updateEmail(e){returnthis._request.send("auth.updateEmail",{newEmail:e})}updateUsername(e){if("string"!=typeofe)thrownewError("username must be a string");returnthis._request.send("auth.updateUsername",{username:e})}asyncgetLinkedUidList(){const{data:e}=awaitthis._request.send("auth.getLinkedUidList",{});lett=!1;const{users:s}=e;returns.forEach(e=>{e.wxOpenId&&e.wxPublicId&&(t=!0)}),{users:s,hasPrimaryUid:t}}setPrimaryUid(e){returnthis._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){returnthis._request.send("auth.unlink",{platform:e})}asyncupdate(e){const{nickName:t,gender:s,avatarUrl:n,province:r,country:o,city:i}=e,{data:a}=awaitthis._request.send("auth.updateUserInfo",{nickName:t,gender:s,avatarUrl:n,province:r,country:o,city:i});this.setLocalUserInfo(a)}asyncrefresh(){const{data:e}=awaitthis._request.send("auth.getUserInfo",{});returnthis.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()}}classve{constructor(e){if(!e)thrownewError("envId is not defined");this._cache=Q(e);const{refreshTokenKey:t,accessTokenKey:s,accessTokenExpireKey:n}=this._cache.keys,r=this._cache.getStore(t),o=this._cache.getStore(s),i=this._cache.getStore(n);this.credential={refreshToken:r,accessToken:o,accessTokenExpire:i},this.user=newwe(e)}getisAnonymousAuth(){returnthis.loginType===he.ANONYMOUS}getisCustomAuth(){returnthis.loginType===he.CUSTOM}getisWeixinAuth(){returnthis.loginType===he.WECHAT||this.loginType===he.WECHAT_OPEN||this.loginType===he.WECHAT_PUBLIC}getloginType(){returnthis._cache.getStore(this._cache.keys.loginTypeKey)}}classSeextends_e{asyncsignIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,s=this._cache.getStore(e)||void0,n=this._cache.getStore(t)||void0,r=awaitthis._request.send("auth.signInAnonymously",{anonymous_uuid:s,refresh_token:n});if(r.uuid&&r.refresh_token){this._setAnonymousUUID(r.uuid),this.setRefreshToken(r.refresh_token),awaitthis._request.refreshAccessToken(),ne(oe),ne(ae,{env:this.config.env,loginType:he.ANONYMOUS,persistence:"local"});conste=newve(this.config.env);returnawaite.user.refresh(),e}thrownewError("匿名登录失败")}asynclinkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:s}=this._cache.keys,n=this._cache.getStore(t),r=this._cache.getStore(s),o=awaitthis._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:n,refresh_token:r,ticket:e});if(o.refresh_token)returnthis._clearAnonymousUUID(),this.setRefreshToken(o.refresh_token),awaitthis._request.refreshAccessToken(),ne(ce,{env:this.config.env}),ne(ae,{loginType:he.CUSTOM,persistence:"local"}),{credential:{refreshToken:o.refresh_token}};thrownewError("匿名转化失败")}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(s,he.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}classkeextends_e{asyncsignIn(e){if("string"!=typeofe)thrownewError("ticket must be a string");const{refreshTokenKey:t}=this._cache.keys,s=awaitthis._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(s.refresh_token)returnthis.setRefreshToken(s.refresh_token),awaitthis._request.refreshAccessToken(),ne(oe),ne(ae,{env:this.config.env,loginType:he.CUSTOM,persistence:this.config.persistence}),awaitthis.refreshUserInfo(),newve(this.config.env);thrownewError("自定义登录失败")}}classTeextends_e{asyncsignIn(e,t){if("string"!=typeofe)thrownewError("email must be a string");const{refreshTokenKey:s}=this._cache.keys,n=awaitthis._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:r,access_token:o,access_token_expire:i}=n;if(r)returnthis.setRefreshToken(r),o&&i?this.setAccessToken(o,i):awaitthis._request.refreshAccessToken(),awaitthis.refreshUserInfo(),ne(oe),ne(ae,{env:this.config.env,loginType:he.EMAIL,persistence:this.config.persistence}),newve(this.config.env);thrown.code?newError(`邮箱登录失败: [${n.code}] ${n.message}`):newError("邮箱登录失败")}asyncactivate(e){returnthis._request.send("auth.activateEndUserMail",{token:e})}asyncresetPasswordWithToken(e,t){returnthis._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}classPeextends_e{asyncsignIn(e,t){if("string"!=typeofe)thrownewError("username must be a string");"string"!=typeoft&&(t="",console.warn("password is empty"));const{refreshTokenKey:s}=this._cache.keys,n=awaitthis._request.send("auth.signIn",{loginType:he.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:r,access_token_expire:o,access_token:i}=n;if(r)returnthis.setRefreshToken(r),i&&o?this.setAccessToken(i,o):awaitthis._request.refreshAccessToken(),awaitthis.refreshUserInfo(),ne(oe),ne(ae,{env:this.config.env,loginType:he.USERNAME,persistence:this.config.persistence}),newve(this.config.env);thrown.code?newError(`用户名密码登录失败: [${n.code}] ${n.message}`):newError("用户名密码登录失败")}}classIe{constructor(e){this.config=e,this._cache=Q(e.env),this._request=ye(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),se(ae,this._onLoginTypeChanged)}getcurrentUser(){conste=this.hasLoginState();returne&&e.user||null}getloginType(){returnthis._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){returnnewSe(this.config)}customAuthProvider(){returnnewke(this.config)}emailAuthProvider(){returnnewTe(this.config)}usernameAuthProvider(){returnnewPe(this.config)}asyncsignInAnonymously(){returnnewSe(this.config).signIn()}asyncsignInWithEmailAndPassword(e,t){returnnewTe(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){returnnewPe(this.config).signIn(e,t)}asynclinkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=newSe(this.config)),se(ce,this._onAnonymousConverted);returnawaitthis._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}asyncsignOut(){if(this.loginType===he.ANONYMOUS)thrownewError("匿名用户不支持登出操作");const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:s}=this._cache.keys,n=this._cache.getStore(e);if(!n)return;constr=awaitthis._request.send("auth.logout",{refresh_token:n});returnthis._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(s),ne(oe),ne(ae,{env:this.config.env,loginType:he.NULL,persistence:this.config.persistence}),r}asyncsignUpWithEmailAndPassword(e,t){returnthis._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}asyncsendPasswordResetEmail(e){returnthis._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){se(oe,()=>{constt=this.hasLoginState();e.call(this,t)});constt=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){se(ie,e.bind(this))}onAccessTokenRefreshed(e){se(ue,e.bind(this))}onAnonymousConverted(e){se(ce,e.bind(this))}onLoginTypeChanged(e){se(ae,()=>{constt=this.hasLoginState();e.call(this,t)})}asyncgetAccessToken(){return{accessToken:(awaitthis._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;returnthis._cache.getStore(e)?newve(this.config.env):null}asyncisUsernameRegistered(e){if("string"!=typeofe)thrownewError("username must be a string");const{data:t}=awaitthis._request.send("auth.isUsernameRegistered",{username:e});returnt&&t.isRegistered}getLoginState(){returnPromise.resolve(this.hasLoginState())}asyncsignInWithTicket(e){returnnewke(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){returnthis._request.send("auth.getUserInfo",{}).then(e=>e.code?e:{...e.data,requestId:e.seqId})}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,s=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+s}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:s,env:n}=e.data;n===this.config.env&&(this._cache.updatePersistence(s),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}constAe=function(e,t){t=t||j();consts=ye(this.config.env),{cloudPath:n,filePath:r,onUploadProgress:o,fileType:i="image"}=e;returns.send("storage.getUploadMetadata",{path:n}).then(e=>{const{data:{url:a,authorization:c,token:u,fileId:h,cosFileId:l},requestId:d}=e,f={key:n,signature:c,"x-cos-meta-fileid":l,success_action_status:"201","x-cos-security-token":u};s.upload({url:a,data:f,file:r,name:n,fileType:i,onUploadProgress:o}).then(e=>{201===e.statusCode?t(null,{fileID:h,requestId:d}):t(newError("STORAGE_REQUEST_FAIL: "+e.data))}).catch(e=>{t(e)})}).catch(e=>{t(e)}),t.promise},Ee=function(e,t){t=t||j();consts=ye(this.config.env),{cloudPath:n}=e;returns.send("storage.getUploadMetadata",{path:n}).then(e=>{t(null,e)}).catch(e=>{t(e)}),t.promise},Oe=function({fileList:e},t){if(t=t||j(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(lettofe)if(!t||"string"!=typeoft)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};consts={fileid_list:e};returnye(this.config.env).send("storage.batchDeleteFile",s).then(e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})}).catch(e=>{t(e)}),t.promise},Ue=function({fileList:e},t){t=t||j(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});lets=[];for(letnofe)"object"==typeofn?(n.hasOwnProperty("fileID")&&n.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),s.push({fileid:n.fileID,max_age:n.maxAge})):"string"==typeofn?s.push({fileid:n}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});constn={file_list:s};returnye(this.config.env).send("storage.batchGetDownloadUrl",n).then(e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})}).catch(e=>{t(e)}),t.promise},be=asyncfunction({fileID:e},t){consts=(awaitUe.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==s.code)returnt?t(s):newPromise(e=>{e(s)});constn=ye(this.config.env);letr=s.download_url;if(r=encodeURI(r),!t)returnn.download({url:r});t(awaitn.download({url:r}))},De=function({name:e,data:t,query:s,parse:n,search:r},o){consti=o||j();leta;try{a=t?JSON.stringify(t):""}catch(e){returnPromise.reject(e)}if(!e)returnPromise.reject(newError("函数名不能为空"));constc={inQuery:s,parse:n,search:r,function_name:e,request_data:a};returnye(this.config.env).send("functions.invokeFunction",c).then(e=>{if(e.code)i(null,e);else{lett=e.data.response_data;if(n)i(null,{result:t,requestId:e.requestId});elsetry{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(newError("response data must be json"))}}returni.promise}).catch(e=>{i(e)}),i.promise},Ce={timeout:15e3,persistence:"session"},xe={};classqe{constructor(e){this.config=e||this.config,this.authObj=void0}init(e){switch(W.adapter||(this.requestClient=newW.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Ce,...e},!0){casethis.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;casethis.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}returnnewqe(this.config)}auth({persistence:e}={}){if(this.authObj)returnthis.authObj;constt=e||W.adapter.primaryStorage||Ce.persistence;vars;returnt!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;X[t]=newY(e),G[t]=newY({...e,persistence:"local"})}(this.config),s=this.config,me[s.env]=newge(s),this.authObj=newIe(this.config),this.authObj}on(e,t){returnse.apply(this,[e,t])}off(e,t){returnre.apply(this,[e,t])}callFunction(e,t){returnDe.apply(this,[e,t])}deleteFile(e,t){returnOe.apply(this,[e,t])}getTempFileURL(e,t){returnUe.apply(this,[e,t])}downloadFile(e,t){returnbe.apply(this,[e,t])}uploadFile(e,t){returnAe.apply(this,[e,t])}getUploadMetadata(e,t){returnEe.apply(this,[e,t])}registerExtension(e){xe[e.name]=e}asyncinvokeExtension(e,t){consts=xe[e];if(!s)throwError(`扩展${e} 必须先注册`);returnawaits.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:s}=H(e)||{};t&&(W.adapter=t),s&&(W.runtime=s)}}constRe=newqe;functionFe(e,t,s){void0===s&&(s={});varn=/\?/.test(t),r="";for(varoins)""===r?!n&&(t+="?"):r+="&",r+=o+"="+encodeURIComponent(s[o]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}classLe{post(e){const{url:t,data:s,headers:n}=e;returnnewPromise((e,r)=>{x.request({url:Fe("https:",t),data:s,method:"POST",header:n,success(t){e(t)},fail(e){r(e)}})})}upload(e){returnnewPromise((t,s)=>{const{url:n,file:r,data:o,headers:i,fileType:a}=e,c=x.uploadFile({url:Fe("https:",n),name:"file",formData:Object.assign({},o),filePath:r,fileType:a,header:i,success(e){consts={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&o.success_action_status&&(s.statusCode=parseInt(o.success_action_status,10)),t(s)},fail(e){v&&"mp-alipay"===S&&console.warn("支付宝小程序开发工具上传腾讯云时无法准确判断是否上传成功,请使用真机测试"),s(newError(e.errMsg||"uploadFile:fail"))}});"function"==typeofe.onUploadProgress&&c&&"function"==typeofc.onProgressUpdate&&c.onProgressUpdate(t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})})})}}constNe={setItem(e,t){x.setStorageSync(e,t)},getItem:e=>x.getStorageSync(e),removeItem(e){x.removeStorageSync(e)},clear(){x.clearStorageSync()}};constMe={genAdapter:function(){return{root:{},reqClass:Le,localStorage:Ne,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Re.useAdapters(Me);constje=Re,$e=je.init;je.init=function(e){e.env=e.spaceId;constt=$e.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;consts=t.auth;returnt.auth=function(e){constt=s.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach(e=>{t[e]=p(t[e]).bind(t)}),t},t.customAuth=t.auth,t};classKeextendsq{getAccessToken(){returnnewPromise((e,t)=>{this.setAccessToken("Anonymous_Access_token"),e("Anonymous_Access_token")})}setupRequest(e,t){consts=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),n={"Content-Type":"application/json"};"auth"!==t&&(s.token=this.accessToken,n["x-basement-token"]=this.accessToken),n["x-serverless-sign"]=C.sign(s,this.config.clientSecret);constr=U(),{APPID:o,PLATFORM:i,DEVICEID:a,CLIENT_SDK_VERSION:c}=r;returnn["x-client-platform"]=i,n["x-client-appid"]=o,n["x-client-device-id"]=a,n["x-client-version"]=c,n["x-client-token"]=x.getStorageSync("uni_id_token"),{url:this.config.requestUrl,method:"POST",data:s,dataType:"json",header:JSON.parse(JSON.stringify(n))}}uploadFileToOSS({url:e,formData:t,name:s,filePath:n,fileType:r,onUploadProgress:o}){returnnewPromise((i,a)=>{constc=this.adapter.uploadFile({url:e,formData:t,name:s,filePath:n,fileType:r,success(e){e&&e.statusCode<400?i(e):a(newg({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(newg({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeofo&&c&&"function"==typeofc.onProgressUpdate&&c.onProgressUpdate(e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})})})}uploadFile({filePath:e,cloudPath:t,fileType:s="image",onUploadProgress:n}){if(!t)thrownewg({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});letr;returnthis.getOSSUploadOptionsFromPath({cloudPath:t}).then(t=>{const{url:o,formData:i,name:a,fileUrl:c}=t.result;r=c;constu={url:o,formData:i,name:a,filePath:e,fileType:s};returnthis.uploadFileToOSS(Object.assign({},u,{onUploadProgress:n}))}).then(()=>this.reportOSSUpload({cloudPath:t})).then(t=>newPromise((s,n)=>{t.success?s({success:!0,filePath:e,fileID:r}):n(newg({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))}}constBe={init(e){constt=newKe(e),s={signInAnonymously:function(){returnt.authorize()},getLoginState:function(){returnPromise.resolve(!1)}};returnt.auth=function(){returns},t.customAuth=t.auth,t}};letHe,We;functionze({name:e,data:t,spaceId:s,provider:n}){He||(He=U(),We={ak:I.appid,p:"android"===E?"a":"i",ut:D(),uuid:b()});constr=JSON.parse(JSON.stringify(t||{})),o=e,i=s,a={tencent:"t",aliyun:"a"}[n];{conste=Object.assign({},We,{fn:o,sid:i,pvd:a});Object.assign(r,{clientInfo:He,uniCloudClientInfo:encodeURIComponent(JSON.stringify(e))});const{deviceId:t}=uni.getSystemInfoSync();r.uniCloudDeviceId=t}if(!r.uniIdToken){conste=x.getStorageSync("uni_id_token")||x.getStorageSync("uniIdToken");e&&(r.uniIdToken=e)}returnr}functionVe({name:e,data:t}){const{localAddress:s,localPort:n}=this,r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],o=this.config.spaceId,i=`http://${s}:${n}/system/check-function`,a=`http://${s}:${n}/cloudfunctions/${e}`;returnnewPromise((t,s)=>{x.request({method:"POST",url:i,data:{name:e,platform:S,provider:r,spaceId:o},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})}).then(({data:e}={})=>{const{code:t,message:s}=e||{};return{code:0===t?0:t||"SYS_ERR",message:s||"SYS_ERR"}}).then(({code:s,message:n})=>{if(0!==s){switch(s){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(n||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{conste="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throwconsole.error(e),newError(e)}case"SWITCH_TO_CLOUD":break;default:{conste=`检测本地调试服务出现错误:${n},请检查网络环境或重启客户端再试`;throwconsole.error(e),newError(e)}}returnthis._originCallFunction({name:e,data:t})}returnnewPromise((s,n)=>{consti=ze({name:e,data:t,provider:this.config.provider,spaceId:o});x.request({method:"POST",url:a,data:{provider:r,platform:S,param:i},success:({statusCode:e,data:t}={})=>!e||e>=400?n(newg({code:t.code||"SYS_ERR",message:t.message||"request:fail"})):s({result:t}),fail(e){n(newg({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})})})}constJe=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];varYe=/[\\^$.*+?()[\]{}|]/g,Xe=RegExp(Ye.source);functionGe(e,t,s){returne.replace(newRegExp((n=t)&&Xe.test(n)?n.replace(Ye,"\\$&"):n,"g"),s);varn}functionQe({functionName:e,result:t,logPvd:s}){if(this.config.useDebugFunction&&t&&t.requestId){constn=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${s}-request]${n}[/${s}-request]`)}}functionZe(e){constt=e.callFunction,s=function(e){consts=e.name;e.data=ze({name:s,data:e.data,provider:this.config.provider,spaceId:this.config.spaceId});constn={aliyun:"aliyun",tencent:"tcb"}[this.config.provider];returnt.call(this,e).then(e=>(Qe.call(this,{functionName:s,result:e,logPvd:n}),Promise.resolve(e)),t=>(Qe.call(this,{functionName:s,result:t,logPvd:n}),t&&t.message&&(t.message=function({message:e="",extraInfo:t={},formatter:s=[]}={}){for(letn=0;n<s.length;n++){const{rule:r,content:o,mode:i}=s[n],a=e.match(r);if(!a)continue;letc=o;for(lete=1;e<a.length;e++)c=Ge(c,`{$${e}}`,a[e]);for(consteint)c=Ge(c,`{${e}}`,t[e]);switch(i){case"replace":returnc;case"append":default:returne+c}}returne}({message:`[${e.name}]: ${t.message}`,formatter:Je,extraInfo:{functionName:s}})),Promise.reject(t)))};e.callFunction=function(t){letn;returnv&&e.debugInfo&&!e.debugInfo.forceRemote&&T?(e._originCallFunction||(e._originCallFunction=s),n=Ve.call(this,t)):n=s.call(this,t),Object.defineProperty(n,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),n}}constet=Symbol("CLIENT_DB_INTERNAL");functiontt(e,t){returne.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=et,newProxy(e,{get:(e,s,n)=>function(e,t){returnObject.prototype.hasOwnProperty.call(e,t)}(e,s)||e[s]||"string"!=typeofs?e[s]:t.get(e,s,n)})}functionst(e){switch(o(e)){case"array":returne.map(e=>st(e));case"object":returne._internalType===et||Object.keys(e).forEach(t=>{e[t]=st(e[t])}),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:returne}}functionnt(){conste=x.getStorageSync("uni_id_token")||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};lets;try{s=JSON.parse((n=t[1],decodeURIComponent(atob(n).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){thrownewError("获取当前用户信息出错,详细错误信息为:"+e.message)}varn;returns.tokenExpired=1e3*s.exp,deletes.exp,deletes.iat,s}varrt=t(s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});consts="chooseAndUploadFile:fail";functionn(e,t){returne.tempFiles.forEach((e,s)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+s+e.name.substring(e.name.lastIndexOf("."))}),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map(e=>e.path)),e}functionr(e,t,{onChooseFile:s,onUploadProgress:n}){returnt.then(e=>{if(s){constt=s(e);if(void0!==t)returnPromise.resolve(t).then(t=>void0===t?e:t)}returne}).then(t=>!1===t?{errMsg:"chooseAndUploadFile:ok",tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,n){(t=Object.assign({},t)).errMsg="chooseAndUploadFile:ok";constr=t.tempFiles,o=r.length;leti=0;returnnewPromise(a=>{for(;i<s;)c();functionc(){consts=i++;if(s>=o)returnvoid(!r.find(e=>!e.url&&!e.errMsg)&&a(t));constu=r[s];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=s,e.tempFile=u,e.tempFilePath=u.path,n&&n(e)}}).then(e=>{u.url=e.fileID,s<o&&c()}).catch(e=>{u.errMsg=e.errMsg||e.message,s<o&&c()})}})}(e,t,5,n))}t.initChooseAndUploadFile=function(e){returnfunction(t={type:"all"}){return"image"===t.type?r(e,function(e){const{count:t,sizeType:r,sourceType:o=["album","camera"],extension:i}=e;returnnewPromise((e,a)=>{uni.chooseImage({count:t,sizeType:r,sourceType:o,extension:i,success(t){e(n(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",s)})}})})}(t),t):"video"===t.type?r(e,function(e){const{camera:t,compressed:r,maxDuration:o,sourceType:i,extension:a}=e;returnnewPromise((e,c)=>{uni.chooseVideo({camera:t,compressed:r,maxDuration:o,sourceType:i,extension:a,success(t){const{tempFilePath:s,duration:r,size:o,height:i,width:a}=t;e(n({errMsg:"chooseVideo:ok",tempFilePaths:[s],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:s,size:o,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:r,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})})}(t),t):r(e,function(e){const{count:t,extension:r}=e;returnnewPromise((e,o)=>{leti=uni.chooseFile;if("undefined"!=typeofwx&&"function"==typeofwx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeofi)returno({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:r,success(t){e(n(t))},fail(e){o({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})})}(t),t)}}})));constot="manual";functionit(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},collection:{type:String,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:{}}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch(()=>{vare=[];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===ot)return;lets=!1;constn=[];for(letr=2;r<e.length;r++)e[r]!==t[r]&&(n.push(e[r]),s=!0);e[0]!==t[0]&&(this.mixinDatacomPage.current=this.pageCurrent),this.mixinDatacomPage.size=this.pageSize,this.onMixinDatacomPropsChange(s,n)})},methods:{onMixinDatacomPropsChange(e,t){},mixinDatacomEasyGet({getone:e=!1,success:t,fail:s}={}){this.mixinDatacomLoading||(this.mixinDatacomLoading=!0,this.mixinDatacomErrorMessage="",this.mixinDatacomGet().then(s=>{this.mixinDatacomLoading=!1;const{data:n,count:r}=s.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=n.length<this.pageSize;consto=e?n.length?n[0]:void0:n;this.mixinDatacomResData=o,t&&t(o)}).catch(e=>{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,s&&s(e)}))},mixinDatacomGet(t={}){lets=e.database();constn=t.action||this.action;n&&(s=s.action(n));constr=t.collection||this.collection;s=s.collection(r);consto=t.where||this.where;o&&Object.keys(o).length&&(s=s.where(o));consti=t.field||this.field;i&&(s=s.field(i));consta=t.foreignKey||this.foreignKey;a&&(s=s.foreignKey(a));constc=t.groupby||this.groupby;c&&(s=s.groupBy(c));constu=t.groupField||this.groupField;u&&(s=s.groupField(u));!0===(void0!==t.distinct?t.distinct:this.distinct)&&(s=s.distinct());consth=t.orderby||this.orderby;h&&(s=s.orderBy(h));constl=void0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void0!==t.getcount?t.getcount:this.getcount,p=void0!==t.gettree?t.gettree:this.gettree,g=void0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void0!==t.startwith?t.startwith:this.startwith};returnp&&(m.getTree=y),g&&(m.getTreePath=y),s=s.skip(d*(l-1)).limit(d).get(m),s}}}}asyncfunctionat(e,t){consts=`http://${e}:${t}/system/ping`;try{conste=await(n={url:s,timeout:500},newPromise((e,t)=>{x.request({...n,success(t){e(t)},fail(e){t(e)}})}));return!(!e.data||0!==e.data.code)}catch(e){return!1}varn}letct=newclass{init(e){lett={};switch(e.provider){case"tencent":t=je.init(Object.assign(e,{useDebugFunction:!1}));break;case"aliyun":t=R.init(Object.assign(e,{useDebugFunction:!1}));break;case"private":t=Be.init(Object.assign(e,{useDebugFunction:!1}));break;default:thrownewError("未提供正确的provider参数")}consts=k;v&&s&&!s.code&&(t.debugInfo=s);letn=Promise.resolve();t.isReady=!1;constr=t.auth();t.initUniCloud=n.then(()=>r.getLoginState()).then(e=>e?Promise.resolve():r.signInAnonymously()).then(()=>{if(v&&t.debugInfo){const{address:e,servePort:s}=t.debugInfo;returnasyncfunction(e,t){lets;for(letn=0;n<e.length;n++){constr=e[n];if(awaitat(r,t)){s=r;break}}return{address:s,port:t}}(e,s)}returnPromise.resolve()}).then(({address:e,port:s}={})=>{if(!v)returnPromise.resolve();if(e)t.localAddress=e,t.localPort=s;elseif(t.debugInfo){conste=console["app-plus"===S?"error":"warn"];"remote"===t.debugInfo.initialLaunchType?(t.debugInfo.forceRemote=!0,e("当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs")):e("无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs")}}).then(()=>(function(){if(!v||"h5"!==S)return;if(uni.getStorageSync("__LAST_DCLOUD_APPID")===I.appid)return;uni.setStorageSync("__LAST_DCLOUD_APPID",I.appid),uni.removeStorageSync("uni_id_token")&&(console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),uni.removeStorageSync("uni_id_token"),uni.removeStorageSync("uni_id_token_expired"))}(),newPromise(e=>{"quickapp-native"===S?(E="android",uni.getStorage({key:"__DC_CLOUD_UUID",success(t){A=t.data?t.data:O(32),e()}})):setTimeout(()=>{E=uni.getSystemInfoSync().platform,A=uni.getStorageSync("__DC_CLOUD_UUID")||O(32),e()},0)}))).then(()=>{t.isReady=!0}),Ze(t),function(e){constt=e.uploadFile;e.uploadFile=function(e){lets;returns=this.isReady?Promise.resolve():this.initUniCloud,s.then(()=>t.call(this,e))}}(t),function(e){e.database=function(){if(this._database)returnthis._database;constt={},s={};classn{constructor(e,t,s){this.content=e,this.prevStage=t,this.actionName=s}toJSON(){lete=this;constt=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map(e=>({$method:e.$method,$param:e.$param}))}}getuseAggregate(){lete=this,t=!1;for(;e.prevStage;){e=e.prevStage;consts=e.content.$method;if("aggregate"===s||"pipeline"===s){t=!0;break}}returnt}getcount(){if(!this.useAggregate)returnfunction(){returnthis._send("count",Array.from(arguments))};conste=this;returnfunction(){returni({$method:"count",$param:st(Array.from(arguments))},e,e.actionName)}}get(){returnthis._send("get",Array.from(arguments))}add(){returnthis._send("add",Array.from(arguments))}remove(){returnthis._send("remove",Array.from(arguments))}update(){returnthis._send("update",Array.from(arguments))}end(){returnthis._send("end",Array.from(arguments))}set(){thrownewError("clientDB禁止使用set方法")}_send(n,r){consto=d(f("database","invoke")),i=this.toJSON();returni.$db.push({$method:n,$param:st(r)}),o.then(()=>e.callFunction({name:"DCloud-clientDB",data:{action:this.actionName,command:i}}).then(e=>{const{code:n,message:r,token:o,tokenExpired:i,systemInfo:c=[]}=e.result;if(c)for(lete=0;e<c.length;e++){const{level:t,message:s,detail:n}=c[e],r=console["app-plus"===S&&"warn"===t?"error":t]||console.log;leto="[System Info]"+s;n&&(o=`${o}\n详细信息:${n}`),r(o)}if(n)returnPromise.reject(newa(r,n));o&&i&&t.refreshToken&&t.refreshToken.forEach(e=>{e({token:o,tokenExpired:i})}),o&&i&&s.refreshToken&&s.refreshToken.forEach(e=>{e({token:o,tokenExpired:i})});constu=e.result.affectedDocs;return"number"==typeofu&&Object.defineProperty(e.result,"affectedDocs",{get:()=>(console.warn("affectedDocs不再推荐使用,请使用inserted/deleted/updated/data.length替代"),u)}),d(f("database","success"),e).then(()=>d(f("database","complete"),e)).then(()=>Promise.resolve(e))},e=>{constt=newa(e.message,e.code||"SYSTEM_ERROR");returns.error&&s.error.forEach(e=>{e(t)}),/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB"),d(f("database","fail"),e).then(()=>d(f("database","complete"),e)).then(()=>Promise.reject(e))}))}}constr=["db.Geo","db.command","command.aggregate"];functiono(e,t){returnr.indexOf(`${e}.${t}`)>-1}functioni(e,t,s){returntt(newn(e,t,s),{get(e,t){letn="db";returne&&e.content&&(n=e.content.$method),o(n,t)?i({$method:t},e,s):function(){returni({$method:t,$param:st(Array.from(arguments))},e,s)}}})}functionc({path:e,method:t}){returnclass{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map(e=>({$method:e})),{$method:t,$param:this.param}]}}}}constu={auth:{on:(e,s)=>{t[e]=t[e]||[],t[e].indexOf(s)>-1||t[e].push(s)},off:(e,s)=>{t[e]=t[e]||[];constn=t[e].indexOf(s);-1!==n&&t[e].splice(n,1)}},on:(e,t)=>{s[e]=s[e]||[],s[e].indexOf(t)>-1||s[e].push(t)},off:(e,t)=>{s[e]=s[e]||[];constn=s[e].indexOf(t);-1!==n&&s[e].splice(n,1)},env:tt({},{get:(e,t)=>({$env:t})}),action:e=>tt({},{get:(t,s)=>o("db",s)?i({$method:s},null,e):function(){returni({$method:s,$param:st(Array.from(arguments))},null,e)}}),Geo:tt({},{get:(e,t)=>c({path:["Geo"],method:t})}),getCloudEnv:function(e){if("string"!=typeofe||!e.trim())thrownewError("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}},getserverDate(){returnc({path:[],method:"serverDate"})},getRegExp(){returnc({path:[],method:"RegExp"})}},h=tt(u,{get:(e,t)=>o("db",t)?i({$method:t}):function(){returni({$method:t,$param:st(Array.from(arguments))})}});returnthis._database=h,h}}(t),function(e){e.getCurrentUserInfo=nt,e.chooseAndUploadFile=rt.initChooseAndUploadFile(e),Object.assign(e,{getmixinDatacom(){returnit(e)}})}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach(e=>{t[e]&&(t[e]=p(t[e],e))}),t.init=this.init,t}};(()=>{{conste=T;lett={};if(1===e.length)t=e[0],ct=ct.init(t);else{constt=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo"];lets;s=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":P?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach(e=>{ct[e]=function(){returnconsole.error(s),Promise.reject(newg({code:"SYS_ERR",message:s}))}})}Object.assign(ct,{getmixinDatacom(){returnit(ct)}}),ct.addInterceptor=h,ct.removeInterceptor=l}})();varut=ct;module.exports=ut;