From 62d67370f898c6868818b1da692c59080db874e8 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Wed, 24 Aug 2022 15:35:23 +0800 Subject: [PATCH] feat(uniCloud): uniCloud.interceptObject --- packages/uni-cloud/dist/uni-cloud.cjs.js | 2 +- packages/uni-cloud/dist/uni-cloud.es.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/uni-cloud/dist/uni-cloud.cjs.js b/packages/uni-cloud/dist/uni-cloud.cjs.js index 3e0ab2745..2c83883bf 100644 --- a/packages/uni-cloud/dist/uni-cloud.cjs.js +++ b/packages/uni-cloud/dist/uni-cloud.cjs.js @@ -1 +1 @@ -"use strict";var e=require("@dcloudio/uni-i18n");"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(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 s=n((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},o=s.lib={},r=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=o.WordArray=r.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,o=e.sigBytes;if(this.clamp(),s%4)for(var r=0;r>>2]>>>24-r%4*8&255;t[s+r>>>2]|=i<<24-(s+r)%4*8}else for(r=0;r>>2]=n[r>>>2];return this.sigBytes+=o,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=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],o=function(t){t=t;var n=987654321,s=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},r=0;r>>2]>>>24-o%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 i.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],o=0;o>>2]>>>24-o%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 i.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new i.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,o=n.sigBytes,r=this.blockSize,a=o/(4*r),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*r,u=e.min(4*c,o);if(c){for(var l=0;l>>24)|4278255360&(o<<24|o>>>8)}var r=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],g=e[t+3],p=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],S=e[t+10],T=e[t+11],v=e[t+12],A=e[t+13],P=e[t+14],I=e[t+15],O=r[0],b=r[1],C=r[2],E=r[3];O=u(O,b,C,E,i,7,a[0]),E=u(E,O,b,C,c,12,a[1]),C=u(C,E,O,b,f,17,a[2]),b=u(b,C,E,O,g,22,a[3]),O=u(O,b,C,E,p,7,a[4]),E=u(E,O,b,C,m,12,a[5]),C=u(C,E,O,b,y,17,a[6]),b=u(b,C,E,O,_,22,a[7]),O=u(O,b,C,E,w,7,a[8]),E=u(E,O,b,C,k,12,a[9]),C=u(C,E,O,b,S,17,a[10]),b=u(b,C,E,O,T,22,a[11]),O=u(O,b,C,E,v,7,a[12]),E=u(E,O,b,C,A,12,a[13]),C=u(C,E,O,b,P,17,a[14]),O=l(O,b=u(b,C,E,O,I,22,a[15]),C,E,c,5,a[16]),E=l(E,O,b,C,y,9,a[17]),C=l(C,E,O,b,T,14,a[18]),b=l(b,C,E,O,i,20,a[19]),O=l(O,b,C,E,m,5,a[20]),E=l(E,O,b,C,S,9,a[21]),C=l(C,E,O,b,I,14,a[22]),b=l(b,C,E,O,p,20,a[23]),O=l(O,b,C,E,k,5,a[24]),E=l(E,O,b,C,P,9,a[25]),C=l(C,E,O,b,g,14,a[26]),b=l(b,C,E,O,w,20,a[27]),O=l(O,b,C,E,A,5,a[28]),E=l(E,O,b,C,f,9,a[29]),C=l(C,E,O,b,_,14,a[30]),O=h(O,b=l(b,C,E,O,v,20,a[31]),C,E,m,4,a[32]),E=h(E,O,b,C,w,11,a[33]),C=h(C,E,O,b,T,16,a[34]),b=h(b,C,E,O,P,23,a[35]),O=h(O,b,C,E,c,4,a[36]),E=h(E,O,b,C,p,11,a[37]),C=h(C,E,O,b,_,16,a[38]),b=h(b,C,E,O,S,23,a[39]),O=h(O,b,C,E,A,4,a[40]),E=h(E,O,b,C,i,11,a[41]),C=h(C,E,O,b,g,16,a[42]),b=h(b,C,E,O,y,23,a[43]),O=h(O,b,C,E,k,4,a[44]),E=h(E,O,b,C,v,11,a[45]),C=h(C,E,O,b,I,16,a[46]),O=d(O,b=h(b,C,E,O,f,23,a[47]),C,E,i,6,a[48]),E=d(E,O,b,C,_,10,a[49]),C=d(C,E,O,b,P,15,a[50]),b=d(b,C,E,O,m,21,a[51]),O=d(O,b,C,E,v,6,a[52]),E=d(E,O,b,C,g,10,a[53]),C=d(C,E,O,b,S,15,a[54]),b=d(b,C,E,O,c,21,a[55]),O=d(O,b,C,E,w,6,a[56]),E=d(E,O,b,C,I,10,a[57]),C=d(C,E,O,b,y,15,a[58]),b=d(b,C,E,O,A,21,a[59]),O=d(O,b,C,E,p,6,a[60]),E=d(E,O,b,C,T,10,a[61]),C=d(C,E,O,b,f,15,a[62]),b=d(b,C,E,O,k,21,a[63]),r[0]=r[0]+O|0,r[1]=r[1]+b|0,r[2]=r[2]+C|0,r[3]=r[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var r=e.floor(s/4294967296),i=s;n[15+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[14+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,o,r,i){var a=e+(t&n|~t&s)+o+i;return(a<>>32-r)+t}function l(e,t,n,s,o,r,i){var a=e+(t&s|n&~s)+o+i;return(a<>>32-r)+t}function h(e,t,n,s,o,r,i){var a=e+(t^n^s)+o+i;return(a<>>32-r)+t}function d(e,t,n,s,o,r,i){var a=e+(n^(t|~s))+o+i;return(a<>>32-r)+t}t.MD5=r._createHelper(c),t.HmacMD5=r._createHmacHelper(c)}(Math),n.MD5)})),n((function(e,t){var n,o,r;e.exports=(o=(n=s).lib.Base,r=n.enc.Utf8,void(n.algo.HMAC=o.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,c=i.words,u=0;u{k.indexOf(n)>-1&&function(e,t,n){let s=S[e][t];s||(s=S[e][t]=[]),-1===s.indexOf(n)&&"function"==typeof n&&s.push(n)}(e,n,t[n])}))}function v(e,t){S[e]||(S[e]={}),u(t)?Object.keys(t).forEach((n=>{k.indexOf(n)>-1&&function(e,t,n){const s=S[e][t];if(!s)return;const o=s.indexOf(n);o>-1&&s.splice(o,1)}(e,n,t[n])})):delete S[e]}function A(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function P(e,t){return S[e]&&S[e][t]||[]}const I=w("_globalUniCloudListener"),O="response",b="needLogin",C="refreshToken",E="clientdb",R="cloudfunction",U="cloudobject";function x(e){return I[e]||(I[e]=[]),I[e]}function L(e,t){const n=x(e);n.includes(t)||n.push(t)}function D(e,t){const n=x(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function N(e,t){const n=x(e);for(let e=0;es?Promise.resolve():A(P(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):A(P(t,"success"),e).then((()=>A(P(t,"complete"),e))).then((()=>(o&&N(O,{type:R,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):A(P(t,"fail"),e).then((()=>A(P(t,"complete"),e))).then((()=>(N(O,{type:R,content:e}),Promise.reject(e))))));if(!(n.success||n.fail||n.complete))return a;a.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e),o&&N(O,{type:R,content:e})}),(e=>{n.fail&&n.fail(e),n.complete&&n.complete(e),o&&N(O,{type:R,content:e})}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.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)}))}}class F extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",this.errCode=this.code=e.code||"SYSTEM_ERROR",this.requestId=e.requestId}}function M(){let e,t;try{if(uni.getLaunchOptionsSync){if(uni.getLaunchOptionsSync.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=uni.getLaunchOptionsSync();e=s,t=n}}catch(e){}return{channel:e,scene:t}}let $;function j(){const e=uni.getLocale&&uni.getLocale()||"en";if($)return{...$,locale:e,LOCALE:e};const t=uni.getSystemInfoSync(),{deviceId:n,osName:s,uniPlatform:o,appId:r}=t,i=["pixelRatio","brand","model","system","language","version","platform","host","SDKVersion","swanNativeVersion","app","AppPlatform","fontSizeSetting"];for(let e=0;e{t(Object.assign(e,{complete(e){e||(e={}),h&&"web"===f&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");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)return s(new F({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const o=e.data;if(o.error)return s(new F({code:o.error.code,message:o.error.message,requestId:t}));o.result=o.data,o.requestId=t,delete o.data,n(o)}}))}))}};var B={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()},H={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:W}=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:H,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"},ja:H},"zh-Hans");var z=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(W("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=B,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return K.wrappedRequest(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"]=K.sign(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"]=K.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(new F({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){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))}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:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new F({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new F({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))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:o}){if("string"!==c(t))throw new F({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new F({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new F({code:"INVALID_PARAM",message:"cloudPath不合法"});const r=o&&o.envType||this.config.envType;let i,a;return this.getOSSUploadOptionsFromPath({env:r,filename:t}).then((t=>{const o=t.result;i=o.id,a="https://"+o.cdnDomain+"/"+o.ossPath;const r={url:"https://"+o.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:o.accessKeyId,Signature:o.signature,host:o.host,id:i,key:o.ossPath,policy:o.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},r,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:i}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:a}):s(new F({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new F({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}};var V={init(e){const t=new z(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 J="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var Y;!function(e){e.local="local",e.none="none",e.session="session"}(Y||(Y={}));var X=function(){};const G=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new F({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 Q(e){return void 0===e}function Z(e){return"[object Null]"===Object.prototype.toString.call(e)}var ee;function te(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(ee||(ee={}));const ne={adapter:null,runtime:void 0},se=["anonymousUuidKey"];class oe extends X{constructor(){super(),ne.adapter.root.tcbObject||(ne.adapter.root.tcbObject={})}setItem(e,t){ne.adapter.root.tcbObject[e]=t}getItem(e){return ne.adapter.root.tcbObject[e]}removeItem(e){delete ne.adapter.root.tcbObject[e]}clear(){delete ne.adapter.root.tcbObject}}function re(e,t){switch(e){case"local":return t.localStorage||new oe;case"none":return new oe;default:return t.sessionStorage||new oe}}class ie{constructor(e){if(!this._storage){this._persistence=ne.adapter.primaryStorage||e.persistence,this._storage=re(this._persistence,ne.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,o=`anonymous_uuid_${e.env}`,r=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:o,loginTypeKey:r,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=re(e,ne.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&se.includes(e))continue;const o=this._storage.getItem(s);Q(o)||Z(o)||(n.setItem(s,o),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},o=JSON.stringify(s);try{this._storage.setItem(e,o)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const ae={},ce={};function ue(e){return ae[e]}class le{constructor(e,t){this.data=t||null,this.name=e}}class he extends le{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const de=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}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 he)return console.error(e.error),this;const n="string"==typeof e?new le(e,t||{}):e;const 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 fe(e,t){de.on(e,t)}function ge(e,t={}){de.fire(e,t)}function pe(e,t){de.off(e,t)}const me="loginStateChanged",ye="loginStateExpire",_e="loginTypeChanged",we="anonymousConverted",ke="refreshAccessToken";var Se;!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"}(Se||(Se={}));const Te=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],ve={"X-SDK-Version":"1.3.5"};function Ae(e,t,n){const s=e[t];e[t]=function(t){const o={},r={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(o,s),Object.assign(r,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...o};else for(const e in o)i.append(e,o[e])})(),t.headers={...t.headers||{},...r},s.call(e,t)}}function Pe(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...ve,"x-seqid":e}}}class Ie{constructor(e={}){var t;this.config=e,this._reqClass=new ne.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=ue(this.config.env),this._localCache=(t=this.config.env,ce[t]),Ae(this._reqClass,"post",[Pe]),Ae(this._reqClass,"upload",[Pe]),Ae(this._reqClass,"download",[Pe])}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(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:o}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let r=this._cache.getStore(n);if(!r)throw new F({message:"未登录CloudBase"});const i={refresh_token:r},a=await this.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(s)===Se.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(o),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()}ge(ye),this._cache.removeStore(n)}throw new F({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return ge(ke),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 F({message:"refresh token不存在,登录状态异常"});let s=this._cache.getStore(e),o=this._cache.getStore(t),r=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,o)&&(r=!1),(!s||!o||o{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:o,country:r,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:o,country:r,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.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 Re{constructor(e){if(!e)throw new F({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=ue(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,o=this._cache.getStore(t),r=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:o,accessToken:r,accessTokenExpire:i},this.user=new Ee(e)}get isAnonymousAuth(){return this.loginType===Se.ANONYMOUS}get isCustomAuth(){return this.loginType===Se.CUSTOM}get isWeixinAuth(){return this.loginType===Se.WECHAT||this.loginType===Se.WECHAT_OPEN||this.loginType===Se.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class Ue extends Ce{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,o=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(o.uuid&&o.refresh_token){this._setAnonymousUUID(o.uuid),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),ge(me),ge(_e,{env:this.config.env,loginType:Se.ANONYMOUS,persistence:"local"});const e=new Re(this.config.env);return await e.user.refresh(),e}throw new F({message:"匿名登录失败"})}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),o=this._cache.getStore(n),r=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:o,ticket:e});if(r.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),ge(we,{env:this.config.env}),ge(_e,{loginType:Se.CUSTOM,persistence:"local"}),{credential:{refreshToken:r.refresh_token}};throw new F({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Se.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class xe extends Ce{async signIn(e){if("string"!=typeof e)throw new F({param:"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(),ge(me),ge(_e,{env:this.config.env,loginType:Se.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new Re(this.config.env);throw new F({message:"自定义登录失败"})}}class Le extends Ce{async signIn(e,t){if("string"!=typeof e)throw new F({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:o,access_token:r,access_token_expire:i}=s;if(o)return this.setRefreshToken(o),r&&i?this.setAccessToken(r,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),ge(me),ge(_e,{env:this.config.env,loginType:Se.EMAIL,persistence:this.config.persistence}),new Re(this.config.env);throw s.code?new F({code:s.code,message:`邮箱登录失败: ${s.message}`}):new F({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 De extends Ce{async signIn(e,t){if("string"!=typeof e)throw new F({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:Se.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:o,access_token_expire:r,access_token:i}=s;if(o)return this.setRefreshToken(o),i&&r?this.setAccessToken(i,r):await this._request.refreshAccessToken(),await this.refreshUserInfo(),ge(me),ge(_e,{env:this.config.env,loginType:Se.USERNAME,persistence:this.config.persistence}),new Re(this.config.env);throw s.code?new F({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new F({message:"用户名密码登录失败"})}}class Ne{constructor(e){this.config=e,this._cache=ue(e.env),this._request=be(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),fe(_e,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 Ue(this.config)}customAuthProvider(){return new xe(this.config)}emailAuthProvider(){return new Le(this.config)}usernameAuthProvider(){return new De(this.config)}async signInAnonymously(){return new Ue(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new Le(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new De(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new Ue(this.config)),fe(we,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Se.ANONYMOUS)throw new F({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const o=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),ge(me),ge(_e,{env:this.config.env,loginType:Se.NULL,persistence:this.config.persistence}),o}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){fe(me,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){fe(ye,e.bind(this))}onAccessTokenRefreshed(e){fe(ke,e.bind(this))}onAnonymousConverted(e){fe(we,e.bind(this))}onLoginTypeChanged(e){fe(_e,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new Re(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new F({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 xe(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 qe=function(e,t){t=t||G();const n=be(this.config.env),{cloudPath:s,filePath:o,onUploadProgress:r,fileType:i="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:l,cosFileId:h},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:o,name:s,fileType:i,onUploadProgress:r}).then((e=>{201===e.statusCode?t(null,{fileID:l,requestId:d}):t(new F({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Fe=function(e,t){t=t||G();const n=be(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},Me=function({fileList:e},t){if(t=t||G(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return be(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},$e=function({fileList:e},t){t=t||G(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return be(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},je=async function({fileID:e},t){const n=(await $e.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=be(this.config.env);let o=n.download_url;if(o=encodeURI(o),!t)return s.download({url:o});t(await s.download({url:o}))},Ke=function({name:e,data:t,query:n,parse:s,search:o},r){const i=r||G();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new F({code:"PARAM_ERROR",message:"函数名不能为空"}));const c={inQuery:n,parse:s,search:o,function_name:e,request_data:a};return be(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let t=e.data.response_data;if(s)i(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(new F({message:"response data must be json"}))}}return i.promise})).catch((e=>{i(e)})),i.promise},Be={timeout:15e3,persistence:"session"},He={};class We{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(ne.adapter||(this.requestClient=new ne.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Be,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new We(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||ne.adapter.primaryStorage||Be.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;ae[t]=new ie(e),ce[t]=new ie({...e,persistence:"local"})}(this.config),n=this.config,Oe[n.env]=new Ie(n),this.authObj=new Ne(this.config),this.authObj}on(e,t){return fe.apply(this,[e,t])}off(e,t){return pe.apply(this,[e,t])}callFunction(e,t){return Ke.apply(this,[e,t])}deleteFile(e,t){return Me.apply(this,[e,t])}getTempFileURL(e,t){return $e.apply(this,[e,t])}downloadFile(e,t){return je.apply(this,[e,t])}uploadFile(e,t){return qe.apply(this,[e,t])}getUploadMetadata(e,t){return Fe.apply(this,[e,t])}registerExtension(e){He[e.name]=e}async invokeExtension(e,t){const n=He[e];if(!n)throw new F({message:`扩展${e} 必须先注册`});return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=te(e)||{};t&&(ne.adapter=t),n&&(ne.runtime=n)}}var ze=new We;function Ve(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),o="";for(var r in n)""===o?!s&&(t+="?"):o+="&",o+=r+"="+encodeURIComponent(n[r]);return/^http(s)?:\/\//.test(t+=o)?t:""+e+t}class Je{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,o)=>{B.request({url:Ve("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){o(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:o,data:r,headers:i,fileType:a}=e,c=B.uploadFile({url:Ve("https:",s),name:"file",formData:Object.assign({},r),filePath:o,fileType:a,header:i,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 Ye={setItem(e,t){B.setStorageSync(e,t)},getItem:e=>B.getStorageSync(e),removeItem(e){B.removeStorageSync(e)},clear(){B.clearStorageSync()}};var Xe={genAdapter:function(){return{root:{},reqClass:Je,localStorage:Ye,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};ze.useAdapters(Xe);const Ge=ze,Qe=Ge.init;Ge.init=function(e){e.env=e.spaceId;const t=Qe.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=>{t[e]=q(t[e]).bind(t)})),t},t.customAuth=t.auth,t};var Ze=Ge;function et(e){return e&&et(e.__v_raw)||e}function tt(){return{token:B.getStorageSync("uni_id_token")||B.getStorageSync("uniIdToken"),tokenExpired:B.getStorageSync("uni_id_token_expired")}}function nt({token:e,tokenExpired:t}={}){e&&B.setStorageSync("uni_id_token",e),t&&B.setStorageSync("uni_id_token_expired",t)}function st(){if(!h||"web"!==f)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==y&&(uni.setStorageSync("__LAST_DCLOUD_APPID",y),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),B.removeStorageSync("uni_id_token"),B.removeStorageSync("uniIdToken"),B.removeStorageSync("uni_id_token_expired"))}var ot=class extends z{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=K.sign(n,this.config.clientSecret);const o=j();s["x-client-info"]=encodeURIComponent(JSON.stringify(o));const{token:r}=tt();return s["x-client-token"]=r,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,success(e){e&&e.statusCode<400?i(e):a(new F({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new F({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})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new F({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let o;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:r,formData:i,name:a}=t.result;o=t.result.fileUrl;const c={url:r,formData:i,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:o}):s(new F({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}};var rt={init(e){const t=new ot(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};function it({data:e}){let t;t=j();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=tt();e&&(n.uniIdToken=e)}return n}function at({name:e,data:t}){const{localAddress:n,localPort:s}=this,o={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],r=this.config.spaceId,i=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;return new Promise(((t,n)=>{B.request({method:"POST",url:i,data:{name:e,platform:f,provider:o,spaceId:r},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._originCallFunction({name:e,data:t})}return new Promise(((e,n)=>{const s=it.call(this,{data:t});B.request({method:"POST",url:a,data:{provider:o,platform:f,param:s},success:({statusCode:t,data:s}={})=>!t||t>=400?n(new F({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):e({result:s}),fail(e){n(new F({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const ct=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var ut=/[\\^$.*+?()[\]{}|]/g,lt=RegExp(ut.source);function ht(e,t,n){return e.replace(new RegExp((s=t)&<.test(s)?s.replace(ut,"\\$&"):s,"g"),n);var s}function dt({functionName:e,result:t,logPvd:n}){if(this.config.debugLog&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function ft(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=it.call(e,{data:n.data});const o={aliyun:"aliyun",tencent:"tcb",tcb:"tcb"}[this.config.provider];return t.call(this,n).then((e=>(e.errCode=0,dt.call(this,{functionName:s,result:e,logPvd:o}),Promise.resolve(e))),(e=>(dt.call(this,{functionName:s,result:e,logPvd:o}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),s}}const gt=Symbol("CLIENT_DB_INTERNAL");function pt(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=gt,e.__v_raw=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;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 mt(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 yt=["db.Geo","db.command","command.aggregate"];function _t(e,t){return yt.indexOf(`${e}.${t}`)>-1}function wt(e){switch(c(e=et(e))){case"array":return e.map((e=>wt(e)));case"object":return e._internalType===gt||Object.keys(e).forEach((t=>{e[t]=wt(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function kt(e){return e&&e.content&&e.content.$method}class St{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:wt(e.$param)})))}}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=kt(e),n=kt(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"===kt(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=kt(e),n=kt(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}get count(){if(!this.isAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return Tt({$method:"count",$param:wt(Array.from(arguments))},e,this._database)}}get remove(){if(!this.isCommand)return function(){return this._send("remove",Array.from(arguments))};const e=this;return function(){return Tt({$method:"remove",$param:wt(Array.from(arguments))},e,this._database)}}get(){return this._send("get",Array.from(arguments))}add(){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(){if(!this.isCommand)return function(){throw new Error("JQL禁止使用set方法")};const e=this;return function(){return Tt({$method:"set",$param:wt(Array.from(arguments))},e,this._database)}}_send(e,t){const n=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:wt(t)}),h){const e=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeof e.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时,未使用getTemp先过滤主表数据,在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档:https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}return this._database._callCloudFunction({action:n,command:s})}}function Tt(e,t,n){return pt(new St(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),_t(s,t)?Tt({$method:t},e,n):function(){return Tt({$method:t,$param:wt(Array.from(arguments))},e,n)}}})}function vt({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}]}}}}class At extends class{constructor({uniClient:e={}}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=w("_globalUniCloudDatabaseCallback")),this.auth=mt(this._authCallBacks),Object.assign(this,mt(this._dbCallBacks)),this.env=pt({},{get:(e,t)=>({$env:t})}),this.Geo=pt({},{get:(e,t)=>vt({path:["Geo"],method:t})}),this.serverDate=vt({path:[],method:"serverDate"}),this.RegExp=vt({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})}}{_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function o(e,t){if(n&&s)for(let n=0;nA(P("database","complete"),e))).then((()=>(o(null,e),N(O,{type:E,content:e}),Promise.reject(e))))}const c=A(P("database","invoke")),u=this._uniClient;return c.then((()=>u.callFunction({name:"DCloud-clientDB",type:a,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:r,systemInfo:a=[]}=e.result;if(a)for(let e=0;e(console.warn(s),t)})}}return function(e){return A(P("database","success"),e).then((()=>A(P("database","complete"),e))).then((()=>(o(e,null),N(O,{type:E,content:e}),Promise.resolve(e))))}(e)}),(e=>{/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB");return i(new F({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))}))}}function Pt(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const n=function(e,t={}){return pt(new e(t),{get:(e,t)=>_t("db",t)?Tt({$method:t},null,e):function(){return Tt({$method:t,$param:wt(Array.from(arguments))},null,e)}})}(At,{uniClient:e});return this._database=n,n}}var It={};const Ot="token无效,跳转登录页面",bt="token过期,跳转登录页面",Ct={TOKEN_INVALID_TOKEN_EXPIRED:bt,TOKEN_INVALID_INVALID_CLIENTID:Ot,TOKEN_INVALID:Ot,TOKEN_INVALID_WRONG_TOKEN:Ot,TOKEN_INVALID_ANONYMOUS_USER:Ot},Et={"uni-id-token-expired":bt,"uni-id-check-token-failed":Ot,"uni-id-token-not-exist":Ot,"uni-id-check-device-feature-failed":Ot};function Rt(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function Ut(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(Rt(t,e.path)):!1===e.needLogin&&s.push(Rt(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function xt(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=e.split("?")[0].replace(/^\//,"");return n.some((e=>e.pagePath===s))}const Lt=!!It.uniIdRouter;const{loginPage:Dt,routerNeedLogin:Nt,resToLogin:qt,needLoginPage:Ft,notNeedLoginPage:Mt,loginPageInTabBar:$t}=function({pages:e=[],subPackages:t=[],uniIdRouter:n={},tabBar:s={}}=It){const{loginPage:o,needLogin:r=[],resToLogin:i=!0}=n,{needLoginPage:a,notNeedLoginPage:c}=Ut(e),{needLoginPage:u,notNeedLoginPage:l}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:o=[]}=e,{needLoginPage:r,notNeedLoginPage:i}=Ut(o,s);t.push(...r),n.push(...i)})),{needLoginPage:t,notNeedLoginPage:n}}(t);return{loginPage:o,routerNeedLogin:r,resToLogin:i,needLoginPage:[...a,...u],notNeedLoginPage:[...c,...l],loginPageInTabBar:xt(o,s)}}();function jt(e){const t=function(e){const t=getCurrentPages(),n=t[t.length-1].route,s=e.charAt(0),o=e.split("?")[0];if("/"===s)return o;const r=o.replace(/^\//,"").split("/"),i=n.split("/");i.pop();for(let e=0;e-1)&&(Ft.indexOf(t)>-1||Nt.some((t=>function(e,t){return new RegExp(t).test(e)}(e,t))))}function Kt(e,t){return"/"!==e.charAt(0)&&(e="/"+e),t?e.indexOf("?")>-1?e+`&uniIdRedirectUrl=${encodeURIComponent(t)}`:e+`?uniIdRedirectUrl=${encodeURIComponent(t)}`:e}function Bt(){const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t0)return setTimeout((()=>{N(b,o)}),0),e.url="",!1;if(!Dt)return e;const t=Kt(Dt,o.uniIdRedirectUrl);if($t){if("navigateTo"===n||"redirectTo"===n)return setTimeout((()=>{uni.switchTab({url:t})})),!1}else if("switchTab"===n)return setTimeout((()=>{uni.navigateTo({url:t})})),!1;e.url=t}return e}})}}function Ht(){this.onResponse((e=>{const{type:t,content:n}=e;let s=!1;switch(t){case"cloudobject":s=function(e){const{errCode:t}=e;return t in Et}(n);break;case"clientdb":s=function(e){const{errCode:t}=e;return t in Ct}(n)}s&&function(e={}){const t=x(b),n=getCurrentPages(),s=n[n.length-1],o=s&&s.$page&&s.$page.fullPath;if(t.length>0)return N(b,Object.assign({uniIdRedirectUrl:o},e));Dt&&uni.navigateTo({url:Kt(Dt,o)})}(n)}))}function Wt(e){e.onNeedLogin=function(e){L(b,e)},e.offNeedLogin=function(e){D(b,e)},Lt&&(w("uni-cloud-status").needLoginInit||(w("uni-cloud-status").needLoginInit=!0,function t(){let n=!1;if("function"==typeof getCurrentPages){const t=getCurrentPages();t&&t[0]&&(Bt.call(e),n=!0)}n||setTimeout((()=>{t()}),30)}(),qt&&Ht.call(e)))}function zt(e){!function(e){e.onResponse=function(e){L(O,e)},e.offResponse=function(e){D(O,e)}}(e),Wt(e),function(e){e.onRefreshToken=function(e){L(C,e)},e.offRefreshToken=function(e){D(C,e)}}(e)}let Vt;const Jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Yt=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function Xt(){const e=tt().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(Vt(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}Vt="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!Yt.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,o="",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 o}:atob;var Gt=n((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function o(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 r(e,t,{onChooseFile:s,onUploadProgress:o}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,o){(t=Object.assign({},t)).errMsg=n;const r=t.tempFiles,i=r.length;let a=0;return new Promise((n=>{for(;a=i)return void(!r.find((e=>!e.url&&!e.errMsg))&&n(t));const u=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,o&&o(e)}}).then((e=>{u.url=e.fileID,s{u.errMsg=e.errMsg||e.message,s{uni.chooseImage({count:t,sizeType:n,sourceType:r,extension:i,success(t){e(o(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:n,maxDuration:r,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:r,sourceType:i,extension:a,success(t){const{tempFilePath:n,duration:s,size:r,height:i,width:a}=t;e(o({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:r,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):r(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,r)=>{let i=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return r({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(o(t))},fail(e){r({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})),Qt=t(Gt);const Zt="manual";function en(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:{}}),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===Zt)return;let n=!1;const s=[];for(let o=2;o{this.mixinDatacomLoading=!1;const{data:s,count:o}=n.result;this.getcount&&(this.mixinDatacomPage.count=o),this.mixinDatacomHasMore=s.length{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const o=t.collection||this.collection;n=Array.isArray(o)?n.collection(...o):n.collection(o);const r=t.where||this.where;r&&Object.keys(r).length&&(n=n.where(r));const i=t.field||this.field;i&&(n=n.field(i));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const l=t.orderby||this.orderby;l&&(n=n.orderBy(l));const h=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,g=void 0!==t.gettree?t.gettree:this.gettree,p=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return g&&(m.getTree=y),p&&(m.getTreePath=y),n=n.skip(d*(h-1)).limit(d).get(m),n}}}}function tn(e){return function(t,n={}){n=function(e,t={}){return e.customUI=t.customUI||e.customUI,Object.assign(e.loadingOptions,t.loadingOptions),Object.assign(e.errorOptions,t.errorOptions),e}({customUI:!1,loadingOptions:{title:"加载中...",mask:!0},errorOptions:{type:"modal",retry:!1}},n);const{customUI:s,loadingOptions:o,errorOptions:r}=n,a=!s;return new Proxy({},{get:(n,s)=>async function n(...c){let u;a&&uni.showLoading({title:o.title,mask:o.mask});try{u=await e.callFunction({name:t,type:i,data:{method:s,params:c}})}catch(e){u={result:e}}const{errCode:l,errMsg:h,newToken:d}=u.result||{};if(a&&uni.hideLoading(),d&&d.token&&d.tokenExpired&&(nt(d),N(C,{...d})),l){if(a)if("toast"===r.type)uni.showToast({title:h,icon:"none"});else{if("modal"!==r.type)throw new Error(`Invalid errorOptions.type: ${r.type}`);{const{confirm:e}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:o}={}){return new Promise(((r,i)=>{uni.showModal({title:e,content:t,showCancel:n,cancelText:s,confirmText:o,success(e){r(e)},fail(){r({confirm:!1,cancel:!0})}})}))}({title:"提示",content:h,showCancel:r.retry,cancelText:"取消",confirmText:r.retry?"重试":"确定"});if(r.retry&&e)return n(...c)}}const e=new F({code:l,message:h,requestId:u.requestId});throw e.detail=u.result,N(O,{type:U,content:e}),e}return N(O,{type:U,content:u.result}),u.result}})}}async function nn(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{B.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}function sn(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;let t=Promise.resolve();e.isReady=!1,e.isDefault=!1;const n=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>n.getLoginState())).then((e=>e?Promise.resolve():n.signInAnonymously())).then((()=>{if(!h)return Promise.resolve();if("app"===f&&"ios"===uni.getSystemInfoSync().osName){const{osName:e,osVersion:t}=uni.getSystemInfoSync();"ios"===e&&function(e){if(!e||"string"!=typeof e)return 0;const t=e.match(/^(\d+)./);return t&&t[1]?parseInt(t[1]):0}(t)>=14&&console.warn("iOS 14及以上版本连接uniCloud本地调试服务需要允许客户端查找并连接到本地网络上的设备(仅开发模式生效,发行模式会连接uniCloud云端服务)")}if(h&&e.debugInfo){const{address:t,servePort:n}=e.debugInfo;return async function(e,t){let n;for(let s=0;s{if(!h)return Promise.resolve();const s=console["app"===f?"error":"warn"];if(t)e.localAddress=t,e.localPort=n;else if(e.debugInfo){let t="";"remote"===e.debugInfo.initialLaunchType?(e.debugInfo.forceRemote=!0,t="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):t="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","web"===f&&(t+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),0===f.indexOf("mp-")&&(t+="\n- 小程序中如何使用uniCloud,请参考:https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinmp"),s(t)}})).then((()=>{st(),e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}let on=new class{init(e){let t={};const n=h&&!1;switch(e.provider){case"tcb":case"tencent":t=Ze.init(Object.assign(e,{debugLog:n}));break;case"aliyun":t=V.init(Object.assign(e,{debugLog:n}));break;case"private":t=rt.init(Object.assign(e,{debugLog:n}));break;default:throw new Error("未提供正确的provider参数")}const s=g;h&&s&&!s.code&&(t.debugInfo=s),sn(t),t.reInit=function(){sn(this)},ft(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),Pt(t),function(e){e.getCurrentUserInfo=Xt,e.chooseAndUploadFile=Qt.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return en(e)}}),e.importObject=tn(e)}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return t.reInit(),n.apply(t,Array.from(arguments))},t[e]=q(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{{const e=p;let t={};if(e&&1===e.length)t=e[0],on=on.init(t),on.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":m?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{on[e]=function(){return console.error(n),Promise.reject(new F({code:"SYS_ERR",message:n}))}}))}Object.assign(on,{get mixinDatacom(){return en(on)}}),zt(on),on.addInterceptor=T,on.removeInterceptor=v}})();var rn=on;module.exports=rn; +"use strict";var e=require("@dcloudio/uni-i18n");"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(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 s=n((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},o=s.lib={},r=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=o.WordArray=r.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,o=e.sigBytes;if(this.clamp(),s%4)for(var r=0;r>>2]>>>24-r%4*8&255;t[s+r>>>2]|=i<<24-(s+r)%4*8}else for(r=0;r>>2]=n[r>>>2];return this.sigBytes+=o,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=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],o=function(t){t=t;var n=987654321,s=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},r=0;r>>2]>>>24-o%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 i.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],o=0;o>>2]>>>24-o%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 i.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new i.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,o=n.sigBytes,r=this.blockSize,a=o/(4*r),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*r,u=e.min(4*c,o);if(c){for(var l=0;l>>24)|4278255360&(o<<24|o>>>8)}var r=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],g=e[t+3],p=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],v=e[t+10],T=e[t+11],S=e[t+12],P=e[t+13],A=e[t+14],I=e[t+15],b=r[0],O=r[1],C=r[2],E=r[3];b=u(b,O,C,E,i,7,a[0]),E=u(E,b,O,C,c,12,a[1]),C=u(C,E,b,O,f,17,a[2]),O=u(O,C,E,b,g,22,a[3]),b=u(b,O,C,E,p,7,a[4]),E=u(E,b,O,C,m,12,a[5]),C=u(C,E,b,O,y,17,a[6]),O=u(O,C,E,b,_,22,a[7]),b=u(b,O,C,E,w,7,a[8]),E=u(E,b,O,C,k,12,a[9]),C=u(C,E,b,O,v,17,a[10]),O=u(O,C,E,b,T,22,a[11]),b=u(b,O,C,E,S,7,a[12]),E=u(E,b,O,C,P,12,a[13]),C=u(C,E,b,O,A,17,a[14]),b=l(b,O=u(O,C,E,b,I,22,a[15]),C,E,c,5,a[16]),E=l(E,b,O,C,y,9,a[17]),C=l(C,E,b,O,T,14,a[18]),O=l(O,C,E,b,i,20,a[19]),b=l(b,O,C,E,m,5,a[20]),E=l(E,b,O,C,v,9,a[21]),C=l(C,E,b,O,I,14,a[22]),O=l(O,C,E,b,p,20,a[23]),b=l(b,O,C,E,k,5,a[24]),E=l(E,b,O,C,A,9,a[25]),C=l(C,E,b,O,g,14,a[26]),O=l(O,C,E,b,w,20,a[27]),b=l(b,O,C,E,P,5,a[28]),E=l(E,b,O,C,f,9,a[29]),C=l(C,E,b,O,_,14,a[30]),b=h(b,O=l(O,C,E,b,S,20,a[31]),C,E,m,4,a[32]),E=h(E,b,O,C,w,11,a[33]),C=h(C,E,b,O,T,16,a[34]),O=h(O,C,E,b,A,23,a[35]),b=h(b,O,C,E,c,4,a[36]),E=h(E,b,O,C,p,11,a[37]),C=h(C,E,b,O,_,16,a[38]),O=h(O,C,E,b,v,23,a[39]),b=h(b,O,C,E,P,4,a[40]),E=h(E,b,O,C,i,11,a[41]),C=h(C,E,b,O,g,16,a[42]),O=h(O,C,E,b,y,23,a[43]),b=h(b,O,C,E,k,4,a[44]),E=h(E,b,O,C,S,11,a[45]),C=h(C,E,b,O,I,16,a[46]),b=d(b,O=h(O,C,E,b,f,23,a[47]),C,E,i,6,a[48]),E=d(E,b,O,C,_,10,a[49]),C=d(C,E,b,O,A,15,a[50]),O=d(O,C,E,b,m,21,a[51]),b=d(b,O,C,E,S,6,a[52]),E=d(E,b,O,C,g,10,a[53]),C=d(C,E,b,O,v,15,a[54]),O=d(O,C,E,b,c,21,a[55]),b=d(b,O,C,E,w,6,a[56]),E=d(E,b,O,C,I,10,a[57]),C=d(C,E,b,O,y,15,a[58]),O=d(O,C,E,b,P,21,a[59]),b=d(b,O,C,E,p,6,a[60]),E=d(E,b,O,C,T,10,a[61]),C=d(C,E,b,O,f,15,a[62]),O=d(O,C,E,b,k,21,a[63]),r[0]=r[0]+b|0,r[1]=r[1]+O|0,r[2]=r[2]+C|0,r[3]=r[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var r=e.floor(s/4294967296),i=s;n[15+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[14+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,o,r,i){var a=e+(t&n|~t&s)+o+i;return(a<>>32-r)+t}function l(e,t,n,s,o,r,i){var a=e+(t&s|n&~s)+o+i;return(a<>>32-r)+t}function h(e,t,n,s,o,r,i){var a=e+(t^n^s)+o+i;return(a<>>32-r)+t}function d(e,t,n,s,o,r,i){var a=e+(n^(t|~s))+o+i;return(a<>>32-r)+t}t.MD5=r._createHelper(c),t.HmacMD5=r._createHmacHelper(c)}(Math),n.MD5)})),n((function(e,t){var n,o,r;e.exports=(o=(n=s).lib.Base,r=n.enc.Utf8,void(n.algo.HMAC=o.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,c=i.words,u=0;u{k.indexOf(n)>-1&&function(e,t,n){let s=v[e][t];s||(s=v[e][t]=[]),-1===s.indexOf(n)&&"function"==typeof n&&s.push(n)}(e,n,t[n])}))}function S(e,t){v[e]||(v[e]={}),u(t)?Object.keys(t).forEach((n=>{k.indexOf(n)>-1&&function(e,t,n){const s=v[e][t];if(!s)return;const o=s.indexOf(n);o>-1&&s.splice(o,1)}(e,n,t[n])})):delete v[e]}function P(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function A(e,t){return v[e]&&v[e][t]||[]}function I(e){T("callObject",e)}const b=w("_globalUniCloudListener"),O="response",C="needLogin",E="refreshToken",R="clientdb",U="cloudfunction",x="cloudobject";function L(e){return b[e]||(b[e]=[]),b[e]}function D(e,t){const n=L(e);n.includes(t)||n.push(t)}function N(e,t){const n=L(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function q(e,t){const n=L(e);for(let e=0;e{F&&e(),function t(){if("function"==typeof getCurrentPages){const t=getCurrentPages();t&&t[0]&&(F=!0,e())}F||setTimeout((()=>{t()}),30)}()}));function $(){return M}function j(e,t){return t?function(n){let s=!1;if("callFunction"===t){const e=n&&n.type||r;s=e!==r}const o="callFunction"===t&&!s;let i;i=this.isReady?Promise.resolve():this.initUniCloud,n=n||{};const a=i.then((()=>s?Promise.resolve():P(A(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):P(A(t,"success"),e).then((()=>P(A(t,"complete"),e))).then((()=>(o&&q(O,{type:U,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):P(A(t,"fail"),e).then((()=>P(A(t,"complete"),e))).then((()=>(q(O,{type:U,content:e}),Promise.reject(e))))));if(!(n.success||n.fail||n.complete))return a;a.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e),o&&q(O,{type:U,content:e})}),(e=>{n.fail&&n.fail(e),n.complete&&n.complete(e),o&&q(O,{type:U,content:e})}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.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)}))}}class K extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",this.errCode=this.code=e.code||"SYSTEM_ERROR",this.requestId=e.requestId}}function B(){let e,t;try{if(uni.getLaunchOptionsSync){if(uni.getLaunchOptionsSync.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=uni.getLaunchOptionsSync();e=s,t=n}}catch(e){}return{channel:e,scene:t}}let H;function W(){const e=uni.getLocale&&uni.getLocale()||"en";if(H)return{...H,locale:e,LOCALE:e};const t=uni.getSystemInfoSync(),{deviceId:n,osName:s,uniPlatform:o,appId:r}=t,i=["pixelRatio","brand","model","system","language","version","platform","host","SDKVersion","swanNativeVersion","app","AppPlatform","fontSizeSetting"];for(let e=0;e{t(Object.assign(e,{complete(e){e||(e={}),h&&"web"===f&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");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)return s(new K({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const o=e.data;if(o.error)return s(new K({code:o.error.code,message:o.error.message,requestId:t}));o.result=o.data,o.requestId=t,delete o.data,n(o)}}))}))}};var J={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()},V={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:Y}=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:V,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"},ja:V},"zh-Hans");var X=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(Y("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=J,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return z.wrappedRequest(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"]=z.sign(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"]=z.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(new K({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){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))}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:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new K({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new K({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))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:o}){if("string"!==c(t))throw new K({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new K({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new K({code:"INVALID_PARAM",message:"cloudPath不合法"});const r=o&&o.envType||this.config.envType;let i,a;return this.getOSSUploadOptionsFromPath({env:r,filename:t}).then((t=>{const o=t.result;i=o.id,a="https://"+o.cdnDomain+"/"+o.ossPath;const r={url:"https://"+o.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:o.accessKeyId,Signature:o.signature,host:o.host,id:i,key:o.ossPath,policy:o.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},r,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:i}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:a}):s(new K({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new K({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}};var G={init(e){const t=new X(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 Q="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var Z;!function(e){e.local="local",e.none="none",e.session="session"}(Z||(Z={}));var ee=function(){};const te=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new K({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 ne(e){return void 0===e}function se(e){return"[object Null]"===Object.prototype.toString.call(e)}var oe;function re(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(oe||(oe={}));const ie={adapter:null,runtime:void 0},ae=["anonymousUuidKey"];class ce extends ee{constructor(){super(),ie.adapter.root.tcbObject||(ie.adapter.root.tcbObject={})}setItem(e,t){ie.adapter.root.tcbObject[e]=t}getItem(e){return ie.adapter.root.tcbObject[e]}removeItem(e){delete ie.adapter.root.tcbObject[e]}clear(){delete ie.adapter.root.tcbObject}}function ue(e,t){switch(e){case"local":return t.localStorage||new ce;case"none":return new ce;default:return t.sessionStorage||new ce}}class le{constructor(e){if(!this._storage){this._persistence=ie.adapter.primaryStorage||e.persistence,this._storage=ue(this._persistence,ie.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,o=`anonymous_uuid_${e.env}`,r=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:o,loginTypeKey:r,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=ue(e,ie.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&ae.includes(e))continue;const o=this._storage.getItem(s);ne(o)||se(o)||(n.setItem(s,o),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},o=JSON.stringify(s);try{this._storage.setItem(e,o)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const he={},de={};function fe(e){return he[e]}class ge{constructor(e,t){this.data=t||null,this.name=e}}class pe extends ge{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const me=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}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 pe)return console.error(e.error),this;const n="string"==typeof e?new ge(e,t||{}):e;const 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 ye(e,t){me.on(e,t)}function _e(e,t={}){me.fire(e,t)}function we(e,t){me.off(e,t)}const ke="loginStateChanged",ve="loginStateExpire",Te="loginTypeChanged",Se="anonymousConverted",Pe="refreshAccessToken";var Ae;!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"}(Ae||(Ae={}));const Ie=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],be={"X-SDK-Version":"1.3.5"};function Oe(e,t,n){const s=e[t];e[t]=function(t){const o={},r={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(o,s),Object.assign(r,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...o};else for(const e in o)i.append(e,o[e])})(),t.headers={...t.headers||{},...r},s.call(e,t)}}function Ce(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...be,"x-seqid":e}}}class Ee{constructor(e={}){var t;this.config=e,this._reqClass=new ie.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=fe(this.config.env),this._localCache=(t=this.config.env,de[t]),Oe(this._reqClass,"post",[Ce]),Oe(this._reqClass,"upload",[Ce]),Oe(this._reqClass,"download",[Ce])}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(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:o}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let r=this._cache.getStore(n);if(!r)throw new K({message:"未登录CloudBase"});const i={refresh_token:r},a=await this.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(s)===Ae.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(o),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()}_e(ve),this._cache.removeStore(n)}throw new K({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return _e(Pe),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 K({message:"refresh token不存在,登录状态异常"});let s=this._cache.getStore(e),o=this._cache.getStore(t),r=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,o)&&(r=!1),(!s||!o||o{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:o,country:r,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:o,country:r,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.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 De{constructor(e){if(!e)throw new K({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=fe(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,o=this._cache.getStore(t),r=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:o,accessToken:r,accessTokenExpire:i},this.user=new Le(e)}get isAnonymousAuth(){return this.loginType===Ae.ANONYMOUS}get isCustomAuth(){return this.loginType===Ae.CUSTOM}get isWeixinAuth(){return this.loginType===Ae.WECHAT||this.loginType===Ae.WECHAT_OPEN||this.loginType===Ae.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class Ne extends xe{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,o=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(o.uuid&&o.refresh_token){this._setAnonymousUUID(o.uuid),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),_e(ke),_e(Te,{env:this.config.env,loginType:Ae.ANONYMOUS,persistence:"local"});const e=new De(this.config.env);return await e.user.refresh(),e}throw new K({message:"匿名登录失败"})}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),o=this._cache.getStore(n),r=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:o,ticket:e});if(r.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),_e(Se,{env:this.config.env}),_e(Te,{loginType:Ae.CUSTOM,persistence:"local"}),{credential:{refreshToken:r.refresh_token}};throw new K({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Ae.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class qe extends xe{async signIn(e){if("string"!=typeof e)throw new K({param:"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(),_e(ke),_e(Te,{env:this.config.env,loginType:Ae.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new De(this.config.env);throw new K({message:"自定义登录失败"})}}class Fe extends xe{async signIn(e,t){if("string"!=typeof e)throw new K({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:o,access_token:r,access_token_expire:i}=s;if(o)return this.setRefreshToken(o),r&&i?this.setAccessToken(r,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),_e(ke),_e(Te,{env:this.config.env,loginType:Ae.EMAIL,persistence:this.config.persistence}),new De(this.config.env);throw s.code?new K({code:s.code,message:`邮箱登录失败: ${s.message}`}):new K({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 Me extends xe{async signIn(e,t){if("string"!=typeof e)throw new K({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:Ae.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:o,access_token_expire:r,access_token:i}=s;if(o)return this.setRefreshToken(o),i&&r?this.setAccessToken(i,r):await this._request.refreshAccessToken(),await this.refreshUserInfo(),_e(ke),_e(Te,{env:this.config.env,loginType:Ae.USERNAME,persistence:this.config.persistence}),new De(this.config.env);throw s.code?new K({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new K({message:"用户名密码登录失败"})}}class $e{constructor(e){this.config=e,this._cache=fe(e.env),this._request=Ue(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),ye(Te,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 Ne(this.config)}customAuthProvider(){return new qe(this.config)}emailAuthProvider(){return new Fe(this.config)}usernameAuthProvider(){return new Me(this.config)}async signInAnonymously(){return new Ne(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new Fe(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new Me(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new Ne(this.config)),ye(Se,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Ae.ANONYMOUS)throw new K({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const o=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),_e(ke),_e(Te,{env:this.config.env,loginType:Ae.NULL,persistence:this.config.persistence}),o}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){ye(ke,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){ye(ve,e.bind(this))}onAccessTokenRefreshed(e){ye(Pe,e.bind(this))}onAnonymousConverted(e){ye(Se,e.bind(this))}onLoginTypeChanged(e){ye(Te,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new De(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new K({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 qe(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 je=function(e,t){t=t||te();const n=Ue(this.config.env),{cloudPath:s,filePath:o,onUploadProgress:r,fileType:i="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:l,cosFileId:h},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:o,name:s,fileType:i,onUploadProgress:r}).then((e=>{201===e.statusCode?t(null,{fileID:l,requestId:d}):t(new K({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Ke=function(e,t){t=t||te();const n=Ue(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},Be=function({fileList:e},t){if(t=t||te(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return Ue(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},He=function({fileList:e},t){t=t||te(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return Ue(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},We=async function({fileID:e},t){const n=(await He.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=Ue(this.config.env);let o=n.download_url;if(o=encodeURI(o),!t)return s.download({url:o});t(await s.download({url:o}))},ze=function({name:e,data:t,query:n,parse:s,search:o},r){const i=r||te();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new K({code:"PARAM_ERROR",message:"函数名不能为空"}));const c={inQuery:n,parse:s,search:o,function_name:e,request_data:a};return Ue(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let t=e.data.response_data;if(s)i(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(new K({message:"response data must be json"}))}}return i.promise})).catch((e=>{i(e)})),i.promise},Je={timeout:15e3,persistence:"session"},Ve={};class Ye{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(ie.adapter||(this.requestClient=new ie.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Je,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new Ye(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||ie.adapter.primaryStorage||Je.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;he[t]=new le(e),de[t]=new le({...e,persistence:"local"})}(this.config),n=this.config,Re[n.env]=new Ee(n),this.authObj=new $e(this.config),this.authObj}on(e,t){return ye.apply(this,[e,t])}off(e,t){return we.apply(this,[e,t])}callFunction(e,t){return ze.apply(this,[e,t])}deleteFile(e,t){return Be.apply(this,[e,t])}getTempFileURL(e,t){return He.apply(this,[e,t])}downloadFile(e,t){return We.apply(this,[e,t])}uploadFile(e,t){return je.apply(this,[e,t])}getUploadMetadata(e,t){return Ke.apply(this,[e,t])}registerExtension(e){Ve[e.name]=e}async invokeExtension(e,t){const n=Ve[e];if(!n)throw new K({message:`扩展${e} 必须先注册`});return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=re(e)||{};t&&(ie.adapter=t),n&&(ie.runtime=n)}}var Xe=new Ye;function Ge(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),o="";for(var r in n)""===o?!s&&(t+="?"):o+="&",o+=r+"="+encodeURIComponent(n[r]);return/^http(s)?:\/\//.test(t+=o)?t:""+e+t}class Qe{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,o)=>{J.request({url:Ge("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){o(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:o,data:r,headers:i,fileType:a}=e,c=J.uploadFile({url:Ge("https:",s),name:"file",formData:Object.assign({},r),filePath:o,fileType:a,header:i,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 Ze={setItem(e,t){J.setStorageSync(e,t)},getItem:e=>J.getStorageSync(e),removeItem(e){J.removeStorageSync(e)},clear(){J.clearStorageSync()}};var et={genAdapter:function(){return{root:{},reqClass:Qe,localStorage:Ze,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Xe.useAdapters(et);const tt=Xe,nt=tt.init;tt.init=function(e){e.env=e.spaceId;const t=nt.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=>{t[e]=j(t[e]).bind(t)})),t},t.customAuth=t.auth,t};var st=tt;function ot(e){return e&&ot(e.__v_raw)||e}function rt(){return{token:J.getStorageSync("uni_id_token")||J.getStorageSync("uniIdToken"),tokenExpired:J.getStorageSync("uni_id_token_expired")}}function it({token:e,tokenExpired:t}={}){e&&J.setStorageSync("uni_id_token",e),t&&J.setStorageSync("uni_id_token_expired",t)}function at(){if(!h||"web"!==f)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==y&&(uni.setStorageSync("__LAST_DCLOUD_APPID",y),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),J.removeStorageSync("uni_id_token"),J.removeStorageSync("uniIdToken"),J.removeStorageSync("uni_id_token_expired"))}var ct=class extends X{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=z.sign(n,this.config.clientSecret);const o=W();s["x-client-info"]=encodeURIComponent(JSON.stringify(o));const{token:r}=rt();return s["x-client-token"]=r,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,success(e){e&&e.statusCode<400?i(e):a(new K({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new K({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})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new K({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let o;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:r,formData:i,name:a}=t.result;o=t.result.fileUrl;const c={url:r,formData:i,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:o}):s(new K({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}};var ut={init(e){const t=new ct(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};function lt({data:e}){let t;t=W();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=rt();e&&(n.uniIdToken=e)}return n}function ht({name:e,data:t}={}){const{localAddress:n,localPort:s}=this.__dev__,o={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],r=this.config.spaceId,i=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;return new Promise(((t,n)=>{J.request({method:"POST",url:i,data:{name:e,platform:f,provider:o,spaceId:r},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._callCloudFunction({name:e,data:t})}return new Promise(((e,n)=>{const s=lt.call(this,{data:t});J.request({method:"POST",url:a,data:{provider:o,platform:f,param:s},success:({statusCode:t,data:s}={})=>!t||t>=400?n(new K({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):e({result:s}),fail(e){n(new K({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const dt=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var ft=/[\\^$.*+?()[\]{}|]/g,gt=RegExp(ft.source);function pt(e,t,n){return e.replace(new RegExp((s=t)&>.test(s)?s.replace(ft,"\\$&"):s,"g"),n);var s}function mt({functionName:e,result:t,logPvd:n}){if(this.__dev__.debugLog&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function yt(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=lt.call(e,{data:n.data});const o={aliyun:"aliyun",tencent:"tcb",tcb:"tcb"}[this.config.provider];return t.call(this,n).then((e=>(e.errCode=0,mt.call(this,{functionName:s,result:e,logPvd:o}),Promise.resolve(e))),(e=>(mt.call(this,{functionName:s,result:e,logPvd:o}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),o}}const _t=Symbol("CLIENT_DB_INTERNAL");function wt(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=_t,e.__v_raw=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;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 kt(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 vt=["db.Geo","db.command","command.aggregate"];function Tt(e,t){return vt.indexOf(`${e}.${t}`)>-1}function St(e){switch(c(e=ot(e))){case"array":return e.map((e=>St(e)));case"object":return e._internalType===_t||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:return e}}function Pt(e){return e&&e.content&&e.content.$method}class At{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:St(e.$param)})))}}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=Pt(e),n=Pt(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"===Pt(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=Pt(e),n=Pt(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}get count(){if(!this.isAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return It({$method:"count",$param:St(Array.from(arguments))},e,this._database)}}get remove(){if(!this.isCommand)return function(){return this._send("remove",Array.from(arguments))};const e=this;return function(){return It({$method:"remove",$param:St(Array.from(arguments))},e,this._database)}}get(){return this._send("get",Array.from(arguments))}add(){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(){if(!this.isCommand)return function(){throw new Error("JQL禁止使用set方法")};const e=this;return function(){return It({$method:"set",$param:St(Array.from(arguments))},e,this._database)}}_send(e,t){const n=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:St(t)}),h){const e=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeof e.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时,未使用getTemp先过滤主表数据,在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档:https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}return this._database._callCloudFunction({action:n,command:s})}}function It(e,t,n){return wt(new At(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),Tt(s,t)?It({$method:t},e,n):function(){return It({$method:t,$param:St(Array.from(arguments))},e,n)}}})}function bt({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}]}}}}class Ot extends class{constructor({uniClient:e={}}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=w("_globalUniCloudDatabaseCallback")),this.auth=kt(this._authCallBacks),Object.assign(this,kt(this._dbCallBacks)),this.env=wt({},{get:(e,t)=>({$env:t})}),this.Geo=wt({},{get:(e,t)=>bt({path:["Geo"],method:t})}),this.serverDate=bt({path:[],method:"serverDate"}),this.RegExp=bt({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})}}{_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function o(e,t){if(n&&s)for(let n=0;nP(A("database","complete"),e))).then((()=>(o(null,e),q(O,{type:R,content:e}),Promise.reject(e))))}const c=P(A("database","invoke")),u=this._uniClient;return c.then((()=>u.callFunction({name:"DCloud-clientDB",type:a,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:r,systemInfo:a=[]}=e.result;if(a)for(let e=0;e(console.warn(s),t)})}}return function(e){return P(A("database","success"),e).then((()=>P(A("database","complete"),e))).then((()=>(o(e,null),q(O,{type:R,content:e}),Promise.resolve(e))))}(e)}),(e=>{/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB");return i(new K({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))}))}}function Ct(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const n=function(e,t={}){return wt(new e(t),{get:(e,t)=>Tt("db",t)?It({$method:t},null,e):function(){return It({$method:t,$param:St(Array.from(arguments))},null,e)}})}(Ot,{uniClient:e});return this._database=n,n}}var Et={};const Rt="token无效,跳转登录页面",Ut="token过期,跳转登录页面",xt={TOKEN_INVALID_TOKEN_EXPIRED:Ut,TOKEN_INVALID_INVALID_CLIENTID:Rt,TOKEN_INVALID:Rt,TOKEN_INVALID_WRONG_TOKEN:Rt,TOKEN_INVALID_ANONYMOUS_USER:Rt},Lt={"uni-id-token-expired":Ut,"uni-id-check-token-failed":Rt,"uni-id-token-not-exist":Rt,"uni-id-check-device-feature-failed":Rt};function Dt(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function Nt(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(Dt(t,e.path)):!1===e.needLogin&&s.push(Dt(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function qt(e){return e.split("?")[0].replace(/^\//,"")}function Ft(){return function(e){let t=e&&e.$page&&e.$page.fullPath||"";return t?("/"!==t.charAt(0)&&(t="/"+t),t):t}(function(){const e=getCurrentPages();return e[e.length-1]}())}function Mt(){return qt(Ft())}function $t(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=qt(e);return n.some((e=>e.pagePath===s))}const jt=!!Et.uniIdRouter;const{loginPage:Kt,routerNeedLogin:Bt,resToLogin:Ht,needLoginPage:Wt,notNeedLoginPage:zt,loginPageInTabBar:Jt}=function({pages:e=[],subPackages:t=[],uniIdRouter:n={},tabBar:s={}}=Et){const{loginPage:o,needLogin:r=[],resToLogin:i=!0}=n,{needLoginPage:a,notNeedLoginPage:c}=Nt(e),{needLoginPage:u,notNeedLoginPage:l}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:o=[]}=e,{needLoginPage:r,notNeedLoginPage:i}=Nt(o,s);t.push(...r),n.push(...i)})),{needLoginPage:t,notNeedLoginPage:n}}(t);return{loginPage:o,routerNeedLogin:r,resToLogin:i,needLoginPage:[...a,...u],notNeedLoginPage:[...c,...l],loginPageInTabBar:$t(o,s)}}();if(Wt.indexOf(Kt)>-1)throw new Error(`Login page [${Kt}] should not be "needLogin", please check your pages.json`);function Vt(e){const t=qt(function(e){const t=Mt(),n=e.charAt(0),s=e.split("?")[0];if("/"===n)return s;const o=s.replace(/^\//,"").split("/"),r=t.split("/");r.pop();for(let e=0;e-1)&&(Wt.indexOf(t)>-1||Bt.some((t=>function(e,t){return new RegExp(t).test(e)}(e,t))))}function Yt({redirect:e}){const t=qt(e),n=qt(Kt);return Mt()!==n&&t!==n}function Xt({api:e,redirect:t}={}){if(!t||!Yt({redirect:t}))return;const n=function(e,t){return"/"!==e.charAt(0)&&(e="/"+e),t?e.indexOf("?")>-1?e+`&uniIdRedirectUrl=${encodeURIComponent(t)}`:e+`?uniIdRedirectUrl=${encodeURIComponent(t)}`:e}(Kt,t);Jt?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo"),setTimeout((()=>{uni[e]({url:n})}))}function Gt({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},n=function(){const{token:e,tokenExpired:t}=rt();let n;if(e){if(t0)return setTimeout((()=>{q(C,n)}),0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function Qt(){!function(){const e=Ft(),{abortLoginPageJump:t,autoToLoginPage:n}=Gt({url:e});t||n&&Xt({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){const{errCode:t}=e;return t in Lt}(n);break;case"clientdb":s=function(e){const{errCode:t}=e;return t in xt}(n)}s&&function(e={}){const t=L(C);$().then((()=>{const n=Ft();if(n&&Yt({redirect:n}))return t.length>0?q(C,Object.assign({uniIdRedirectUrl:n},e)):void(Kt&&Xt({api:"navigateTo",redirect:n}))}))}(n)}))}function en(e){!function(e){e.onResponse=function(e){D(O,e)},e.offResponse=function(e){N(O,e)}}(e),function(e){e.onNeedLogin=function(e){D(C,e)},e.offNeedLogin=function(e){N(C,e)},jt&&(w("uni-cloud-status").needLoginInit||(w("uni-cloud-status").needLoginInit=!0,$().then((()=>{Qt.call(e)})),Ht&&Zt.call(e)))}(e),function(e){e.onRefreshToken=function(e){D(E,e)},e.offRefreshToken=function(e){N(E,e)}}(e)}let tn;const nn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",sn=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function on(){const e=rt().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(tn(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}tn="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!sn.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,o="",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 o}:atob;var rn=n((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function o(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 r(e,t,{onChooseFile:s,onUploadProgress:o}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,o){(t=Object.assign({},t)).errMsg=n;const r=t.tempFiles,i=r.length;let a=0;return new Promise((n=>{for(;a=i)return void(!r.find((e=>!e.url&&!e.errMsg))&&n(t));const u=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,o&&o(e)}}).then((e=>{u.url=e.fileID,s{u.errMsg=e.errMsg||e.message,s{uni.chooseImage({count:t,sizeType:n,sourceType:r,extension:i,success(t){e(o(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:n,maxDuration:r,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:r,sourceType:i,extension:a,success(t){const{tempFilePath:n,duration:s,size:r,height:i,width:a}=t;e(o({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:r,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):r(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,r)=>{let i=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return r({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(o(t))},fail(e){r({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})),an=t(rn);const cn="manual";function un(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:{}}),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===cn)return;let n=!1;const s=[];for(let o=2;o{this.mixinDatacomLoading=!1;const{data:s,count:o}=n.result;this.getcount&&(this.mixinDatacomPage.count=o),this.mixinDatacomHasMore=s.length{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const o=t.collection||this.collection;n=Array.isArray(o)?n.collection(...o):n.collection(o);const r=t.where||this.where;r&&Object.keys(r).length&&(n=n.where(r));const i=t.field||this.field;i&&(n=n.field(i));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const l=t.orderby||this.orderby;l&&(n=n.orderBy(l));const h=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,g=void 0!==t.gettree?t.gettree:this.gettree,p=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return g&&(m.getTree=y),p&&(m.getTreePath=y),n=n.skip(d*(h-1)).limit(d).get(m),n}}}}function ln(e){return function(t,n={}){n=function(e,t={}){return e.customUI=t.customUI||e.customUI,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}},n);const{customUI:s,loadingOptions:o,errorOptions:r}=n,a=!s;return new Proxy({},{get:(s,c)=>function({fn:e,interceptorName:t,getCallbackArgs:n}={}){return async function(...s){const o=n?n({params:s}):{};let r,i;try{return await P(A(t,"invoke"),{...o}),r=await e(...s),await P(A(t,"success"),{...o,result:r}),r}catch(e){throw i=e,await P(A(t,"fail"),{...o,error:i}),i}finally{await P(A(t,"complete"),i?{...o,error:i}:{...o,result:r})}}}({fn:async function s(...u){let l;a&&uni.showLoading({title:o.title,mask:o.mask});const h={name:t,type:i,data:{method:c,params:u}};"object"==typeof n.secretMethods&&function(e,t){const n=t.data.method,s=e.secretMethods[n];s&&(t.secret=s)}(n,h);try{l=await e.callFunction(h)}catch(e){l={result:e}}const{errCode:d,errMsg:f,newToken:g}=l.result||{};if(a&&uni.hideLoading(),g&&g.token&&g.tokenExpired&&(it(g),q(E,{...g})),d){if(a)if("toast"===r.type)uni.showToast({title:f,icon:"none"});else{if("modal"!==r.type)throw new Error(`Invalid errorOptions.type: ${r.type}`);{const{confirm:e}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:o}={}){return new Promise(((r,i)=>{uni.showModal({title:e,content:t,showCancel:n,cancelText:s,confirmText:o,success(e){r(e)},fail(){r({confirm:!1,cancel:!0})}})}))}({title:"提示",content:f,showCancel:r.retry,cancelText:"取消",confirmText:r.retry?"重试":"确定"});if(r.retry&&e)return s(...u)}}const e=new K({code:d,message:f,requestId:l.requestId});throw e.detail=l.result,q(O,{type:x,content:e}),e}return q(O,{type:x,content:l.result}),l.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:t,methodName:c,params:e}}})})}}async function hn(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{J.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}function dn(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;let t=Promise.resolve();e.isReady=!1,e.isDefault=!1;const n=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>n.getLoginState())).then((e=>e?Promise.resolve():n.signInAnonymously())).then((()=>{if(!h)return Promise.resolve();if("app"===f){const{osName:e,osVersion:t}=uni.getSystemInfoSync();"ios"===e&&function(e){if(!e||"string"!=typeof e)return 0;const t=e.match(/^(\d+)./);return t&&t[1]?parseInt(t[1]):0}(t)>=14&&console.warn("iOS 14及以上版本连接uniCloud本地调试服务需要允许客户端查找并连接到本地网络上的设备(仅开发模式生效,发行模式会连接uniCloud云端服务)")}if(h&&e.__dev__.debugInfo){const{address:t,servePort:n}=e.__dev__.debugInfo;return async function(e,t){let n;for(let s=0;s{if(!h)return Promise.resolve();const s=console["app"===f?"error":"warn"];if(t)e.__dev__.localAddress=t,e.__dev__.localPort=n;else if(e.__dev__.debugInfo){let t="";"remote"===e.__dev__.debugInfo.initialLaunchType?(e.__dev__.debugInfo.forceRemote=!0,t="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):t="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","web"===f&&(t+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),0===f.indexOf("mp-")&&(t+="\n- 小程序中如何使用uniCloud,请参考:https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinmp"),s(t)}})).then((()=>{at(),e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}const fn={tcb:st,tencent:st,aliyun:G,private:ut};let gn=new class{init(e){let t={};const n=fn[e.provider];if(!n)throw new Error("未提供正确的provider参数");t=n.init(e),t.__dev__={},t.__dev__.debugLog=h&&!1;const s=g;h&&s&&!s.code&&(t.__dev__.debugInfo=s),dn(t),t.reInit=function(){dn(this)},yt(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),Ct(t),function(e){e.getCurrentUserInfo=on,e.chooseAndUploadFile=an.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return un(e)}}),e.importObject=ln(e)}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return t.reInit(),n.apply(t,Array.from(arguments))},t[e]=j(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{const e=p;let t={};if(e&&1===e.length)t=e[0],gn=gn.init(t),gn.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":m?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{gn[e]=function(){return console.error(n),Promise.reject(new K({code:"SYS_ERR",message:n}))}}))}Object.assign(gn,{get mixinDatacom(){return un(gn)}}),en(gn),gn.addInterceptor=T,gn.removeInterceptor=S,gn.interceptObject=I})();var pn=gn;module.exports=pn; diff --git a/packages/uni-cloud/dist/uni-cloud.es.js b/packages/uni-cloud/dist/uni-cloud.es.js index af58358ac..1ae8e11ad 100644 --- a/packages/uni-cloud/dist/uni-cloud.es.js +++ b/packages/uni-cloud/dist/uni-cloud.es.js @@ -1 +1 @@ -import{initVueI18n as e}from"@dcloudio/uni-i18n";import t from"@/pages.json";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function s(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=s((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},o=s.lib={},r=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=o.WordArray=r.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,o=e.sigBytes;if(this.clamp(),s%4)for(var r=0;r>>2]>>>24-r%4*8&255;t[s+r>>>2]|=i<<24-(s+r)%4*8}else for(r=0;r>>2]=n[r>>>2];return this.sigBytes+=o,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=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],o=function(t){t=t;var n=987654321,s=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},r=0;r>>2]>>>24-o%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 i.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],o=0;o>>2]>>>24-o%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 i.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new i.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,o=n.sigBytes,r=this.blockSize,a=o/(4*r),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*r,u=e.min(4*c,o);if(c){for(var l=0;l>>24)|4278255360&(o<<24|o>>>8)}var r=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],g=e[t+3],p=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],T=e[t+10],S=e[t+11],v=e[t+12],A=e[t+13],P=e[t+14],I=e[t+15],b=r[0],O=r[1],C=r[2],E=r[3];b=u(b,O,C,E,i,7,a[0]),E=u(E,b,O,C,c,12,a[1]),C=u(C,E,b,O,f,17,a[2]),O=u(O,C,E,b,g,22,a[3]),b=u(b,O,C,E,p,7,a[4]),E=u(E,b,O,C,m,12,a[5]),C=u(C,E,b,O,y,17,a[6]),O=u(O,C,E,b,_,22,a[7]),b=u(b,O,C,E,w,7,a[8]),E=u(E,b,O,C,k,12,a[9]),C=u(C,E,b,O,T,17,a[10]),O=u(O,C,E,b,S,22,a[11]),b=u(b,O,C,E,v,7,a[12]),E=u(E,b,O,C,A,12,a[13]),C=u(C,E,b,O,P,17,a[14]),b=l(b,O=u(O,C,E,b,I,22,a[15]),C,E,c,5,a[16]),E=l(E,b,O,C,y,9,a[17]),C=l(C,E,b,O,S,14,a[18]),O=l(O,C,E,b,i,20,a[19]),b=l(b,O,C,E,m,5,a[20]),E=l(E,b,O,C,T,9,a[21]),C=l(C,E,b,O,I,14,a[22]),O=l(O,C,E,b,p,20,a[23]),b=l(b,O,C,E,k,5,a[24]),E=l(E,b,O,C,P,9,a[25]),C=l(C,E,b,O,g,14,a[26]),O=l(O,C,E,b,w,20,a[27]),b=l(b,O,C,E,A,5,a[28]),E=l(E,b,O,C,f,9,a[29]),C=l(C,E,b,O,_,14,a[30]),b=h(b,O=l(O,C,E,b,v,20,a[31]),C,E,m,4,a[32]),E=h(E,b,O,C,w,11,a[33]),C=h(C,E,b,O,S,16,a[34]),O=h(O,C,E,b,P,23,a[35]),b=h(b,O,C,E,c,4,a[36]),E=h(E,b,O,C,p,11,a[37]),C=h(C,E,b,O,_,16,a[38]),O=h(O,C,E,b,T,23,a[39]),b=h(b,O,C,E,A,4,a[40]),E=h(E,b,O,C,i,11,a[41]),C=h(C,E,b,O,g,16,a[42]),O=h(O,C,E,b,y,23,a[43]),b=h(b,O,C,E,k,4,a[44]),E=h(E,b,O,C,v,11,a[45]),C=h(C,E,b,O,I,16,a[46]),b=d(b,O=h(O,C,E,b,f,23,a[47]),C,E,i,6,a[48]),E=d(E,b,O,C,_,10,a[49]),C=d(C,E,b,O,P,15,a[50]),O=d(O,C,E,b,m,21,a[51]),b=d(b,O,C,E,v,6,a[52]),E=d(E,b,O,C,g,10,a[53]),C=d(C,E,b,O,T,15,a[54]),O=d(O,C,E,b,c,21,a[55]),b=d(b,O,C,E,w,6,a[56]),E=d(E,b,O,C,I,10,a[57]),C=d(C,E,b,O,y,15,a[58]),O=d(O,C,E,b,A,21,a[59]),b=d(b,O,C,E,p,6,a[60]),E=d(E,b,O,C,S,10,a[61]),C=d(C,E,b,O,f,15,a[62]),O=d(O,C,E,b,k,21,a[63]),r[0]=r[0]+b|0,r[1]=r[1]+O|0,r[2]=r[2]+C|0,r[3]=r[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var r=e.floor(s/4294967296),i=s;n[15+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[14+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,o,r,i){var a=e+(t&n|~t&s)+o+i;return(a<>>32-r)+t}function l(e,t,n,s,o,r,i){var a=e+(t&s|n&~s)+o+i;return(a<>>32-r)+t}function h(e,t,n,s,o,r,i){var a=e+(t^n^s)+o+i;return(a<>>32-r)+t}function d(e,t,n,s,o,r,i){var a=e+(n^(t|~s))+o+i;return(a<>>32-r)+t}t.MD5=r._createHelper(c),t.HmacMD5=r._createHmacHelper(c)}(Math),n.MD5)})),s((function(e,t){var n,s,r;e.exports=(s=(n=o).lib.Base,r=n.enc.Utf8,void(n.algo.HMAC=s.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,c=i.words,u=0;u{T.indexOf(n)>-1&&function(e,t,n){let s=S[e][t];s||(s=S[e][t]=[]),-1===s.indexOf(n)&&"function"==typeof n&&s.push(n)}(e,n,t[n])}))}function A(e,t){S[e]||(S[e]={}),l(t)?Object.keys(t).forEach((n=>{T.indexOf(n)>-1&&function(e,t,n){const s=S[e][t];if(!s)return;const o=s.indexOf(n);o>-1&&s.splice(o,1)}(e,n,t[n])})):delete S[e]}function P(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function I(e,t){return S[e]&&S[e][t]||[]}const b=k("_globalUniCloudListener"),O="response",C="needLogin",E="refreshToken",R="clientdb",U="cloudfunction",x="cloudobject";function L(e){return b[e]||(b[e]=[]),b[e]}function D(e,t){const n=L(e);n.includes(t)||n.push(t)}function N(e,t){const n=L(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function q(e,t){const n=L(e);for(let e=0;es?Promise.resolve():P(I(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):P(I(t,"success"),e).then((()=>P(I(t,"complete"),e))).then((()=>(o&&q(O,{type:U,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):P(I(t,"fail"),e).then((()=>P(I(t,"complete"),e))).then((()=>(q(O,{type:U,content:e}),Promise.reject(e))))));if(!(n.success||n.fail||n.complete))return a;a.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e),o&&q(O,{type:U,content:e})}),(e=>{n.fail&&n.fail(e),n.complete&&n.complete(e),o&&q(O,{type:U,content:e})}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.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)}))}}class M extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",this.errCode=this.code=e.code||"SYSTEM_ERROR",this.requestId=e.requestId}}function $(){let e,t;try{if(uni.getLaunchOptionsSync){if(uni.getLaunchOptionsSync.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=uni.getLaunchOptionsSync();e=s,t=n}}catch(e){}return{channel:e,scene:t}}let j;function K(){const e=uni.getLocale&&uni.getLocale()||"en";if(j)return{...j,locale:e,LOCALE:e};const t=uni.getSystemInfoSync(),{deviceId:n,osName:s,uniPlatform:o,appId:r}=t,i=["pixelRatio","brand","model","system","language","version","platform","host","SDKVersion","swanNativeVersion","app","AppPlatform","fontSizeSetting"];for(let e=0;e{t(Object.assign(e,{complete(e){e||(e={}),d&&"web"===g&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");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)return s(new M({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const o=e.data;if(o.error)return s(new M({code:o.error.code,message:o.error.message,requestId:t}));o.result=o.data,o.requestId=t,delete o.data,n(o)}}))}))}};var H={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()},W={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:z}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:W,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"},ja:W},"zh-Hans");var V=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(z("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=H,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return B.wrappedRequest(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"]=B.sign(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"]=B.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(new M({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){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))}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:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new M({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new M({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))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:o}){if("string"!==u(t))throw new M({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new M({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new M({code:"INVALID_PARAM",message:"cloudPath不合法"});const r=o&&o.envType||this.config.envType;let i,a;return this.getOSSUploadOptionsFromPath({env:r,filename:t}).then((t=>{const o=t.result;i=o.id,a="https://"+o.cdnDomain+"/"+o.ossPath;const r={url:"https://"+o.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:o.accessKeyId,Signature:o.signature,host:o.host,id:i,key:o.ossPath,policy:o.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},r,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:i}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:a}):s(new M({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new M({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}};var J={init(e){const t=new V(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 Y="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var X;!function(e){e.local="local",e.none="none",e.session="session"}(X||(X={}));var G=function(){};const Q=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new M({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 Z(e){return void 0===e}function ee(e){return"[object Null]"===Object.prototype.toString.call(e)}var te;function ne(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(te||(te={}));const se={adapter:null,runtime:void 0},oe=["anonymousUuidKey"];class re extends G{constructor(){super(),se.adapter.root.tcbObject||(se.adapter.root.tcbObject={})}setItem(e,t){se.adapter.root.tcbObject[e]=t}getItem(e){return se.adapter.root.tcbObject[e]}removeItem(e){delete se.adapter.root.tcbObject[e]}clear(){delete se.adapter.root.tcbObject}}function ie(e,t){switch(e){case"local":return t.localStorage||new re;case"none":return new re;default:return t.sessionStorage||new re}}class ae{constructor(e){if(!this._storage){this._persistence=se.adapter.primaryStorage||e.persistence,this._storage=ie(this._persistence,se.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,o=`anonymous_uuid_${e.env}`,r=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:o,loginTypeKey:r,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=ie(e,se.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&oe.includes(e))continue;const o=this._storage.getItem(s);Z(o)||ee(o)||(n.setItem(s,o),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},o=JSON.stringify(s);try{this._storage.setItem(e,o)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const ce={},ue={};function le(e){return ce[e]}class he{constructor(e,t){this.data=t||null,this.name=e}}class de extends he{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const fe=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}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 de)return console.error(e.error),this;const n="string"==typeof e?new he(e,t||{}):e;const 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 ge(e,t){fe.on(e,t)}function pe(e,t={}){fe.fire(e,t)}function me(e,t){fe.off(e,t)}const ye="loginStateChanged",_e="loginStateExpire",we="loginTypeChanged",ke="anonymousConverted",Te="refreshAccessToken";var Se;!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"}(Se||(Se={}));const ve=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],Ae={"X-SDK-Version":"1.3.5"};function Pe(e,t,n){const s=e[t];e[t]=function(t){const o={},r={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(o,s),Object.assign(r,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...o};else for(const e in o)i.append(e,o[e])})(),t.headers={...t.headers||{},...r},s.call(e,t)}}function Ie(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...Ae,"x-seqid":e}}}class be{constructor(e={}){var t;this.config=e,this._reqClass=new se.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=le(this.config.env),this._localCache=(t=this.config.env,ue[t]),Pe(this._reqClass,"post",[Ie]),Pe(this._reqClass,"upload",[Ie]),Pe(this._reqClass,"download",[Ie])}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(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:o}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let r=this._cache.getStore(n);if(!r)throw new M({message:"未登录CloudBase"});const i={refresh_token:r},a=await this.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(s)===Se.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(o),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()}pe(_e),this._cache.removeStore(n)}throw new M({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return pe(Te),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 M({message:"refresh token不存在,登录状态异常"});let s=this._cache.getStore(e),o=this._cache.getStore(t),r=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,o)&&(r=!1),(!s||!o||o{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:o,country:r,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:o,country:r,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.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 Ue{constructor(e){if(!e)throw new M({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=le(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,o=this._cache.getStore(t),r=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:o,accessToken:r,accessTokenExpire:i},this.user=new Re(e)}get isAnonymousAuth(){return this.loginType===Se.ANONYMOUS}get isCustomAuth(){return this.loginType===Se.CUSTOM}get isWeixinAuth(){return this.loginType===Se.WECHAT||this.loginType===Se.WECHAT_OPEN||this.loginType===Se.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class xe extends Ee{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,o=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(o.uuid&&o.refresh_token){this._setAnonymousUUID(o.uuid),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),pe(ye),pe(we,{env:this.config.env,loginType:Se.ANONYMOUS,persistence:"local"});const e=new Ue(this.config.env);return await e.user.refresh(),e}throw new M({message:"匿名登录失败"})}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),o=this._cache.getStore(n),r=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:o,ticket:e});if(r.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),pe(ke,{env:this.config.env}),pe(we,{loginType:Se.CUSTOM,persistence:"local"}),{credential:{refreshToken:r.refresh_token}};throw new M({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Se.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Le extends Ee{async signIn(e){if("string"!=typeof e)throw new M({param:"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(),pe(ye),pe(we,{env:this.config.env,loginType:Se.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new Ue(this.config.env);throw new M({message:"自定义登录失败"})}}class De extends Ee{async signIn(e,t){if("string"!=typeof e)throw new M({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:o,access_token:r,access_token_expire:i}=s;if(o)return this.setRefreshToken(o),r&&i?this.setAccessToken(r,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),pe(ye),pe(we,{env:this.config.env,loginType:Se.EMAIL,persistence:this.config.persistence}),new Ue(this.config.env);throw s.code?new M({code:s.code,message:`邮箱登录失败: ${s.message}`}):new M({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 Ne extends Ee{async signIn(e,t){if("string"!=typeof e)throw new M({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:Se.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:o,access_token_expire:r,access_token:i}=s;if(o)return this.setRefreshToken(o),i&&r?this.setAccessToken(i,r):await this._request.refreshAccessToken(),await this.refreshUserInfo(),pe(ye),pe(we,{env:this.config.env,loginType:Se.USERNAME,persistence:this.config.persistence}),new Ue(this.config.env);throw s.code?new M({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new M({message:"用户名密码登录失败"})}}class qe{constructor(e){this.config=e,this._cache=le(e.env),this._request=Ce(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),ge(we,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 xe(this.config)}customAuthProvider(){return new Le(this.config)}emailAuthProvider(){return new De(this.config)}usernameAuthProvider(){return new Ne(this.config)}async signInAnonymously(){return new xe(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new De(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new Ne(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new xe(this.config)),ge(ke,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Se.ANONYMOUS)throw new M({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const o=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),pe(ye),pe(we,{env:this.config.env,loginType:Se.NULL,persistence:this.config.persistence}),o}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){ge(ye,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){ge(_e,e.bind(this))}onAccessTokenRefreshed(e){ge(Te,e.bind(this))}onAnonymousConverted(e){ge(ke,e.bind(this))}onLoginTypeChanged(e){ge(we,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new Ue(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new M({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 Le(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 Fe=function(e,t){t=t||Q();const n=Ce(this.config.env),{cloudPath:s,filePath:o,onUploadProgress:r,fileType:i="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:l,cosFileId:h},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:o,name:s,fileType:i,onUploadProgress:r}).then((e=>{201===e.statusCode?t(null,{fileID:l,requestId:d}):t(new M({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Me=function(e,t){t=t||Q();const n=Ce(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},$e=function({fileList:e},t){if(t=t||Q(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return Ce(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},je=function({fileList:e},t){t=t||Q(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return Ce(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},Ke=async function({fileID:e},t){const n=(await je.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=Ce(this.config.env);let o=n.download_url;if(o=encodeURI(o),!t)return s.download({url:o});t(await s.download({url:o}))},Be=function({name:e,data:t,query:n,parse:s,search:o},r){const i=r||Q();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new M({code:"PARAM_ERROR",message:"函数名不能为空"}));const c={inQuery:n,parse:s,search:o,function_name:e,request_data:a};return Ce(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let t=e.data.response_data;if(s)i(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(new M({message:"response data must be json"}))}}return i.promise})).catch((e=>{i(e)})),i.promise},He={timeout:15e3,persistence:"session"},We={};class ze{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(se.adapter||(this.requestClient=new se.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...He,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new ze(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||se.adapter.primaryStorage||He.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;ce[t]=new ae(e),ue[t]=new ae({...e,persistence:"local"})}(this.config),n=this.config,Oe[n.env]=new be(n),this.authObj=new qe(this.config),this.authObj}on(e,t){return ge.apply(this,[e,t])}off(e,t){return me.apply(this,[e,t])}callFunction(e,t){return Be.apply(this,[e,t])}deleteFile(e,t){return $e.apply(this,[e,t])}getTempFileURL(e,t){return je.apply(this,[e,t])}downloadFile(e,t){return Ke.apply(this,[e,t])}uploadFile(e,t){return Fe.apply(this,[e,t])}getUploadMetadata(e,t){return Me.apply(this,[e,t])}registerExtension(e){We[e.name]=e}async invokeExtension(e,t){const n=We[e];if(!n)throw new M({message:`扩展${e} 必须先注册`});return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=ne(e)||{};t&&(se.adapter=t),n&&(se.runtime=n)}}var Ve=new ze;function Je(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),o="";for(var r in n)""===o?!s&&(t+="?"):o+="&",o+=r+"="+encodeURIComponent(n[r]);return/^http(s)?:\/\//.test(t+=o)?t:""+e+t}class Ye{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,o)=>{H.request({url:Je("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){o(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:o,data:r,headers:i,fileType:a}=e,c=H.uploadFile({url:Je("https:",s),name:"file",formData:Object.assign({},r),filePath:o,fileType:a,header:i,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 Xe={setItem(e,t){H.setStorageSync(e,t)},getItem:e=>H.getStorageSync(e),removeItem(e){H.removeStorageSync(e)},clear(){H.clearStorageSync()}};var Ge={genAdapter:function(){return{root:{},reqClass:Ye,localStorage:Xe,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Ve.useAdapters(Ge);const Qe=Ve,Ze=Qe.init;Qe.init=function(e){e.env=e.spaceId;const t=Ze.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=>{t[e]=F(t[e]).bind(t)})),t},t.customAuth=t.auth,t};var et=Qe;function tt(e){return e&&tt(e.__v_raw)||e}function nt(){return{token:H.getStorageSync("uni_id_token")||H.getStorageSync("uniIdToken"),tokenExpired:H.getStorageSync("uni_id_token_expired")}}function st({token:e,tokenExpired:t}={}){e&&H.setStorageSync("uni_id_token",e),t&&H.setStorageSync("uni_id_token_expired",t)}function ot(){if(!d||"web"!==g)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==_&&(uni.setStorageSync("__LAST_DCLOUD_APPID",_),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),H.removeStorageSync("uni_id_token"),H.removeStorageSync("uniIdToken"),H.removeStorageSync("uni_id_token_expired"))}var rt=class extends V{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=B.sign(n,this.config.clientSecret);const o=K();s["x-client-info"]=encodeURIComponent(JSON.stringify(o));const{token:r}=nt();return s["x-client-token"]=r,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,success(e){e&&e.statusCode<400?i(e):a(new M({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new M({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})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new M({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let o;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:r,formData:i,name:a}=t.result;o=t.result.fileUrl;const c={url:r,formData:i,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:o}):s(new M({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}};var it={init(e){const t=new rt(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};function at({data:e}){let t;t=K();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=nt();e&&(n.uniIdToken=e)}return n}function ct({name:e,data:t}){const{localAddress:n,localPort:s}=this,o={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],r=this.config.spaceId,i=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;return new Promise(((t,n)=>{H.request({method:"POST",url:i,data:{name:e,platform:g,provider:o,spaceId:r},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._originCallFunction({name:e,data:t})}return new Promise(((e,n)=>{const s=at.call(this,{data:t});H.request({method:"POST",url:a,data:{provider:o,platform:g,param:s},success:({statusCode:t,data:s}={})=>!t||t>=400?n(new M({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):e({result:s}),fail(e){n(new M({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const ut=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var lt=/[\\^$.*+?()[\]{}|]/g,ht=RegExp(lt.source);function dt(e,t,n){return e.replace(new RegExp((s=t)&&ht.test(s)?s.replace(lt,"\\$&"):s,"g"),n);var s}function ft({functionName:e,result:t,logPvd:n}){if(this.config.debugLog&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function gt(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=at.call(e,{data:n.data});const o={aliyun:"aliyun",tencent:"tcb",tcb:"tcb"}[this.config.provider];return t.call(this,n).then((e=>(e.errCode=0,ft.call(this,{functionName:s,result:e,logPvd:o}),Promise.resolve(e))),(e=>(ft.call(this,{functionName:s,result:e,logPvd:o}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),s}}const pt=Symbol("CLIENT_DB_INTERNAL");function mt(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=pt,e.__v_raw=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;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 yt(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 _t=["db.Geo","db.command","command.aggregate"];function wt(e,t){return _t.indexOf(`${e}.${t}`)>-1}function kt(e){switch(u(e=tt(e))){case"array":return e.map((e=>kt(e)));case"object":return e._internalType===pt||Object.keys(e).forEach((t=>{e[t]=kt(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function Tt(e){return e&&e.content&&e.content.$method}class St{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:kt(e.$param)})))}}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=Tt(e),n=Tt(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"===Tt(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=Tt(e),n=Tt(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}get count(){if(!this.isAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return vt({$method:"count",$param:kt(Array.from(arguments))},e,this._database)}}get remove(){if(!this.isCommand)return function(){return this._send("remove",Array.from(arguments))};const e=this;return function(){return vt({$method:"remove",$param:kt(Array.from(arguments))},e,this._database)}}get(){return this._send("get",Array.from(arguments))}add(){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(){if(!this.isCommand)return function(){throw new Error("JQL禁止使用set方法")};const e=this;return function(){return vt({$method:"set",$param:kt(Array.from(arguments))},e,this._database)}}_send(e,t){const n=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:kt(t)}),d){const e=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeof e.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时,未使用getTemp先过滤主表数据,在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档:https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}return this._database._callCloudFunction({action:n,command:s})}}function vt(e,t,n){return mt(new St(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),wt(s,t)?vt({$method:t},e,n):function(){return vt({$method:t,$param:kt(Array.from(arguments))},e,n)}}})}function At({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}]}}}}class Pt extends class{constructor({uniClient:e={}}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=k("_globalUniCloudDatabaseCallback")),this.auth=yt(this._authCallBacks),Object.assign(this,yt(this._dbCallBacks)),this.env=mt({},{get:(e,t)=>({$env:t})}),this.Geo=mt({},{get:(e,t)=>At({path:["Geo"],method:t})}),this.serverDate=At({path:[],method:"serverDate"}),this.RegExp=At({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})}}{_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function o(e,t){if(n&&s)for(let n=0;nP(I("database","complete"),e))).then((()=>(o(null,e),q(O,{type:R,content:e}),Promise.reject(e))))}const a=P(I("database","invoke")),u=this._uniClient;return a.then((()=>u.callFunction({name:"DCloud-clientDB",type:c,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:r,systemInfo:a=[]}=e.result;if(a)for(let e=0;e(console.warn(s),t)})}}return function(e){return P(I("database","success"),e).then((()=>P(I("database","complete"),e))).then((()=>(o(e,null),q(O,{type:R,content:e}),Promise.resolve(e))))}(e)}),(e=>{/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB");return i(new M({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))}))}}function It(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const n=function(e,t={}){return mt(new e(t),{get:(e,t)=>wt("db",t)?vt({$method:t},null,e):function(){return vt({$method:t,$param:kt(Array.from(arguments))},null,e)}})}(Pt,{uniClient:e});return this._database=n,n}}const bt="token无效,跳转登录页面",Ot="token过期,跳转登录页面",Ct={TOKEN_INVALID_TOKEN_EXPIRED:Ot,TOKEN_INVALID_INVALID_CLIENTID:bt,TOKEN_INVALID:bt,TOKEN_INVALID_WRONG_TOKEN:bt,TOKEN_INVALID_ANONYMOUS_USER:bt},Et={"uni-id-token-expired":Ot,"uni-id-check-token-failed":bt,"uni-id-token-not-exist":bt,"uni-id-check-device-feature-failed":bt};function Rt(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function Ut(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(Rt(t,e.path)):!1===e.needLogin&&s.push(Rt(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function xt(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=e.split("?")[0].replace(/^\//,"");return n.some((e=>e.pagePath===s))}const Lt=!!t.uniIdRouter;const{loginPage:Dt,routerNeedLogin:Nt,resToLogin:qt,needLoginPage:Ft,notNeedLoginPage:Mt,loginPageInTabBar:$t}=function({pages:e=[],subPackages:n=[],uniIdRouter:s={},tabBar:o={}}=t){const{loginPage:r,needLogin:i=[],resToLogin:a=!0}=s,{needLoginPage:c,notNeedLoginPage:u}=Ut(e),{needLoginPage:l,notNeedLoginPage:h}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:o=[]}=e,{needLoginPage:r,notNeedLoginPage:i}=Ut(o,s);t.push(...r),n.push(...i)})),{needLoginPage:t,notNeedLoginPage:n}}(n);return{loginPage:r,routerNeedLogin:i,resToLogin:a,needLoginPage:[...c,...l],notNeedLoginPage:[...u,...h],loginPageInTabBar:xt(r,o)}}();function jt(e){const t=function(e){const t=getCurrentPages(),n=t[t.length-1].route,s=e.charAt(0),o=e.split("?")[0];if("/"===s)return o;const r=o.replace(/^\//,"").split("/"),i=n.split("/");i.pop();for(let e=0;e-1)&&(Ft.indexOf(t)>-1||Nt.some((t=>function(e,t){return new RegExp(t).test(e)}(e,t))))}function Kt(e,t){return"/"!==e.charAt(0)&&(e="/"+e),t?e.indexOf("?")>-1?e+`&uniIdRedirectUrl=${encodeURIComponent(t)}`:e+`?uniIdRedirectUrl=${encodeURIComponent(t)}`:e}function Bt(){const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t0)return setTimeout((()=>{q(C,o)}),0),e.url="",!1;if(!Dt)return e;const t=Kt(Dt,o.uniIdRedirectUrl);if($t){if("navigateTo"===n||"redirectTo"===n)return setTimeout((()=>{uni.switchTab({url:t})})),!1}else if("switchTab"===n)return setTimeout((()=>{uni.navigateTo({url:t})})),!1;e.url=t}return e}})}}function Ht(){this.onResponse((e=>{const{type:t,content:n}=e;let s=!1;switch(t){case"cloudobject":s=function(e){const{errCode:t}=e;return t in Et}(n);break;case"clientdb":s=function(e){const{errCode:t}=e;return t in Ct}(n)}s&&function(e={}){const t=L(C),n=getCurrentPages(),s=n[n.length-1],o=s&&s.$page&&s.$page.fullPath;if(t.length>0)return q(C,Object.assign({uniIdRedirectUrl:o},e));Dt&&uni.navigateTo({url:Kt(Dt,o)})}(n)}))}function Wt(e){e.onNeedLogin=function(e){D(C,e)},e.offNeedLogin=function(e){N(C,e)},Lt&&(k("uni-cloud-status").needLoginInit||(k("uni-cloud-status").needLoginInit=!0,function t(){let n=!1;if("function"==typeof getCurrentPages){const t=getCurrentPages();t&&t[0]&&(Bt.call(e),n=!0)}n||setTimeout((()=>{t()}),30)}(),qt&&Ht.call(e)))}function zt(e){!function(e){e.onResponse=function(e){D(O,e)},e.offResponse=function(e){N(O,e)}}(e),Wt(e),function(e){e.onRefreshToken=function(e){D(E,e)},e.offRefreshToken=function(e){N(E,e)}}(e)}let Vt;const Jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Yt=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function Xt(){const e=nt().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(Vt(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}Vt="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!Yt.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,o="",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 o}:atob;var Gt=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function o(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 r(e,t,{onChooseFile:s,onUploadProgress:o}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,o){(t=Object.assign({},t)).errMsg=n;const r=t.tempFiles,i=r.length;let a=0;return new Promise((n=>{for(;a=i)return void(!r.find((e=>!e.url&&!e.errMsg))&&n(t));const u=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,o&&o(e)}}).then((e=>{u.url=e.fileID,s{u.errMsg=e.errMsg||e.message,s{uni.chooseImage({count:t,sizeType:n,sourceType:r,extension:i,success(t){e(o(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:n,maxDuration:r,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:r,sourceType:i,extension:a,success(t){const{tempFilePath:n,duration:s,size:r,height:i,width:a}=t;e(o({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:r,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):r(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,r)=>{let i=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return r({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(o(t))},fail(e){r({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})),Qt=n(Gt);const Zt="manual";function en(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:{}}),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===Zt)return;let n=!1;const s=[];for(let o=2;o{this.mixinDatacomLoading=!1;const{data:s,count:o}=n.result;this.getcount&&(this.mixinDatacomPage.count=o),this.mixinDatacomHasMore=s.length{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const o=t.collection||this.collection;n=Array.isArray(o)?n.collection(...o):n.collection(o);const r=t.where||this.where;r&&Object.keys(r).length&&(n=n.where(r));const i=t.field||this.field;i&&(n=n.field(i));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const l=t.orderby||this.orderby;l&&(n=n.orderBy(l));const h=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,g=void 0!==t.gettree?t.gettree:this.gettree,p=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return g&&(m.getTree=y),p&&(m.getTreePath=y),n=n.skip(d*(h-1)).limit(d).get(m),n}}}}function tn(e){return function(t,n={}){n=function(e,t={}){return e.customUI=t.customUI||e.customUI,Object.assign(e.loadingOptions,t.loadingOptions),Object.assign(e.errorOptions,t.errorOptions),e}({customUI:!1,loadingOptions:{title:"加载中...",mask:!0},errorOptions:{type:"modal",retry:!1}},n);const{customUI:s,loadingOptions:o,errorOptions:r}=n,i=!s;return new Proxy({},{get:(n,s)=>async function n(...c){let u;i&&uni.showLoading({title:o.title,mask:o.mask});try{u=await e.callFunction({name:t,type:a,data:{method:s,params:c}})}catch(e){u={result:e}}const{errCode:l,errMsg:h,newToken:d}=u.result||{};if(i&&uni.hideLoading(),d&&d.token&&d.tokenExpired&&(st(d),q(E,{...d})),l){if(i)if("toast"===r.type)uni.showToast({title:h,icon:"none"});else{if("modal"!==r.type)throw new Error(`Invalid errorOptions.type: ${r.type}`);{const{confirm:e}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:o}={}){return new Promise(((r,i)=>{uni.showModal({title:e,content:t,showCancel:n,cancelText:s,confirmText:o,success(e){r(e)},fail(){r({confirm:!1,cancel:!0})}})}))}({title:"提示",content:h,showCancel:r.retry,cancelText:"取消",confirmText:r.retry?"重试":"确定"});if(r.retry&&e)return n(...c)}}const e=new M({code:l,message:h,requestId:u.requestId});throw e.detail=u.result,q(O,{type:x,content:e}),e}return q(O,{type:x,content:u.result}),u.result}})}}async function nn(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{H.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}function sn(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;let t=Promise.resolve();var n;n=1,t=new Promise(((e,t)=>{setTimeout((()=>{e()}),n)})),e.isReady=!1,e.isDefault=!1;const s=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>s.getLoginState())).then((e=>e?Promise.resolve():s.signInAnonymously())).then((()=>{if(!d)return Promise.resolve();if("app"===g&&"ios"===uni.getSystemInfoSync().osName){const{osName:e,osVersion:t}=uni.getSystemInfoSync();"ios"===e&&function(e){if(!e||"string"!=typeof e)return 0;const t=e.match(/^(\d+)./);return t&&t[1]?parseInt(t[1]):0}(t)>=14&&console.warn("iOS 14及以上版本连接uniCloud本地调试服务需要允许客户端查找并连接到本地网络上的设备(仅开发模式生效,发行模式会连接uniCloud云端服务)")}if(d&&e.debugInfo){const{address:t,servePort:n}=e.debugInfo;return async function(e,t){let n;for(let s=0;s{if(!d)return Promise.resolve();const s=console["app"===g?"error":"warn"];if(t)e.localAddress=t,e.localPort=n;else if(e.debugInfo){let t="";"remote"===e.debugInfo.initialLaunchType?(e.debugInfo.forceRemote=!0,t="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):t="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","web"===g&&(t+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),0===g.indexOf("mp-")&&(t+="\n- 小程序中如何使用uniCloud,请参考:https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinmp"),s(t)}})).then((()=>{ot(),e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}let on=new class{init(e){let t={};const n=d&&("web"===g&&navigator.userAgent.indexOf("HBuilderX")>0||"app"===g);switch(e.provider){case"tcb":case"tencent":t=et.init(Object.assign(e,{debugLog:n}));break;case"aliyun":t=J.init(Object.assign(e,{debugLog:n}));break;case"private":t=it.init(Object.assign(e,{debugLog:n}));break;default:throw new Error("未提供正确的provider参数")}const s=p;d&&s&&!s.code&&(t.debugInfo=s),sn(t),t.reInit=function(){sn(this)},gt(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),It(t),function(e){e.getCurrentUserInfo=Xt,e.chooseAndUploadFile=Qt.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return en(e)}}),e.importObject=tn(e)}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return t.reInit(),n.apply(t,Array.from(arguments))},t[e]=F(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{{const e=m;let t={};if(e&&1===e.length)t=e[0],on=on.init(t),on.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":y?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{on[e]=function(){return console.error(n),Promise.reject(new M({code:"SYS_ERR",message:n}))}}))}Object.assign(on,{get mixinDatacom(){return en(on)}}),zt(on),on.addInterceptor=v,on.removeInterceptor=A,d&&"web"===g&&(window.uniCloud=on)}})();var rn=on;export{rn as default}; +import{initVueI18n as e}from"@dcloudio/uni-i18n";import t from"@/pages.json";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function s(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=s((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},o=s.lib={},r=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=o.WordArray=r.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,o=e.sigBytes;if(this.clamp(),s%4)for(var r=0;r>>2]>>>24-r%4*8&255;t[s+r>>>2]|=i<<24-(s+r)%4*8}else for(r=0;r>>2]=n[r>>>2];return this.sigBytes+=o,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=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],o=function(t){t=t;var n=987654321,s=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},r=0;r>>2]>>>24-o%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 i.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],o=0;o>>2]>>>24-o%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 i.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new i.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,o=n.sigBytes,r=this.blockSize,a=o/(4*r),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*r,u=e.min(4*c,o);if(c){for(var l=0;l>>24)|4278255360&(o<<24|o>>>8)}var r=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],g=e[t+3],p=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],v=e[t+10],T=e[t+11],S=e[t+12],P=e[t+13],A=e[t+14],I=e[t+15],b=r[0],O=r[1],C=r[2],E=r[3];b=u(b,O,C,E,i,7,a[0]),E=u(E,b,O,C,c,12,a[1]),C=u(C,E,b,O,f,17,a[2]),O=u(O,C,E,b,g,22,a[3]),b=u(b,O,C,E,p,7,a[4]),E=u(E,b,O,C,m,12,a[5]),C=u(C,E,b,O,y,17,a[6]),O=u(O,C,E,b,_,22,a[7]),b=u(b,O,C,E,w,7,a[8]),E=u(E,b,O,C,k,12,a[9]),C=u(C,E,b,O,v,17,a[10]),O=u(O,C,E,b,T,22,a[11]),b=u(b,O,C,E,S,7,a[12]),E=u(E,b,O,C,P,12,a[13]),C=u(C,E,b,O,A,17,a[14]),b=l(b,O=u(O,C,E,b,I,22,a[15]),C,E,c,5,a[16]),E=l(E,b,O,C,y,9,a[17]),C=l(C,E,b,O,T,14,a[18]),O=l(O,C,E,b,i,20,a[19]),b=l(b,O,C,E,m,5,a[20]),E=l(E,b,O,C,v,9,a[21]),C=l(C,E,b,O,I,14,a[22]),O=l(O,C,E,b,p,20,a[23]),b=l(b,O,C,E,k,5,a[24]),E=l(E,b,O,C,A,9,a[25]),C=l(C,E,b,O,g,14,a[26]),O=l(O,C,E,b,w,20,a[27]),b=l(b,O,C,E,P,5,a[28]),E=l(E,b,O,C,f,9,a[29]),C=l(C,E,b,O,_,14,a[30]),b=h(b,O=l(O,C,E,b,S,20,a[31]),C,E,m,4,a[32]),E=h(E,b,O,C,w,11,a[33]),C=h(C,E,b,O,T,16,a[34]),O=h(O,C,E,b,A,23,a[35]),b=h(b,O,C,E,c,4,a[36]),E=h(E,b,O,C,p,11,a[37]),C=h(C,E,b,O,_,16,a[38]),O=h(O,C,E,b,v,23,a[39]),b=h(b,O,C,E,P,4,a[40]),E=h(E,b,O,C,i,11,a[41]),C=h(C,E,b,O,g,16,a[42]),O=h(O,C,E,b,y,23,a[43]),b=h(b,O,C,E,k,4,a[44]),E=h(E,b,O,C,S,11,a[45]),C=h(C,E,b,O,I,16,a[46]),b=d(b,O=h(O,C,E,b,f,23,a[47]),C,E,i,6,a[48]),E=d(E,b,O,C,_,10,a[49]),C=d(C,E,b,O,A,15,a[50]),O=d(O,C,E,b,m,21,a[51]),b=d(b,O,C,E,S,6,a[52]),E=d(E,b,O,C,g,10,a[53]),C=d(C,E,b,O,v,15,a[54]),O=d(O,C,E,b,c,21,a[55]),b=d(b,O,C,E,w,6,a[56]),E=d(E,b,O,C,I,10,a[57]),C=d(C,E,b,O,y,15,a[58]),O=d(O,C,E,b,P,21,a[59]),b=d(b,O,C,E,p,6,a[60]),E=d(E,b,O,C,T,10,a[61]),C=d(C,E,b,O,f,15,a[62]),O=d(O,C,E,b,k,21,a[63]),r[0]=r[0]+b|0,r[1]=r[1]+O|0,r[2]=r[2]+C|0,r[3]=r[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var r=e.floor(s/4294967296),i=s;n[15+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[14+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,o,r,i){var a=e+(t&n|~t&s)+o+i;return(a<>>32-r)+t}function l(e,t,n,s,o,r,i){var a=e+(t&s|n&~s)+o+i;return(a<>>32-r)+t}function h(e,t,n,s,o,r,i){var a=e+(t^n^s)+o+i;return(a<>>32-r)+t}function d(e,t,n,s,o,r,i){var a=e+(n^(t|~s))+o+i;return(a<>>32-r)+t}t.MD5=r._createHelper(c),t.HmacMD5=r._createHmacHelper(c)}(Math),n.MD5)})),s((function(e,t){var n,s,r;e.exports=(s=(n=o).lib.Base,r=n.enc.Utf8,void(n.algo.HMAC=s.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,c=i.words,u=0;u{v.indexOf(n)>-1&&function(e,t,n){let s=T[e][t];s||(s=T[e][t]=[]),-1===s.indexOf(n)&&"function"==typeof n&&s.push(n)}(e,n,t[n])}))}function P(e,t){T[e]||(T[e]={}),l(t)?Object.keys(t).forEach((n=>{v.indexOf(n)>-1&&function(e,t,n){const s=T[e][t];if(!s)return;const o=s.indexOf(n);o>-1&&s.splice(o,1)}(e,n,t[n])})):delete T[e]}function A(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function I(e,t){return T[e]&&T[e][t]||[]}function b(e){S("callObject",e)}const O=k("_globalUniCloudListener"),C="response",E="needLogin",R="refreshToken",U="clientdb",x="cloudfunction",L="cloudobject";function D(e){return O[e]||(O[e]=[]),O[e]}function N(e,t){const n=D(e);n.includes(t)||n.push(t)}function q(e,t){const n=D(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function F(e,t){const n=D(e);for(let e=0;e{M&&e(),function t(){if("function"==typeof getCurrentPages){const t=getCurrentPages();t&&t[0]&&(M=!0,e())}M||setTimeout((()=>{t()}),30)}()}));function $(){return j}function K(e,t){return t?function(n){let s=!1;if("callFunction"===t){const e=n&&n.type||i;s=e!==i}const o="callFunction"===t&&!s;let r;r=this.isReady?Promise.resolve():this.initUniCloud,n=n||{};const a=r.then((()=>s?Promise.resolve():A(I(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):A(I(t,"success"),e).then((()=>A(I(t,"complete"),e))).then((()=>(o&&F(C,{type:x,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):A(I(t,"fail"),e).then((()=>A(I(t,"complete"),e))).then((()=>(F(C,{type:x,content:e}),Promise.reject(e))))));if(!(n.success||n.fail||n.complete))return a;a.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e),o&&F(C,{type:x,content:e})}),(e=>{n.fail&&n.fail(e),n.complete&&n.complete(e),o&&F(C,{type:x,content:e})}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.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)}))}}class B extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",this.errCode=this.code=e.code||"SYSTEM_ERROR",this.requestId=e.requestId}}function H(){let e,t;try{if(uni.getLaunchOptionsSync){if(uni.getLaunchOptionsSync.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=uni.getLaunchOptionsSync();e=s,t=n}}catch(e){}return{channel:e,scene:t}}let W;function z(){const e=uni.getLocale&&uni.getLocale()||"en";if(W)return{...W,locale:e,LOCALE:e};const t=uni.getSystemInfoSync(),{deviceId:n,osName:s,uniPlatform:o,appId:r}=t,i=["pixelRatio","brand","model","system","language","version","platform","host","SDKVersion","swanNativeVersion","app","AppPlatform","fontSizeSetting"];for(let e=0;e{t(Object.assign(e,{complete(e){e||(e={}),d&&"web"===g&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");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)return s(new B({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const o=e.data;if(o.error)return s(new B({code:o.error.code,message:o.error.message,requestId:t}));o.result=o.data,o.requestId=t,delete o.data,n(o)}}))}))}};var V={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()},Y={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:X}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:Y,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"},ja:Y},"zh-Hans");var G=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(X("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=V,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return J.wrappedRequest(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"]=J.sign(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"]=J.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(new B({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){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))}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:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new B({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))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:o}){if("string"!==u(t))throw new B({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new B({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new B({code:"INVALID_PARAM",message:"cloudPath不合法"});const r=o&&o.envType||this.config.envType;let i,a;return this.getOSSUploadOptionsFromPath({env:r,filename:t}).then((t=>{const o=t.result;i=o.id,a="https://"+o.cdnDomain+"/"+o.ossPath;const r={url:"https://"+o.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:o.accessKeyId,Signature:o.signature,host:o.host,id:i,key:o.ossPath,policy:o.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},r,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:i}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:a}):s(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new B({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}};var Q={init(e){const t=new G(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 Z="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var ee;!function(e){e.local="local",e.none="none",e.session="session"}(ee||(ee={}));var te=function(){};const ne=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new B({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 se(e){return void 0===e}function oe(e){return"[object Null]"===Object.prototype.toString.call(e)}var re;function ie(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(re||(re={}));const ae={adapter:null,runtime:void 0},ce=["anonymousUuidKey"];class ue extends te{constructor(){super(),ae.adapter.root.tcbObject||(ae.adapter.root.tcbObject={})}setItem(e,t){ae.adapter.root.tcbObject[e]=t}getItem(e){return ae.adapter.root.tcbObject[e]}removeItem(e){delete ae.adapter.root.tcbObject[e]}clear(){delete ae.adapter.root.tcbObject}}function le(e,t){switch(e){case"local":return t.localStorage||new ue;case"none":return new ue;default:return t.sessionStorage||new ue}}class he{constructor(e){if(!this._storage){this._persistence=ae.adapter.primaryStorage||e.persistence,this._storage=le(this._persistence,ae.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,o=`anonymous_uuid_${e.env}`,r=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:o,loginTypeKey:r,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=le(e,ae.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&ce.includes(e))continue;const o=this._storage.getItem(s);se(o)||oe(o)||(n.setItem(s,o),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},o=JSON.stringify(s);try{this._storage.setItem(e,o)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const de={},fe={};function ge(e){return de[e]}class pe{constructor(e,t){this.data=t||null,this.name=e}}class me extends pe{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const ye=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}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 me)return console.error(e.error),this;const n="string"==typeof e?new pe(e,t||{}):e;const 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 _e(e,t){ye.on(e,t)}function we(e,t={}){ye.fire(e,t)}function ke(e,t){ye.off(e,t)}const ve="loginStateChanged",Te="loginStateExpire",Se="loginTypeChanged",Pe="anonymousConverted",Ae="refreshAccessToken";var Ie;!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"}(Ie||(Ie={}));const be=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],Oe={"X-SDK-Version":"1.3.5"};function Ce(e,t,n){const s=e[t];e[t]=function(t){const o={},r={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(o,s),Object.assign(r,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...o};else for(const e in o)i.append(e,o[e])})(),t.headers={...t.headers||{},...r},s.call(e,t)}}function Ee(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...Oe,"x-seqid":e}}}class Re{constructor(e={}){var t;this.config=e,this._reqClass=new ae.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=ge(this.config.env),this._localCache=(t=this.config.env,fe[t]),Ce(this._reqClass,"post",[Ee]),Ce(this._reqClass,"upload",[Ee]),Ce(this._reqClass,"download",[Ee])}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(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:o}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let r=this._cache.getStore(n);if(!r)throw new B({message:"未登录CloudBase"});const i={refresh_token:r},a=await this.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(s)===Ie.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(o),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()}we(Te),this._cache.removeStore(n)}throw new B({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return we(Ae),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 B({message:"refresh token不存在,登录状态异常"});let s=this._cache.getStore(e),o=this._cache.getStore(t),r=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,o)&&(r=!1),(!s||!o||o{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:o,country:r,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:o,country:r,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.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 Ne{constructor(e){if(!e)throw new B({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=ge(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,o=this._cache.getStore(t),r=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:o,accessToken:r,accessTokenExpire:i},this.user=new De(e)}get isAnonymousAuth(){return this.loginType===Ie.ANONYMOUS}get isCustomAuth(){return this.loginType===Ie.CUSTOM}get isWeixinAuth(){return this.loginType===Ie.WECHAT||this.loginType===Ie.WECHAT_OPEN||this.loginType===Ie.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class qe extends Le{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,o=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(o.uuid&&o.refresh_token){this._setAnonymousUUID(o.uuid),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),we(ve),we(Se,{env:this.config.env,loginType:Ie.ANONYMOUS,persistence:"local"});const e=new Ne(this.config.env);return await e.user.refresh(),e}throw new B({message:"匿名登录失败"})}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),o=this._cache.getStore(n),r=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:o,ticket:e});if(r.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),we(Pe,{env:this.config.env}),we(Se,{loginType:Ie.CUSTOM,persistence:"local"}),{credential:{refreshToken:r.refresh_token}};throw new B({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Ie.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Fe extends Le{async signIn(e){if("string"!=typeof e)throw new B({param:"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(),we(ve),we(Se,{env:this.config.env,loginType:Ie.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new Ne(this.config.env);throw new B({message:"自定义登录失败"})}}class Me extends Le{async signIn(e,t){if("string"!=typeof e)throw new B({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:o,access_token:r,access_token_expire:i}=s;if(o)return this.setRefreshToken(o),r&&i?this.setAccessToken(r,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),we(ve),we(Se,{env:this.config.env,loginType:Ie.EMAIL,persistence:this.config.persistence}),new Ne(this.config.env);throw s.code?new B({code:s.code,message:`邮箱登录失败: ${s.message}`}):new B({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 je extends Le{async signIn(e,t){if("string"!=typeof e)throw new B({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:Ie.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:o,access_token_expire:r,access_token:i}=s;if(o)return this.setRefreshToken(o),i&&r?this.setAccessToken(i,r):await this._request.refreshAccessToken(),await this.refreshUserInfo(),we(ve),we(Se,{env:this.config.env,loginType:Ie.USERNAME,persistence:this.config.persistence}),new Ne(this.config.env);throw s.code?new B({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new B({message:"用户名密码登录失败"})}}class $e{constructor(e){this.config=e,this._cache=ge(e.env),this._request=xe(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),_e(Se,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 qe(this.config)}customAuthProvider(){return new Fe(this.config)}emailAuthProvider(){return new Me(this.config)}usernameAuthProvider(){return new je(this.config)}async signInAnonymously(){return new qe(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new Me(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new je(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new qe(this.config)),_e(Pe,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Ie.ANONYMOUS)throw new B({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const o=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),we(ve),we(Se,{env:this.config.env,loginType:Ie.NULL,persistence:this.config.persistence}),o}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){_e(ve,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){_e(Te,e.bind(this))}onAccessTokenRefreshed(e){_e(Ae,e.bind(this))}onAnonymousConverted(e){_e(Pe,e.bind(this))}onLoginTypeChanged(e){_e(Se,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new Ne(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new B({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 Fe(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 Ke=function(e,t){t=t||ne();const n=xe(this.config.env),{cloudPath:s,filePath:o,onUploadProgress:r,fileType:i="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:l,cosFileId:h},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:o,name:s,fileType:i,onUploadProgress:r}).then((e=>{201===e.statusCode?t(null,{fileID:l,requestId:d}):t(new B({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Be=function(e,t){t=t||ne();const n=xe(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},He=function({fileList:e},t){if(t=t||ne(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return xe(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},We=function({fileList:e},t){t=t||ne(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return xe(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},ze=async function({fileID:e},t){const n=(await We.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=xe(this.config.env);let o=n.download_url;if(o=encodeURI(o),!t)return s.download({url:o});t(await s.download({url:o}))},Je=function({name:e,data:t,query:n,parse:s,search:o},r){const i=r||ne();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new B({code:"PARAM_ERROR",message:"函数名不能为空"}));const c={inQuery:n,parse:s,search:o,function_name:e,request_data:a};return xe(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let t=e.data.response_data;if(s)i(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(new B({message:"response data must be json"}))}}return i.promise})).catch((e=>{i(e)})),i.promise},Ve={timeout:15e3,persistence:"session"},Ye={};class Xe{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(ae.adapter||(this.requestClient=new ae.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Ve,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new Xe(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||ae.adapter.primaryStorage||Ve.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;de[t]=new he(e),fe[t]=new he({...e,persistence:"local"})}(this.config),n=this.config,Ue[n.env]=new Re(n),this.authObj=new $e(this.config),this.authObj}on(e,t){return _e.apply(this,[e,t])}off(e,t){return ke.apply(this,[e,t])}callFunction(e,t){return Je.apply(this,[e,t])}deleteFile(e,t){return He.apply(this,[e,t])}getTempFileURL(e,t){return We.apply(this,[e,t])}downloadFile(e,t){return ze.apply(this,[e,t])}uploadFile(e,t){return Ke.apply(this,[e,t])}getUploadMetadata(e,t){return Be.apply(this,[e,t])}registerExtension(e){Ye[e.name]=e}async invokeExtension(e,t){const n=Ye[e];if(!n)throw new B({message:`扩展${e} 必须先注册`});return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=ie(e)||{};t&&(ae.adapter=t),n&&(ae.runtime=n)}}var Ge=new Xe;function Qe(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),o="";for(var r in n)""===o?!s&&(t+="?"):o+="&",o+=r+"="+encodeURIComponent(n[r]);return/^http(s)?:\/\//.test(t+=o)?t:""+e+t}class Ze{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,o)=>{V.request({url:Qe("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){o(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:o,data:r,headers:i,fileType:a}=e,c=V.uploadFile({url:Qe("https:",s),name:"file",formData:Object.assign({},r),filePath:o,fileType:a,header:i,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 et={setItem(e,t){V.setStorageSync(e,t)},getItem:e=>V.getStorageSync(e),removeItem(e){V.removeStorageSync(e)},clear(){V.clearStorageSync()}};var tt={genAdapter:function(){return{root:{},reqClass:Ze,localStorage:et,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Ge.useAdapters(tt);const nt=Ge,st=nt.init;nt.init=function(e){e.env=e.spaceId;const t=st.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=>{t[e]=K(t[e]).bind(t)})),t},t.customAuth=t.auth,t};var ot=nt;function rt(e){return e&&rt(e.__v_raw)||e}function it(){return{token:V.getStorageSync("uni_id_token")||V.getStorageSync("uniIdToken"),tokenExpired:V.getStorageSync("uni_id_token_expired")}}function at({token:e,tokenExpired:t}={}){e&&V.setStorageSync("uni_id_token",e),t&&V.setStorageSync("uni_id_token_expired",t)}function ct(){if(!d||"web"!==g)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==_&&(uni.setStorageSync("__LAST_DCLOUD_APPID",_),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),V.removeStorageSync("uni_id_token"),V.removeStorageSync("uniIdToken"),V.removeStorageSync("uni_id_token_expired"))}var ut=class extends G{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=J.sign(n,this.config.clientSecret);const o=z();s["x-client-info"]=encodeURIComponent(JSON.stringify(o));const{token:r}=it();return s["x-client-token"]=r,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,success(e){e&&e.statusCode<400?i(e):a(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new B({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})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new B({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let o;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:r,formData:i,name:a}=t.result;o=t.result.fileUrl;const c={url:r,formData:i,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:o}):s(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}};var lt={init(e){const t=new ut(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};function ht({data:e}){let t;t=z();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=it();e&&(n.uniIdToken=e)}return n}function dt({name:e,data:t}={}){const{localAddress:n,localPort:s}=this.__dev__,o={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],r=this.config.spaceId,i=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;return new Promise(((t,n)=>{V.request({method:"POST",url:i,data:{name:e,platform:g,provider:o,spaceId:r},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._callCloudFunction({name:e,data:t})}return new Promise(((e,n)=>{const s=ht.call(this,{data:t});V.request({method:"POST",url:a,data:{provider:o,platform:g,param:s},success:({statusCode:t,data:s}={})=>!t||t>=400?n(new B({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):e({result:s}),fail(e){n(new B({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const ft=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var gt=/[\\^$.*+?()[\]{}|]/g,pt=RegExp(gt.source);function mt(e,t,n){return e.replace(new RegExp((s=t)&&pt.test(s)?s.replace(gt,"\\$&"):s,"g"),n);var s}function yt({functionName:e,result:t,logPvd:n}){if(this.__dev__.debugLog&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function _t(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=ht.call(e,{data:n.data});const o={aliyun:"aliyun",tencent:"tcb",tcb:"tcb"}[this.config.provider];return t.call(this,n).then((e=>(e.errCode=0,yt.call(this,{functionName:s,result:e,logPvd:o}),Promise.resolve(e))),(e=>(yt.call(this,{functionName:s,result:e,logPvd:o}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),o}}const wt=Symbol("CLIENT_DB_INTERNAL");function kt(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=wt,e.__v_raw=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;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 vt(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 Tt=["db.Geo","db.command","command.aggregate"];function St(e,t){return Tt.indexOf(`${e}.${t}`)>-1}function Pt(e){switch(u(e=rt(e))){case"array":return e.map((e=>Pt(e)));case"object":return e._internalType===wt||Object.keys(e).forEach((t=>{e[t]=Pt(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function At(e){return e&&e.content&&e.content.$method}class It{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:Pt(e.$param)})))}}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=At(e),n=At(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"===At(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=At(e),n=At(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}get count(){if(!this.isAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return bt({$method:"count",$param:Pt(Array.from(arguments))},e,this._database)}}get remove(){if(!this.isCommand)return function(){return this._send("remove",Array.from(arguments))};const e=this;return function(){return bt({$method:"remove",$param:Pt(Array.from(arguments))},e,this._database)}}get(){return this._send("get",Array.from(arguments))}add(){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(){if(!this.isCommand)return function(){throw new Error("JQL禁止使用set方法")};const e=this;return function(){return bt({$method:"set",$param:Pt(Array.from(arguments))},e,this._database)}}_send(e,t){const n=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:Pt(t)}),d){const e=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeof e.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时,未使用getTemp先过滤主表数据,在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档:https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}return this._database._callCloudFunction({action:n,command:s})}}function bt(e,t,n){return kt(new It(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),St(s,t)?bt({$method:t},e,n):function(){return bt({$method:t,$param:Pt(Array.from(arguments))},e,n)}}})}function Ot({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}]}}}}class Ct extends class{constructor({uniClient:e={}}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=k("_globalUniCloudDatabaseCallback")),this.auth=vt(this._authCallBacks),Object.assign(this,vt(this._dbCallBacks)),this.env=kt({},{get:(e,t)=>({$env:t})}),this.Geo=kt({},{get:(e,t)=>Ot({path:["Geo"],method:t})}),this.serverDate=Ot({path:[],method:"serverDate"}),this.RegExp=Ot({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})}}{_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function o(e,t){if(n&&s)for(let n=0;nA(I("database","complete"),e))).then((()=>(o(null,e),F(C,{type:U,content:e}),Promise.reject(e))))}const a=A(I("database","invoke")),u=this._uniClient;return a.then((()=>u.callFunction({name:"DCloud-clientDB",type:c,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:r,systemInfo:a=[]}=e.result;if(a)for(let e=0;e(console.warn(s),t)})}}return function(e){return A(I("database","success"),e).then((()=>A(I("database","complete"),e))).then((()=>(o(e,null),F(C,{type:U,content:e}),Promise.resolve(e))))}(e)}),(e=>{/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB");return i(new B({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))}))}}function Et(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const n=function(e,t={}){return kt(new e(t),{get:(e,t)=>St("db",t)?bt({$method:t},null,e):function(){return bt({$method:t,$param:Pt(Array.from(arguments))},null,e)}})}(Ct,{uniClient:e});return this._database=n,n}}const Rt="token无效,跳转登录页面",Ut="token过期,跳转登录页面",xt={TOKEN_INVALID_TOKEN_EXPIRED:Ut,TOKEN_INVALID_INVALID_CLIENTID:Rt,TOKEN_INVALID:Rt,TOKEN_INVALID_WRONG_TOKEN:Rt,TOKEN_INVALID_ANONYMOUS_USER:Rt},Lt={"uni-id-token-expired":Ut,"uni-id-check-token-failed":Rt,"uni-id-token-not-exist":Rt,"uni-id-check-device-feature-failed":Rt};function Dt(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function Nt(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(Dt(t,e.path)):!1===e.needLogin&&s.push(Dt(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function qt(e){return e.split("?")[0].replace(/^\//,"")}function Ft(){return function(e){let t=e&&e.$page&&e.$page.fullPath||"";return t?("/"!==t.charAt(0)&&(t="/"+t),t):t}(function(){const e=getCurrentPages();return e[e.length-1]}())}function Mt(){return qt(Ft())}function jt(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=qt(e);return n.some((e=>e.pagePath===s))}const $t=!!t.uniIdRouter;const{loginPage:Kt,routerNeedLogin:Bt,resToLogin:Ht,needLoginPage:Wt,notNeedLoginPage:zt,loginPageInTabBar:Jt}=function({pages:e=[],subPackages:n=[],uniIdRouter:s={},tabBar:o={}}=t){const{loginPage:r,needLogin:i=[],resToLogin:a=!0}=s,{needLoginPage:c,notNeedLoginPage:u}=Nt(e),{needLoginPage:l,notNeedLoginPage:h}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:o=[]}=e,{needLoginPage:r,notNeedLoginPage:i}=Nt(o,s);t.push(...r),n.push(...i)})),{needLoginPage:t,notNeedLoginPage:n}}(n);return{loginPage:r,routerNeedLogin:i,resToLogin:a,needLoginPage:[...c,...l],notNeedLoginPage:[...u,...h],loginPageInTabBar:jt(r,o)}}();if(Wt.indexOf(Kt)>-1)throw new Error(`Login page [${Kt}] should not be "needLogin", please check your pages.json`);function Vt(e){const t=qt(function(e){const t=Mt(),n=e.charAt(0),s=e.split("?")[0];if("/"===n)return s;const o=s.replace(/^\//,"").split("/"),r=t.split("/");r.pop();for(let e=0;e-1)&&(Wt.indexOf(t)>-1||Bt.some((t=>function(e,t){return new RegExp(t).test(e)}(e,t))))}function Yt({redirect:e}){const t=qt(e),n=qt(Kt);return Mt()!==n&&t!==n}function Xt({api:e,redirect:t}={}){if(!t||!Yt({redirect:t}))return;const n=function(e,t){return"/"!==e.charAt(0)&&(e="/"+e),t?e.indexOf("?")>-1?e+`&uniIdRedirectUrl=${encodeURIComponent(t)}`:e+`?uniIdRedirectUrl=${encodeURIComponent(t)}`:e}(Kt,t);Jt?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo"),setTimeout((()=>{uni[e]({url:n})}))}function Gt({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},n=function(){const{token:e,tokenExpired:t}=it();let n;if(e){if(t0)return setTimeout((()=>{F(E,n)}),0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function Qt(){!function(){const e=Ft(),{abortLoginPageJump:t,autoToLoginPage:n}=Gt({url:e});t||n&&Xt({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){const{errCode:t}=e;return t in Lt}(n);break;case"clientdb":s=function(e){const{errCode:t}=e;return t in xt}(n)}s&&function(e={}){const t=D(E);$().then((()=>{const n=Ft();if(n&&Yt({redirect:n}))return t.length>0?F(E,Object.assign({uniIdRedirectUrl:n},e)):void(Kt&&Xt({api:"navigateTo",redirect:n}))}))}(n)}))}function en(e){!function(e){e.onResponse=function(e){N(C,e)},e.offResponse=function(e){q(C,e)}}(e),function(e){e.onNeedLogin=function(e){N(E,e)},e.offNeedLogin=function(e){q(E,e)},$t&&(k("uni-cloud-status").needLoginInit||(k("uni-cloud-status").needLoginInit=!0,$().then((()=>{Qt.call(e)})),Ht&&Zt.call(e)))}(e),function(e){e.onRefreshToken=function(e){N(R,e)},e.offRefreshToken=function(e){q(R,e)}}(e)}let tn;const nn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",sn=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function on(){const e=it().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(tn(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}tn="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!sn.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,o="",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 o}:atob;var rn=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function o(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 r(e,t,{onChooseFile:s,onUploadProgress:o}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,o){(t=Object.assign({},t)).errMsg=n;const r=t.tempFiles,i=r.length;let a=0;return new Promise((n=>{for(;a=i)return void(!r.find((e=>!e.url&&!e.errMsg))&&n(t));const u=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,o&&o(e)}}).then((e=>{u.url=e.fileID,s{u.errMsg=e.errMsg||e.message,s{uni.chooseImage({count:t,sizeType:n,sourceType:r,extension:i,success(t){e(o(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:n,maxDuration:r,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:r,sourceType:i,extension:a,success(t){const{tempFilePath:n,duration:s,size:r,height:i,width:a}=t;e(o({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:r,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):r(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,r)=>{let i=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return r({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(o(t))},fail(e){r({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})),an=n(rn);const cn="manual";function un(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:{}}),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===cn)return;let n=!1;const s=[];for(let o=2;o{this.mixinDatacomLoading=!1;const{data:s,count:o}=n.result;this.getcount&&(this.mixinDatacomPage.count=o),this.mixinDatacomHasMore=s.length{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const o=t.collection||this.collection;n=Array.isArray(o)?n.collection(...o):n.collection(o);const r=t.where||this.where;r&&Object.keys(r).length&&(n=n.where(r));const i=t.field||this.field;i&&(n=n.field(i));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const l=t.orderby||this.orderby;l&&(n=n.orderBy(l));const h=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,g=void 0!==t.gettree?t.gettree:this.gettree,p=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return g&&(m.getTree=y),p&&(m.getTreePath=y),n=n.skip(d*(h-1)).limit(d).get(m),n}}}}function ln(e){return function(t,n={}){n=function(e,t={}){return e.customUI=t.customUI||e.customUI,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}},n);const{customUI:s,loadingOptions:o,errorOptions:r}=n,i=!s;return new Proxy({},{get:(s,c)=>function({fn:e,interceptorName:t,getCallbackArgs:n}={}){return async function(...s){const o=n?n({params:s}):{};let r,i;try{return await A(I(t,"invoke"),{...o}),r=await e(...s),await A(I(t,"success"),{...o,result:r}),r}catch(e){throw i=e,await A(I(t,"fail"),{...o,error:i}),i}finally{await A(I(t,"complete"),i?{...o,error:i}:{...o,result:r})}}}({fn:async function s(...u){let l;i&&uni.showLoading({title:o.title,mask:o.mask});const h={name:t,type:a,data:{method:c,params:u}};"object"==typeof n.secretMethods&&function(e,t){const n=t.data.method,s=e.secretMethods[n];s&&(t.secret=s)}(n,h);try{l=await e.callFunction(h)}catch(e){l={result:e}}const{errCode:d,errMsg:f,newToken:g}=l.result||{};if(i&&uni.hideLoading(),g&&g.token&&g.tokenExpired&&(at(g),F(R,{...g})),d){if(i)if("toast"===r.type)uni.showToast({title:f,icon:"none"});else{if("modal"!==r.type)throw new Error(`Invalid errorOptions.type: ${r.type}`);{const{confirm:e}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:o}={}){return new Promise(((r,i)=>{uni.showModal({title:e,content:t,showCancel:n,cancelText:s,confirmText:o,success(e){r(e)},fail(){r({confirm:!1,cancel:!0})}})}))}({title:"提示",content:f,showCancel:r.retry,cancelText:"取消",confirmText:r.retry?"重试":"确定"});if(r.retry&&e)return s(...u)}}const e=new B({code:d,message:f,requestId:l.requestId});throw e.detail=l.result,F(C,{type:L,content:e}),e}return F(C,{type:L,content:l.result}),l.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:t,methodName:c,params:e}}})})}}async function hn(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{V.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}function dn(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;let t=Promise.resolve();var n;n=1,t=new Promise(((e,t)=>{setTimeout((()=>{e()}),n)})),e.isReady=!1,e.isDefault=!1;const s=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>s.getLoginState())).then((e=>e?Promise.resolve():s.signInAnonymously())).then((()=>{if(!d)return Promise.resolve();if("app"===g){const{osName:e,osVersion:t}=uni.getSystemInfoSync();"ios"===e&&function(e){if(!e||"string"!=typeof e)return 0;const t=e.match(/^(\d+)./);return t&&t[1]?parseInt(t[1]):0}(t)>=14&&console.warn("iOS 14及以上版本连接uniCloud本地调试服务需要允许客户端查找并连接到本地网络上的设备(仅开发模式生效,发行模式会连接uniCloud云端服务)")}if(d&&e.__dev__.debugInfo){const{address:t,servePort:n}=e.__dev__.debugInfo;return async function(e,t){let n;for(let s=0;s{if(!d)return Promise.resolve();const s=console["app"===g?"error":"warn"];if(t)e.__dev__.localAddress=t,e.__dev__.localPort=n;else if(e.__dev__.debugInfo){let t="";"remote"===e.__dev__.debugInfo.initialLaunchType?(e.__dev__.debugInfo.forceRemote=!0,t="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):t="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","web"===g&&(t+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),0===g.indexOf("mp-")&&(t+="\n- 小程序中如何使用uniCloud,请参考:https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinmp"),s(t)}})).then((()=>{ct(),e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}const fn={tcb:ot,tencent:ot,aliyun:Q,private:lt};let gn=new class{init(e){let t={};const n=fn[e.provider];if(!n)throw new Error("未提供正确的provider参数");t=n.init(e),t.__dev__={},t.__dev__.debugLog=d&&("web"===g&&navigator.userAgent.indexOf("HBuilderX")>0||"app"===g);const s=p;d&&s&&!s.code&&(t.__dev__.debugInfo=s),dn(t),t.reInit=function(){dn(this)},_t(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),Et(t),function(e){e.getCurrentUserInfo=on,e.chooseAndUploadFile=an.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return un(e)}}),e.importObject=ln(e)}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return t.reInit(),n.apply(t,Array.from(arguments))},t[e]=K(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{const e=m;let t={};if(e&&1===e.length)t=e[0],gn=gn.init(t),gn.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":y?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{gn[e]=function(){return console.error(n),Promise.reject(new B({code:"SYS_ERR",message:n}))}}))}Object.assign(gn,{get mixinDatacom(){return un(gn)}}),en(gn),gn.addInterceptor=S,gn.removeInterceptor=P,gn.interceptObject=b,d&&"web"===g&&(window.uniCloud=gn)})();var pn=gn;export{pn as default}; -- GitLab