@cloudbase/js-sdk 3.10.4-beta.0 → 3.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see index.cjs.js.LICENSE.txt */
2
- !function(){var e,t,n={2772:function(e){"use strict";var t,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(s,{Channel:()=>I,LongPoll:()=>A,Presence:()=>T,Push:()=>w,Serializer:()=>P,Socket:()=>C,Timer:()=>S}),e.exports=(t=s,((e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||void 0===s||n(e,s,{get:()=>t[s],enumerable:!(a=r(t,s))||a.enumerable});return e})(n({},"__esModule",{value:!0}),t));var a=e=>"function"==typeof e?e:function(){return e},c="undefined"!=typeof self?self:null,u="undefined"!=typeof window?window:null,l=c||u||globalThis,h="closed",d="errored",f="joined",p="joining",v="leaving",y="phx_close",g="phx_error",m="phx_reply",b="phx_leave",_="websocket",E="base64url.bearer.phx.",w=class{constructor(e,t,n,r){this.channel=e,this.event=t,this.payload=n||function(){return{}},this.receivedResp=null,this.timeout=r,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:e,response:t,_ref:n}){this.recHooks.filter(t=>t.status===e).forEach(e=>e.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},S=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},I=class{constructor(e,t,n){this.state=h,this.topic=e,this.params=a(t||{}),this.socket=n,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new w(this,"phx_join",this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new S(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=f,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=d,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=h,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=d,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new w(this,b,a({}),this.timeout).send(),this.state=d,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(m,(e,t)=>{this.trigger(this.replyEventName(t),e)})}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=h,this.bindings=[]}onClose(e){this.on(y,e)}onError(e){return this.on(g,t=>e(t))}on(e,t){let n=this.bindingRef++;return this.bindings.push({event:e,ref:n,callback:t}),n}off(e,t){this.bindings=this.bindings.filter(n=>!(n.event===e&&(void 0===t||t===n.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,n=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let r=new w(this,e,function(){return t},n);return this.canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=v;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(y,"leave")},n=new w(this,b,a({}),e);return n.receive("ok",()=>t()).receive("timeout",()=>t()),n.send(),this.canPush()||n.trigger("ok",{}),n}onMessage(e,t,n){return t}filterBindings(e,t,n){return!0}isMember(e,t,n,r){return!(this.topic!==e||r&&r!==this.joinRef()&&(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:n,joinRef:r}),1))}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=p,this.joinPush.resend(e))}trigger(e,t,n,r){let o=this.onMessage(e,t,n,r);if(t&&!o)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(r=>r.event===e&&this.filterBindings(r,t,n));for(let e=0;e<i.length;e++)i[e].callback(o,n,r||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===h}isErrored(){return this.state===d}isJoined(){return this.state===f}isJoining(){return this.state===p}isLeaving(){return this.state===v}},O=class{static request(e,t,n,r,o,i,s){if(l.XDomainRequest){let n=new l.XDomainRequest;return this.xdomainRequest(n,e,t,r,o,i,s)}if(l.XMLHttpRequest){let a=new l.XMLHttpRequest;return this.xhrRequest(a,e,t,n,r,o,i,s)}if(l.fetch&&l.AbortController)return this.fetchRequest(e,t,n,r,o,i,s);throw new Error("No suitable XMLHttpRequest implementation found")}static fetchRequest(e,t,n,r,o,i,s){let a={method:e,headers:n,body:r},c=null;return o&&(c=new AbortController,setTimeout(()=>c.abort(),o),a.signal=c.signal),l.fetch(t,a).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>s&&s(e)).catch(e=>{"AbortError"===e.name&&i?i():s&&s(null)}),c}static xdomainRequest(e,t,n,r,o,i,s){return e.timeout=o,e.open(t,n),e.onload=()=>{let t=this.parseJSON(e.responseText);s&&s(t)},i&&(e.ontimeout=i),e.onprogress=()=>{},e.send(r),e}static xhrRequest(e,t,n,r,o,i,s,a){e.open(t,n,!0),e.timeout=i;for(let[t,n]of Object.entries(r))e.setRequestHeader(t,n);return e.onerror=()=>a&&a(null),e.onreadystatechange=()=>{if(4===e.readyState&&a){let t=this.parseJSON(e.responseText);a(t)}},s&&(e.ontimeout=s),e.send(o),e}static parseJSON(e){if(!e||""===e)return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let n=[];for(var r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let o=t?`${t}[${r}]`:r,i=e[r];"object"==typeof i?n.push(this.serialize(i,o)):n.push(encodeURIComponent(o)+"="+encodeURIComponent(i))}return n.join("&")}static appendParams(e,t){if(0===Object.keys(t).length)return e;let n=e.match(/\?/)?"&":"?";return`${e}${n}${this.serialize(t)}`}},A=class{constructor(e,t){t&&2===t.length&&t[1].startsWith(E)&&(this.authToken=atob(t[1].slice(21))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=0,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+_),"$1/longpoll")}endpointURL(){return O.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,n){this.close(e,t,n),this.readyState=0}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return 1===this.readyState||0===this.readyState}poll(){const e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:n,messages:r}=e;if(410===t&&null!==this.token)return this.onerror(410),void this.closeAndRetry(3410,"session_gone",!1);this.token=n}else t=0;switch(t){case 200:r.forEach(e=>{setTimeout(()=>this.onmessage({data:e}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=1,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${t}`)}})}send(e){"string"!=typeof e&&(e=(e=>{let t="",n=new Uint8Array(e),r=n.byteLength;for(let e=0;e<r;e++)t+=String.fromCharCode(n[e]);return btoa(t)})(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e,t=0){this.awaitingBatchAck=!0;const n=t+100,r=e.slice(t,n);this.ajax("POST",{"Content-Type":"application/x-ndjson"},r.join("\n"),()=>this.onerror("timeout"),t=>{t&&200===t.status?n<e.length?this.batchSend(e,n):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1:(this.awaitingBatchAck=!1,this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1))})}close(e,t,n){for(let e of this.reqs)e.abort();this.readyState=3;let r=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:n});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,"undefined"!=typeof CloseEvent?this.onclose(new CloseEvent("close",r)):this.onclose(r)}ajax(e,t,n,r,o){let i;i=O.request(e,this.endpointURL(),t,n,this.timeout,()=>{this.reqs.delete(i),r()},e=>{this.reqs.delete(i),this.isActive()&&o(e)}),this.reqs.add(i)}},T=class e{constructor(t,n={}){let r=n.events||{state:"presence_state",diff:"presence_diff"};this.state=Object.create(null),this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(r.state,t=>{let{onJoin:n,onLeave:r,onSync:o}=this.caller;this.joinRef=this.channel.joinRef(),this.state=e.syncState(this.state,t,n,r),this.pendingDiffs.forEach(t=>{this.state=e.syncDiff(this.state,t,n,r)}),this.pendingDiffs=[],o()}),this.channel.on(r.diff,t=>{let{onJoin:n,onLeave:r,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(t):(this.state=e.syncDiff(this.state,t,n,r),o())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(t){return e.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,t,n,r){let o=this.toNullProtoObj(this.clone(e));t=this.toNullProtoObj(t);let i=Object.create(null),s=Object.create(null);return this.map(o,(e,n)=>{t[e]||(s[e]=n)}),this.map(t,(e,t)=>{let n=o[e];if(n){let r=t.metas.map(e=>e.phx_ref),o=n.metas.map(e=>e.phx_ref),a=t.metas.filter(e=>o.indexOf(e.phx_ref)<0),c=n.metas.filter(e=>r.indexOf(e.phx_ref)<0);a.length>0&&(i[e]=t,i[e].metas=a),c.length>0&&(s[e]=this.clone(n),s[e].metas=c)}else i[e]=t}),this.syncDiff(o,{joins:i,leaves:s},n,r)}static syncDiff(e,t,n,r){e=this.toNullProtoObj(e);let{joins:o,leaves:i}=this.clone(t);return n||(n=function(){}),r||(r=function(){}),this.map(o,(t,r)=>{let o=e[t];if(e[t]=this.clone(r),o){let n=e[t].metas.map(e=>e.phx_ref),r=o.metas.filter(e=>n.indexOf(e.phx_ref)<0);e[t].metas.unshift(...r)}n(t,o,r)}),this.map(i,(t,n)=>{let o=e[t];if(!o)return;let i=n.metas.map(e=>e.phx_ref);o.metas=o.metas.filter(e=>i.indexOf(e.phx_ref)<0),r(t,o,n),0===o.metas.length&&delete e[t]}),e}static list(e,t){return t||(t=function(e,t){return t}),this.map(e,(e,n)=>t(e,n))}static map(e,t){return Object.getOwnPropertyNames(e).map(n=>t(n,e[n]))}static toNullProtoObj(e){if(null===Object.getPrototypeOf(e))return e;let t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(n=>{t[n]=e[n]}),t}static clone(e){return JSON.parse(JSON.stringify(e))}},P={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[n,r,o,i,s]=JSON.parse(e);return t({join_ref:n,ref:r,topic:o,event:i,payload:s})}},binaryEncode(e){let{join_ref:t,ref:n,event:r,topic:o,payload:i}=e,s=new TextEncoder,a=s.encode(t),c=s.encode(n),u=s.encode(o),l=s.encode(r);this.assertFieldSize(a.byteLength,"join_ref"),this.assertFieldSize(c.byteLength,"ref"),this.assertFieldSize(u.byteLength,"topic"),this.assertFieldSize(l.byteLength,"event");let h=this.META_LENGTH+a.byteLength+c.byteLength+u.byteLength+l.byteLength,d=new ArrayBuffer(this.HEADER_LENGTH+h),f=new Uint8Array(d),p=new DataView(d),v=0;p.setUint8(v++,this.KINDS.push),p.setUint8(v++,a.byteLength),p.setUint8(v++,c.byteLength),p.setUint8(v++,u.byteLength),p.setUint8(v++,l.byteLength),f.set(a,v),v+=a.byteLength,f.set(c,v),v+=c.byteLength,f.set(u,v),v+=u.byteLength,f.set(l,v),v+=l.byteLength;var y=new Uint8Array(d.byteLength+i.byteLength);return y.set(f,0),y.set(new Uint8Array(i),d.byteLength),y.buffer},assertFieldSize(e,t){if(e>255)throw new Error(`unable to convert ${t} to binary: must be less than or equal to 255 bytes, but is ${e} bytes`)},binaryDecode(e){let t=new DataView(e),n=t.getUint8(0),r=new TextDecoder;switch(n){case this.KINDS.push:return this.decodePush(e,t,r);case this.KINDS.reply:return this.decodeReply(e,t,r);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,r)}},decodePush(e,t,n){let r=t.getUint8(1),o=t.getUint8(2),i=t.getUint8(3),s=this.HEADER_LENGTH+this.META_LENGTH-1,a=n.decode(e.slice(s,s+r));s+=r;let c=n.decode(e.slice(s,s+o));s+=o;let u=n.decode(e.slice(s,s+i));return s+=i,{join_ref:a,ref:null,topic:c,event:u,payload:e.slice(s,e.byteLength)}},decodeReply(e,t,n){let r=t.getUint8(1),o=t.getUint8(2),i=t.getUint8(3),s=t.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,c=n.decode(e.slice(a,a+r));a+=r;let u=n.decode(e.slice(a,a+o));a+=o;let l=n.decode(e.slice(a,a+i));a+=i;let h=n.decode(e.slice(a,a+s));a+=s;let d=e.slice(a,e.byteLength);return{join_ref:c,ref:u,topic:l,event:m,payload:{status:h,response:d}}},decodeBroadcast(e,t,n){let r=t.getUint8(1),o=t.getUint8(2),i=this.HEADER_LENGTH+2,s=n.decode(e.slice(i,i+r));i+=r;let a=n.decode(e.slice(i,i+o));return i+=o,{join_ref:null,ref:null,topic:s,event:a,payload:e.slice(i,e.byteLength)}}},C=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=t.timeout||1e4,this.transport=t.transport||l.WebSocket||A,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let n=null;try{n=l&&l.sessionStorage}catch{}this.sessionStore=t.sessionStorage||n,this.establishedConnections=0,this.defaultEncoder=P.encode.bind(P),this.defaultDecoder=P.decode.bind(P),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==A?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let r=null;u&&u.addEventListener&&(u.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),r=this.connectClock)}),u.addEventListener("pageshow",e=>{r===this.connectClock&&(r=null,this.connect())}),u.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?this.pageHidden=!0:(this.pageHidden=!1,this.isConnected()||this.closeWasClean||this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=t.autoSendHeartbeat??!0,this.heartbeatCallback=t.heartbeatCallback??(()=>{}),this.rejoinAfterMs=e=>t.rejoinAfterMs?t.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>t.reconnectAfterMs?t.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(e,t,n)=>{console.log(`${e}: ${t}`,n)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=a(t.params||{}),this.endPoint=`${e}/${_}`,this.vsn=t.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new S(()=>{if(this.pageHidden)return this.log("Not reconnecting as page is hidden!"),void this.teardown();this.teardown(async()=>{t.beforeReconnect&&await t.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=t.authToken&&a(t.authToken)}getLongPollTransport(){return A}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=O.appendParams(O.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return"/"!==e.charAt(0)?e:"/"===e.charAt(1)?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,n){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,n)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=a(e)),this.conn&&!this.disconnecting||(this.longPollFallbackMs&&this.transport!==A?this.connectWithFallback(A,this.longPollFallbackMs):this.transportConnect())}log(e,t,n){this.logger&&this.logger(e,t,n)}hasLogger(){return null!==this.logger}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),n=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let r=this.onMessage(o=>{o.ref===t&&(this.off([r]),e(Date.now()-n))});return!0}transportName(e){return e===A?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix",`${E}${btoa(this.authToken()).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let n,r=!1,o=!0,i=this.transportName(e),s=t=>{this.log("transport",`falling back to ${i}...`,t),this.off([void 0,n]),o=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${i}`))return s("memorized");this.fallbackTimer=setTimeout(s,t),n=this.onError(e=>{this.log("transport","error",e),o&&!r&&(clearTimeout(this.fallbackTimer),s(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(r=!0,!o){let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t}`,"true"),this.log("transport",`established ${t} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(s,t),this.ping(e=>{this.log("transport","connected to primary after",e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),1e3,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,n){if(!this.conn)return e&&e();const r=this.conn;this.waitForBufferDone(r,()=>{t?r.close(t,n||""):r.close(),this.waitForSocketClosed(r,()=>{this.conn===r&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t,n=1){5!==n&&e.bufferedAmount?setTimeout(()=>{this.waitForBufferDone(e,t,n+1)},150*n):t()}waitForSocketClosed(e,t,n=1){5!==n&&3!==e.readyState?setTimeout(()=>{this.waitForSocketClosed(e,t,n+1)},150*n):t()}onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(e),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport","error",e);let t=this.transport,n=this.establishedConnections;this.triggerStateCallbacks("error",e,t,n),(t===this.transport||n>0)&&this.triggerChanError(e)}triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(g,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case 0:return"connecting";case 1:return"open";case 2:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([t])=>-1===e.indexOf(t))}channel(e,t={}){let n=new I(e,t,this);return this.channels.push(n),n}push(e){if(this.hasLogger()){let{topic:t,event:n,payload:r,ref:o,join_ref:i}=e;this.log("push",`${t} ${n} (${i}, ${o})`,r)}this.isConnected()?this.encode(e,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(e,e=>this.conn.send(e)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(this.isConnected())if(this.pendingHeartbeatRef)this.heartbeatTimeout();else{this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}else try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:n,payload:r,ref:o,join_ref:i}=e;if(o&&o===this.pendingHeartbeatRef){const e=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback("ok"===r.status?"ok":"error",e)}catch(e){this.log("error","error in heartbeat callback",e)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${r.status||""} ${t} ${n} ${o&&"("+o+")"||""}`.trim(),r);for(let e=0;e<this.channels.length;e++){const s=this.channels[e];s.isMember(t,n,r,i)&&s.trigger(n,r,o,i)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(e,...t){try{this.stateChangeCallbacks[e].forEach(([n,r])=>{try{r(...t)}catch(t){this.log("error",`error in ${e} callback`,t)}})}catch(t){this.log("error",`error triggering ${e} callbacks`,t)}}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}}},7756:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AI=void 0;var u=n(9737),l=s(n(5305)),h=n(1689),d=n(2877),f=l.MODELS,p=function(){function e(e,t,n,o){var i=this;this.req=e,this.baseUrl=t,this.modelRequest=function(e){var t=e.url,n=e.data,o=e.headers,s=e.stream,u=e.timeout;return a(i,void 0,void 0,function(){var e,i,a,l,h,d,f;return c(this,function(c){switch(c.label){case 0:return e={"Content-Type":"application/json"},s&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:r(r((h={},h[null===(d=this.i18n)||void 0===d?void 0:d.LANG_HEADER_KEY]=null===(f=this.i18n)||void 0===f?void 0:f.lang,h),e),o),body:JSON.stringify(n),url:this.resolveUrl(t),stream:s,timeout:u})];case 1:return i=c.sent(),a=i.data,l=i.header,[2,this.handleResponseData(a,l)]}})})},this.botRequest=function(e){var t=e.method,n=e.url,o=e.data,s=void 0===o?{}:o,u=e.headers,l=e.stream,h=e.timeout;return a(i,void 0,void 0,function(){var e,o,i,a,d,f,p,v,y;return c(this,function(c){switch(c.label){case 0:return e=this.resolveUrl(n),"get"!==t?[3,2]:(o=this.handleResponseData,[4,this.req.fetch({url:"".concat(e,"?").concat((g=s,Object.entries(g).map(function(e){var t=e[0],n=e[1];return"".concat(t,"=").concat(n)}).join("&"))),method:t,headers:u,stream:l,timeout:h})]);case 1:return[2,o.apply(this,[c.sent().data])];case 2:return i={"Content-Type":"application/json"},l&&Object.assign(i,{Accept:"text/event-stream"}),[4,this.req.fetch({url:e,body:JSON.stringify(s),headers:r(r((p={},p[null===(v=this.i18n)||void 0===v?void 0:v.LANG_HEADER_KEY]=null===(y=this.i18n)||void 0===y?void 0:y.lang,p),i),u),stream:l,method:t,timeout:h})];case 3:return a=c.sent(),d=a.data,f=a.header,[2,this.handleResponseData(d,f)]}var g})})},this._getBaseUrl=o,this.bot=new u.Bot(this.botRequest,this.aiBotBaseUrl),this.i18n=n,d.langEvent.bus.on(d.langEvent.LANG_CHANGE_EVENT,function(e){var t;i.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||i.i18n})}return Object.defineProperty(e.prototype,"aiBaseUrl",{get:function(){return"".concat(this._getBaseUrl?this._getBaseUrl():this.baseUrl,"/ai")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aiBotBaseUrl",{get:function(){return"".concat(this._getBaseUrl?this._getBaseUrl():this.baseUrl,"/aibot")},enumerable:!1,configurable:!0}),e.prototype.handleResponseData=function(e,t){var n,r;return a(this,void 0,void 0,function(){var o,i,s,a,u=this;return c(this,function(c){switch(c.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),i=function(e){if("object"==typeof e&&e&&"code"in e&&"NORMAL"!==e.code)throw new Error("".concat(u.i18n.t("AI+ 请求出错,错误码"),":").concat(e.code,",").concat(u.i18n.t("错误信息"),":").concat(e.message,"\n").concat(o,"\n").concat(JSON.stringify(e,null,2)))},"object"==typeof e&&e&&"function"!=typeof e.getReader?"then"in e?[4,e]:[3,2]:[3,4];case 1:return s=c.sent(),[3,3];case 2:s=e,c.label=3;case 3:return i(a=s),[2,e];case 4:if("function"!=typeof(null==e?void 0:e.getReader)){if("object"==typeof(a=e)&&a&&"code"in a&&"NORMAL"!==a.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(a.code,",").concat(this.i18n.t("错误信息"),":").concat(a.message,"\n").concat(o,"\n").concat(JSON.stringify(a,null,2)));return[2,e]}return(null===(r=null===(n=null==t?void 0:t.get)||void 0===n?void 0:n.call(t,"content-type"))||void 0===r?void 0:r.includes("application/json"))?[4,(0,h.readableStream2JsonObject)(e)]:[3,6];case 5:a=c.sent(),i(a),c.label=6;case 6:return[2,e]}})})},e.prototype.createModel=function(e,t){var n,r=f[e];if(r)n=new r(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==t?void 0:t.defaultModelSubUrl)?t.defaultModelSubUrl:"/chat/completions";n=new l.DefaultSimpleModel(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new l.ReactModel(n)},e.prototype.registerModel=function(e,t){null==f[e]?f[e]=t:console.warn("AI model ".concat(e," already exists!"))},e.prototype.createImageModel=function(e){return new l.DefaultImageModel(this.modelRequest,this.aiBaseUrl,e)},e.prototype.registerFunctionTool=function(e){l.toolMap.has(e.name)&&console.warn("AI function tool ".concat(e.name," already exists and will be overwritten!")),l.toolMap.set(e.name,e.fn)},e.prototype.resolveUrl=function(e){if(!this._getBaseUrl)return e;var t=this._getBaseUrl();return t!==this.baseUrl&&e.startsWith(this.baseUrl)?e.replace(this.baseUrl,t):e},e}();t.AI=p},9737:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.Bot=void 0;var a=n(1689),c=function(){function e(e,t){this.baseUrl=t;var n=arguments[2];this.req="string"==typeof n?function(t){var o=t.headers,i=void 0===o?{}:o,a=s(t,["headers"]);return e(r(r({},a),{headers:r(r({},i),{Authorization:"Bearer ".concat(n)})}))}:e}return e.prototype.list=function(e,t){return this.req({method:"get",url:this.join("bots"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.create=function(e,t){var n=e.botInfo;return this.req({method:"post",url:this.join("bots"),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.get=function(e,t){var n=e.botId;return this.req({method:"get",url:this.join("bots/".concat(n)),timeout:null==t?void 0:t.timeout})},e.prototype.update=function(e,t){var n=e.botId,r=e.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(n)),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.delete=function(e,t){var n=e.botId;return this.req({method:"delete",url:this.join("bots/".concat(n)),timeout:null==t?void 0:t.timeout})},e.prototype.getChatRecords=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/records")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendFeedback=function(e,t){var n=e.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(n.botId,"/feedback")),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.getFeedback=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/feedback")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.uploadFiles=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/files")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.createConversation=function(e,t){var n=e.botId,r=s(e,["botId"]);return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.req({method:"post",url:this.join("bots/".concat(n,"/conversation")),data:r,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getConversation=function(e,t){var n=e.pageSize,a=void 0===n?10:n,c=e.pageNumber,u=void 0===c?1:c,l=e.botId,h=s(e,["pageSize","pageNumber","botId"]);return o(this,void 0,void 0,function(){var e,n;return i(this,function(o){if(u<1)throw new Error("pageNumber must be greater than 0");return e=a*(u-1),n=a,[2,this.req({method:"get",url:this.join("bots/".concat(l,"/conversation")),data:r(r({},h),{offset:e,limit:n}),timeout:null==t?void 0:t.timeout})]})})},e.prototype.deleteConversation=function(e,t){var n=e.botId,r=e.conversationId,a=s(e,["botId","conversationId"]);return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.req({method:"delete",url:this.join("bots/".concat(n,"/conversation/").concat(r)),data:a,timeout:null==t?void 0:t.timeout})]})})},e.prototype.speechToText=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/speech-to-text")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.textToSpeech=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getTextToSpeechResult=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"get",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getRecommendQuestions=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/recommend-questions")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.generateBot=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.getPreview=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.generateImage=function(e,t){return this.req({method:"post",url:this.join("generate-image"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendMessage=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/send-message")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}();t.Bot=c;var u=function(){function e(e){var t=(0,a.toPolyfillReadable)(e);this._eventSourceStream=t.pipeThrough(new a.TextDecoderStream).pipeThrough((0,a.createEventSourceParserTransformStream)())}return Object.defineProperty(e.prototype,"teeedStream",{get:function(){var e=this._eventSourceStream.tee(),t=e[0],n=e[1];return this._eventSourceStream=n,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eventSourceStream",{get:function(){return(0,a.createAsyncIterable)(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataStream",{get:function(){return(0,a.createAsyncIterable)(this.eventSourceStream.pipeThrough(new a.TransformStream({transform:function(e,t){try{var n=JSON.parse(e.data);t.enqueue(n)}catch(n){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",n,e):t.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textStream",{get:function(){return(0,a.createAsyncIterable)(this.dataStream.pipeThrough(new a.TransformStream({transform:function(e,t){var n;t.enqueue(null!==(n=null==e?void 0:e.content)&&void 0!==n?n:"")}})))},enumerable:!1,configurable:!0}),e}()},713:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidParamsError=void 0;var o=function(e){function t(t,n){var r=e.call(this,t)||this;return r.name="InvalidParamsError",r.code="INVALID_PARAMS",r.field=n,r}return r(t,e),t.prototype.toJSON=function(){return{code:this.code,message:this.message,field:this.field}},t}(Error);t.InvalidParamsError=o},9964:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0;var r=n(6298);Object.defineProperty(t,"createParser",{enumerable:!0,get:function(){return r.createParser}})},6298:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0,t.createParser=function(e){var t,r,o,i,s,a,c;return u(),{feed:function(e){r=r?r+e:e,t&&function(e){return n.every(function(t,n){return e.charCodeAt(n)===t})}(r)&&(r=r.slice(n.length)),t=!1;for(var s=r.length,a=0,c=!1;a<s;){c&&("\n"===r[a]&&(a+=1),c=!1);for(var u=-1,h=i,d=void 0,f=o;u<0&&f<s;f++)":"===(d=r[f])&&h<0?h=f-a:"\r"===d?(c=!0,u=f-a):"\n"===d&&(u=f-a);if(u<0){o=s-a,i=h;break}o=0,i=-1,l(r,a,h,u),a+=u+1}a===s?r="":a>0&&(r=r.slice(a))},reset:u};function u(){t=!0,r="",o=0,i=-1,s=void 0,a=void 0,c=""}function l(t,n,r,o){if(0===o)return c.length>0&&(e({type:"event",id:s,event:a||void 0,data:c.slice(0,-1)}),c="",s=void 0),void(a=void 0);var i,u=r<0,l=t.slice(n,n+(u?o:r)),h=n+(i=u?o:" "===t[n+r+1]?r+2:r+1),d=o-i,f=t.slice(h,h+d).toString();if("data"===l)c+=f?"".concat(f,"\n"):"\n";else if("event"===l)a=f;else if("id"!==l||f.includes("\0")){if("retry"===l){var p=parseInt(f,10);Number.isNaN(p)||e({type:"reconnect-interval",value:p})}}else s=f}};var n=[239,187,191]},5337:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},c=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},u=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},l=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.registerAi=t.models=t.createAI=t.createAi=t.Bot=t.AI=void 0;var h=n(7756);Object.defineProperty(t,"AI",{enumerable:!0,get:function(){return h.AI}});var d=n(9737);Object.defineProperty(t,"Bot",{enumerable:!0,get:function(){return d.Bot}});var f=s(n(5305)),p=s(n(1689));t.utils=p,f.MODELS;var v=l(f,["MODELS"]);function y(e){var t=e.env,n=e.baseUrl,o=e.getBaseUrl,i=e.req,s=e.getAccessToken,a=e.handleReqInstance,d=e.i18n;return new h.AI(function(){if(null==a){if(null==s)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return function(e){var t=e.getAccessToken,n=e.req;return{download:n.download,post:n.post,upload:n.upload,fetch:function(e){return c(void 0,void 0,void 0,function(){var o,i,s,a,c;return u(this,function(u){switch(u.label){case 0:if("function"!=typeof n.fetch)throw new Error("req.fetch is not a function");return o=e.token,i=e.headers,s=void 0===i?{}:i,a=l(e,["token","headers"]),null==o?[3,1]:(c=o,[3,3]);case 1:return[4,t()];case 2:c=u.sent().accessToken,u.label=3;case 3:return[2,n.fetch(r({headers:r({Authorization:"Bearer ".concat(c)},s)},a))]}})})}}}({req:i,getAccessToken:s})}return a({req:i})}(),function(){if(null!=o)return o();if(null!=n)return n;if(null==t)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(t,".api.tcloudbasegateway.com/v1")}(),d,o)}t.models=v,t.createAI=y;var g=y;t.createAi=g;var m={name:"ai",entity:{ai:function(e){var t=this,n=this.request;if(null==n.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");var r=function(){var e=t.getEndPointWithKey("GATEWAY"),n=e.BASE_URL,r=e.PROTOCOL;return"".concat(r).concat(n)};return(null==e?void 0:e.baseUrl)?y({req:n,baseUrl:e.baseUrl,handleReqInstance:function(e){return e.req},i18n:this.config.i18n}):y({req:n,baseUrl:r(),getBaseUrl:r,handleReqInstance:function(e){return e.req},i18n:this.config.i18n})}}};function b(e){try{e.registerComponent(m)}catch(e){console.warn(e)}}t.registerAi=b,a(n(4669),t),a(n(713),t);try{window.registerAi=b}catch(e){}},5476:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ArkSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,s=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:s,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="ark/api/v3/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.ArkSimpleModel=c},7265:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DSSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,s=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:s,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),r(r({},e),n?{finish_reason:"tool_calls",delta:t}:{delta:t})}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.DSSimpleModel=c},2102:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepSeekSimpleModel=void 0;var s=n(1689),a=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="deepseek/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},e),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,a,c,u;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),a=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(a),u=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(u)]}})})},e}();t.DeepSeekSimpleModel=a},8017:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSimpleModel=void 0;var s=n(1689),a=function(){function e(e,t,n){void 0===n&&(n=""),this.req=e,this.baseUrl=t,this.subUrl=n}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},e),{stream:!1}),stream:!1})];case 1:return t=n.sent(),[2,r(r({},t),{rawResponse:t})]}})})},e.prototype.doStream=function(e){return o(this,void 0,Promise,function(){var t,n,o,a,c;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:r(r({},e),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,s.toPolyfillReadable)(n),a=(0,s.intoStandardStream)(o),c=a.pipeThrough(new s.TransformStream({transform:function(e,n){var o=e.choices.map(function(e){var n=e.delta;return null==t&&(t=(0,s.isToolCallAssistantMessage)(n)),t?r(r({},e),{finish_reason:"tool_calls",delta:n}):e}),i=r(r({},e),{choices:o});n.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(c)]}})})},e}();t.DefaultSimpleModel=a},7239:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanSimpleModel=void 0;var s=n(1689),a=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=(0,a.titleCaseToSnakeCase)(n.Response),[2,r(r({},o),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=(0,a.titleCaseToSnakeCase)(e),i=o.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),c=r(r({},o),{choices:i});t.enqueue(r(r({},c),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.HunYuanSimpleModel=c},8586:function(e,t){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.titleCaseToSnakeCase=t.processInput=void 0,t.processInput=function(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tool_choice,s=e.tools,a=e.top_p;return n(n({},e),{messages:(t.forEach(function(e){"tool_calls"in e&&e.tool_calls.filter(function(e){return"function"!==e.type}).forEach(function(t){return console.warn("`type` in tool_call is not 'function'",t,e)})}),t),model:r,tools:function(){if(s)return s.forEach(function(e){"function"!==e.type&&console.warn("`type` in tool is not 'function'",e)}),s}(),top_p:a,tool_choice:i,temperature:o})},t.titleCaseToSnakeCase=function e(t){return"object"!=typeof t||null==t?t:Array.isArray(t)?t.map(function(t){return e(t)}):Object.entries(t).reduce(function(t,n){var r,o=n[0],i=n[1];return t["_"===(r=o.replace(/[A-Z]/g,function(e){return"_".concat(e.toLowerCase())})).charAt(0)?r.slice(1):r]="object"==typeof i?e(i):i,t},{})}},9301:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanBetaSimpleModel=void 0;var s=n(1689),a=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.HunYuanBetaSimpleModel=c},5720:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanExpSimpleModel=void 0;var s=n(1689),a=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-exp/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!1}),stream:!1})];case 1:return t=n.sent(),[2,r(r({},t),{rawResponse:t})]}})})},e.prototype.doStream=function(e){return o(this,void 0,Promise,function(){var t,n,o,c,u;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,s.toPolyfillReadable)(n),c=(0,s.intoStandardStream)(o),u=c.pipeThrough(new s.TransformStream({transform:function(e,n){var o=e.choices.map(function(e){var n=e.delta;return null==t&&(t=(0,s.isToolCallAssistantMessage)(n)),t?r(r({},e),{finish_reason:"tool_calls",delta:n}):e}),i=r(r({},e),{choices:o});n.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(u)]}})})},e}();t.HunYuanExpSimpleModel=c},1586:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanOpenSimpleModel=void 0;var s=n(1689),a=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-open/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.HunYuanOpenSimpleModel=c},3925:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.MoonshotSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,s=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:s,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="moonshot/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.MoonshotSimpleModel=c},4532:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.YiSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,s=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:s,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="01-ai/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o,i,a,c,u,l;if((null===(a=null===(i=null===(o=null==e?void 0:e.choices)||void 0===o?void 0:o[0])||void 0===i?void 0:i.delta)||void 0===a?void 0:a.content)||(null===(l=null===(u=null===(c=null==e?void 0:e.choices)||void 0===c?void 0:c[0])||void 0===u?void 0:u.delta)||void 0===l?void 0:l.tool_calls)){var h=e.choices.map(function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),r(r({},e),n?{finish_reason:"tool_calls",delta:t}:{delta:t})}),d=r(r({},e),{choices:h});t.enqueue(r(r({},d),{rawResponse:e}))}}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.YiSimpleModel=c},7173:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ZhiPuSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tool_choice,s=e.tools,a=e.top_p;return r(r({},e),{messages:t,model:n,temperature:o,tool_choice:(i&&"auto"!==i&&console.warn("`tool_choice` is not 'auto'"),i),tools:s,top_p:a})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return n=a(e),[4,this.req({url:this.url,data:r(r({},n),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),[2,r(r({},o),{rawResponse:o})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l,h;return i(this,function(i){switch(i.label){case 0:return n=a(e),o=null,[4,this.req({url:this.url,data:r(r({},n),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return c=i.sent(),u=(0,s.toPolyfillReadable)(c),l=(0,s.intoStandardStream)(u),h=l.pipeThrough(new s.TransformStream({transform:function(e,t){var n=e.choices.map(function(e){var t=e.delta;return null==o&&(o=(0,s.isToolCallAssistantMessage)(t)),o?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:n});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(h)]}})})},e}();t.ZhiPuSimpleModel=c},8328:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultImageModel=void 0;var i=n(713),s=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.provider=n,this.defaultGenerateImageSubUrl="images/ar/generations",this.generateImageSubUrlConfig={"hunyuan-image":[[/^hunyuan-image(-v[12](\..*)?)?$/,"images/generations"]]},this.generateImage=this.generateImageImpl.bind(this)}return e.prototype.generateImageImpl=function(e){return r(this,void 0,Promise,function(){var t,n,r,s,a;return o(this,function(o){switch(o.label){case 0:if("object"==typeof e&&e&&"model"in e&&"HY-Image-v3.0-I2I-ToB-v1.0.1"===e.model&&(""===this.provider||"hunyuan-image"===this.provider)){if(n=(t=e).image_urls,r=t.images,n&&n.length>1)throw new i.InvalidParamsError("当模型为 HY-Image-v3.0-I2I-ToB-v1.0.1 时,image_urls 最多只能有 1 个元素","image_urls");if(r&&r.length>1)throw new i.InvalidParamsError("当模型为 HY-Image-v3.0-I2I-ToB-v1.0.1 时,images 最多只能有 1 个元素","images")}return s=this.defaultGenerateImageSubUrl,"object"==typeof e&&e&&"model"in e&&"string"==typeof e.model&&(a=this.getGenerateImageSubUrl(this.provider,e.model))&&(s=a),[4,this.req({url:this.getGenerateUrl(s),data:e,stream:!1})];case 1:return[2,o.sent()]}})})},e.prototype.getGenerateUrl=function(e){return"".concat(this.baseUrl,"/").concat(this.provider,"/").concat(e)},e.prototype.getGenerateImageSubUrl=function(e,t){var n=this.generateImageSubUrlConfig[e];if(n)for(var r=0,o=n;r<o.length;r++){var i=o[r],s=i[0],a=i[1];if(s.test(t))return a}},e}();t.DefaultImageModel=s},5305:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toolMap=t.ReactModel=t.DefaultImageModel=t.DefaultSimpleModel=t.HunYuanOpenSimpleModel=t.HunYuanExpSimpleModel=t.MoonshotSimpleModel=t.YiSimpleModel=t.DSSimpleModel=t.ArkSimpleModel=t.HunYuanSimpleModel=t.HunYuanBetaSimpleModel=t.ZhiPuSimpleModel=t.MODELS=void 0;var r=n(7173);Object.defineProperty(t,"ZhiPuSimpleModel",{enumerable:!0,get:function(){return r.ZhiPuSimpleModel}});var o=n(9301);Object.defineProperty(t,"HunYuanBetaSimpleModel",{enumerable:!0,get:function(){return o.HunYuanBetaSimpleModel}});var i=n(7239);Object.defineProperty(t,"HunYuanSimpleModel",{enumerable:!0,get:function(){return i.HunYuanSimpleModel}});var s=n(5476);Object.defineProperty(t,"ArkSimpleModel",{enumerable:!0,get:function(){return s.ArkSimpleModel}});var a=n(7265);Object.defineProperty(t,"DSSimpleModel",{enumerable:!0,get:function(){return a.DSSimpleModel}});var c=n(4532);Object.defineProperty(t,"YiSimpleModel",{enumerable:!0,get:function(){return c.YiSimpleModel}});var u=n(3925);Object.defineProperty(t,"MoonshotSimpleModel",{enumerable:!0,get:function(){return u.MoonshotSimpleModel}});var l=n(5720);Object.defineProperty(t,"HunYuanExpSimpleModel",{enumerable:!0,get:function(){return l.HunYuanExpSimpleModel}});var h=n(1586);Object.defineProperty(t,"HunYuanOpenSimpleModel",{enumerable:!0,get:function(){return h.HunYuanOpenSimpleModel}});var d=n(2102),f=n(8017);Object.defineProperty(t,"DefaultSimpleModel",{enumerable:!0,get:function(){return f.DefaultSimpleModel}});var p=n(8328);Object.defineProperty(t,"DefaultImageModel",{enumerable:!0,get:function(){return p.DefaultImageModel}}),t.MODELS={hunyuan:i.HunYuanSimpleModel,"hunyuan-beta":o.HunYuanBetaSimpleModel,ark:s.ArkSimpleModel,dashscope:a.DSSimpleModel,"01-ai":c.YiSimpleModel,moonshot:u.MoonshotSimpleModel,zhipu:r.ZhiPuSimpleModel,"hunyuan-exp":l.HunYuanExpSimpleModel,"hunyuan-open":h.HunYuanOpenSimpleModel,deepseek:d.DeepSeekSimpleModel};var v=n(1443);Object.defineProperty(t,"ReactModel",{enumerable:!0,get:function(){return v.ReactModel}}),Object.defineProperty(t,"toolMap",{enumerable:!0,get:function(){return v.toolMap}})},1443:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},a=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise(function(r,o){!function(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}(r,o,(t=e[n](t)).done,t.value)})}}},c=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.toolMap=t.ReactModel=void 0;var u=n(1689);function l(e){var t,n=e.onStepFinish,o=e.abortSignal,i=e.maxSteps,a=e.topP,c=e.toolChoice,l=s(e,["onStepFinish","abortSignal","maxSteps","topP","toolChoice"]);if(null!=i&&i<1)throw new Error("`maxSteps` muse be greater than 0.");return[{onStepFinish:n,abortSignal:o,maxSteps:i},r(r({},l),{tools:null===(t=l.tools)||void 0===t?void 0:t.map(function(e){return"fn"in e?(0,u.functionToolToModelTool)(e):e}),top_p:null!=a?a:l.top_p,tool_choice:null!=c?c:l.tool_choice})]}var h=function(){function e(e){this.model=e}return e.prototype.generateText=function(e,t){var n,r;return o(this,void 0,Promise,function(){var o,s,a,u,h,g,m,b,_,E,w,S,I,O,A,T,P,C,R,N,k,U=this;return i(this,function(i){switch(i.label){case 0:return o=[],s={completion_tokens:0,prompt_tokens:0,total_tokens:0},a=l(e),u=a[0],h=u.onStepFinish,g=u.maxSteps,m=void 0===g?10:g,b=a[1],[4,(_=function(){return U.model.doGenerate(b,t)})()];case 1:E=i.sent(),w=1,E.rawResponse&&o.push(E.rawResponse),S=null,i.label=2;case 2:if(!(w<m&&null!=(S=d(E))))return[3,9];I=v(E.usage),y(s,I),i.label=3;case 3:return i.trys.push([3,7,,8]),[4,p(S)];case 4:return O=i.sent(),A=E.choices[0],[4,null==h?void 0:h({finishReason:A.finish_reason,messages:b.messages.slice(),text:A.message.content,toolCall:S,toolResult:O,stepUsage:I,totalUsage:Object.assign({},s)})];case 5:return i.sent(),f(b.messages,A.message,O),[4,_()];case 6:return(E=i.sent()).rawResponse&&o.push(E.rawResponse),w+=1,[3,8];case 7:return T=i.sent(),[2,{text:"",messages:b.messages,usage:s,error:T,rawResponses:o}];case 8:return[3,2];case 9:return P=null===(n=null==E?void 0:E.choices)||void 0===n?void 0:n[0],C=null==P?void 0:P.message,R=null!==(r=null==C?void 0:C.content)&&void 0!==r?r:"",N=C?c(c([],b.messages,!0),[C],!1):b.messages,k=v(E.usage),y(s,k),[4,null==h?void 0:h({finishReason:P.finish_reason,messages:N.slice(),text:R,toolCall:d(E),toolResult:null,stepUsage:k,totalUsage:Object.assign({},s)})];case 10:return i.sent(),[2,{text:R,messages:N,usage:s,rawResponses:o}]}})})},e.prototype.streamText=function(e,t){var n;return o(this,void 0,Promise,function(){var r,s,h,d,v,g,m,b,_,E,w,S,I,O,A,T,P,C,R,N,k,U,D,L,j,x,M,q,F,B,W,H,G,V,K,J,Y=this;return i(this,function(z){switch(z.label){case 0:return r={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=l(e),h=s[0],d=h.onStepFinish,v=h.maxSteps,g=void 0===v?10:v,m=s[1],[4,(b=function(){return Y.model.doStream(m,t)})()];case 1:_=z.sent(),E=1,w=null,S=function(){var e=_.tee(),t=e[0],n=e[1];return _=(0,u.createAsyncIterable)(t),function(e){var t,n,r,s,c,l,h,d,f,p;return o(this,void 0,Promise,function(){var o,v,y,g,m,b,_,E,w,S,I,O,A;return i(this,function(i){switch(i.label){case 0:o={completion_tokens:0,prompt_tokens:0,total_tokens:0},v=(0,u.createAsyncIterable)(e),g={role:"assistant",content:"",tool_calls:[y={id:"",function:{name:"",arguments:""},type:""}]},i.label=1;case 1:i.trys.push([1,6,7,12]),m=!0,b=a(v),i.label=2;case 2:return[4,b.next()];case 3:if(_=i.sent(),t=_.done)return[3,5];s=_.value,m=!1;try{if(!(w=null==(E=s)?void 0:E.choices[0]))return[2,null];if(S=w.finish_reason,I=w.delta,"tool_calls"!==S)return[2,null];if(!I)return[3,4];if(I.content&&(g.content+=I.content),!("tool_calls"in I))return[3,4];(null==(O=null===(c=null==I?void 0:I.tool_calls)||void 0===c?void 0:c[0])?void 0:O.id)&&(y.id=O.id),(null==O?void 0:O.type)&&(y.type=O.type),(null===(l=null==O?void 0:O.function)||void 0===l?void 0:l.name)&&(y.function.name=O.function.name),(null===(h=null==O?void 0:O.function)||void 0===h?void 0:h.arguments)&&(y.function.arguments+=O.function.arguments),(null===(d=null==E?void 0:E.usage)||void 0===d?void 0:d.completion_tokens)&&(o.completion_tokens=E.usage.completion_tokens),(null===(f=null==E?void 0:E.usage)||void 0===f?void 0:f.prompt_tokens)&&(o.prompt_tokens=E.usage.prompt_tokens),(null===(p=null==E?void 0:E.usage)||void 0===p?void 0:p.total_tokens)&&(o.total_tokens=E.usage.total_tokens)}finally{m=!0}i.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return A=i.sent(),n={error:A},[3,12];case 7:return i.trys.push([7,,10,11]),m||t||!(r=b.return)?[3,9]:[4,r.call(b)];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,{message:g,usage:o}]}})})}(n)},z.label=2;case 2:return(I=E<g)?[4,S()]:[3,4];case 3:I=null!=(w=z.sent()),z.label=4;case 4:if(!I)return[3,11];O=w.message,A=w.usage,y(r,A),T=null===(n=O.tool_calls)||void 0===n?void 0:n[0],z.label=5;case 5:return z.trys.push([5,9,,10]),[4,p(T)];case 6:return P=z.sent(),[4,null==d?void 0:d({finishReason:"tool_calls",messages:m.messages.slice(),text:O.content,toolCall:T,toolResult:P,stepUsage:A,totalUsage:Object.assign({},r)})];case 7:return z.sent(),f(m.messages,O,P),[4,b()];case 8:return _=z.sent(),[3,10];case 9:return C=z.sent(),R=_.tee(),N=R[0],k=R[1],[2,{messages:Promise.resolve(m.messages),dataStream:(0,u.createAsyncIterable)(N),textStream:(0,u.createAsyncIterable)(k.pipeThrough(new u.TransformStream({transform:function(e,t){var n,r,o,i=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:Promise.resolve(r),error:C}];case 10:return[3,2];case 11:return[4,S()];case 12:return(w=z.sent())?(U=w.message,D=w.usage,y(r,D),L=c(c([],m.messages,!0),[U],!1),d({messages:L.slice(),finishReason:"tool_call",stepUsage:D,text:U.content,toolCall:U.tool_calls[0],totalUsage:Object.assign({},r)}),j=_.tee(),x=j[0],M=j[1],[2,{messages:Promise.resolve(c(c([],m.messages,!0),[U],!1)),dataStream:(0,u.createAsyncIterable)(x),textStream:(0,u.createAsyncIterable)(M.pipeThrough(new u.TransformStream({transform:function(e,t){var n,r,o,i=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:Promise.resolve(r)}]):(q=(0,u.createPromise)(),F=(0,u.createPromise)(),B={role:"assistant",content:""},W="",H={completion_tokens:0,prompt_tokens:0,total_tokens:0},G=_.pipeThrough(new u.TransformStream({transform:function(e,t){var n,r,o,i,s,a,c,u,l=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof l&&(B.content+=l);var h=null===(s=null===(i=null==e?void 0:e.choices)||void 0===i?void 0:i[0])||void 0===s?void 0:s.finish_reason;h&&(W=h),(null===(a=null==e?void 0:e.usage)||void 0===a?void 0:a.completion_tokens)&&(H.completion_tokens=e.usage.completion_tokens),(null===(c=null==e?void 0:e.usage)||void 0===c?void 0:c.prompt_tokens)&&(H.prompt_tokens=e.usage.prompt_tokens),(null===(u=null==e?void 0:e.usage)||void 0===u?void 0:u.total_tokens)&&(H.total_tokens=e.usage.total_tokens),t.enqueue(e)},flush:function(){q.res(c(c([],m.messages,!0),[B],!1)),y(r,H),F.res(Object.assign({},r)),null==d||d({messages:c(c([],m.messages,!0),[B],!1),finishReason:W,text:B.content,stepUsage:H,totalUsage:Object.assign({},r)})}})),V=G.tee(),K=V[0],J=V[1],[2,{messages:q.promise,dataStream:(0,u.createAsyncIterable)(K),textStream:(0,u.createAsyncIterable)(J.pipeThrough(new u.TransformStream({transform:function(e,t){var n,r,o,i=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:F.promise}])}})})},e}();function d(e){var t,n=null===(t=null==e?void 0:e.choices)||void 0===t?void 0:t[0];if(!n)return null;var r=n.finish_reason,o=n.message;return"tool_calls"!==r?null:o&&(0,u.isToolCallAssistantMessage)(o)?o.tool_calls[0]:null}function f(e,t,n){e.push(t,{role:"tool",tool_call_id:t.tool_calls[0].id,content:JSON.stringify(n)})}function p(e){return t.toolMap.get(e.function.name)(JSON.parse(e.function.arguments))}function v(e){var t,n,r;return{completion_tokens:null!==(t=null==e?void 0:e.completion_tokens)&&void 0!==t?t:0,prompt_tokens:null!==(n=null==e?void 0:e.prompt_tokens)&&void 0!==n?n:0,total_tokens:null!==(r=null==e?void 0:e.total_tokens)&&void 0!==r?r:0}}function y(e,t){e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens}t.ReactModel=h,t.toolMap=new Map},4669:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleChatModel=void 0;t.SimpleChatModel=function(){}},1689:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},i=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise(function(r,o){!function(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}(r,o,(t=e[n](t)).done,t.value)})}}};Object.defineProperty(t,"__esModule",{value:!0}),t.functionToolToModelTool=t.isToolCallAssistantMessage=t.createPromise=t.readableStream2JsonObject=t.intoTextStream=t.intoStandardStream=t.createAsyncIterable=t.TextDecoderStream=t.toPolyfillReadable=t.createEventSourceParserTransformStream=t.TransformStream=t.ReadableStream=void 0;var s=n(8775),a=n(766),c=n(9964),u=n(6282),l="function"==typeof globalThis.ReadableStream&&"function"==typeof globalThis.TransformStream&&"function"==typeof globalThis.ReadableStream.prototype.pipeThrough;t.ReadableStream=l?globalThis.ReadableStream:s.ReadableStream,t.TransformStream=l?globalThis.TransformStream:s.TransformStream,t.createEventSourceParserTransformStream=function(){var e;return new t.TransformStream({start:function(t){e=(0,c.createParser)(function(e){"event"===e.type&&t.enqueue(e)})},transform:function(t){e.feed(t)}})},t.toPolyfillReadable=l?function(e){return e}:(0,a.createReadableStreamWrapper)(t.ReadableStream);var h=function(){function e(e,n){void 0===e&&(e="utf-8"),void 0===n&&(n={});var r=this;this.transform=new t.TransformStream({transform:function(e,t){var n=r.handle.decode(new Uint8Array(e),{stream:!0});n&&t.enqueue(n)},flush:function(e){var t=r.handle.decode();t&&e.enqueue(t),e.terminate()}}),this.handle=new u.TextDecoder(e,n)}return Object.defineProperty(e.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),e}();function d(e){var t=e;return t[Symbol.asyncIterator]=function(){var t=e.getReader();return{next:function(){return r(this,void 0,Promise,function(){var e,n,r;return o(this,function(o){switch(o.label){case 0:return[4,t.read()];case 1:return e=o.sent(),n=e.done,r=e.value,[2,n?{done:!0,value:void 0}:{done:!1,value:r}]}})})}}},t}function f(e){return d((0,t.toPolyfillReadable)(e).pipeThrough(new h))}t.TextDecoderStream=h,t.createAsyncIterable=d,t.intoStandardStream=function(e){return d(e.pipeThrough(new h).pipeThrough((0,t.createEventSourceParserTransformStream)()).pipeThrough(new t.TransformStream({transform:function(e,t){try{var n=JSON.parse(e.data);t.enqueue(n)}catch(n){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",n,e):t.terminate()}}})))},t.intoTextStream=f,t.readableStream2JsonObject=function(e){var t,n,s,a;return r(this,void 0,void 0,function(){var r,c,u,l,h,d;return o(this,function(o){switch(o.label){case 0:r=f(e),c="",o.label=1;case 1:o.trys.push([1,6,7,12]),u=!0,l=i(r),o.label=2;case 2:return[4,l.next()];case 3:if(h=o.sent(),t=h.done)return[3,5];a=h.value,u=!1;try{c+=a}finally{u=!0}o.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return d=o.sent(),n={error:d},[3,12];case 7:return o.trys.push([7,,10,11]),u||t||!(s=l.return)?[3,9]:[4,s.call(l)];case 8:o.sent(),o.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,JSON.parse(c)]}})})},t.createPromise=function(){var e,t;return{promise:new Promise(function(n,r){e=n,t=r}),res:e,rej:t}},t.isToolCallAssistantMessage=function(e){var t;return"assistant"===e.role&&"tool_calls"in e&&null!=(null===(t=e.tool_calls)||void 0===t?void 0:t[0])},t.functionToolToModelTool=function(e){return{type:"function",function:{description:e.description,name:e.name,parameters:e.parameters}}}},5378:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateApis=t.generateCallApis=t.callApi=void 0;var s=n(794);function a(e,t){var n,a,c,u;return o(this,void 0,Promise,function(){var o,l,h,d,f,p,v,y,g,m,b,_,E,w,S,I,O,A,T,P,C,R,N;return i(this,function(i){switch(i.label){case 0:l=(o=e||{}).name,h=o.body,d=o.path,f=void 0===d?"":d,p=o.method,v=void 0===p?"POST":p,y=o.headers,g=void 0===y?{}:y,m=(e||{}).token,b={};try{b=JSON.parse(h)}catch(e){b=h||{}}if(!l)throw new Error(JSON.stringify({code:s.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return _="",w=(E=this).gatewayOrigin,S=E.getAccessToken,I=E.env,w?_="".concat(w,"/v1"):this.getEndPointWithKey?(O=this.getEndPointWithKey("GATEWAY"),A=O.BASE_URL,T=O.PROTOCOL,_="".concat(T).concat(A)):_="https://".concat(I,".api.tcloudbasegateway.com/v1"),P="".concat(_,"/apis/").concat(l),C=f.startsWith("/")?f:"/".concat(f),S?[4,S()]:[3,2];case 1:R=i.sent().accessToken,g.Authorization="Bearer ".concat(R),i.label=2;case 2:if(N=["GET","HEAD"].includes(null===(n=null==v?void 0:v.toUpperCase)||void 0===n?void 0:n.call(v)))try{C="".concat(C).concat(C.includes("?")?"&":"?").concat(Object.keys(b).map(function(e){return"".concat(e,"=").concat(b[e])}).join("&"))}catch(e){}return[4,this.request.fetch(r(r(r({url:"".concat(P).concat(C),method:v||"POST",headers:r({"Content-Type":"application/json; charset=utf-8"},g)},N?{}:{body:JSON.stringify(b)}),{token:(null===(a=null==m?void 0:m.trim)||void 0===a?void 0:a.call(m))||(null===(u=null===(c=g.Authorization)||void 0===c?void 0:c.replace)||void 0===u?void 0:u.call(c,/^Bearer /,""))||null}),t))];case 3:return[4,i.sent().data];case 4:return[2,i.sent()]}})})}t.callApi=a;var c=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function u(e){var t=this;return new Proxy({},{get:function(n,s){if("string"!=typeof s)throw new Error("[apis] method must be string");var u=s.toLocaleUpperCase();if(!c.includes(u))throw new Error("[apis] invalid method: ".concat(s));return function(n,s){return o(t,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,a.call(this,r({name:e,method:("REQUEST"===u?n.method:u)||"POST"},n),s)];case 1:return[2,t.sent()]}})})}}})}t.generateCallApis=u,t.generateApis=function(e){var t=this;return Object.keys(e||{}).forEach(function(n){void 0!==e[n]&&(t[n]=e[n])}),new Proxy({},{get:function(e,n){if("string"==typeof n)return u.call(t,n)}})}},1944:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.registerApis=t.generateApis=void 0;var i=n(5378);Object.defineProperty(t,"generateApis",{enumerable:!0,get:function(){return i.generateApis}});var s="apis",a={name:s,IIFE:!0,entity:function(){Object.defineProperty(this.prototype,s,{get:function(){return i.generateApis.call(this)},configurable:!0,enumerable:!0})}};function c(e){try{e.registerComponent(a)}catch(e){console.warn(e)}}t.registerApis=c;try{cloudbase.registerComponent(a)}catch(e){}o(n(2026),t);try{window.registerApis=c}catch(e){}},2026:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},7922:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.OAUTH2_LOGINTYPE_PREFIX=t.LOGINTYPE=t.getBaseEndPoint=t.setRegionLevelEndpoint=t.setGatewayEndPointWithEnv=t.getEndPointInfo=t.setEndPointInfo=t.DEFAULT_PROTOCOL=t.DATA_VERSION=t.getSdkName=t.setSdkName=t.getSdkVersion=t.setSdkVersion=void 0;var o=n(2877),i=o.constants.setSdkName,s=o.constants.setProtocol,a="",c="@cloudbase/js-sdk";t.setSdkVersion=function(e){a=e},t.getSdkVersion=function(){return a},t.setSdkName=function(e){c=e,i(e)},t.getSdkName=function(){return c},t.DATA_VERSION="2020-01-10";var u,l=[],h=["env","endPointKey","region"];function d(e){return l.find(function(t){return h.filter(function(t){return null!=e[t]}).every(function(n){return t[n]===e[n]})})}function f(e){var n,o;e.protocol&&!/:$/.test(e.protocol)&&(e.protocol="".concat(e.protocol,":"));var i=d(e);i?(null!=e.baseUrl&&(i.baseUrl=e.baseUrl),null!=e.protocol&&(i.protocol=e.protocol)):l.push(r(r({},e),{protocol:null!==(n=e.protocol)&&void 0!==n?n:t.DEFAULT_PROTOCOL})),"CLOUD_API"===e.endPointKey&&s(null!==(o=e.protocol)&&void 0!==o?o:t.DEFAULT_PROTOCOL)}function p(e,t,n){return d({env:e,endPointKey:t,region:n})}t.DEFAULT_PROTOCOL="https:",t.setEndPointInfo=f,t.getEndPointInfo=p,t.setGatewayEndPointWithEnv=function(e,t,n){var r="//".concat(e,".api.tcloudbasegateway.com/v1");n&&(r="//".concat(e,".api.intl.tcloudbasegateway.com/v1")),f({endPointKey:"GATEWAY",env:e,baseUrl:r,protocol:t})},t.setRegionLevelEndpoint=function(e,t,n){f({env:e,region:t,baseUrl:"//".concat(e,".").concat(t||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:n,endPointKey:"CLOUD_API"})},t.getBaseEndPoint=function(e,t){void 0===t&&(t="CLOUD_API");var n=p(e,t||"CLOUD_API"),r=n.protocol,o=n.baseUrl;return"".concat(r).concat(o).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]},(u=t.LOGINTYPE||(t.LOGINTYPE={})).NULL="NULL",u.ANONYMOUS="ANONYMOUS",u.WECHAT="WECHAT",u.WECHAT_PUBLIC="WECHAT-PUBLIC",u.WECHAT_OPEN="WECHAT-OPEN",u.CUSTOM="CUSTOM",u.EMAIL="EMAIL",u.USERNAME="USERNAME",u.PHONE="PHONE",t.OAUTH2_LOGINTYPE_PREFIX="OAUTH2"},6950:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.cloudbase=t.LANGS=t.getBaseEndPoint=void 0;var c=n(2877),u=n(4276),l=n(1985),h=n(6938),d=n(901),f=n(7922),p=n(3509),v=n(3809),y=n(7922);Object.defineProperty(t,"getBaseEndPoint",{enumerable:!0,get:function(){return y.getBaseEndPoint}});var g=n(3509);Object.defineProperty(t,"LANGS",{enumerable:!0,get:function(){return g.LANGS}});var m=c.adapters.useAdapters,b=c.adapters.useDefaultAdapter,_=c.constants.ERRORS,E=c.constants.COMMUNITY_SITE_URL,w=c.utils.printWarn,S=c.helpers.catchErrorsDecorator,I={persistence:"local"},O=6e5,A={},T=function(){function e(e){this.cloudbaseConfig=e||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.requestInstance=null,this.version=(0,f.getSdkVersion)()}return Object.defineProperty(e.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return l.Platform},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return(0,h.getCacheByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return(0,h.getLocalCache)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return this.requestInstance||(0,d.getRequestByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),e.prototype.init=function(t){var n,o,i,s,a;if(void 0===t&&(t={env:""}),t.endPointMode=t.endPointMode||"GATEWAY",l.Platform.adapter||this.useDefaultAdapter(),(t=this.dealNodeAdapterConfig(t)).throw=null===(o=null!==(n=t.throw)&&void 0!==n?n:t.throwOnCode)||void 0===o||o,delete t.throwOnCode,!t.env)throw new Error(JSON.stringify({code:_.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(t);var c=this.isNodeEnv()?void 0:15e3,u=t.timeout||c,y={env:t.env,region:t.region,accessKey:t.accessKey,context:t.context,auth:t.auth,timeout:u,timeoutMsg:u?"[".concat((0,f.getSdkName)(),"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(u/1e3,"s"):void 0};this.requestClient=new l.Platform.adapter.reqClass(y),this.cloudbaseConfig=r(r(r({},I),t),{timeout:u,i18n:(0,p.i18nProxy)(l.Platform,t)}),(0,v.registerThrowConfig)(this.cloudbaseConfig),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var g=this.cloudbaseConfig,m=g.env,b=g.persistence,E=g.debug,w=g.timeout,S=g.oauthClient,O=g.i18n;(0,h.initCache)({env:m,persistence:b,debug:E,platformInfo:this.platform}),(0,f.setRegionLevelEndpoint)(m,t.region||""),(0,f.setGatewayEndPointWithEnv)(m,f.DEFAULT_PROTOCOL,t.intl);var A=new e(this.cloudbaseConfig);return A.requestInstance=(0,d.initRequest)({env:m,region:t.region||"",timeout:w,oauthClient:S,_fromApp:A,i18n:O,endPointMode:t.endPointMode,auth:t.auth,context:t.context,accessKey:t.accessKey,throw:t.throw}),A.requestClient=this.requestClient,null===(i=null==this?void 0:this.fire)||void 0===i||i.call(this,"cloudbase_init",A),this.try2InitAuth(A),(null===(s=l.Platform.adapter)||void 0===s?void 0:s.nodeTool)&&(null===(a=l.Platform.adapter)||void 0===a||a.nodeTool(A,this.cloudbaseConfig)),A},e.prototype.updateConfig=function(e){var t=e.persistence,n=e.debug;this.cloudbaseConfig.persistence=t,this.cloudbaseConfig.debug=n,(0,h.initCache)({env:this.cloudbaseConfig.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.setThrowOnCode=function(e){this.cloudbaseConfig.throw=e},e.prototype.updateLang=function(e){var t;e&&e!==(null===(t=this.cloudbaseConfig.i18n)||void 0===t?void 0:t.lang)&&(this.cloudbaseConfig.i18n.lang=e)},e.prototype.registerExtension=function(e){A[e.name]=e},e.prototype.invokeExtension=function(e,t){return s(this,void 0,void 0,function(){var n;return a(this,function(r){switch(r.label){case 0:if(!(n=A[e]))throw new Error(JSON.stringify({code:_.INVALID_PARAMS,msg:"extension:".concat(e," must be registered before invoke")}));return[4,n.invoke(t,this)];case 1:return[2,r.sent()]}})})},e.prototype.useAdapters=function(e,t){var n=m(e,t)||{},r=n.adapter,o=n.runtime;r&&(l.Platform.adapter=r),o&&(l.Platform.runtime=o)},e.prototype.registerHook=function(t){(0,u.registerHook)(e,t)},e.prototype.registerComponent=function(t){(0,u.registerComponent)(e,t)},e.prototype.registerVersion=function(e){(0,f.setSdkVersion)(e),this.version=e},e.prototype.registerSdkName=function(e){(0,f.setSdkName)(e)},e.prototype.isInitialized=function(e){return void 0===e&&(e=this.cloudbaseConfig),"string"==typeof e.env&&["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some(function(t){return e.env.toLowerCase()===t.toLowerCase()})&&w(_.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(e.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==e?void 0:e.env)},e.prototype.registerEndPoint=function(e,t){(0,f.setEndPointInfo)({baseUrl:e,protocol:t,env:this.config.env,endPointKey:"CLOUD_API"})},e.prototype.registerEndPointWithKey=function(e){(0,f.setEndPointInfo)({env:this.config.env,endPointKey:e.key,baseUrl:e.url,protocol:e.protocol})},e.prototype.registerHost=function(e,t){void 0===t&&(t="http");var n=e.replace(/^(https?:)?\/\//,""),r="//".concat(n);(0,f.setEndPointInfo)({baseUrl:"".concat(r,"/web"),protocol:t,env:this.config.env,endPointKey:"CLOUD_API"}),(0,f.setEndPointInfo)({baseUrl:"".concat(r,"/v1"),protocol:t,env:this.config.env,endPointKey:"GATEWAY"})},e.prototype.getEndPointWithKey=function(e){var t=(0,f.getEndPointInfo)(this.config.env,e);return{BASE_URL:t.baseUrl,PROTOCOL:t.protocol}},e.prototype.parseCaptcha=function(e){return c.utils.parseCaptcha(e)},e.prototype.useDefaultAdapter=function(){var e=b.bind(this)(),t=e.adapter,n=e.runtime;l.Platform.adapter=t,l.Platform.runtime=n},e.prototype.isNodeEnv=function(){var e;return"undefined"!=typeof process&&!!(null===(e=l.Platform.adapter)||void 0===e?void 0:e.getSecretInfo)},e.prototype.formatTimeout=function(e){if(null==e)return e;switch(!0){case e>O:return w(_.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),O;case e<100:return w(_.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},e.prototype.try2InitAuth=function(e){try{e.auth()}catch(e){console.log("try2InitAuth error:",e)}},e.prototype.dealNodeAdapterConfig=function(e){var t,n,o,i,s;if(this.isNodeEnv()){var a=null===(t=l.Platform.adapter)||void 0===t?void 0:t.getSecretInfo(e);e.env&&"symbol"!=typeof e.env||(e.env=a.env),a.credentials&&(e.auth=r(r({},e.auth),{credentials:a.credentials}));var c=e,u=c.secretId||(null===(n=e.auth)||void 0===n?void 0:n.secretId),h=c.secretKey||(null===(o=e.auth)||void 0===o?void 0:o.secretKey);if(u&&h){var d=c.sessionToken||(null===(i=e.auth)||void 0===i?void 0:i.sessionToken)||"";e.auth=r(r({},e.auth),{secretId:u,secretKey:h,sessionToken:d,secretType:(null===(s=e.auth)||void 0===s?void 0:s.secretType)||(d?"SESSION_SECRET":"SECRET")})}}return e},o([S({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",e)],e.prototype,"init",null),o([S({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),i("design:type",Function),i("design:paramtypes",[String,Object]),i("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}();t.cloudbase=new T;var P=(0,l.getWxDefaultAdapter)();P&&t.cloudbase.useAdapters(P),t.default=t.cloudbase},1985:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.getWxDefaultAdapter=t.Platform=void 0;var c=s(n(7917)),u=n(2764);t.Platform={},t.getWxDefaultAdapter=function(){return void 0===c.WxRequest?null:(c.default.genAdapter=function(e){return{root:{globalThis:{}},reqClass:c.WxRequest,wsClass:c.WxMpWebSocket,captchaOptions:{openURIWithCallback:function(t){var n=e.EventBus,o={},i=t;console.log("openURIWithCallback",t);var s=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(s){i=s[1],console.log("openURIWithCallback url",i);var u=s[2];u&&(o=(0,c.parseQueryString)(u))}console.log("openURIWithCallback queryObj",o);var l=o.token,h=a(o,["token"]);return/^data:/.test(i)&&!l?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(t)}):l?new Promise(function(e){console.log("wait for captcha..."),n.$emit("CAPTCHA_DATA_CHANGE",r(r({},h),{token:l,url:i})),n.$once("RESOLVE_CAPTCHA_DATA",function(t){e(t)})}):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:c.wxMpStorage,primaryStorage:u.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},c.default)}},6938:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.getLocalCache=t.getCacheByEnvId=t.initCache=void 0;var o=n(2877).cache.CloudbaseCache,i={},s={};t.initCache=function(e){var t=e.env,n=e.platformInfo,a={userInfoKey:"".concat("user_info","_").concat(t)};i[t]=i[t]||new o(r(r({},e),{keys:a,platformInfo:n})),s[t]=s[t]||new o(r(r({},e),{keys:a,platformInfo:n,persistence:"local"}))},t.getCacheByEnvId=function(e){return i[e]},t.getLocalCache=function(e){return s[e]}},4276:function(e,t,n){"use strict";var r=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.registerHook=t.registerComponent=void 0;var o=n(2877).constants.ERRORS,i={};function s(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var n=0,r=Object.keys(t);n<r.length;n++){var o=r[n];Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=s(e[o],t[o]))}return e}t.registerComponent=function(e,t){var n=t.name,a=t.namespace,c=t.entity,u=t.injectEvents,l=t.IIFE,h=void 0!==l&&l;if(i[n]||a&&e[a])throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(h){if(!c||"function"!=typeof c)throw new Error(JSON.stringify({code:o.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));c.call(e)}if(i[n]=t,a?e.prototype[a]=c:s(e.prototype,c),u){var d=u.bus,f=u.events;if(!d||!f||0===f.length)return;var p=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[n]?e.prototype.events[n].events=r(r([],e.prototype.events[n].events,!0),f,!0):e.prototype.events[n]={bus:d,events:f},e.prototype.fire=function(e,t){p(e,t);for(var n=0,r=Object.keys(this.events);n<r.length;n++){var o=r[n],i=this.events[o],s=i.bus;if(i.events.includes(e)){s.fire(e,t);break}}}}},t.registerHook=function(e,t){var n=t.entity,i=t.target;if(Object.prototype.hasOwnProperty.call(e,i))throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:".concat(i," is not exist")}));var s=e.prototype[i];if("function"!=typeof s)throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:".concat(i," is not a function which is the only type supports hook")}));e.prototype[i]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.call.apply(n,r([this],e,!1)),s.call.apply(s,r([this],e,!1))}}},3509:function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.i18nProxy=t.t=t.langMap=t.LANG_HEADER_KEY=t.LANGS=void 0;var o,i=n(2877);!function(e){e.ZH="zh-CN",e.EN="en-US"}(o=t.LANGS||(t.LANGS={})),t.LANG_HEADER_KEY="Accept-Language",t.langMap=((r={})[o.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code","错误信息":"error message","未实现":"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs","请求超时":"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},r),t.t=function(e,n){var r;return(null===(r=t.langMap[n])||void 0===r?void 0:r[e])||e},t.i18nProxy=function(e,n){var r,s,a=function(e){return"lang_".concat(e.clientId||e.env)}(n),c=(e.adapter||{}).localStorage,u=n.lang||(null===(r=null==c?void 0:c.getItem)||void 0===r?void 0:r.call(c,a))||o.ZH;return null===(s=null==c?void 0:c.setItem)||void 0===s||s.call(c,a,u),new Proxy({t:function(e){return(0,t.t)(e,u)},LANG_HEADER_KEY:t.LANG_HEADER_KEY,lang:u},{get:function(e,t){var n;return"lang"===t&&(null===(n=null==c?void 0:c.getItem)||void 0===n?void 0:n.call(c,a))||e[t]},set:function(e,n,r){var o;return"lang"===n&&r!==e[n]&&(e[n]=r,e.t=function(e){return(0,t.t)(e,r)},null===(o=null==c?void 0:c.setItem)||void 0===o||o.call(c,a,r),i.langEvent.bus.fire(i.langEvent.LANG_CHANGE_EVENT,{i18n:e})),e[n]=r,!0}})}},901:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestByEnvId=t.initRequest=t.CloudbaseRequest=void 0;var a=n(7922),c=n(2877),u=n(6938),l=n(1985),h=c.constants.ERRORS,d=c.utils.genSeqId,f=c.utils.isFormData,p=c.utils.formatUrl,v=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function y(e,t,n){var o=e[t];e[t]=function(t){var i={},s={};n.forEach(function(n){var r=n.call(e,t),o=r.data,a=r.headers;Object.assign(i,o),Object.assign(s,a)});var a=t.data;return a&&(f(a)?Object.keys(i).forEach(function(e){a.append(e,i[e])}):t.data=r(r({},a),i)),t.headers=r(r({},t.headers||{}),s),o.call(e,t)}}function g(){var e=d();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat((0,a.getSdkVersion)()),"x-seqid":e}}}var m=function(){function e(e){var t=this;this.config=e;var n={env:this.config.env,region:this.config.region,accessKey:this.config.accessKey,context:this.config.context,auth:this.config.auth,timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"]};this.reqClass=new l.Platform.adapter.reqClass(n),this.localCache=(0,u.getLocalCache)(this.config.env),"GATEWAY"!==this.config.endPointMode&&(y(this.reqClass,"post",[g]),y(this.reqClass,"upload",[g]),y(this.reqClass,"download",[g])),c.langEvent.bus.on(c.langEvent.LANG_CHANGE_EVENT,function(e){var n;t.config.i18n=(null===(n=e.data)||void 0===n?void 0:n.i18n)||t.config.i18n})}return Object.defineProperty(e.prototype,"throwWhenRequestFail",{get:function(){var e,t,n,r,o=null===(n=null===(t=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===t?void 0:t.config)||void 0===n?void 0:n.throw;return"boolean"==typeof o?o:!1!==(null===(r=this.config)||void 0===r?void 0:r.throw)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"errorFactory",{get:function(){var e,t,n,r=this.config;return null!==(e=null==r?void 0:r.errorFactory)&&void 0!==e?e:null===(n=null===(t=null==r?void 0:r._fromApp)||void 0===t?void 0:t.config)||void 0===n?void 0:n.errorFactory},enumerable:!1,configurable:!0}),e.prototype.getAccessToken=function(e){return void 0===e&&(e=null),o(this,void 0,void 0,function(){var t,n,r;return i(this,function(o){switch(o.label){case 0:if(null!=e)return[2,e];if(!(t=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return n=t.oauthInstance,r=n.oauth2client,[4,this.getOauthAccessTokenV2(r)];case 1:return[2,o.sent().accessToken]}})})},e.prototype.getDefaultHeaders=function(){var e,t,n;return(e={})[null===(t=this.config.i18n)||void 0===t?void 0:t.LANG_HEADER_KEY]=null===(n=this.config.i18n)||void 0===n?void 0:n.lang,e["X-SDK-Version"]="@cloudbase/js-sdk/".concat((0,a.getSdkVersion)()),e},Object.defineProperty(e.prototype,"requestDebug",{get:function(){var e,t,n;return!0===(null===(n=null===(t=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===t?void 0:t.config)||void 0===n?void 0:n.debug)},enumerable:!1,configurable:!0}),e.prototype.post=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return[4,this.reqClass.post(r(r({},e),{headers:r(r({},e.headers),this.getDefaultHeaders()),customReqOpts:t,debug:this.requestDebug}))];case 1:return[2,n.sent()]}})})},e.prototype.upload=function(e){var t;return o(this,void 0,Promise,function(){var n,o,s;return i(this,function(i){switch(i.label){case 0:return o=null!==(t=(n=e).file)&&void 0!==t?t:n.fileContent,delete(s=r(r({},n),{file:o,headers:r(r({},n.headers),this.getDefaultHeaders()),debug:this.requestDebug})).fileContent,[4,this.reqClass.upload(s)];case 1:return[2,i.sent()]}})})},e.prototype.download=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.reqClass.download(r(r({},e),{headers:r(r({},e.headers),this.getDefaultHeaders()),debug:this.requestDebug}))];case 1:return[2,t.sent()]}})})},e.prototype.getUploadByteLength=function(e){var t,n;return null===(n=(t=this.reqClass).getUploadByteLength)||void 0===n?void 0:n.call(t,e)},e.prototype.getBaseEndPoint=function(e){return void 0===e&&(e="CLOUD_API"),(0,a.getBaseEndPoint)(this.config.env,e)},e.prototype.getOauthAccessTokenV2=function(e){return o(this,void 0,Promise,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return[4,e.getAccessToken()];case 1:return t=r.sent(),[4,e.getCredentials()];case 2:return n=r.sent(),[2,{accessToken:t,accessTokenExpire:new Date(n.expires_at).getTime()}]}})})},e.prototype.request=function(e,t,n,s){var c,u;return o(this,void 0,Promise,function(){var o,l,h,d,f,y,g,m,b,_,E,w,S,I,O,A,T,P,C,R,N,k,U;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,4,,5]),o="x-tcb-trace_".concat(this.config.env),l="application/x-www-form-urlencoded",h=r({action:e,dataVersion:a.DATA_VERSION,env:this.config.env},t),-1!==v.indexOf(e))return[3,2];if(!(d=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return f=d.oauthInstance,y=f.oauth2client,g=h,[4,this.getOauthAccessTokenV2(y)];case 1:g.access_token=i.sent().accessToken,i.label=2;case 2:return"storage.uploadFile"===e?(m=new FormData,Object.keys(m).forEach(function(e){Object.prototype.hasOwnProperty.call(m,e)&&void 0!==m[e]&&m.append(e,h[e])}),l="multipart/form-data"):(l="application/json;charset=UTF-8",m={},Object.keys(h).forEach(function(e){void 0!==h[e]&&(m[e]=h[e])})),b={headers:r(r({"content-type":l},this.getDefaultHeaders()),null==n?void 0:n.headers)},(null==n?void 0:n.onUploadProgress)&&(b.onUploadProgress=n.onUploadProgress),this.config.region&&(b.headers["X-TCB-Region"]=this.config.region),(_=this.localCache.getStore(o))&&(b.headers["X-TCB-Trace"]=_),E=void 0!==(null==n?void 0:n.parse)?n.parse:t.parse,w=void 0!==(null==n?void 0:n.inQuery)?n.inQuery:t.inQuery,S=void 0!==(null==n?void 0:n.search)?n.search:t.search,I=r(r({},(null==n?void 0:n.defaultQuery)||{}),{env:this.config.env}),E&&(I.parse=!0),w&&(I=r(r({},w),I)),O=(null==n?void 0:n.endPointMode)||this.config.endPointMode||"CLOUD_API",A=(0,a.getEndPointInfo)(this.config.env,O),T=A.baseUrl,P=A.protocol,"GATEWAY"===O&&/^((database)\.)|(auth\.wsWebSign)/.test(e)&&(C=(0,a.getEndPointInfo)(this.config.env,"CLOUD_API"),T="".concat(C.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),R=void 0,R=n.pathname?p(P,"".concat(null===(c=(0,a.getBaseEndPoint)(this.config.env,O))||void 0===c?void 0:c.replace(/^https?:/,""),"/").concat(n.pathname),I):p(P,T,I),S&&(R+=S),[4,this.post(r({url:R,data:m},b),s)];case 3:if(N=i.sent(),(k=null===(u=N.header)||void 0===u?void 0:u["x-tcb-trace"])&&this.localCache.setStore(o,k),200!==Number(N.status)&&200!==Number(N.statusCode)||!N.data)throw new Error("network request error");return[2,N];case 4:U=i.sent();try{U.requestId=U.requestId||(null==n?void 0:n.headers["x-request-id"])||(null==n?void 0:n.headers["X-Request-Id"])||""}catch(e){}throw U;case 5:return[2]}})})},e.prototype.fetch=function(e){var t,n,c,u,l,h,d,f;return o(this,void 0,Promise,function(){var p,v,y,g,m,b,_,E,w=this;return i(this,function(S){switch(S.label){case 0:p=e.token,v=e.headers,y=void 0===v?{}:v,g=e.withCredentials,m=void 0===g||g,b=s(e,["token","headers","withCredentials"]),_=function(){return o(w,void 0,void 0,function(){var e,t,n,o;return i(this,function(i){switch(i.label){case 0:if(e={},!m)return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getAccessToken(p)];case 2:return(t=i.sent())&&(e.Authorization="Bearer ".concat(t)),[3,4];case 3:if(n=i.sent(),"undefined"==typeof process||null==process.versions||null==process.versions.node)throw n;return[3,4];case 4:return o=r({headers:r(r(r({"X-SDK-Version":"@cloudbase/js-sdk/".concat((0,a.getSdkVersion)())},e),this.getDefaultHeaders()),y),withCredentials:m},b),[2,this.reqClass.fetch(o)]}})})},S.label=1;case 1:return S.trys.push([1,3,,6]),[4,_()];case 2:return[2,S.sent()];case 3:E=S.sent();try{E.requestId=E.requestId||y["x-request-id"]||y["X-Request-Id"]||""}catch(e){}if("ACCESS_TOKEN_EXPIRED"!==(null==E?void 0:E.code))return[3,5];if("function"!=typeof(null===(u=null===(c=null===(n=null===(t=this.config)||void 0===t?void 0:t._fromApp)||void 0===n?void 0:n.oauthInstance)||void 0===c?void 0:c.authApi)||void 0===u?void 0:u.refreshTokenForce))throw E;return[4,null===(f=null===(d=null===(h=null===(l=this.config)||void 0===l?void 0:l._fromApp)||void 0===h?void 0:h.oauthInstance)||void 0===d?void 0:d.authApi)||void 0===f?void 0:f.refreshTokenForce()];case 4:return S.sent(),[2,_()];case 5:throw E;case 6:return[2]}})})},e.prototype.send=function(e,t,n,s){return void 0===t&&(t={}),void 0===n&&(n={}),o(this,void 0,Promise,function(){var o;return i(this,function(i){switch(i.label){case 0:return[4,this.request(e,t,r(r({},n),{onUploadProgress:t.onUploadProgress}),s)];case 1:if((o=i.sent()).data.code&&this.throwWhenRequestFail)throw c.utils.createCloudbaseError({code:o.data.code,msg:o.data.message||"",requestId:o.requestId},this.errorFactory);return[2,o.data]}})})},e.prototype.gateWay=function(e,t){var n,s;return o(this,void 0,void 0,function(){var o,u,l,d,f,p,v,y,g,m,b,_,E,w,S,I,O,A,T;return i(this,function(i){switch(i.label){case 0:if(o=e.url,u=e.name,l=e.data,d=e.path,f=void 0===d?"":d,p=e.method,v=e.header,y=void 0===v?{}:v,!(u&&f||o))throw c.utils.createCloudbaseError({code:h.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"},this.errorFactory);try{g=l?JSON.stringify(l):""}catch(e){throw c.utils.createCloudbaseError({code:h.INVALID_PARAMS,msg:"[gateWay] invalid data"},this.errorFactory)}if(m=c.utils.generateRequestId(),b=(0,a.getEndPointInfo)(this.config.env,"GATEWAY"),_=b.baseUrl,E=b.protocol,w="".concat(E).concat(_).concat(o||"/".concat(f,"/").concat(u)),S=["GET","HEAD"].includes(null===(n=null==p?void 0:p.toUpperCase)||void 0===n?void 0:n.call(p)))try{I={};try{I=JSON.parse(l)}catch(e){I=l||{}}w="".concat(w).concat(w.includes("?")?"&":"?").concat(Object.keys(I).map(function(e){return"".concat(e,"=").concat(I[e])}).join("&"))}catch(e){}return[4,this.fetch(r(r({method:p||"POST",headers:r({"Content-Type":"application/json; charset=utf-8","X-Request-Id":m},y)},S?{}:{body:g}),{url:w,customReqOpts:t,shouldThrowOnError:null!==(s=e.shouldThrowOnError)&&void 0!==s?s:this.throwWhenRequestFail}))];case 1:return O=i.sent(),A=[r({requestId:m},O)],T={},[4,O.data];case 2:return[2,r.apply(void 0,A.concat([(T.data=i.sent(),T)]))]}})})},e}();t.CloudbaseRequest=m;var b={};t.initRequest=function(e){var t=new m(r(r({},e),{throw:e.throw}));return b[e.env]=t,t},t.getRequestByEnvId=function(e){return b[e]}},3809:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setThrowOnCode=t.registerThrowConfig=void 0;var n=new Set;t.registerThrowConfig=function(e){e&&"object"==typeof e&&n.add(e)},t.setThrowOnCode=function(e){n.forEach(function(t){t.throw=e})}},3548:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.useAuthAdapter=void 0;var s=n(1019),a=function(){function e(e){var t,n;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(n=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===n?void 0:n.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.localStorage.getItem(e)]})})},e.prototype.removeItem=function(e){return o(this,void 0,void 0,function(){return i(this,function(t){return this.localStorage.removeItem(e),[2]})})},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){return this.localStorage.setItem(e,t),[2]})})},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),c=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,u=function(e,t){var n,r,o,i,s=null===(n=null==t?void 0:t.headers)||void 0===n?void 0:n["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(i=null==t?void 0:t.url,c.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}};t.useAuthAdapter=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var n=r({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(n.storage=new a({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(n.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var s={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:e.auth},c=new t.reqClass(s);n.baseRequest=function(e,t){var n,s,a,l,h;return o(this,void 0,void 0,function(){var o,d,f,p;return i(this,function(i){switch(i.label){case 0:if(o={},d=(null===(n=t.method)||void 0===n?void 0:n.toLocaleLowerCase())||"post","function"!=typeof(f=null===(a=null===(s=null==c?void 0:c[d])||void 0===s?void 0:s.bind)||void 0===a?void 0:a.call(s,c)))throw new Error("invalid 【".concat(d,"】 request method"));i.label=1;case 1:return i.trys.push([1,3,,4]),(null===(l=t.headers)||void 0===l?void 0:l["content-type"])&&!(null===(h=t.headers)||void 0===h?void 0:h["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,f(r({url:e},t))];case 2:return o=i.sent(),o=u(o,r(r({},t),{url:e})),[3,4];case 3:throw p=i.sent(),o=r(r({},null==p?void 0:p.data),p);case 4:if(null==o?void 0:o.error)throw o;return[2,o]}})})}}}catch(e){console.error("user adapter generate fail:",e)}return n}(e,e.adapter):function(e,t){var n=r({},e),c={};if((null==t?void 0:t.captchaOptions)&&(n.captchaOptions=t.captchaOptions),!s.adapterForWxMp.isMatch()||e.storage&&e.baseRequest)return n;try{var l=s.adapterForWxMp.genAdapter({}),h=l.localStorage,d=l.reqClass;if(h&&(c.storage=new a({localStorage:h,adapter:t})),d){var f=new d({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});c.request=function(e){return function(t,n){return o(this,void 0,void 0,function(){return i(this,function(o){return[2,new Promise(function(o,i){var s=Object.assign({},n);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:t,data:s.body,timeout:e._timeout,method:s.method||"GET",header:s.headers,success:function(e){(e=u(e,r(r({},n),{url:t}))).error&&i(e),o(e)},fail:function(e){i({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{a.abort()}catch(e){}}}})})]})})}}(f)}return n.captchaOptions&&(c.baseRequest=c.request,c.request=void 0),r(r({},n),c)}catch(e){console.error("adapter generate fail:",e)}return n}(e,e.adapter)}},9895:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},c=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},u=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},l=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=t.AuthError=t.AuthErrorCode=t.AuthErrorCategory=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=t.Auth=t.generateAuthInstance=t.LoginState=t.User=void 0;var h=n(6722),d=n(3548),f=n(1019),p=n(5266),v=n(916);Object.defineProperty(t,"WeixinAuthProvider",{enumerable:!0,get:function(){return v.WeixinAuthProvider}}),Object.defineProperty(t,"CustomAuthProvider",{enumerable:!0,get:function(){return v.CustomAuthProvider}}),Object.defineProperty(t,"AnonymousAuthProvider",{enumerable:!0,get:function(){return v.AnonymousAuthProvider}});var y=n(2877),g=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},m=["avatar_url","avatarUrl"];function b(e){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(e).length:e.length}function _(e,t){if(e)for(var n=0,r=m;n<r.length;n++){var o=r[n],i=e[o];if(null!=i&&""!==i){var s=b(String(i));if(s>204800)throw new h.AuthError({error:"invalid_argument",error_code:h.AuthErrorCode.INVALID_ARGUMENT,error_description:"auth.".concat(t,'(params): "').concat(o,'" 超过 200KB 限制(当前 ').concat(s," 字节),请传入图片 URL 而非文件内容")},{method:t})}}}var E=t.User=function(){function e(e){var t=e.cache,n=e.oauthInstance;this.cache=t,this.oauthInstance=n,this.setUserInfo()}var t,n,r;return e.prototype.checkLocalInfo=function(){return c(this,void 0,void 0,function(){return u(this,function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]})})},e.prototype.checkLocalInfoAsync=function(){return c(this,void 0,void 0,function(){var e,t,n,r;return u(this,function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),n=this,[4,this.getLocalUserInfoAsync("email")];case 3:return n.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),r=this,[4,this.getLocalUserInfoAsync("username")];case 4:return r.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}})})},e.prototype.update=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return _(e,"update"),[4,this.oauthInstance.authApi.setUserProfile(i({},e))];case 1:return t=n.sent(),this.setLocalUserInfo(t),[2]}})})},e.prototype.updateUserBasicInfo=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return _(e,"updateUserBasicInfo"),[4,this.oauthInstance.authApi.updateUserBasicInfo(i({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}})})},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=n.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}})})},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,n=this.cache.getStore(t);return e?n[e]:n||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,n.sent()[e]]}})})},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,n=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach(function(t){e[t]=n[t]})},s([(0,f.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(t=void 0!==h.authModels&&h.authModels.UserProfile)?t:Object]),a("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"update",null),s([(0,f.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String,String]),a("design:returntype",void 0)],e.prototype,"updatePassword",null),s([(0,f.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],e.prototype,"updateUsername",null),s([(0,f.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(r="undefined"!=typeof Promise&&Promise)?r:Object)],e.prototype,"refresh",null),e}();(0,v.applyUserV1Compat)(E);var w=function(){function e(e){var t=e.envId,n=e.cache,r=e.oauthInstance;t||(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=n,this.oauthInstance=r,this.user=new E({cache:this.cache,oauthInstance:r})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return c(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}})})},e}();t.LoginState=w;var S=function(e){function t(t){var n=e.call(this)||this;return n.listeners=new Map,n.hasListenerSetUp=!1,n.config=t,n.oauthInstance=t.oauthInstance,n.cache=t.cache,n.init(),n.setAccessKey(),n}var n,r,d,v,m,b,E,S,I,O,A,T,P,C,R,N,k,U,D,L,j;return o(t,e),t.prototype.signInAnonymously=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,s;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return a.sent(),[4,this.createLoginState()];case 2:return t=a.sent(),[4,this.getSession()];case 3:return n=a.sent().data,r=(void 0===n?{}:n).session,[2,i(i({},t),{data:{user:r.user,session:r},error:null})];case 4:return o=a.sent(),(s=new h.AuthError(o,{method:"signInAnonymously"})).category===h.AuthErrorCategory.PROVIDER_NOT_ENABLED?(console.error(s.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(s.category,"]: ").concat(s.message)),s.loginMethodHint&&console.warn(s.loginMethodHint)),[2,{data:{user:null,session:null},error:s}];case 5:return[2]}})})},t.prototype.signUp=function(e){return c(this,void 0,Promise,function(){var t,n,r=this;return u(this,function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?(e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[4,this.oauthInstance.authApi.signUp(e)]):[3,2];case 1:return o.sent(),[2,this.createLoginState()];case 2:return o.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"signUp"),[4,this.getVerification(e.email?{email:e.email,usage:h.VerificationUsage.EMAIL}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=o.sent(),[2,{data:{verifyOtp:function(n){var o=n.token,s=n.messageId,a=void 0===s?t.verification_id:s;return c(r,void 0,Promise,function(){var n,r,s,c,l;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.verify({verification_id:a||t.verification_id,verification_code:String(o)})];case 1:return n=u.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:n.verification_token})]:[3,3];case 2:return u.sent(),[3,6];case 3:return delete(r=JSON.parse(JSON.stringify(e))).email,delete r.phone,[4,this.oauthInstance.authApi.signUp(i(i(i({},r),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:n.verification_token,verification_code:o}))];case 4:return u.sent(),[4,this.createLoginState()];case 5:u.sent(),u.label=6;case 6:return[4,this.getSession()];case 7:return s=u.sent().data,[2,{data:{user:(c=(void 0===s?{}:s).session).user,session:c},error:null}];case 8:return l=u.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(l,{method:"signUp"})}];case 9:return[2]}})})}},error:null}];case 4:return n=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(n,{method:"signUp"})}];case 5:return[2]}})})},t.prototype.signOut=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return n=o.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return o.sent(),this.setAccessKey(),[2,i(i({},n),{data:{},error:null})];case 3:return r=o.sent(),[2,{data:{},error:new h.AuthError(r,{method:"signOut"})}];case 4:return[2]}})})},t.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var n=Math.random().toString(36);return this.listeners.has(n)||this.listeners.set(n,new Set),this.listeners.get(n).add(e),{data:{subscription:{id:n,callback:e,unsubscribe:function(){var r=t.listeners.get(n);r&&(r.delete(e),0===r.size&&t.listeners.delete(n))}}}}},t.prototype.signInWithPassword=function(e){var t,n;return c(this,void 0,Promise,function(){var r,o,s,a,c,l,d,f;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"signInWithPassword"),this.validateParams(e,{password:{required:!0,message:"Password is required"}},"signInWithPassword"),r="username"in e?e.username:void 0,o="email"in e?e.email:void 0,s="phone"in e?e.phone:void 0,a=null!==(n=null===(t=e.options)||void 0===t?void 0:t.is_encrypt)&&void 0!==n?n:e.is_encrypt,[4,this.signIn(i({username:r||o||this.formatPhone(s),password:e.password},a?{isEncrypt:!0,version:"v2"}:{}))];case 1:return u.sent(),[4,this.getSession()];case 2:return c=u.sent().data,[2,{data:{user:(l=(void 0===c?{}:c).session).user,session:l},error:null}];case 3:return d=u.sent(),(f=new h.AuthError(d,{method:"signInWithPassword"})).category===h.AuthErrorCategory.PROVIDER_NOT_ENABLED?console.error(f.helpMessage):f.category===h.AuthErrorCategory.INVALID_CREDENTIALS||f.category===h.AuthErrorCategory.USER_NOT_FOUND?console.warn(f.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(f.category,"]: ").concat(f.message)),f.loginMethodHint&&console.info(f.loginMethodHint),[2,{data:{user:null,session:null},error:f}];case 4:return[2]}})})},t.prototype.signInWithIdToken=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}},"signInWithIdToken"),[4,this.signInWithProvider({provider_id:e.provider,provider_id_token:e.token})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(n=(void 0===t?{}:t).session).user,session:n},error:null}];case 3:return r=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"signInWithIdToken"})}];case 4:return[2]}})})},t.prototype.signInWithOtp=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,s,a=this;return u(this,function(l){switch(l.label){case 0:if(t=e.options,n="email"in e?e.email:void 0,r="phone"in e?e.phone:void 0,!(null==t?void 0:t.emailRedirectTo)&&(void 0===(null==t?void 0:t.shouldCreateUser)||(null==t?void 0:t.shouldCreateUser)))return[2,this.signUp(n?{email:n}:{phone:r})];l.label=1;case 1:return l.trys.push([1,3,,4]),this.validateAtLeastOne(e,[["email"],["phone"]],"signInWithOtp"),[4,this.getVerification(i(i({email_redirect_to:null==t?void 0:t.emailRedirectTo},n?{email:n,usage:h.VerificationUsage.EMAIL}:{phone_number:this.formatPhone(r)}),{target:(null==t?void 0:t.emailRedirectTo)&&(null==t?void 0:t.shouldCreateUser)?"ANY":"USER"}))];case 2:return o=l.sent(),[2,{data:{user:null,session:null,verifyOtp:function(e){var t=e.token,i=e.messageId,s=void 0===i?o.verification_id:i;return c(a,void 0,Promise,function(){return u(this,function(e){return[2,this.verifyOtp(n?{email:n,token:String(t),messageId:s||""}:{phone:r,token:String(t),messageId:s||""})]})})}},error:null}];case 3:return s=l.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"signInWithOtp"})}];case 4:return[2]}})})},t.prototype.verifyOAuth=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,s,a,c,l,d;return u(this,function(u){switch(u.label){case 0:t={},u.label=1;case 1:return u.trys.push([1,7,,8]),n=(null==e?void 0:e.code)||y.utils.getQuery("code"),r=(null==e?void 0:e.state)||y.utils.getQuery("state"),n?r?(o=(0,p.getBrowserSession)(r),t.type=null==o?void 0:o.type,(s=(null==e?void 0:e.provider)||(null==o?void 0:o.provider)||y.utils.getQuery("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:n})]:[2,{data:i(i({},t),{user:null,session:null,redirectUrl:null}),error:this.missingRequiredParam("verifyOAuth","provider")}]):[2,{data:{user:null,session:null,redirectUrl:null},error:this.missingRequiredParam("verifyOAuth","state")}]:[2,{data:{user:null,session:null,redirectUrl:null},error:this.missingRequiredParam("verifyOAuth","code")}];case 2:return a=u.sent().provider_token,c=void 0,o.type!==h.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return c=u.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(c=u.sent()).data=i(i({},t),c.data),u.label=6;case 6:return(l=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),l.delete("state"),c.data.redirectUrl=(0,p.addUrlSearch)(void 0===(null==o?void 0:o.search)?"?".concat(l.toString()):null==o?void 0:o.search,(null==o?void 0:o.hash)||location.hash),(0,p.removeBrowserSession)(r),[2,c];case 7:return d=u.sent(),[2,{data:i(i({},t),{user:null,session:null,redirectUrl:null}),error:new h.AuthError(d,{method:"verifyOAuth"})}];case 8:return[2]}})})},t.prototype.signInWithOAuth=function(e){var t,n,r,o,i;return c(this,void 0,Promise,function(){var s,a,c,l,d,f,v,y,m;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}},"signInWithOAuth"),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),c=a.origin+a.pathname,l=(null===(n=e.options)||void 0===n?void 0:n.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:c,state:l})];case 1:return d=u.sent().uri,f=decodeURIComponent(d),v=f,(null===(r=e.options)||void 0===r?void 0:r.queryParams)&&(y=new URL(f),Object.entries(e.options.queryParams).forEach(function(e){var t=e[0],n=e[1];y.searchParams.set(t,n)}),v=y.toString()),(0,p.saveToBrowserSession)(l,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(o=e.options)||void 0===o?void 0:o.type)||h.OAUTH_TYPE.SIGN_IN}),g()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(v),[2,{data:{url:v,provider:e.provider},error:null}];case 2:return m=u.sent(),[2,{data:{url:null,provider:null},error:new h.AuthError(m,{method:"signInWithOAuth"})}];case 3:return[2]}})})},t.prototype.getClaims=function(){return c(this,void 0,Promise,function(){var e,t;return u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=n.sent().accessToken,[2,{data:(0,h.weAppJwtDecodeAll)(e),error:null}];case 2:return t=n.sent(),[2,{data:{claims:null,header:null,signature:null},error:new h.AuthError(t,{method:"getClaims"})}];case 3:return[2]}})})},t.prototype.resetPasswordForEmail=function(e,t){return c(this,void 0,Promise,function(){var n,r,o,s,a,l,d=this;return u(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}},"resetPasswordForEmail"),n=(t||{}).redirectTo,r=e.includes("@"),o=void 0,r?o={email:e,usage:h.VerificationUsage.RECOVERY}:(s=this.formatPhone(e),o={phone_number:s}),[4,this.getVerification(i(i({},o),{target:"USER"}))];case 1:return a=f.sent(),[2,{data:{updateUser:function(t){return c(d,void 0,Promise,function(){var o,i,s,c;return u(this,function(u){switch(u.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}},"resetPasswordForEmail"),u.label=1;case 1:return u.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:t.nonce})];case 2:return o=u.sent(),[4,this.oauthInstance.authApi.resetPassword({email:r?e:void 0,phone_number:r?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return u.sent(),null===(c=this.config.eventBus)||void 0===c||c.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:r?e:void 0,phone:r?void 0:e,password:t.password})];case 4:return i=u.sent(),n&&g()&&window.location.assign(n),[2,i];case 5:return s=u.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"resetPasswordForEmail"})}];case 6:return[2]}})})}},error:null}];case 2:return l=f.sent(),[2,{data:{updateUser:null},error:new h.AuthError(l,{method:"resetPasswordForEmail"})}];case 3:return[2]}})})},t.prototype.resetPasswordForOld=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(n=(void 0===t?{}:t).session).user,session:n},error:null}];case 3:return r=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"resetPasswordForOld"})}];case 4:return[2]}})})},t.prototype.verifyOtp=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,i,s,a;return u(this,function(c){switch(c.label){case 0:return c.trys.push([0,6,,7]),t=e.type,n=String(e.token),r="email"in e?e.email:void 0,o="phone"in e?e.phone:void 0,this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}},"verifyOtp"),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:n})]:[3,2];case 1:return c.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:n,username:r||this.formatPhone(o)||"",loginType:r?"email":"phone"})];case 3:c.sent(),c.label=4;case 4:return[4,this.getSession()];case 5:return i=c.sent().data,[2,{data:{user:(s=(void 0===i?{}:i).session).user,session:s},error:null}];case 6:return a=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(a,{method:"verifyOtp"})}];case 7:return[2]}})})},t.prototype.getSession=function(){return c(this,void 0,Promise,function(){var e,t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=o.sent())&&"accessKey"!==e.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return t=o.sent().data,n=(void 0===t?{}:t).user,[2,{data:{session:i(i({},e),{user:n}),user:n},error:null}];case 3:return r=o.sent(),[2,{data:{session:null,user:null},error:new h.AuthError(r,{method:"getSession"})}];case 4:return[2]}})})},t.prototype.refreshSession=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,s;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=a.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return n=a.sent(),[4,this.getUser(!1)];case 3:return r=a.sent().data,[2,{data:{user:o=(void 0===r?{}:r).user,session:i(i({},n),{user:o})},error:null}];case 4:return s=a.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"refreshSession"})}];case 5:return[2]}})})},t.prototype.getUser=function(e){return void 0===e&&(e=!0),c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=o.sent())&&"accessKey"!==t.scope?(n=this.convertToUser,[4,this.getCurrentUser(e)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:n.apply(this,[o.sent()])},error:null}];case 3:return r=o.sent(),[2,{data:{user:null},error:new h.AuthError(r,{method:"getUser"})}];case 4:return[2]}})})},t.prototype.refreshUser=function(){return c(this,void 0,Promise,function(){var e,t,n;return u(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return r.sent(),[4,this.getSession()];case 2:return e=r.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return n=r.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(n,{method:"refreshUser"})}];case 4:return[2]}})})},t.prototype.updateUser=function(e){var t;return c(this,void 0,Promise,function(){var n,r,o,s,a,d,f,p,v,y,g,m,b,E=this;return u(this,function(w){switch(w.label){case 0:if(w.trys.push([0,8,,9]),_(e,"updateUser"),n=["password","new_password"].find(function(t){var n=e[t];return null!=n&&""!==n}))throw new h.AuthError({message:'updateUser 不支持更新密码,检测到传入了 "'.concat(n,'" 参数。如需修改密码请使用 resetPasswordForOld(旧密码修改)、resetPasswordForEmail(验证码重置)或 reauthenticate(重新认证后改密)')});if(!Object.keys(e).some(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}))throw this.missingRequiredParam("updateUser","(at least one field)");return r=e.email,o=e.phone,s=l(e,["email","phone"]),d=void 0!==o,f={},(a=void 0!==r)||d?(p=void 0,a?(p={email:e.email,usage:h.VerificationUsage.REAUTHENTICATION},v="email_change"):(y=this.formatPhone(e.phone),p={phone_number:y},v="phone_change"),[4,this.getVerification(i({},p))]):[3,4];case 1:return g=w.sent(),Object.keys(s).length>0?[4,this.updateUserBasicInfo(s)]:[3,3];case 2:w.sent(),w.label=3;case 3:return f={messageId:g.verification_id,verifyOtp:function(t){return c(E,void 0,Promise,function(){var n,r,o,i;return u(this,function(s){switch(s.label){case 0:return s.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:g.verification_id||""})]:[3,3];case 1:return(n=s.sent()).error?[2,n]:[4,this.updateUserBasicInfo({email:e.email})];case 2:return s.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:g.verification_id||""})]:[3,6];case 4:return(n=s.sent()).error?[2,n]:[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return s.sent(),[3,9];case 6:return[4,this.verifyOtp(a?{type:v,email:e.email,token:t.token,messageId:g.verification_id||""}:{type:v,phone:e.phone,token:t.token,messageId:g.verification_id||""})];case 7:return(n=s.sent()).error?[2,n]:[4,this.updateUserBasicInfo(e)];case 8:s.sent(),s.label=9;case 9:return[4,this.getUser(!1)];case 10:return r=s.sent().data.user,null===(i=this.config.eventBus)||void 0===i||i.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:r},error:null}];case 11:return o=s.sent(),[2,{data:{user:null},error:new h.AuthError(o,{method:"updateUser"})}];case 12:return[2]}})})}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:w.sent(),w.label=6;case 6:return[4,this.getUser(!1)];case 7:return m=w.sent().data.user,Object.keys(s).length>0&&(null===(t=this.config.eventBus)||void 0===t||t.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.USER_UPDATED})),[2,{data:i({user:m},f),error:null}];case 8:return b=w.sent(),[2,{data:{user:null},error:new h.AuthError(b,{method:"updateUser"})}];case 9:return[2]}})})},t.prototype.getUserIdentities=function(){var e;return c(this,void 0,Promise,function(){var t,n;return u(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=r.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter(function(e){return!!e.bind})},error:null}];case 2:return n=r.sent(),[2,{data:{identities:null},error:new h.AuthError(n,{method:"getUserIdentities"})}];case 3:return[2]}})})},t.prototype.linkIdentity=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}},"linkIdentity"),[4,this.signInWithOAuth({provider:e.provider,options:{type:h.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return n.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=n.sent(),[2,{data:{provider:null},error:new h.AuthError(t,{method:"linkIdentity"})}];case 3:return[2]}})})},t.prototype.unlinkIdentity=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}},"unlinkIdentity"),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return n.sent(),[2,{data:{},error:null}];case 2:return t=n.sent(),[2,{data:{},error:new h.AuthError(t,{method:"unlinkIdentity"})}];case 3:return[2]}})})},t.prototype.reauthenticate=function(){return c(this,void 0,Promise,function(){var e,t,n,r,o=this;return u(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return e=s.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"reauthenticate"),t=e.email?{email:e.email,usage:h.VerificationUsage.REAUTHENTICATION}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return n=s.sent(),[2,{data:{updateUser:function(e){return c(o,void 0,Promise,function(){var r,o,s,a,c;return u(this,function(u){switch(u.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}},"reauthenticate"),u.label=1;case 1:return u.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:n.verification_id,verification_code:e.nonce})]:[3,5];case 2:return r=u.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:r.verification_token})];case 3:return o=u.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:o.sudo_token})];case 4:return u.sent(),[3,7];case 5:return[4,this.signInWithUsername(i(i({verificationInfo:n,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:u.sent(),u.label=7;case 7:return[4,this.getSession()];case 8:return s=u.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return c=u.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(c,{method:"reauthenticate"})}];case 10:return[2]}})})}},error:null}];case 3:return r=s.sent(),[2,{data:{updateUser:null},error:new h.AuthError(r,{method:"reauthenticate"})}];case 4:return[2]}})})},t.prototype.resend=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"resend"),t="signup"===e.type?"ANY":"USER",n={target:t},"email"in e&&(n.email=e.email,n.usage=h.VerificationUsage.EMAIL),"phone"in e&&(n.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(n)];case 1:return[2,{data:{messageId:o.sent().verification_id},error:null}];case 2:return r=o.sent(),[2,{data:{messageId:null},error:new h.AuthError(r,{method:"resend"})}];case 3:return[2]}})})},t.prototype.setSession=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}},"setSession"),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(n=(void 0===t?{}:t).session).user,session:n},error:null}];case 3:return r=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"setSession"})}];case 4:return[2]}})})},t.prototype.exchangeCodeForSession=function(){return c(this,void 0,void 0,function(){return u(this,function(e){return[2]})})},t.prototype.deleteUser=function(e){return c(this,void 0,Promise,function(){var t,n;return u(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}},"deleteUser"),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=r.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return r.sent(),[2,{data:{},error:null}];case 3:return n=r.sent(),[2,{data:{},error:new h.AuthError(n,{method:"deleteUser"})}];case 4:return[2]}})})},t.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),c(this,void 0,Promise,function(){var t,n,r,o,i;return u(this,function(s){try{return t=e.config_version||"env",n=Object.keys(e.query||{}).map(function(t){return"".concat(t,"=").concat(e.query[t])}).join("&"),f.adapterForWxMp.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(n?"?".concat(n):"")}):(r=e.redirect_uri||window.location.href,o=new URL(r),i="".concat(o.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(r)).concat(n?"&".concat(n):""),window.location.href=i),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new h.AuthError(e,{method:"toDefaultLoginPage"})}]}return[2]})})},t.prototype.signInWithCustomTicket=function(e){return c(this,void 0,Promise,function(){var t,n,r,o;return u(this,function(s){switch(s.label){case 0:e&&this.setCustomSignFunc(e),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return t=s.sent(),[4,this.getSession()];case 4:return n=s.sent().data,r=(void 0===n?{}:n).session,[2,i(i({},t),{data:{user:r.user,session:r},error:null})];case 5:return o=s.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(o,{method:"signInWithCustomTicket"})}];case 6:return[2]}})})},t.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,n=void 0===t||t;return c(this,void 0,Promise,function(){var e,t,r,o,s,a,l=this;return u(this,function(d){switch(d.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return c(l,void 0,void 0,function(){var r,o;return u(this,function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},n)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:r.provider_token},n)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}})})},d.label=1;case 1:return d.trys.push([1,5,,6]),[4,new Promise(function(e,n){wx.login({success:function(r){return c(l,void 0,void 0,function(){var o;return u(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(r.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),n(o),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})})];case 2:return d.sent(),[4,this.createLoginState()];case 3:return r=d.sent(),[4,this.getSession()];case 4:return o=d.sent().data,s=(void 0===o?{}:o).session,[2,i(i({},r),{data:{user:s.user,session:s},error:null})];case 5:return a=d.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(a,{method:"signInWithOpenId"})}];case 6:return[2]}})})},t.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,n=void 0===t?"":t,r=e.useWxCloud,o=void 0!==r&&r;return c(this,void 0,Promise,function(){var e,t,r,s,a,c,l,d,p;return u(this,function(u){switch(u.label){case 0:return f.adapterForWxMp.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone",code:n,appid:e.appId},provider_id:e.appId},[4,wx.login()]):[2,{data:{user:null,session:null},error:new h.AuthError({message:"wx api undefined"})}];case 1:r=u.sent().code,t.provider_code=r,u.label=2;case 2:return u.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(t,o)];case 3:if((s=u.sent()).error_code)throw s;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:s.provider_token},o)];case 4:if(null==(a=u.sent())?void 0:a.error_code)throw a;return[3,6];case 5:return c=u.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(c,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return l=u.sent(),[4,this.getSession()];case 8:return d=u.sent().data,p=(void 0===d?{}:d).session,[2,i(i({},l),{data:{user:p.user,session:p},error:null})]}})})},t.prototype.bindPhoneNumber=function(e){return c(this,void 0,void 0,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.editContact(e)]})})},t.prototype.unbindProvider=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]})})},t.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},t.prototype.verify=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.verify(e)]})})},t.prototype.getVerification=function(e,t){return c(this,void 0,Promise,function(){return u(this,function(n){return e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[2,this.oauthInstance.authApi.getVerification(e,t)]})})},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(e){return void 0===e&&(e=!0),c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),e?[4,this.getLoginState()]:[3,3];case 1:return(t=o.sent())?[4,t.user.refresh()]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return o.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(n=o.sent())?(r=n.user.getLocalUserInfo(),[4,n.user.checkLocalInfoAsync()]):[3,8];case 7:return o.sent(),[2,i(i({},n.user),r)];case 8:return[2,null]}})})},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return c(this,void 0,Promise,function(){var e,n,r=this;return u(this,function(o){switch(o.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,n=function(n){return c(r,void 0,void 0,function(){var r,o;return u(this,function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:n,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:r.provider_token},t)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}})})},[4,new Promise(function(e,t){wx.login({success:function(o){return c(r,void 0,void 0,function(){var r;return u(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,n(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),t(r),[3,3];case 3:return[2]}})})},fail:function(e){var n=new Error(null==e?void 0:e.errMsg);n.code=null==e?void 0:e.errno,t(n)}})})];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}})})},t.prototype.bindOpenId=function(){return c(this,void 0,Promise,function(){var e,t,n=this;return u(this,function(r){switch(r.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return c(n,void 0,void 0,function(){var n;return u(this,function(r){switch(r.label){case 0:n=void 0,r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(n=r.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:n.provider_token})];case 3:return r.sent(),[3,5];case 4:throw r.sent();case 5:return[2]}})})},[4,new Promise(function(e,r){wx.login({success:function(o){return c(n,void 0,void 0,function(){var n;return u(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),r(n),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 1:return r.sent(),[2]}})})},t.prototype.signInWithUnionId=function(){return c(this,void 0,Promise,function(){var e=this;return u(this,function(t){switch(t.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise(function(t,n){var r=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return c(e,void 0,void 0,function(){var e,i,s,a,c;return u(this,function(u){switch(u.label){case 0:e=null==r?void 0:r.appId,u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==r?void 0:r.appId}})];case 2:return i=u.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(n(i),[2]);case 3:return(null==(a=u.sent())?void 0:a.error_code)?(n(a),[2]):(t(!0),[3,5]);case 4:return c=u.sent(),n(c),[3,5];case 5:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})})];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}})})},t.prototype.signInWithSms=function(e){var t=e.verificationInfo,n=void 0===t?{verification_id:"",is_user:!1}:t,r=e.verificationCode,o=void 0===r?"":r,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,l=void 0===a?void 0:a;return c(this,void 0,Promise,function(){return u(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:l,username:s,loginType:"sms"})]}catch(e){throw e}return[2]})})},t.prototype.signInWithEmail=function(e){var t=e.verificationInfo,n=void 0===t?{verification_id:"",is_user:!1}:t,r=e.verificationCode,o=void 0===r?"":r,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,l=void 0===a?"":a;return c(this,void 0,Promise,function(){return u(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:s,username:l,loginType:"email"})]}catch(e){throw e}return[2]})})},t.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},t.prototype.signIn=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.setPassword=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.setPassword(e)]})})},t.prototype.isUsernameRegistered=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}})})},t.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new w({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},t.prototype.getLoginState=function(){return c(this,void 0,Promise,function(){var e;return u(this,function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new w({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}})})},t.prototype.getUserInfo=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.getCurrentUser()]})})},t.prototype.getWedaUserInfo=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]})})},t.prototype.updateUserBasicInfo=function(e){return c(this,void 0,void 0,function(){var t;return u(this,function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return(t=n.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]})})},t.prototype.queryUser=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]})})},t.prototype.getAccessToken=function(){return c(this,void 0,Promise,function(){return u(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}})})},t.prototype.grantProviderToken=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]})})},t.prototype.patchProviderToken=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]})})},t.prototype.signInWithProvider=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),c(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.grantToken=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}})})},t.prototype.genProviderRedirectUri=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]})})},t.prototype.resetPassword=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]})})},t.prototype.deviceAuthorize=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]})})},t.prototype.sudo=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.sudo(e)]})})},t.prototype.deleteMe=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]})})},t.prototype.getProviders=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.getProviders()]})})},t.prototype.loginScope=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.loginScope()]})})},t.prototype.loginGroups=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.loginGroups()]})})},t.prototype.onLoginStateChanged=function(e){var t;return c(this,void 0,void 0,function(){var n,r=this;return u(this,function(o){switch(o.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(h.EVENTS.LOGIN_STATE_CHANGED,function(t){return c(r,void 0,void 0,function(){var n,r,o;return u(this,function(s){switch(s.label){case 0:return(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.eventType)===h.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return r=s.sent(),[3,3];case 2:r={},s.label=3;case 3:return n=r,e.call(this,i(i({},t),n)),[2]}})})}),[4,this.getLoginState()];case 1:return n=o.sent(),e.call(this,n),[2]}})})},t.prototype.refreshTokenForce=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]})})},t.prototype.getCredentials=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.getCredentials()]})})},t.prototype.setCredentials=function(e){return c(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}})})},t.prototype.getProviderSubType=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]})})},t.prototype.createCaptchaData=function(e){return c(this,void 0,void 0,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]})})},t.prototype.verifyCaptchaData=function(e){return c(this,void 0,void 0,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]})})},t.prototype.getMiniProgramQrCode=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]})})},t.prototype.getMiniProgramQrCodeStatus=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]})})},t.prototype.modifyPassword=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]})})},t.prototype.modifyPasswordWithoutLogin=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]})})},t.prototype.getUserBehaviorLog=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]})})},t.prototype.signInWithUsername=function(e){var t=e.verificationInfo,n=void 0===t?{verification_id:"",is_user:!1}:t,r=e.verificationCode,o=void 0===r?"":r,s=e.username,a=void 0===s?"":s,l=e.bindInfo,h=void 0===l?void 0:l,d=e.loginType,f=void 0===d?"":d;return c(this,void 0,Promise,function(){var e,t,r,s,c,l,d;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:n.verification_id,verification_code:o})];case 1:if(null==(e=u.sent())?void 0:e.error_code)throw e;return t=e.verification_token,r=this.formatPhone(a),s={phone_number:r},"email"===f&&(s={email:r=a}),n.is_user?[4,this.oauthInstance.authApi.signIn({username:r,verification_token:t})]:[3,5];case 2:if(null==(c=u.sent())?void 0:c.error_code)throw c;return h?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==h?void 0:h.providerToken})]:[3,4];case 3:if(null==(l=u.sent())?void 0:l.error_code)throw l;u.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(i(i({},s),{verification_token:t,provider_token:null==h?void 0:h.providerId}))];case 6:if(null==(d=u.sent())?void 0:d.error_code)throw d;u.label=7;case 7:return[2,this.createLoginState()];case 8:throw u.sent();case 9:return[2]}})})},t.prototype.createLoginState=function(e,t){return c(this,void 0,Promise,function(){var n;return u(this,function(r){switch(r.label){case 0:return[4,(n=new w({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return r.sent(),(null==t?void 0:t.userInfo)?(n.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(n.user.refresh(e),[3,5]):[3,3];case 3:return[4,n.user.refresh(e)];case 4:r.sent(),r.label=5;case 5:return[2,n]}})})},t.prototype.setAccessKey=function(){var e,t;return c(this,void 0,void 0,function(){var n,r;return u(this,function(o){if(n="",r="",this.config.accessKey?(n=this.config.accessKey,r="accessKey"):(null===(e=this.config.auth)||void 0===e?void 0:e.secretId)&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretKey)&&(n="",r=h.DEFAULT_NODE_ACCESS_SCOPE),!r)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:n,token_type:"Bearer",scope:r,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]})})},t.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},t.prototype.notifyListeners=function(e,t,n){this.listeners.forEach(function(r){r.forEach(function(r){try{r(e,t,n)}catch(e){console.error("Error in auth state change callback:",e)}})})},t.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(h.EVENTS.AUTH_STATE_CHANGED,function(e){return c(t,void 0,void 0,function(){var t,n,r,o,i,s,a;return u(this,function(c){switch(c.label){case 0:return t=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.event,n=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.info,t!==h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN||n?[3,2]:[4,this.getUser(!0)];case 1:r=c.sent().data,(o=(void 0===r?{}:r).user)&&(n={user:o}),c.label=2;case 2:return[4,this.getSession()];case 3:return i=c.sent().data.session,this.notifyListeners(t,i,n),[2]}})})})},t.prototype.convertToUser=function(e){var t,n,r,o,i,s;if(!e)return null;var a=(null==e?void 0:e.email)||"",c=(null==e?void 0:e.phone_number)||"",u=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:u,aud:"authenticated",role:null===(n=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===n?void 0:n.call(t,function(e){return"string"==typeof e?e:e.id}),email:a||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:c,phone_confirmed_at:c?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(r=e.loginType)||void 0===r?void 0:r.toLowerCase())||"cloudbase",providers:[(null===(o=e.loginType)||void 0===o?void 0:o.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:null!==(i=e.hasPassword)&&void 0!==i?i:"SET"===e.password,open_id:null==e?void 0:e.open_id},identities:(null===(s=null==e?void 0:e.providers)||void 0===s?void 0:s.map(function(t){return{id:t.id||"",identity_id:t.id||"",user_id:u,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}}))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},t.prototype.missingRequiredParam=function(e,t){return new h.AuthError({error:"missing_required_param",error_code:4e3,error_description:"auth.".concat(e,"(params): missing required param '").concat(t,"'")},{method:e})},t.prototype.validateParams=function(e,t,n){for(var r=0,o=Object.entries(t);r<o.length;r++){var i=o[r],s=i[0];if(i[1].required&&(void 0===(null==e?void 0:e[s])||null===(null==e?void 0:e[s])||""===(null==e?void 0:e[s])))throw this.missingRequiredParam(n,s)}},t.prototype.validateAtLeastOne=function(e,t,n){if(!t.some(function(t){return t.some(function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])})}))throw this.missingRequiredParam(n,t.map(function(e){return e.join("|")}).join("|"))},t.prototype.init=function(){var e;return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&!this.oauthInstance.oauth2client.initSessionEmitted&&(null===(e=this.config.eventBus)||void 0===e||e.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}})})},s([(0,f.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(n=void 0!==h.authModels&&h.authModels.BindPhoneRequest)?n:Object]),a("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),s([(0,f.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(r=void 0!==h.authModels&&h.authModels.UnbindProviderRequest)?r:Object]),a("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],t.prototype,"unbindProvider",null),s([(0,f.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(v=void 0!==h.authModels&&h.authModels.BindEmailRequest)?v:Object]),a("design:returntype",void 0)],t.prototype,"bindEmail",null),s([(0,f.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(m=void 0!==h.authModels&&h.authModels.VerifyRequest)?m:Object]),a("design:returntype","function"==typeof(b="undefined"!=typeof Promise&&Promise)?b:Object)],t.prototype,"verify",null),s([(0,f.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(E=void 0!==h.authModels&&h.authModels.GetVerificationRequest)?E:Object,Object]),a("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],t.prototype,"getVerification",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(I="undefined"!=typeof Promise&&Promise)?I:Object)],t.prototype,"getCurrentUser",null),s([(0,f.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],t.prototype,"signInAnonymouslyInWx",null),s([(0,f.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],t.prototype,"bindOpenId",null),s([(0,f.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],t.prototype,"signInWithUnionId",null),s([(0,f.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],t.prototype,"signInWithSms",null),s([(0,f.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],t.prototype,"signInWithEmail",null),s([(0,f.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype","function"==typeof(R="undefined"!=typeof Promise&&Promise)?R:Object)],t.prototype,"isUsernameRegistered",null),s([(0,f.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],t.prototype,"getLoginState",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(k="undefined"!=typeof Promise&&Promise)?k:Object)],t.prototype,"getUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],t.prototype,"getWedaUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(D=void 0!==h.authModels&&h.authModels.BindWithProviderRequest)?D:Object]),a("design:returntype","function"==typeof(L="undefined"!=typeof Promise&&Promise)?L:Object)],t.prototype,"bindWithProvider",null),s([(0,f.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(j="undefined"!=typeof Promise&&Promise)?j:Object)],t.prototype,"getProviderSubType",null),t}(v.AuthV1Compat);function I(e,t){var n,r,o,s,a=this,l=e.region,p=void 0===l?"ap-shanghai":l,v=e.i18n,y=e.accessKey,g=e.useWxCloud,m=(null==t?void 0:t.platform)||f.useDefaultAdapter.bind(t)(),b=m.runtime,_=m.adapter,E=t||{},w=E.env,I=E.clientId,O=E.debug,A=E.cache,T=E.app,P=E.getApiOrigin,C=(t||{}).apiOrigin;C||(C="https://".concat(w,".").concat(p,".tcb-api.tencentcloudapi.com"));var R,N={env:w,clientId:I,i18n:v,accessKey:y,useWxCloud:g,eventBus:new f.CloudbaseEventEmitter},k=new h.CloudbaseOAuth((0,d.useAuthAdapter)(i(i({},N),{apiOrigin:C,getApiOrigin:P,apiPath:(null==e?void 0:e.apiPath)||h.AUTH_API_PREFIX,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:_,onCredentialsError:(R=N.eventBus,function(e){R.fire(h.EVENTS.LOGIN_STATE_CHANGED,i(i({},e),{eventType:h.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:i({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:O,auth:null===(r=null===(n=t.app)||void 0===n?void 0:n.config)||void 0===r?void 0:r.auth}))),U=new S(i(i({},N),{region:p,persistence:e.persistence,debug:O,cache:A||new f.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(w)},platformInfo:m}),runtime:b||"web",_fromApp:T,oauthInstance:k,auth:null===(s=null===(o=t.app)||void 0===o?void 0:o.config)||void 0===s?void 0:s.auth}));return k.initializeSession(function(e,t){return c(a,void 0,void 0,function(){return u(this,function(n){return e?(e.type===h.OAUTH_TYPE.SIGN_IN?t?N.eventBus.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:i(i({},e),{error:t})}):e.user&&U.createLoginState({},{userInfo:e.user}):e.type===h.OAUTH_TYPE.BIND_IDENTITY&&N.eventBus.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:i(i({},e),{error:t})}),[2]):[2]})})}),{authInstance:U,oauthInstance:k}}t.Auth=S,t.generateAuthInstance=I;var O="auth";function A(e,t){for(var n=[],r=0;r<=e.length;r++)n[r]=[r];for(var o=0;o<=t.length;o++)n[0][o]=o;for(r=1;r<=e.length;r++)for(o=1;o<=t.length;o++){var i=e[r-1].toLowerCase()===t[o-1].toLowerCase()?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+i)}return n[e.length][t.length]}var T={name:"auth",namespace:O,entity:function(e){var t=function(e){var t,n=this;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:h.AUTH_API_PREFIX};var r=this.platform.adapter,o=e.persistence||r.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var s=I(i(i({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,getApiOrigin:function(){return n.request.getBaseEndPoint(n.config.endPointMode||"CLOUD_API")},platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),a=s.authInstance,c=s.oauthInstance;return this.oauthInstance=c,this.authInstance=a,this.authInstance},n=t.call(this,e);Object.assign(t,n),Object.setPrototypeOf(t,Object.getPrototypeOf(n));var r="undefined"!=typeof Proxy?new Proxy(t,{get:function(e,t,n){var r=Reflect.get(e,t,n);if(void 0!==r||"string"!=typeof t)return r;var o=function(e,t){for(var n=null,r=1/0,o=0,i=t;o<i.length;o++){var s=i[o];if(!s.startsWith("_")&&"constructor"!==s){var a=A(e,s);a<r&&(r=a,n=s)}}return n}(t,Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)).filter(function(t){return"function"==typeof e[t]}));return o&&console.warn("[CloudBase Auth] auth.".concat(t," is not a function. Did you mean: auth.").concat(o,"() ?")),r}}):t;return this[O]=r,r}};try{cloudbase.registerComponent(T)}catch(e){}var P=n(6722);Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return P.AuthErrorCategory}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return P.AuthErrorCode}}),Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return P.AuthError}}),t.registerAuth=function(e){try{e.registerComponent(T)}catch(e){console.warn(e)}}},1019:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.adapterForWxMp=t.CloudbaseCache=t.CloudbaseEventEmitter=t.catchErrorsDecorator=t.COMMUNITY_SITE_URL=t.ERRORS=t.throwError=t.printWarn=void 0;var o=n(3616);Object.defineProperty(t,"printWarn",{enumerable:!0,get:function(){return o.printWarn}}),Object.defineProperty(t,"throwError",{enumerable:!0,get:function(){return o.throwError}});var i=n(794);Object.defineProperty(t,"ERRORS",{enumerable:!0,get:function(){return i.ERRORS}}),Object.defineProperty(t,"COMMUNITY_SITE_URL",{enumerable:!0,get:function(){return i.COMMUNITY_SITE_URL}});var s=n(141);Object.defineProperty(t,"catchErrorsDecorator",{enumerable:!0,get:function(){return s.catchErrorsDecorator}});var a=n(9689);Object.defineProperty(t,"CloudbaseEventEmitter",{enumerable:!0,get:function(){return a.CloudbaseEventEmitter}});var c=n(6197);Object.defineProperty(t,"CloudbaseCache",{enumerable:!0,get:function(){return c.CloudbaseCache}});var u=n(7917);Object.defineProperty(t,"adapterForWxMp",{enumerable:!0,get:function(){return r(u).default}});var l=n(8182);Object.defineProperty(t,"useDefaultAdapter",{enumerable:!0,get:function(){return l.useDefaultAdapter}})},5266:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlParams=t.addUrlSearch=t.removeBrowserSession=t.getBrowserSession=t.saveToBrowserSession=void 0,t.saveToBrowserSession=function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}},t.getBrowserSession=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}},t.removeBrowserSession=function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}},t.addUrlSearch=function(e,t){if(void 0!==e){var n=new URL(window.location.href);return n.search=e,n.hash=t||n.hash,window.history.replaceState({},"",n.href),n.href}},t.removeUrlParams=function(e){if("undefined"!=typeof window)try{var t=new URL(window.location.href);e.forEach(function(e){t.searchParams.delete(e)}),window.history.replaceState({},"",t.href)}catch(e){console.error("Failed to remove URL params:",e)}}},916:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.applyUserV1Compat=t.AuthV1Compat=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=void 0;var s=n(6722),a=n(1019),c=function(){function e(e){}return e.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},e.prototype.getRedirectResult=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")})})},e.prototype.getLinkRedirectResult=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")})})},e}();t.WeixinAuthProvider=c;var u=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.authInstance.signInWithCustomTicket(function(){return Promise.resolve(e)})];case 1:return t.sent(),[2]}})})},e}();t.CustomAuthProvider=u;var l=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return e.sent(),[2]}})})},e}();t.AnonymousAuthProvider=l;var h=function(){function e(){}return e.prototype.weixinAuthProvider=function(e){return new c({authInstance:this,appid:e.appid,scope:e.scope})},e.prototype.customAuthProvider=function(){return new u({authInstance:this})},e.prototype.anonymousAuthProvider=function(){return new l({authInstance:this})},e.prototype.signUpWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:e,password:t})];case 1:return[2,n.sent()]}})})},e.prototype.signInWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return n.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPasswordResetEmail=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.signInWithUsernameAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return n.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPhoneCode=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),t=this.formatPhone(e),[4,this.getVerification({phone_number:t})];case 1:return n.sent(),[2,!0]}})})},e.prototype.signUpWithPhoneCode=function(e,t,n){return o(this,void 0,Promise,function(){var o;return i(this,function(i){switch(i.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),o=this.formatPhone(e),[4,this.signUp(r({phone_number:o,verification_code:t},n?{password:n}:{}))];case 1:return i.sent(),[2,this.createLoginState()]}})})},e.prototype.signInWithPhoneCodeOrPassword=function(e){return o(this,void 0,Promise,function(){var t,n,r,o;return i(this,function(i){switch(i.label){case 0:return t=e.phoneNumber,n=e.phoneCode,r=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),o=this.formatPhone(t),r?[4,this.signIn({username:o,password:r})]:[3,2];case 1:return i.sent(),[3,5];case 2:return n?[4,this.signIn({username:o,verification_token:n})]:[3,4];case 3:return i.sent(),[3,5];case 4:(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),i.label=5;case 5:return[2,this.createLoginState()]}})})},e.prototype.forceResetPwdByPhoneCode=function(e){return o(this,void 0,Promise,function(){var t,n,r,o;return i(this,function(i){switch(i.label){case 0:return t=e.phoneNumber,n=e.phoneCode,r=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof n&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof r&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),o=this.formatPhone(t),[4,this.resetPassword({phone_number:o,new_password:r,verification_token:n})];case 1:return i.sent(),[4,this.signIn({username:o,password:r})];case 2:return i.sent(),[2,this.createLoginState()]}})})},e.prototype.shouldRefreshAccessToken=function(e){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},e.prototype.onLoginStateExpired=function(e){var t=this;this.onLoginStateChanged(function(n){(null==n?void 0:n.eventType)===s.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR&&e.call(t)})},e.prototype.onAccessTokenRefreshed=function(e){var t=this;this.onAuthStateChange(function(n){n===s.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED&&e.call(t)})},e.prototype.onAnonymousConverted=function(e){var t=this;this.onAuthStateChange(function(n){n===s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&e.call(t)})},e.prototype.onLoginTypeChanged=function(e){var t=this;this.onAuthStateChange(function(n){n!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&n!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT||e.call(t)})},e}();t.AuthV1Compat=h,t.applyUserV1Compat=function(e){e.prototype.linkWithTicket=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")})})},e.prototype.linkWithRedirect=function(e){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},e.prototype.updateEmail=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.linkWithPhoneNumber=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")})})},e.prototype.updatePhoneNumber=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")})})},e.prototype.unlink=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")})})}}},3198:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerDatabase=t.gateWayFunc=void 0;var c=n(4954),u=n(2701),l=n(2877);function h(e,t,n,r){(function(e){var t,n,r;return!0===(null===(r=null===(n=null===(t=null==e?void 0:e.config)||void 0===t?void 0:t._fromApp)||void 0===n?void 0:n.config)||void 0===r?void 0:r.debug)})(e)&&function(e,t){var n=e.data;console.error("[cloudbase] NETWORK_ERROR",{status:t,requestId:e.requestId,body:"string"==typeof n?n.slice(0,1024):""})}(t,n),t.code=l.constants.ERRORS.NETWORK_ERROR,t.message=function(e,t){return"HTTP ".concat(e,". Expected ").concat(t,". Set debug: true to see the response.")}(n,r)}t.gateWayFunc={filterRes:function(e,t){e=l.utils.promoteGatewayError(e);var n=Number(e.statusCode);return n>=400&&!e.code&&h(null!=t?t:this,e,n,"HTTP 2xx"),delete e.header,delete e.statusCode,e},normalizeTransactionResponse:function(e,n){var r=null==(e=l.utils.promoteGatewayError(e))?void 0:e.data;r&&"object"==typeof r&&"string"==typeof r.request_id&&r.request_id&&(e.requestId=r.request_id);var o=Number(e.statusCode),i="start"===n?"HTTP 201 with transactionId":"HTTP 204 with an empty body";if(o>=400)return e.code||h(this,e,o,i),delete e.header,delete e.statusCode,e;if("start"===n){var s=null==r?void 0:r.transactionId;if(201===o&&"string"==typeof s&&s){var a=t.gateWayFunc.flattenResData(e);return delete a.header,delete a.statusCode,a}return e.code||h(this,e,o,i),delete e.header,delete e.statusCode,e}return 204!==o||""!==r&&null!=r?(e.code||h(this,e,o,i),delete e.header,delete e.statusCode,e):(delete e.data,delete e.header,delete e.statusCode,e)},flattenResData:function(e){if("object"==typeof e.data&&null!==e.data){var t=i(i({},e),e.data);return delete t.data,t}return e},safeParseEJSON:function(e){if("string"!=typeof e)return e;try{return u.EJSON.parse(e)}catch(t){return e}},parseEJSONParam:function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}},parseEJSONValue:function(e){if("string"!=typeof e)return e;try{return u.EJSON.parse(e)}catch(n){return t.gateWayFunc.parseEJSONParam(e)}},normalizeOrderParam:function(e){if(null!=e&&""!==e){for(var n=t.gateWayFunc.parseEJSONValue(e),r=function(e){var t=e&&"object"==typeof e?Number(e):e;if("number"==typeof t&&!isNaN(t))return t<0?"desc":"asc";if("string"==typeof t){var n=t.toLowerCase();if("desc"===n||"-1"===n)return"desc";if("asc"===n||"1"===n)return"asc"}},o=[],i=0,s=Array.isArray(n)?n:[n];i<s.length;i++){var a=s[i];if(a&&"object"==typeof a)if(void 0!==a.field)(l=r(a.direction))&&o.push({field:a.field,direction:l});else for(var c=0,u=Object.entries(a);c<u.length;c++){var l,h=u[c],d=h[0];(l=r(h[1]))&&o.push({field:d,direction:l})}}return o.length?o:void 0}},extractDocId:function(e){if(e&&"object"==typeof e&&!Array.isArray(e)&&1===Object.keys(e).length&&"_id"in e){var t=e._id;if("string"==typeof t||"number"==typeof t)return String(t);if(t&&"object"==typeof t){if("string"==typeof t.$oid)return t.$oid;var n=t.$eq;if("string"==typeof n||"number"==typeof n)return String(n);if(n&&"object"==typeof n&&"string"==typeof n.$oid)return n.$oid}}},toLegacyRegExp:function(e){if(!e||"object"!=typeof e)return e;if(e.$regularExpression&&"object"==typeof e.$regularExpression){var n=e.$regularExpression;return{$regex:n.pattern,$options:n.options}}if(Array.isArray(e))return e.map(function(e){return t.gateWayFunc.toLegacyRegExp(e)});var r={};for(var o in e)r[o]=t.gateWayFunc.toLegacyRegExp(e[o]);return r},parseWriteParam:function(e){return t.gateWayFunc.toLegacyRegExp(t.gateWayFunc.parseEJSONParam(e))},buildQueryParams:function(e){return Object.entries(e).filter(function(e){e[0];var t=e[1];return null!=t&&""!==t}).map(function(e){var t=e[0],n=e[1],r="object"==typeof n?JSON.stringify(n):String(n);return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(r))}).join("&")},getUrlPrefix:function(e){var t=(null==e?void 0:e.instance)||"(default)",n=(null==e?void 0:e.database)||"(default)";return"/database/instances/".concat(t,"/databases/").concat(n)},"database.queryDocument":function(e,n){var r,o,c,l;return s(this,void 0,Promise,function(){var s,h,d,f,p,v,y;return a(this,function(a){switch(a.label){case 0:return s=t.gateWayFunc.parseEJSONParam(e.query),h=t.gateWayFunc.parseEJSONValue(e.projection),d=t.gateWayFunc.extractDocId(s),f=void 0!==d,p=t.gateWayFunc.buildQueryParams(i({projection:h,transactionId:e.transactionId},f?{}:{offset:null!==(r=e.offset)&&void 0!==r?r:0,limit:null!==(o=e.limit)&&void 0!==o?o:100,order:t.gateWayFunc.normalizeOrderParam(e.order),query:s?u.EJSON.stringify(s,{relaxed:!1}):void 0})),v="".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(p),f&&(v="".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/").concat(d,"?").concat(p)),[4,this.gateWay({url:v,method:"GET"},n)];case 1:return(y=a.sent()).data=t.gateWayFunc.safeParseEJSON(JSON.stringify(y.data)),!f||y.code||(null===(c=y.data)||void 0===c?void 0:c.code)?(y.code||(null===(l=y.data)||void 0===l?void 0:l.code)?y=i(i({},y),{data:i(i({},y.data),{list:[]})}):Array.isArray(y.data)?y=i(i({},y),{data:{list:y.data}}):y.data&&!Array.isArray(y.data.list)&&(y=i(i({},y),{data:i(i({},y.data),{list:[]})})),[2,t.gateWayFunc.filterRes(y,this)]):[2,i(i({},y),{data:{list:[y.data]}})]}})})},"database.addDocument":function(e,n){var r,o,c;return s(this,void 0,Promise,function(){var s,u;return a(this,function(a){switch(a.label){case 0:return s=(Array.isArray(e.data)?e.data:[e.data]).map(function(e){return t.gateWayFunc.parseWriteParam(e)}),[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"POST",data:i({data:s},e.transactionId&&{transactionId:e.transactionId})},n)];case 1:return u=a.sent(),Array.isArray(e.data)?u=i(i({},u),{data:i({ids:(null===(r=u.data)||void 0===r?void 0:r.insertedIds)||[]},u.data)}):(null===(c=null===(o=u.data)||void 0===o?void 0:o.insertedIds)||void 0===c?void 0:c[0])&&(u=i(i({},u),{data:i({_id:u.data.insertedIds[0]},u.data)})),[2,t.gateWayFunc.filterRes(u,this)]}})})},"database.updateDocument":function(e,n){var r;return s(this,void 0,Promise,function(){var o;return a(this,function(s){switch(s.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"PATCH",data:i({query:t.gateWayFunc.parseEJSONParam(e.query),data:t.gateWayFunc.parseEJSONParam(e.data),multi:!!e.multi,upsert:!!e.upsert,replaceMode:null!==(r=e.replaceMode)&&void 0!==r?r:!1===e.merge},e.transactionId&&{transactionId:e.transactionId})},n)];case 1:return o=s.sent(),[2,t.gateWayFunc.filterRes(o,this)]}})})},"database.deleteDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/remove"),method:"POST",data:i({query:t.gateWayFunc.parseEJSONParam(e.query),multi:!!e.multi},e.transactionId&&{transactionId:e.transactionId})},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.filterRes(r,this)]}})})},"database.countDocument":function(e,n){return s(this,void 0,Promise,function(){var r,o,i;return a(this,function(s){switch(s.label){case 0:return r=t.gateWayFunc.parseEJSONParam(e.query),o=t.gateWayFunc.buildQueryParams({count:!0,query:r?u.EJSON.stringify(r,{relaxed:!1}):void 0}),[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(o),method:"GET"},n)];case 1:return i=s.sent(),[2,t.gateWayFunc.filterRes(i,this)]}})})},"database.addCollection":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections"),method:"POST",data:{collectionName:e.collectionName}},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.filterRes(r,this)]}})})},"database.aggregate":function(e,n){var r;return s(this,void 0,Promise,function(){var o,i;return a(this,function(s){switch(s.label){case 0:return o=e.stages.map(function(e){var t,n;try{var r="string"==typeof e.stageValue?JSON.parse(e.stageValue):e.stageValue;return(t={})[e.stageKey]=u.EJSON.serialize(r),t}catch(t){return(n={})[e.stageKey]=e.stageValue,n}}),[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/aggregations"),method:"POST",data:{pipeline:o}},n)];case 1:return i=s.sent(),Array.isArray(null===(r=i.data)||void 0===r?void 0:r.list)&&(i.data.list=JSON.stringify(i.data.list.map(function(e){return JSON.stringify(e)}))),[2,t.gateWayFunc.filterRes(i,this)]}})})},"database.startTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/transactions"),method:"POST",shouldThrowOnError:!1},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.normalizeTransactionResponse.call(this,r,"start")]}})})},"database.commitTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/commit"),method:"POST",shouldThrowOnError:!1},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.normalizeTransactionResponse.call(this,r,"commit")]}})})},"database.abortTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/rollback"),method:"POST",shouldThrowOnError:!1},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.normalizeTransactionResponse.call(this,r,"rollback")]}})})},"database.getInTransaction":function(e,n){var r;return s(this,void 0,void 0,function(){var o;return a(this,function(s){switch(s.label){case 0:return[4,t.gateWayFunc["database.queryDocument"].call(this,e,n)];case 1:return"object"==typeof(o=s.sent()).data&&null!==o.data?(null===(r=o.data)||void 0===r?void 0:r.code)?[2,t.gateWayFunc.flattenResData(o)]:[2,i(i({},o),{data:JSON.stringify(o.data)})]:[2,o]}})})},"database.updateDocInTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,t.gateWayFunc["database.updateDocument"].call(this,e,n)];case 1:return r=o.sent(),[2,t.gateWayFunc.flattenResData(r)]}})})},"database.deleteDocInTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,t.gateWayFunc["database.deleteDocument"].call(this,e,n)];case 1:return r=o.sent(),[2,t.gateWayFunc.flattenResData(r)]}})})},"database.insertDocInTransaction":function(e,n){var r;return s(this,void 0,Promise,function(){var o,s;return a(this,function(a){switch(a.label){case 0:return[4,t.gateWayFunc["database.addDocument"].call(this,e,n)];case 1:return"object"==typeof(o=a.sent()).data&&null!==o.data?(s=!!(null===(r=o.data)||void 0===r?void 0:r._id),o=i(i(i({},o),{inserted:s?1:0,ok:s?1:0}),o.data)):o=i({inserted:0,ok:0},o),delete o.data,[2,o]}})})},"database.runCommands":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/commands"),method:"POST",data:i({commands:u.EJSON.serialize(Array.isArray(e.commands)?e.commands.map(function(e){return t.gateWayFunc.parseEJSONParam(e)}):e.commands)},e.transactionId&&{transactionId:e.transactionId})},n)];case 1:"object"==typeof(r=o.sent()).data&&null!==r.data&&(delete(r=i(i({},r),r.data)).data,delete r.request_id);try{r=u.EJSON.deserialize(r)}catch(e){}return[2,t.gateWayFunc.filterRes(r,this)]}})})},"database.getDocument":function(e,n){var r;return s(this,void 0,Promise,function(){var o,s;return a(this,function(a){switch(a.label){case 0:return(o=i({},e)).query=t.gateWayFunc.parseEJSONParam(o.query),o.projection=t.gateWayFunc.parseEJSONValue(o.projection),[4,t.gateWayFunc["database.queryDocument"].call(this,o,n)];case 1:return s=a.sent(),Array.isArray(null===(r=s.data)||void 0===r?void 0:r.list)&&(s.data.list=s.data.list.map(function(e){return u.EJSON.stringify(e,{relaxed:!1})})),[2,s]}})})},"database.insertDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){return(r=i({},e)).data=Array.isArray(r.data)?r.data.map(function(e){return t.gateWayFunc.parseWriteParam(e)}):t.gateWayFunc.parseWriteParam(r.data),[2,t.gateWayFunc["database.addDocument"].call(this,r,n)]})})},"database.modifyDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){return(r=i({},e)).query=t.gateWayFunc.parseEJSONParam(r.query),r.data=t.gateWayFunc.parseEJSONParam(r.data),[2,t.gateWayFunc["database.updateDocument"].call(this,r,n)]})})},"database.modifyAndReturnDoc":function(e,n){var r,o;return s(this,void 0,Promise,function(){var s,c,l;return a(this,function(a){switch(a.label){case 0:return(s=i({},e)).query=t.gateWayFunc.parseEJSONParam(s.query),s.data=t.gateWayFunc.parseEJSONParam(s.data),(c=t.gateWayFunc.extractDocId(s.query))?[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(s),"/collections/").concat(s.collectionName,"/documents/").concat(c),method:"PATCH",data:i({data:s.data,replaceMode:null!==(r=s.replaceMode)&&void 0!==r&&r,upsert:!!s.upsert,returnDoc:!0},s.transactionId&&{transactionId:s.transactionId})},n)]:[2,t.gateWayFunc["database.updateDocument"].call(this,s,n)];case 1:return l=a.sent(),void 0!==(null===(o=l.data)||void 0===o?void 0:o.doc)&&"string"!=typeof l.data.doc&&(l.data.doc=u.EJSON.stringify(l.data.doc,{relaxed:!1})),[2,t.gateWayFunc.filterRes(l,this)]}})})},"database.removeDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){return(r=i({},e)).query=t.gateWayFunc.parseEJSONParam(r.query),void 0!==r.query&&null!==r.query&&""!==r.query||(r.query={_id:{$exists:!0}}),[2,t.gateWayFunc["database.deleteDocument"].call(this,r,n)]})})},"database.calculateDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){return(r=i({},e)).query=t.gateWayFunc.parseEJSONParam(r.query),[2,t.gateWayFunc["database.countDocument"].call(this,r,n)]})})},"database.aggregateDocuments":function(e,n){var r;return s(this,void 0,Promise,function(){var o,s;return a(this,function(a){switch(a.label){case 0:return o=i({},e),Array.isArray(o.stages)&&(o.stages=o.stages.map(function(e){return i(i({},e),{stageValue:t.gateWayFunc.parseEJSONParam(e.stageValue)})})),[4,t.gateWayFunc["database.aggregate"].call(this,o,n)];case 1:if(s=a.sent(),"string"==typeof(null===(r=s.data)||void 0===r?void 0:r.list))try{s.data.list=JSON.parse(s.data.list)}catch(e){}return[2,s]}})})}};var d={name:"database",entity:{database:function(e){var n;if(void 0!==e&&"Object"!==Object.prototype.toString.call(e).slice(8,-1))throw l.utils.createCloudbaseError({code:"INVALID_PARAM",msg:"dbConfig must be an object"},null===(n=this.config)||void 0===n?void 0:n.errorFactory);var r=this.platform,u=r.adapter,h=r.runtime,d=function(e){function n(t){return e.call(this,t)||this}return o(n,e),n.prototype.send=function(n,r,o){var i,c,u,h;return s(this,void 0,void 0,function(){var s,d,f;return a(this,function(a){switch(a.label){case 0:return s=null,d=o&&"number"==typeof o.timeout?{timeout:o.timeout}:void 0,"GATEWAY"===this.config.endPointMode&&t.gateWayFunc[n]?[4,t.gateWayFunc[n].call(this,r,d)]:[3,2];case 1:return s=a.sent(),[3,4];case 2:return[4,e.prototype.send.call(this,n,r,void 0,d)];case 3:s=a.sent(),a.label=4;case 4:if(f=l.utils.resolveThrow(null!==(u=null===(c=null===(i=this.config)||void 0===i?void 0:i._fromApp)||void 0===c?void 0:c.config)&&void 0!==u?u:this.config),s&&s.code&&f)throw l.utils.createCloudbaseError({code:s.code,msg:s.message||s.data&&s.data.message||"",requestId:s.requestId},null===(h=this.config)||void 0===h?void 0:h.errorFactory);return[2,s]}})})},n}(this.request.constructor);return c.Db.reqClass=d,c.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},c.Db.runtime=h,this.wsClientClass&&(c.Db.wsClass=u.wsClass,c.Db.wsClientClass=this.wsClientClass),c.Db.ws||(c.Db.ws=null),new(function(e){function t(t){return e.call(this,t)||this}return o(t,e),t.prototype.runCommands=function(e){return s(this,void 0,Promise,function(){return a(this,function(t){return[2,c.Db.createRequest(this.config).send("database.runCommands",e)]})})},t}(c.Db))(i(i(i({},this.config),{_fromApp:this}),e))}}};try{cloudbase.registerComponent(d)}catch(e){}function f(e){try{e.registerComponent(d)}catch(e){console.warn(e)}}t.registerDatabase=f;try{window.registerDatabase=f}catch(e){}},8795:function(e,t,n){"use strict";var r=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(n(6950)),o=n(9895),i=n(1060),s=n(3456),a=n(7209),c=n(7397),u=n(3645),l=n(5337),h=n(9253),d=n(9126),f=n(1944),p=n(3198);r.default.registerVersion("3.10.4-beta.0");try{(0,o.registerAuth)(r.default),(0,i.registerFunctions)(r.default),(0,s.registerStorage)(r.default),(0,p.registerDatabase)(r.default),(0,a.registerRealtime)(r.default),(0,c.registerRealtimeJs)(r.default),(0,u.registerModel)(r.default),(0,l.registerAi)(r.default),(0,h.registerCloudrun)(r.default),(0,d.registerMySQL)(r.default),(0,f.registerApis)(r.default)}catch(e){}try{window.cloudbase=r.default}catch(e){}t.default=r.default,e.exports=r.default},9253:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerCloudrun=t.requestContainer=void 0;var s=n(2877).constants.ERRORS,a="cloudrun",c=function(){function e(){}return e.prototype.callContainer=function(e,t){return o(this,void 0,void 0,function(){var n,o,c;return i(this,function(i){switch(i.label){case 0:if(n=e.name,o=e.data,!n)throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(a,".callContainer] invalid name")}));try{c=o?JSON.stringify(o):""}catch(e){throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(a,".callContainer] invalid data")}))}return[4,u.call(this,r(r({},e),{data:c}),t)];case 1:return[2,i.sent()]}})})},e}();function u(e,t){var n;return o(this,void 0,void 0,function(){var o,s,a,c,u,l,h,d,f,p,v,y,g,m,b;return i(this,function(i){switch(i.label){case 0:if(o=e.name,s=e.data,a=e.path,c=void 0===a?"":a,u=e.method,l=e.header,h=void 0===l?{}:l,d=this.getEndPointWithKey("GATEWAY"),f=d.BASE_URL,p=d.PROTOCOL,v="".concat(p).concat(f,"/cloudrun/").concat(o),y=c.startsWith("/")?c:"/".concat(c),g=["GET","HEAD"].includes(null===(n=null==u?void 0:u.toUpperCase)||void 0===n?void 0:n.call(u)))try{m={};try{m=JSON.parse(s)}catch(e){m=s||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(m).map(function(e){return"".concat(e,"=").concat(m[e])}).join("&"))}catch(e){}return[4,this.request.fetch(r(r({method:u||"POST",headers:Object.assign({},{"Content-Type":"application/json; charset=utf-8"},h)},g?{}:{body:s}),{url:"".concat(v).concat(y),customReqOpts:t}))];case 1:return b=i.sent(),"node-sdk"===(null==t?void 0:t.from)?[2,b]:[4,b.data];case 2:return[2,i.sent()]}})})}t.requestContainer=u;var l=new c,h={name:a,entity:{callContainer:l.callContainer}};try{cloudbase.registerComponent(h)}catch(e){}function d(e){try{e.registerComponent(h)}catch(e){console.warn(e)}}t.registerCloudrun=d;try{window.registerCloudrun=d}catch(e){}},1060:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerFunctions=void 0;var c=n(3388),u=n(2877),l=n(9253),h=u.constants.getSdkName,d=u.constants.ERRORS,f=u.constants.COMMUNITY_SITE_URL,p=u.utils.execCallback,v=u.utils.maybeThrow,y=u.helpers.catchErrorsDecorator,g="functions";function m(e){return e.length<=1024?e:"".concat(e.slice(0,1024),"…")}function b(e,t){return{code:(null==e?void 0:e.code)||d.NETWORK_ERROR,message:(null==e?void 0:e.message)||(null==e?void 0:e.msg)||"",requestId:t}}function _(e,t){if(e&&"object"==typeof e&&!Array.isArray(e))return b(e,t);if("string"==typeof e){try{var n=JSON.parse(e);if(n&&"object"==typeof n&&!Array.isArray(n))return b(n,t)}catch(e){}return{code:d.NETWORK_ERROR,message:m(e),requestId:t}}return{code:d.NETWORK_ERROR,message:m(null==e?"":String(e)),requestId:t}}var E=new(function(){function e(){}var t,n,m;return e.invokeCloudrun=function(e,t,n){return s(this,void 0,void 0,function(){var o,i,s,c,h,d,f;return a(this,function(a){switch(a.label){case 0:return o=t.name,i=t.path,s=void 0===i?"":i,c=t.method,h=t.header,d=void 0===h?{}:h,f=u.utils.generateRequestId(),[4,l.requestContainer.call(e,{name:o,data:n,path:s,method:c,header:r(r({},d),{"X-Request-Id":f})})];case 1:return[2,{result:a.sent(),requestId:f}]}})})},e.invokeGateway=function(e,t,n,o){return s(this,void 0,void 0,function(){var i,s,c,u,l;return a(this,function(a){switch(a.label){case 0:i=e.request,s=e.config,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,i.gateWay(r(r({},t),{path:"functions",shouldThrowOnError:!1}),o)];case 2:return c=a.sent(),[3,4];case 3:return u=a.sent(),function(e){if(!e)return!1;if(e instanceof SyntaxError||"SyntaxError"===e.name)return!0;var t=String(e.message||"");return/not valid JSON|Unexpected token|JSON\.parse|Failed to execute 'json'/i.test(t)}(l=u)?[2,v(s,_(l.message,l.requestId))]:[2,p(n,l)];case 4:return Number(null==c?void 0:c.statusCode)>=400?[2,v(s,_(null==c?void 0:c.data,null==c?void 0:c.requestId))]:[2,p(n,null,{requestId:null==c?void 0:c.requestId,result:null==c?void 0:c.data})]}})})},e.invokeCloudApi=function(e,t,n,r,o){var i,c,u;return s(this,void 0,void 0,function(){var s,l,f,v,y,m,b;return a(this,function(a){switch(a.label){case 0:return s=t.name,l=t.data,f=t.query,v=t.parse,y=t.search,[4,e.request.send("functions.invokeFunction",{inQuery:f,parse:v,search:y,function_name:s,request_data:n},{endPointMode:"CLOUD_API",defaultQuery:(null===(i=null==l?void 0:l.params)||void 0===i?void 0:i.action)?{action:null===(c=null==l?void 0:l.params)||void 0===c?void 0:c.action}:{}},o)];case 1:if(m=a.sent(),void 0===(b=null===(u=m.data)||void 0===u?void 0:u.response_data))return[2,p(r,null,m)];if(v)return[2,p(r,null,{result:b,requestId:m.requestId})];try{return b=JSON.parse(b),[2,p(r,null,{result:b,requestId:m.requestId})]}catch(e){return[2,p(r,new Error("[".concat(h(),"][").concat(d.INVALID_PARAMS,"][").concat(g,".callFunction] response data must be json")))]}return[2]}})})},e.prototype.callFunction=function(t,n,r){return s(this,void 0,void 0,function(){var o,i,s,c,u,l;return a(this,function(a){switch(a.label){case 0:if(o=t.name,i=t.data,s=t.type,c=this.config,!o)return[2,v(c,{code:d.INVALID_PARAMS,message:"[".concat(g,".callFunction] invalid function name")})];try{u=i?JSON.stringify(i):""}catch(e){return[2,v(c,{code:d.INVALID_PARAMS,message:"[".concat(g,".callFunction] invalid data")})]}if("cloudrun"===s)return[2,e.invokeCloudrun(this,t,u)];a.label=1;case 1:return a.trys.push([1,5,,6]),function(e,t){return"GATEWAY"===e.endPointMode&&!function(e){return"lcap-common-service"===e||"lcap-datasource-test"===e||e.startsWith("lcap-data")||e.startsWith("lowcode-datasource")||"cloudbase_module"===e}(t)&&!function(e){return"lowcode-wx-datasource"===e}(t)}(c,o)?[4,e.invokeGateway(this,t,n,r)]:[3,3];case 2:return[2,a.sent()];case 3:return[4,e.invokeCloudApi(this,t,u,n,r)];case 4:return[2,a.sent()];case 5:return l=a.sent(),p(n,l),[3,6];case 6:return[2]}})})},o([y({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(t=void 0!==c.ICallFunctionOptions&&c.ICallFunctionOptions)?t:Object,"function"==typeof(n="undefined"!=typeof Function&&Function)?n:Object,"function"==typeof(m=void 0!==c.ICustomReqOpts&&c.ICustomReqOpts)?m:Object]),i("design:returntype",Promise)],e.prototype,"callFunction",null),e}()),w={name:g,entity:{callFunction:E.callFunction}};try{cloudbase.registerComponent(w)}catch(e){}t.registerFunctions=function(e){try{e.registerComponent(w)}catch(e){console.warn(e)}}},3645:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerModel=t.lazyGetEntity=void 0;var c=n(8630),u=n(2877).events.CloudbaseEventEmitter,l="models",h=new WeakMap;function d(e){return new Proxy({},{get:function(t,n){var o=e.getEndPointWithKey("GATEWAY"),i=o.BASE_URL,u=o.PROTOCOL,l=r(r({},e),{BASE_URL:i,PROTOCOL:u}),d=h.get(l);return d||(d=function(e){var t=this,n=e.callFunction.bind(e),o=e.request.fetch.bind(e.request),i=e.getEndPointWithKey("GATEWAY"),u=i.BASE_URL,l=i.PROTOCOL,h="".concat(l).concat(u,"/model"),d="".concat(l).concat(u,"/sql"),f=(0,c.generateHTTPClient)(n,function(e){return s(t,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:return[4,o(r(r({},e),{headers:r({"Content-Type":"application/json"},e.headers)}))];case 1:return[4,t.sent().data];case 2:return[2,t.sent()]}})})},h,{sqlBaseUrl:d});return f}(e),h.set(l,d)),d[n]}})}t.lazyGetEntity=d;var f="cloudbase_init",p=new u;p.on(f,function(e){var t=e.data;Object.assign(t,{models:d(t)})});var v={name:l,namespace:l,entity:new Proxy({},{get:function(e,t){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(t,"."))}}),injectEvents:{bus:p,events:[f]}};try{cloudbase.registerComponent(v)}catch(e){}function y(e){try{e.registerComponent(v)}catch(e){console.warn(e)}}t.registerModel=y;try{window.registerModel=y}catch(e){}i(n(8630),t)},9126:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerMySQL=void 0;var c=n(8630);function u(e){if(!e)return{get:function(){return null},forEach:function(){}};if("function"==typeof e.get)return e;var t={};return Object.keys(e).forEach(function(n){t[n.toLowerCase()]=e[n]}),{get:function(e){var n;return null!==(n=t[e.toLowerCase()])&&void 0!==n?n:null},forEach:function(e){Object.entries(t).forEach(function(t){var n=t[0],r=t[1];return e(r,n)})}}}function l(e,t,n){var o=this,i=e.request.fetch.bind(e.request),l=t||{},h=l.instance,d=void 0===h?n?void 0:"default":h,f=l.database,p=void 0===f?n?void 0:e.config.env:f,v=e.getEndPointWithKey("GATEWAY"),y=v.BASE_URL,g=v.PROTOCOL,m="".concat(g).concat(y),b=function(t,n){return s(o,void 0,void 0,function(){var o,s,c,l,h,f,v,y,g,b;return a(this,function(a){switch(a.label){case 0:return o={},n.headers instanceof Headers?n.headers.forEach(function(e,t){o[t]=e}):n.headers&&Object.assign(o,n.headers),[["X-Db-Instance",d],["Accept-Profile",p],["Content-Profile",p]].forEach(function(e){var t=e[0],n=e[1];o[t]||o[t.toLocaleLowerCase()]||!n||(o[t]=n)}),s=t.toString(),c=e.getEndPointWithKey("GATEWAY"),l=c.BASE_URL,h=c.PROTOCOL,(f="".concat(h).concat(l))!==m&&s.startsWith(m)&&(s=s.replace(m,f)),[4,i(r(r({url:s},n),{headers:r({"Content-Type":"application/json"},o),shouldThrowOnError:!1}))];case 1:v=a.sent(),y={},a.label=2;case 2:return a.trys.push([2,4,,5]),[4,v.data];case 3:return y=a.sent(),[3,5];case 4:if(g=a.sent(),!(null===(b=null==g?void 0:g.message)||void 0===b?void 0:b.includes("Unexpected end of JSON input")))throw g;return[3,5];case 5:return[2,{ok:(null==v?void 0:v.statusCode)>=200&&(null==v?void 0:v.statusCode)<300,status:(null==v?void 0:v.statusCode)||200,statusText:(null==v?void 0:v.statusMessage)||"OK",json:function(){return Promise.resolve(y||{})},text:function(){return Promise.resolve("string"==typeof y?y:JSON.stringify(y||{}))},headers:u(null==v?void 0:v.header)}]}})})},_="".concat(g).concat(y,"/rdb/rest");return n?(0,c.generatePGClient)(e,{pgBaseUrl:_,fetch:b}):(0,c.generateMySQLClient)(e,{mysqlBaseUrl:_,fetch:b})}var h={name:"mysql",entity:{mysql:function(e){return l(this,e,!1)(e)}}},d={name:"rdb",entity:{rdb:function(e){return l(this,e,!0)(e)}}};try{cloudbase.registerComponent(h),cloudbase.registerComponent(d)}catch(e){}function f(e){try{e.registerComponent(h),e.registerComponent(d)}catch(e){console.warn(e)}}t.registerMySQL=f;try{window.registerMySQL=f}catch(e){}i(n(8630),t)},5413:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Auth=void 0;var c=n(4949),u=n(5257),l=n(2962),h=n(2631),d=a(n(9639)),f=n(8308);function p(e,t){var r;return o(this,void 0,void 0,function(){var s,a=this;return i(this,function(c){s=function(){return o(a,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,1,,6]),[2,n(5814)];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,Promise.resolve().then(n.t.bind(n,5814,23))];case 3:return[2,e.sent()];case 4:return e.sent(),[2];case 5:return[3,6];case 6:return[2]}})})};try{if(((null===(r=null==t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).IS_MP_BUILD)return[2];if(e)return[2,s()]}catch(t){if(e)return[2,s()]}return[2]})})}var v=function(){function e(e){var t=e.request,n=e.credentialsClient;if(!n){var o={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};n=new u.OAuth2Client(o)}if(!t){var i=n.request.bind(n),s=new l.Captcha(r({env:e.env,clientId:e.clientId,request:i,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=s.request.bind(s)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:n,storage:e.storage||u.defaultStorage,adapter:e.adapter}}return e.parseParamsToSearch=function(e){return Object.keys(e).forEach(function(t){e[t]||delete e[t]}),new d.default(e).toString()},e.prototype.getParamsByVersion=function(e,t){var n,r=(0,h.deepClone)(e),o=(null===(n={v2:c.ApiUrlsV2}[null==r?void 0:r.version])||void 0===n?void 0:n[t])||c.ApiUrls[t];return r&&delete r.version,{params:r,url:o}},e.prototype.signIn=function(e){return o(this,void 0,Promise,function(){var t,n,o,s;return i(this,function(i){switch(i.label){case 0:return t=e.version||"v1",(n=this.getParamsByVersion(e,"AUTH_SIGN_IN_URL")).params.query&&delete n.params.query,[4,this.getEncryptParams(n.params)];case 1:return o=i.sent(),[4,this.config.request(n.url,{method:"POST",body:o})];case 2:return s=i.sent(),[4,this.config.credentialsClient.setCredentials(r(r({},s),{version:t}))];case 3:return i.sent(),[2,Promise.resolve(s)]}})})},e.prototype.signInAnonymously=function(e,t){return void 0===e&&(e={}),void 0===t&&(t=!1),o(this,void 0,Promise,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:e,useWxCloud:t})];case 1:return n=r.sent(),[4,this.config.credentialsClient.setCredentials(n)];case 2:return r.sent(),[2,Promise.resolve(n)]}})})},e.prototype.signUp=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_SIGN_UP_URL,{method:"POST",body:e})];case 1:return t=n.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return n.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signOut=function(e){return o(this,void 0,Promise,function(){var t,n,r,o;return i(this,function(i){switch(i.label){case 0:if(t={},!e)return[3,6];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.config.request(c.ApiUrls.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})];case 2:return t=i.sent(),[3,4];case 3:return(n=i.sent()).error!==c.ErrorType.UNAUTHENTICATED&&console.log("sign_out_error",n),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return i.sent(),[2,t];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return r=i.sent(),[4,this.config.request(c.ApiUrls.AUTH_REVOKE_URL,{method:"POST",body:{token:r}})];case 8:return o=i.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return i.sent(),[2,Promise.resolve(o)]}})})},e.prototype.revokeAllDevices=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}})})},e.prototype.revokeDevice=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.config.request(c.ApiUrls.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}})})},e.prototype.getVerification=function(e,t){return o(this,void 0,Promise,function(){var n,r;return i(this,function(o){switch(o.label){case 0:return n=!1,"CUR_USER"!==e.target?[3,1]:(n=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:o.sent()&&(n=!0),o.label=3;case 3:return(r=(0,h.deepClone)(e)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(r.phone_number)&&(r.phone_number="+86 ".concat(r.phone_number)),[2,this.config.request(c.ApiUrls.VERIFICATION_URL,{method:"POST",body:r,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:n})]}})})},e.prototype.verify=function(e){return o(this,void 0,Promise,function(){var t,n;return i(this,function(o){switch(o.label){case 0:return t=this.getParamsByVersion(e,"VERIFY_URL"),[4,this.config.request(t.url,{method:"POST",body:t.params})];case 1:return n=o.sent(),"v2"!==(null==e?void 0:e.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(r(r({},n),{version:"v2"}))];case 2:o.sent(),o.label=3;case 3:return[2,n]}})})},e.prototype.genProviderRedirectUri=function(t){return o(this,void 0,Promise,function(){var n,r,o,a,u;return i(this,function(i){return n=t.provider_redirect_uri,r=t.other_params,o=void 0===r?{}:r,a=s(t,["provider_redirect_uri","other_params"]),n&&!a.redirect_uri&&(a.redirect_uri=n),u="".concat(c.ApiUrls.PROVIDER_URI_URL,"?").concat(e.parseParamsToSearch(a)),Object.keys(o).forEach(function(e){var t=o[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(u+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))}),[2,this.config.request(u,{method:"GET"})]})})},e.prototype.grantProviderToken=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,function(){return i(this,function(n){return[2,this.config.request(c.ApiUrls.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:t})]})})},e.prototype.patchProviderToken=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})]})})},e.prototype.signInWithProvider=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return n=this.getParamsByVersion(e,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(n.url,{method:"POST",body:n.params,useWxCloud:t})];case 1:return o=i.sent(),[4,this.config.credentialsClient.setCredentials(r(r({},o),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return i.sent(),[2,Promise.resolve(o)]}})})},e.prototype.toBindIdentity=function(e){var t,n;return o(this,void 0,void 0,function(){var r,o,s,a;return i(this,function(i){switch(i.label){case 0:return(o=e.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:o=i.sent(),i.label=2;case 2:r=o,i.label=3;case 3:return i.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:e.provider_token},r)];case 4:return i.sent(),s={data:{type:c.OAUTH_TYPE.BIND_IDENTITY,provider:e.provider},error:null},[3,6];case 5:return a=i.sent(),s={data:{type:c.OAUTH_TYPE.BIND_IDENTITY},error:new f.AuthError(a)},[3,6];case 6:return e.fireEvent&&(null===(n=null===(t=this.config.eventBus)||void 0===t?void 0:t.fire)||void 0===n||n.call(t,c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:s})),[2,s]}})})},e.prototype.getInitialSession=function(){return o(this,void 0,Promise,function(){var e,t,n,o,s,a,u,l,h,d,p,v,y,g,m;return i(this,function(i){switch(i.label){case 0:e={},i.label=1;case 1:if(i.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(t=new URLSearchParams(null===location||void 0===location?void 0:location.search),n=t.get("code"),o=t.get("state"),!n||!o)return[2,{data:null,error:null}];s=null;try{s=JSON.parse(sessionStorage.getItem(o)||"null")}catch(e){}return e={type:null==s?void 0:s.type},a=t.get("error"),u=t.get("error_description"),a||u?[2,{data:e,error:new f.AuthError({message:u||a||"Unknown error from OAuth provider"})}]:(l=(null==s?void 0:s.provider)||t.get("provider"))?(h=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:l,provider_redirect_uri:h,provider_code:n})]):[2,{data:e,error:new f.AuthError({message:"Provider is required for OAuth verification"})}];case 2:return d=i.sent().provider_token,p=void 0,v=null,y=void 0,s.type!==c.OAUTH_TYPE.BIND_IDENTITY?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return p=i.sent(),[4,this.toBindIdentity({provider:l,provider_token:d,credentials:p})];case 4:return y=i.sent(),[3,11];case 5:return s.type!==c.OAUTH_TYPE.SIGN_IN?[3,11]:(y=this.getParamsByVersion({provider:l},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(y.url,{method:"POST",body:{provider_token:d}})]);case 6:p=i.sent(),i.label=7;case 7:return i.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:p})];case 8:return v=i.sent(),[3,10];case 9:return g=i.sent(),console.error("get user info error",g),[3,10];case 10:y={data:r(r({},e),{session:p,user:v}),error:null},i.label=11;case 11:t.delete("code"),t.delete("state"),t.delete("provider"),this.restoreUrlState(void 0===(null==s?void 0:s.search)?"?".concat(t.toString()):s.search,(null==s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(o)}catch(e){}return[2,y];case 12:return m=i.sent(),[2,{data:e,error:new f.AuthError(m)}];case 13:return[2]}})})},e.prototype.signInCustom=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e})];case 1:return t=n.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return n.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:e})];case 1:return t=n.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return n.sent(),[2,Promise.resolve(t)]}})})},e.prototype.bindWithProvider=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){return[2,this.config.request(c.ApiUrls.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?function(){return t}:void 0})]})})},e.prototype.getUserProfile=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.getUserInfo(e)]})})},e.prototype.getUserInfo=function(e){var t,n,r;return void 0===e&&(e={}),o(this,void 0,Promise,function(){var o,s,a,c,u;return i(this,function(i){switch(i.label){case 0:return o=this.getParamsByVersion(e,"USER_ME_URL"),(null===(t=o.params)||void 0===t?void 0:t.query)&&(s=new d.default(o.params.query),o.url+="?".concat(s.toString())),[4,this.config.request(o.url,{method:"GET",withCredentials:!0,getCredentials:e.credentials?function(){return e.credentials}:void 0})];case 1:if((a=i.sent()).sub&&(a.uid=a.sub),null===(n=a.providers)||void 0===n?void 0:n.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(c=null===(r=wx.getAccountInfoSync().miniProgram)||void 0===r?void 0:r.appId,(null==(u=a.providers.find(function(e){return e.id===c}))?void 0:u.provider_user_id)&&(a.open_id=u.provider_user_id))}catch(e){}return[2,a]}})})},e.prototype.getWedaUserInfo=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.config.request(c.ApiUrls.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,e.sent()]}})})},e.prototype.deleteMe=function(t){return o(this,void 0,Promise,function(){var n,r;return i(this,function(o){return n=this.getParamsByVersion(t,"USER_ME_URL"),r="".concat(n.url,"?").concat(e.parseParamsToSearch(n.params)),[2,this.config.request(r,{method:"DELETE",withCredentials:!0})]})})},e.prototype.hasLoginState=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}})})},e.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},e.prototype.getLoginState=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getCredentialsAsync()]})})},e.prototype.transByProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.grantToken=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){return t=this.getParamsByVersion(e,"AUTH_TOKEN_URL"),[2,this.config.request(t.url,{method:"POST",body:t.params})]})})},e.prototype.getProviders=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrls.PROVIDER_LIST,{method:"GET",withCredentials:!0})]})})},e.prototype.unbindProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})]})})},e.prototype.checkPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.editContact=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.setPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.updatePasswordByOld=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.sudo({password:e.old_password})];case 1:return t=n.sent(),[2,this.setPassword({sudo_token:t.sudo_token,new_password:e.new_password})]}})})},e.prototype.sudo=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.SUDO_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.sendVerificationCodeToCurrentUser=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return e.target="CUR_USER",[2,this.config.request(c.ApiUrls.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})]})})},e.prototype.changeBoundProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})]})})},e.prototype.setUserProfile=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.updateUserBasicInfo=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.queryUserProfile=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){return t=new d.default(e),[2,this.config.request("".concat(c.ApiUrls.USER_QUERY_URL,"?").concat(t.toString()),{method:"GET",withCredentials:!0})]})})},e.prototype.setCustomSignFunc=function(e){this.getCustomSignTicketFn=e},e.prototype.signInWithCustomTicket=function(){return o(this,void 0,Promise,function(){var e,t;return i(this,function(n){switch(n.label){case 0:return(e=this.getCustomSignTicketFn)?[4,e()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return t=n.sent(),[2,this.signInCustom({provider_id:"custom",ticket:t})]}})})},e.prototype.resetPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.AUTH_RESET_PASSWORD,{method:"POST",body:e})]})})},e.prototype.authorize=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.authorizeDevice=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.deviceAuthorize=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.AUTH_GET_DEVICE_CODE,{method:"POST",body:e})]})})},e.prototype.authorizeInfo=function(t){return o(this,void 0,Promise,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n="".concat(c.ApiUrls.AUTHORIZE_INFO_URL,"?").concat(e.parseParamsToSearch(t)),r=!0,o=!1,[4,this.hasLoginState()];case 1:return i.sent()&&(o=!0,r=!1),[2,this.config.request(n,{method:"GET",withBasicAuth:r,withCredentials:o})]}})})},e.prototype.checkUsername=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})]})})},e.prototype.checkIfUserExist=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){return t=new d.default(e),[2,this.config.request("".concat(c.ApiUrls.CHECK_IF_USER_EXIST,"?").concat(t.toString()),{method:"GET"})]})})},e.prototype.loginScope=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getScope()]})})},e.prototype.loginGroups=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getGroups()]})})},e.prototype.refreshTokenForce=function(e){return o(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return t=n.sent(),[4,this.config.credentialsClient.refreshToken(r(r({},t),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return[2,n.sent()]}})})},e.prototype.getCredentials=function(){return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.credentialsClient.getCredentials()]})})},e.prototype.getPublicKey=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrlsV2.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]})})},e.prototype.getEncryptParams=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,a;return i(this,function(i){switch(i.label){case 0:return t=e.isEncrypt,delete e.isEncrypt,n=(0,h.deepClone)(e),[4,p(t,this.config.adapter)];case 1:if(!(r=i.sent()))return[2,e];o="",s="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(a=i.sent(),o=a.public_key,s=a.public_key_thumbprint,!o||!s)throw a;return[3,5];case 4:throw i.sent();case 5:return[2,{params:r.getEncryptInfo({publicKey:o,payload:n}),public_key_thumbprint:s}]}})})},e.prototype.getProviderSubType=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrls.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]})})},e.prototype.verifyCaptchaData=function(e){var t=e.token,n=e.key;return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrls.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:n},withCredentials:!1})]})})},e.prototype.createCaptchaData=function(e){var t=e.state,n=e.redirect_uri,r=void 0===n?void 0:n;return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:r},withCredentials:!1})]})})},e.prototype.getMiniProgramCode=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})]})})},e.prototype.getMiniProgramQrCodeStatus=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})]})})},e.prototype.getUserBehaviorLog=function(e){return o(this,void 0,Promise,function(){var t,n;return i(this,function(r){return t={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},n="".concat(c.ApiUrls.GET_USER_BEHAVIOR_LOG,"?").concat(t[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):""),[2,this.config.request(n,{method:"GET",withCredentials:!0})]})})},e.prototype.modifyPassword=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,a;return i(this,function(i){switch(i.label){case 0:return t="",n="",[4,p(!0,this.config.adapter)];case 1:if(!(r=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,n=o.public_key_thumbprint,!t||!n)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?r.getEncryptInfo({publicKey:t,payload:e.password}):"",a=r.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(c.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:n}})]}})})},e.prototype.modifyPasswordWithoutLogin=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,a;return i(this,function(i){switch(i.label){case 0:return t="",n="",[4,p(!0,this.config.adapter)];case 1:if(!(r=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,n=o.public_key_thumbprint,!t||!n)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?r.getEncryptInfo({publicKey:t,payload:e.password}):"",a=r.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(c.ApiUrlsV2.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:s,new_password:a,public_key_thumbprint:n}})]}})})},e.prototype.restoreUrlState=function(e,t){if(void 0!==e)try{var n=new URL(window.location.href);n.search=e,n.hash=t||"",window.history.replaceState(null,"",n.toString()),window.location.replace(n.toString())}catch(e){}},e}();t.Auth=v},8308:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.isAuthError=t.AuthError=t.AuthErrorCategory=void 0;var i,s=n(4949);!function(e){e.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS",e.USER_NOT_FOUND="USER_NOT_FOUND",e.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",e.SERVICE_ERROR="SERVICE_ERROR",e.INVALID_PARAMS="INVALID_PARAMS",e.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",e.RATE_LIMITED="RATE_LIMITED",e.CAPTCHA_REQUIRED="CAPTCHA_REQUIRED",e.CAPTCHA_INVALID="CAPTCHA_INVALID",e.MFA_REQUIRED="MFA_REQUIRED",e.PRECONDITION_FAILED="PRECONDITION_FAILED",e.VERIFICATION_FAILED="VERIFICATION_FAILED",e.UNKNOWN="UNKNOWN"}(i=t.AuthErrorCategory||(t.AuthErrorCategory={}));var a="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",c="https://docs.cloudbase.net/api-reference/webv3/initialization";function u(e,t){var n=(null==t?void 0:t.method)||"signIn",r={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」",getVerification:"「短信验证码登录」或「邮箱验证码登录」",verify:"「短信验证码登录」或「邮箱验证码登录」",verifyOtp:"「短信验证码登录」或「邮箱验证码登录」",resetPasswordForEmail:"「邮箱验证码登录」",reauthenticate:"「短信验证码登录」或「邮箱验证码登录」"}[n]||"对应的登录方式";switch(e){case i.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(n,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(r,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(a,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(c);case i.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(n,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case i.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(a,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case i.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(a);case i.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。\n 常见服务端错误:smtp 未配置、短信服务未配置、wedaapis 未设置等。";case i.INVALID_PARAMS:if((null==t?void 0:t.errorCode)===s.AuthErrorCode.MISSING_REQUIRED_PARAM||(null==t?void 0:t.code)===s.ErrorType.MISSING_REQUIRED_PARAM){var o=["verifyOtp","signInWithOtp","signUp"].includes(n)?"\n 若在校验验证码阶段缺参:\n - 独立调用 auth.verifyOtp() 时 messageId 为必填,请补上 params.messageId。\n - 推荐改用发码接口返回的回调(SDK 会自动携带 messageId):\n const { data } = await auth.signInWithOtp({ phone })\n await data.verifyOtp({ token })\n // 或 auth.signUp({ phone }) 返回的 data.verifyOtp\n":"";return"[CloudBase Auth] 缺少必填参数\n\n"+" 调用 auth.".concat(n,"() 时缺少必填参数。\n")+" 这是客户端入参问题,不是控制台通道配置问题。\n\n 修复方式:\n"+" 1. 查看 error.message 中的参数路径,补上缺失字段。\n".concat(o,"\n 参考 API 文档确认各参数的格式和约束:").concat(c)}return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求:\n - 不能同时输入手机号和邮箱\n - 手机号格式需正确(如 +86 开头)\n - 必须提供手机号或邮箱\n\n"+" 参考 API 文档确认各参数的格式和约束:".concat(c);case i.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(n,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(a);case i.RATE_LIMITED:return"[CloudBase Auth] 发送频率受限\n\n 验证码发送过于频繁,已触发频率限制。\n\n 限制规则:\n - 手机号:每分钟最多 1 条,每天有上限\n - 邮箱:每分钟有上限,每天有上限(默认 50 条)\n\n 建议:\n 1. 检查 error.retryAfter 获取建议等待时间\n 2. 在 UI 中显示倒计时,防止用户重复点击\n 3. 如业务需要更高频率,请联系技术支持调整限额";case i.CAPTCHA_REQUIRED:return"[CloudBase Auth] 需要滑块验证码\n\n 当前操作触发了风控策略,需要完成滑块验证。\n\n 处理方式:\n 1. 调用滑块验证码 SDK 展示验证组件\n 2. 用户完成验证后,将 captcha_token 附带到请求中重新发送\n 3. 可通过 getVerification 的 options.withCaptcha 参数自动携带验证码";case i.CAPTCHA_INVALID:return"[CloudBase Auth] 滑块验证码校验失败\n\n 提交的验证码 token 校验未通过(可能已过期或 client_id 不匹配)。\n\n 处理方式:\n 1. 刷新滑块验证码,让用户重新验证\n 2. 确认 captcha 组件初始化的 client_id 与认证配置一致";case i.MFA_REQUIRED:return"[CloudBase Auth] 需要 MFA 验证\n\n 当前操作要求用户绑定手机号进行多因素认证 (MFA)。\n\n 处理方式:\n 1. 引导用户进入手机号绑定流程\n 2. 绑定完成后重新执行原操作\n 3. error 中可能包含 MFA 详情信息";case i.PRECONDITION_FAILED:return"[CloudBase Auth] 前置条件不满足\n\n 当前操作的前置条件不满足,常见原因:\n - 该手机号/邮箱已被其他账号绑定\n - 目标用户不存在或已存在(与 target 参数冲突)\n - 当前邮箱/手机号未注册用户\n\n 请根据 error.message 中的具体描述处理。";case i.VERIFICATION_FAILED:return'[CloudBase Auth] 验证码校验失败\n\n 验证码验证未通过,常见原因:\n - 验证码已过期(通常有效期为几分钟)\n - 验证码输入不正确\n - verification_id 无效或已被使用\n - 验证码不属于当前项目(project id does not match)\n\n 处理方式:\n 1. 提示用户"验证码已过期或不正确,请重新获取"\n 2. 调用 getVerification() 重新发送验证码\n 3. 确保 verification_id 与最新发送的验证码对应\n\n 注意:每次重新发送验证码后,之前的 verification_id 即失效。';default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(a,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(c)}}function l(e){return e&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[e]||""}var h=function(e){function t(t,n){var r=this,o=d(t);return(r=e.call(this,o?t.message:t.error_description||t.message)||this).__isAuthError=!0,r.name="AuthError",o?(r.status=t.status,r.code=t.code,r.errorCode=t.errorCode,r.requestId=t.requestId,r.category=t.category,r.retryAfter=t.retryAfter,r.helpMessage=u(r.category,{method:null==n?void 0:n.method,errorCode:r.errorCode,code:r.code}),r.loginMethodHint=l(null==n?void 0:n.method),r):(r.status=t.error,r.code=String(t.error||t.error_code||"unknown").toLowerCase(),r.errorCode="number"==typeof t.error_code?t.error_code:"string"==typeof t.error_code&&parseInt(t.error_code,10)||void 0,r.requestId=t.requestId,r.category=function(e,t,n){if(!e&&!t&&!n)return i.UNKNOWN;try{var r=(e||"").toLowerCase(),o="string"==typeof n?parseInt(n,10):n;return o===s.AuthErrorCode.MISSING_REQUIRED_PARAM||t===s.ErrorType.MISSING_REQUIRED_PARAM?i.INVALID_PARAMS:o===s.AuthErrorCode.CAPTCHA_REQUIRED||t===s.ErrorType.CAPTCHA_REQUIRED?i.CAPTCHA_REQUIRED:o===s.AuthErrorCode.CAPTCHA_INVALID||t===s.ErrorType.CAPTCHA_INVALID?i.CAPTCHA_INVALID:o===s.AuthErrorCode.MFA_PHONE_REQUIRED||t===s.ErrorType.MFA_PHONE_REQUIRED?i.MFA_REQUIRED:o===s.AuthErrorCode.LOGIN_TYPE_DISABLED||t===s.ErrorType.LOGIN_TYPE_DISABLED?i.PROVIDER_NOT_ENABLED:o===s.AuthErrorCode.RESOURCE_EXHAUSTED||t===s.ErrorType.RESOURCE_EXHAUSTED?i.RATE_LIMITED:o===s.AuthErrorCode.INTERNAL||o===s.AuthErrorCode.UNAVAILABLE||o===s.AuthErrorCode.UNIMPLEMENTED||o===s.AuthErrorCode.ABORTED?i.SERVICE_ERROR:o===s.AuthErrorCode.NOT_FOUND?i.USER_NOT_FOUND:o===s.AuthErrorCode.UNAUTHENTICATED?i.INVALID_CREDENTIALS:o===s.AuthErrorCode.INVALID_ARGUMENT&&(r.includes("验证码")||r.includes("verification")||r.includes("verification_code")||r.includes("verification_id")||r.includes("does not match")||r.includes("token expired")||r.includes("token error")||r.includes("过期"))?i.VERIFICATION_FAILED:t===s.ErrorType.PROVIDER_NOT_ENABLED||t===s.ErrorType.LOGIN_METHOD_DISABLED||r.includes("身份源")||r.includes("开启")||r.includes("identity provider")||r.includes("provider not enabled")||r.includes("login method")||r.includes("登录方式")||r.includes("not enabled")||r.includes("未开启")||r.includes("未启用")||r.includes("请联系开发者")||r.includes("anonymous login is not enabled")||r.includes("匿名登录未开启")?i.PROVIDER_NOT_ENABLED:t===s.ErrorType.FAILED_PRECONDITION||o===s.AuthErrorCode.FAILED_PRECONDITION&&!r.includes("请联系开发者")?r.includes("不存在")||r.includes("not found")||r.includes("未注册")?i.USER_NOT_FOUND:i.PRECONDITION_FAILED:t===s.ErrorType.INVALID_PASSWORD||t===s.ErrorType.INVALID_GRANT||t===s.ErrorType.INVALID_VERIFICATION_CODE||t===s.ErrorType.INVALID_USERNAME_OR_PASSWORD||t===s.ErrorType.INVALID_CREDENTIALS||t===s.ErrorType.WRONG_PASSWORD||t===s.ErrorType.UNAUTHENTICATED||t===s.ErrorType.INVALID_TWO_FACTOR||t===s.ErrorType.INVALID_TWO_FACTOR_RECOVERY||t===s.ErrorType.PASSWORD_NOT_SET||r.includes("密码不正确")||r.includes("password")||r.includes("invalid_password")||r.includes("凭据")||r.includes("credentials")||r.includes("验证码")||r.includes("verification")||r.includes("invalid_verification_code")||r.includes("invalid_username_or_password")||r.includes("username or password")||r.includes("用户名或密码")||r.includes("wrong password")||r.includes("incorrect password")?i.INVALID_CREDENTIALS:t===s.ErrorType.NOT_FOUND||t===s.ErrorType.USER_NOT_FOUND||r.includes("用户不存在")||r.includes("not found")||r.includes("user not found")||r.includes("no such user")||r.includes("user does not exist")?i.USER_NOT_FOUND:t===s.ErrorType.USER_BLOCKED||t===s.ErrorType.USER_PENDING||t===s.ErrorType.UNDER_REVIEW||t===s.ErrorType.INVALID_STATUS||r.includes("被封禁")||r.includes("blocked")||r.includes("pending")||r.includes("审核")||r.includes("review")||r.includes("locked")||r.includes("已锁定")?i.USER_STATUS_ABNORMAL:t===s.ErrorType.SERVER_ERROR||t===s.ErrorType.UNAVAILABLE||t===s.ErrorType.TEMPORARILY_UNAVAILABLE||t===s.ErrorType.INTERNAL||t===s.ErrorType.UNREACHABLE||t===s.ErrorType.DEADLINE_EXCEEDED||t===s.ErrorType.DATA_LOSS||t===s.ErrorType.ABORTED||r.includes("network")||r.includes("timeout")||r.includes("timed out")||r.includes("超时")||r.includes("smtp is not set")||r.includes("sms sender does not config")?i.SERVICE_ERROR:t===s.ErrorType.INVALID_ARGUMENT||t===s.ErrorType.INVALID_REQUEST||t===s.ErrorType.INVALID_SCOPE||t===s.ErrorType.INVALID_REQUEST_URI||t===s.ErrorType.INVALID_REQUEST_OBJECT||o===s.AuthErrorCode.INVALID_ARGUMENT?i.INVALID_PARAMS:t===s.ErrorType.PERMISSION_DENIED||t===s.ErrorType.ACCESS_DENIED||t===s.ErrorType.UNAUTHORIZED_CLIENT?i.PROVIDER_NOT_ENABLED:i.UNKNOWN}catch(e){return t}}(r.message,r.status,r.errorCode),r.helpMessage=u(r.category,{method:null==n?void 0:n.method,errorCode:r.errorCode,code:r.code}),r.loginMethodHint=l(null==n?void 0:n.method),r.category===i.RATE_LIMITED&&(r.retryAfter=t.retry_after||t.retryAfter||void 0),r)}return o(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,code:this.code,errorCode:this.errorCode,status:this.status,requestId:this.requestId,category:this.category,retryAfter:this.retryAfter}},t}(Error);function d(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}t.AuthError=h,t.isAuthError=d},4949:function(e,t){"use strict";var n,r,o,i,s,a;Object.defineProperty(t,"__esModule",{value:!0}),t.VerificationUsage=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.EVENTS=t.AUTH_STATE_CHANGED_TYPE=t.LOGIN_STATE_CHANGED_TYPE=t.AuthErrorCode=t.ErrorType=t.VerificationUsages=t.ApiUrlsV2=t.ApiUrls=t.AUTH_API_PREFIX=void 0,t.AUTH_API_PREFIX="/auth",(a=t.ApiUrls||(t.ApiUrls={})).AUTH_SIGN_UP_URL="/v1/signup",a.AUTH_TOKEN_URL="/v1/token",a.AUTH_REVOKE_URL="/v1/revoke",a.WEDA_USER_URL="/v1/plugin/weda/userinfo",a.AUTH_RESET_PASSWORD="/v1/reset",a.AUTH_GET_DEVICE_CODE="/v1/device/code",a.CHECK_USERNAME="/v1/checkUsername",a.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",a.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",a.AUTH_SIGN_IN_URL="/v1/signin",a.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",a.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",a.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",a.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",a.PROVIDER_TOKEN_URL="/v1/provider/token",a.PROVIDER_URI_URL="/v1/provider/uri",a.USER_ME_URL="/v1/user/me",a.AUTH_SIGNOUT_URL="/v1/user/signout",a.USER_QUERY_URL="/v1/user/query",a.USER_PRIFILE_URL="/v1/user/profile",a.USER_BASIC_EDIT_URL="/v1/user/basic/edit",a.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",a.PROVIDER_LIST="/v1/user/provider",a.PROVIDER_BIND_URL="/v1/user/provider/bind",a.PROVIDER_UNBIND_URL="/v1/user/provider",a.CHECK_PWD_URL="/v1/user/sudo",a.SUDO_URL="/v1/user/sudo",a.BIND_CONTACT_URL="/v1/user/contact",a.AUTH_SET_PASSWORD="/v1/user/password",a.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",a.AUTHORIZE_URL="/v1/user/authorize",a.AUTHORIZE_INFO_URL="/v1/user/authorize/info",a.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",a.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",a.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",a.VERIFICATION_URL="/v1/verification",a.VERIFY_URL="/v1/verification/verify",a.CAPTCHA_DATA_URL="/v1/captcha/data",a.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",a.GET_CAPTCHA_URL="/v1/captcha/init",a.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",a.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status",(s=t.ApiUrlsV2||(t.ApiUrlsV2={})).AUTH_SIGN_IN_URL="/v2/signin/username",s.AUTH_TOKEN_URL="/v2/token",s.USER_ME_URL="/v2/user/me",s.VERIFY_URL="/v2/signin/verificationcode",s.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",s.AUTH_PUBLIC_KEY="/v2/signin/publichkey",s.AUTH_RESET_PASSWORD="/v2/signin/password/update",(i=t.VerificationUsages||(t.VerificationUsages={})).REGISTER="REGISTER",i.SIGN_IN="SIGN_IN",i.PASSWORD_RESET="PASSWORD_RESET",i.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",i.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE",(o=t.ErrorType||(t.ErrorType={})).UNREACHABLE="unreachable",o.LOCAL="local",o.CANCELLED="cancelled",o.UNKNOWN="unknown",o.UNAUTHENTICATED="unauthenticated",o.RESOURCE_EXHAUSTED="resource_exhausted",o.FAILED_PRECONDITION="failed_precondition",o.INVALID_ARGUMENT="invalid_argument",o.DEADLINE_EXCEEDED="deadline_exceeded",o.NOT_FOUND="not_found",o.ALREADY_EXISTS="already_exists",o.PERMISSION_DENIED="permission_denied",o.ABORTED="aborted",o.OUT_OF_RANGE="out_of_range",o.UNIMPLEMENTED="unimplemented",o.INTERNAL="internal",o.UNAVAILABLE="unavailable",o.DATA_LOSS="data_loss",o.INVALID_PASSWORD="invalid_password",o.PASSWORD_NOT_SET="password_not_set",o.INVALID_STATUS="invalid_status",o.USER_PENDING="user_pending",o.USER_BLOCKED="user_blocked",o.INVALID_VERIFICATION_CODE="invalid_verification_code",o.TWO_FACTOR_REQUIRED="two_factor_required",o.INVALID_TWO_FACTOR="invalid_two_factor",o.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",o.UNDER_REVIEW="under_review",o.INVALID_REQUEST="invalid_request",o.UNAUTHORIZED_CLIENT="unauthorized_client",o.ACCESS_DENIED="access_denied",o.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",o.INVALID_SCOPE="invalid_scope",o.INVALID_GRANT="invalid_grant",o.SERVER_ERROR="server_error",o.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",o.INTERACTION_REQUIRED="interaction_required",o.LOGIN_REQUIRED="login_required",o.ACCOUNT_SELECTION_REQUIRED="account_selection_required",o.CONSENT_REQUIRED="consent_required",o.INVALID_REQUEST_URI="invalid_request_uri",o.INVALID_REQUEST_OBJECT="invalid_request_object",o.REQUEST_NOT_SUPPORTED="request_not_supported",o.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",o.REGISTRATION_NOT_SUPPORTED="registration_not_supported",o.CAPTCHA_REQUIRED="captcha_required",o.CAPTCHA_INVALID="captcha_invalid",o.PROVIDER_NOT_ENABLED="provider_not_enabled",o.LOGIN_METHOD_DISABLED="login_method_disabled",o.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",o.INVALID_CREDENTIALS="invalid_credentials",o.WRONG_PASSWORD="wrong_password",o.USER_NOT_FOUND="user_not_found",o.MFA_PHONE_REQUIRED="mfa_phone_required",o.LOGIN_TYPE_DISABLED="login_type_disabled",o.PROVIDER_ERROR="provider_error",o.MISSING_REQUIRED_PARAM="missing_required_param",(r=t.AuthErrorCode||(t.AuthErrorCode={}))[r.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",r[r.NOT_FOUND=5]="NOT_FOUND",r[r.PERMISSION_DENIED=7]="PERMISSION_DENIED",r[r.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",r[r.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",r[r.ABORTED=10]="ABORTED",r[r.UNIMPLEMENTED=12]="UNIMPLEMENTED",r[r.INTERNAL=13]="INTERNAL",r[r.UNAVAILABLE=14]="UNAVAILABLE",r[r.UNAUTHENTICATED=16]="UNAUTHENTICATED",r[r.MISSING_REQUIRED_PARAM=4e3]="MISSING_REQUIRED_PARAM",r[r.CAPTCHA_REQUIRED=4001]="CAPTCHA_REQUIRED",r[r.CAPTCHA_INVALID=4002]="CAPTCHA_INVALID",r[r.PROVIDER_ERROR=4019]="PROVIDER_ERROR",r[r.UNAUTHORIZED_CLIENT=4022]="UNAUTHORIZED_CLIENT",r[r.MFA_PHONE_REQUIRED=4042]="MFA_PHONE_REQUIRED",r[r.LOGIN_TYPE_DISABLED=4045]="LOGIN_TYPE_DISABLED",t.LOGIN_STATE_CHANGED_TYPE={SIGN_OUT:"sign_out",SIGN_IN:"sign_in",CREDENTIALS_ERROR:"credentials_error"},t.AUTH_STATE_CHANGED_TYPE={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},t.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},t.OAUTH_TYPE={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},t.DEFAULT_NODE_ACCESS_SCOPE="node-sdk-scope",(n=t.VerificationUsage||(t.VerificationUsage={})).EMAIL="email",n.RECOVERY="recovery",n.REAUTHENTICATION="reauthentication"},3538:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2084:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.openURIWithCallback=void 0;var s=n(9689),a=n(3616),c=function(e,t){var n;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];clearTimeout(n),n=setTimeout(function(){return e.apply(null,r)},t)}},u=new s.CloudbaseEventEmitter,l="resolveCaptchaData",h="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",d="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",f="background:#6c757d;cursor:not-allowed";t.openURIWithCallback=function(e,t){return o(void 0,void 0,Promise,function(){var n,s,p,v;return i(this,function(y){return n=(0,a.parseCaptcha)(e),s=n.captchaData,p=n.state,v=n.token,function(e){var t=e.oauthInstance,n=e.captchaState,s="captcha-image",a=function(){return o(void 0,void 0,void 0,function(){var e,o;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t.createCaptchaData({state:n.state})];case 1:return e=i.sent(),n=r(r({},n),{captchaData:e.data,token:e.token}),document.getElementById(s).src=e.data,[3,3];case 2:return o=i.sent(),console.error("刷新图形验证码失败",o),[3,3];case 3:return[2]}})})},p=function(e,t,n){var r=document.createElement(e);return t&&(r.style.cssText=t),n&&(r.textContent=n),r},v=p("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),y=p("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");y.appendChild(p("p","margin-bottom:15px","请输入你看到的字符:"));var g=p("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),m=p("img","width:100%;height:auto;border:1px solid #eee");m.id=s,m.src=n.captchaData,g.appendChild(m);var b=p("button",h,"刷新");b.onclick=c(function(){return o(void 0,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:b.textContent="加载中...",b.disabled=!0,b.style.cssText="".concat(h,";").concat(f),e.label=1;case 1:return e.trys.push([1,,3,4]),[4,a()];case 2:return e.sent(),[3,4];case 3:return b.textContent="刷新",b.disabled=!1,b.style.cssText=h,[7];case 4:return[2]}})})},500),g.appendChild(b),y.appendChild(g);var _=p("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");_.type="text",_.placeholder="输入字符",_.maxLength=4,y.appendChild(_);var E=p("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");y.appendChild(E);var w=function(e){E.textContent=e,E.style.display="block"},S=p("button",d,"确定");S.onclick=c(function(){return o(void 0,void 0,void 0,function(){var e,r,o,s;return i(this,function(i){switch(i.label){case 0:if(!(e=_.value.trim()))return w("请输入字符"),[2];E.style.display="none",S.textContent="验证中...",S.disabled=!0,S.style.cssText="".concat(d,";").concat(f),i.label=1;case 1:return i.trys.push([1,3,5,6]),[4,t.verifyCaptchaData({token:n.token,key:e})];case 2:return r=i.sent(),u.fire(l,r),console.log("图形验证码校验成功"),document.body.removeChild(v),document.body.removeChild(y),[3,6];case 3:return o=i.sent(),console.error("图形验证码校验失败",o),s=o.error_description||"图形验证码校验失败",w(s),_.value="",_.focus(),[4,a()];case 4:return i.sent(),[3,6];case 5:return S.textContent="确定",S.disabled=!1,S.style.cssText=d,[7];case 6:return[2]}})})},500),y.appendChild(S),document.body.appendChild(v),document.body.appendChild(y)}({oauthInstance:t,captchaState:{captchaData:s,state:p,token:v}}),[2,new Promise(function(e){console.log("等待图形验证码校验结果..."),u.on(l,function(t){e(null==t?void 0:t.data)})})]})})}},2962:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Captcha=void 0;var i=n(4949),s=n(5257),a=n(7425),c=n(2084),u=function(){function e(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=s.defaultStorage),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}return e.prototype.isMatch=function(){var e,t,n;return(null===(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.adapter)||void 0===t?void 0:t.isMatch)||void 0===n?void 0:n.call(t))||(0,a.isMp)()},e.prototype.request=function(e,t){return r(this,void 0,Promise,function(){var n,r,s,a;return o(this,function(o){switch(o.label){case 0:return t||(t={}),t.method||(t.method="GET"),n="".concat(t.method,":").concat(e),r=e,t.withCaptcha?[4,this.appendCaptchaTokenToURL(e,n,!1)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return o.trys.push([2,4,,7]),[4,this.config.request(r,t)];case 3:return s=o.sent(),[3,7];case 4:return(a=o.sent()).error!==i.ErrorType.CAPTCHA_REQUIRED&&a.error!==i.ErrorType.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(e,n,a.error===i.ErrorType.CAPTCHA_INVALID)];case 5:return e=o.sent(),[2,this.config.request(e,t)];case 6:return[2,Promise.reject(a)];case 7:return[2,s]}})})},e.prototype.getDefaultOpenURIWithCallback=function(){var e=this;return function(t){return(0,c.openURIWithCallback)(t,e.config.oauthInstance)}},e.prototype.getCaptchaToken=function(e,t){return r(this,void 0,Promise,function(){var n,r,s,a;return o(this,function(o){switch(o.label){case 0:return e?[3,2]:[4,this.findCaptchaToken()];case 1:if(n=o.sent())return[2,n];o.label=2;case 2:return[4,this.config.request(i.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1})];case 3:return r=o.sent(),s="".concat(r.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(r.token)),[4,this.config.openURIWithCallback(s)];case 4:return a=o.sent(),this.saveCaptchaToken(a),[2,a.captcha_token]}})})},e.prototype.appendCaptchaTokenToURL=function(e,t,n){return r(this,void 0,Promise,function(){var r;return o(this,function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(n,t)];case 1:return r=o.sent(),e.indexOf("?")>0?e+="&captcha_token=".concat(r):e+="?captcha_token=".concat(r),[2,e]}})})},e.prototype.saveCaptchaToken=function(e){return r(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10)),t=JSON.stringify(e),[4,this.config.storage.setItem(this.tokenSectionName,t)];case 1:return n.sent(),[2]}})})},e.prototype.findCaptchaToken=function(){return r(this,void 0,Promise,function(){var e,t;return o(this,function(n){switch(n.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),t.expires_at<new Date?[2,null]:[2,t.captcha_token];case 3:return n.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),[2,null];case 5:return[2,null]}})})},e}();t.Captcha=u},6722:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseOAuth=t.VerificationUsage=t.ErrorType=t.AuthErrorCode=t.AUTH_STATE_CHANGED_TYPE=t.EVENTS=t.LOGIN_STATE_CHANGED_TYPE=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.AUTH_API_PREFIX=t.weAppJwtDecodeAll=t.authModels=t.isAuthError=t.AuthErrorCategory=t.AuthError=t.Auth=void 0;var a=n(5257),c=n(5413),u=n(4949),l=n(5413);Object.defineProperty(t,"Auth",{enumerable:!0,get:function(){return l.Auth}});var h=n(8308);Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return h.AuthError}}),Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return h.AuthErrorCategory}}),Object.defineProperty(t,"isAuthError",{enumerable:!0,get:function(){return h.isAuthError}}),t.authModels=s(n(3538));var d=n(2344);Object.defineProperty(t,"weAppJwtDecodeAll",{enumerable:!0,get:function(){return d.weAppJwtDecodeAll}});var f=n(4949);Object.defineProperty(t,"AUTH_API_PREFIX",{enumerable:!0,get:function(){return f.AUTH_API_PREFIX}}),Object.defineProperty(t,"OAUTH_TYPE",{enumerable:!0,get:function(){return f.OAUTH_TYPE}}),Object.defineProperty(t,"DEFAULT_NODE_ACCESS_SCOPE",{enumerable:!0,get:function(){return f.DEFAULT_NODE_ACCESS_SCOPE}}),Object.defineProperty(t,"LOGIN_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.LOGIN_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"EVENTS",{enumerable:!0,get:function(){return f.EVENTS}}),Object.defineProperty(t,"AUTH_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.AUTH_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return f.AuthErrorCode}}),Object.defineProperty(t,"ErrorType",{enumerable:!0,get:function(){return f.ErrorType}}),Object.defineProperty(t,"VerificationUsage",{enumerable:!0,get:function(){return f.VerificationUsage}});var p=function(){function e(e){var t=e.apiOrigin,n=e.getApiOrigin,o=e.apiPath,i=void 0===o?u.AUTH_API_PREFIX:o,s=e.clientId,l=e.env,h=e.storage,d=e.request,f=e.baseRequest,p=e.anonymousSignInFunc,v=e.wxCloud,y=e.adapter,g=e.onCredentialsError,m=e.headers,b=e.i18n,_=e.useWxCloud,E=e.eventBus,w=e.detectSessionInUrl,S=e.debug;if(this.detectSessionInUrl=null!=w&&w,this.oauth2client=new a.OAuth2Client({apiOrigin:t,getApiOrigin:n,apiPath:i,clientId:s,env:l,storage:h,baseRequest:f||d,anonymousSignInFunc:p,wxCloud:v,onCredentialsError:g,headers:m||{},i18n:b,useWxCloud:_,eventBus:E,debug:S}),this.authApi=new c.Auth(r(r({credentialsClient:this.oauth2client},e),{request:d?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:y})),w)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var I=new URL(window.location.href),O=I.searchParams.get("code"),A=I.searchParams.get("state"),T=JSON.parse(sessionStorage.getItem(A)||"null");O&&A&&(null==T?void 0:T.hash)&&(I.hash=T.hash,window.history.replaceState(null,"",I.toString()),window.location.replace(I.toString()))}catch(e){}}return e.prototype.initializeSession=function(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},e}();t.CloudbaseOAuth=p},6877:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Syntax=t.ErrorType=void 0;var r,o=n(4949);Object.defineProperty(t,"ErrorType",{enumerable:!0,get:function(){return o.ErrorType}}),(r=t.Syntax||(t.Syntax={})).CLIENT_ID="client_id",r.CLIENT_SECRET="client_secret",r.RESPONSE_TYPE="response_type",r.SCOPE="scope",r.STATE="state",r.REDIRECT_URI="redirect_uri",r.ERROR="error",r.ERROR_DESCRIPTION="error_description",r.ERROR_URI="error_uri",r.GRANT_TYPE="grant_type",r.CODE="code",r.ACCESS_TOKEN="access_token",r.TOKEN_TYPE="token_type",r.EXPIRES_IN="expires_in",r.USERNAME="username",r.PASSWORD="password",r.REFRESH_TOKEN="refresh_token"},5257:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Client=t.defaultStorage=t.generateRequestId=t.toResponseError=t.defaultRequest=void 0;var a=n(6877),c=n(4949),u=n(873),l=n(2631),h=n(8547),d=n(2344),f=n(7425),p=n(2877),v="x-request-id",y="x-device-id",g="device_id";function m(){return(0,u.uuidv4)()}t.defaultRequest=function(e,t){return o(this,void 0,Promise,function(){var n,r,o,s,c;return i(this,function(i){switch(i.label){case 0:n=null,r=null,i.label=1;case 1:return i.trys.push([1,4,,5]),(o=Object.assign({},t)).method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)),[4,fetch(e,o)];case 2:return[4,i.sent().json()];case 3:return(null==(s=i.sent())?void 0:s.error)?(r=s).error_uri=new URL(e).pathname:n=s,[3,5];case 4:return c=i.sent(),r={error:a.ErrorType.UNREACHABLE,error_description:c.message,error_uri:new URL(e).pathname},[3,5];case 5:if(r)throw r;return[2,n]}})})},t.toResponseError=function(e,t){var n,r=t||{};if(e instanceof Error)n={error:r.error||a.ErrorType.LOCAL,error_description:r.error_description||e.message,error_uri:r.error_uri,details:r.details||e.stack};else{var o=e||{};n={error:r.error||o.error||a.ErrorType.LOCAL,error_description:r.error_description||o.error_description,error_uri:r.error_uri||o.error_uri,details:r.details||o.details}}return n},t.generateRequestId=m;var b=function(){function e(e){this._env=(null==e?void 0:e.env)||""}return e.prototype.getItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,window.localStorage.getItem("".concat(e).concat(this._env))]})})},e.prototype.removeItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return window.localStorage.removeItem("".concat(e).concat(this._env)),[2]})})},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){return window.localStorage.setItem("".concat(e).concat(this._env),t),[2]})})},e.prototype.getItemSync=function(e){return window.localStorage.getItem("".concat(e).concat(this._env))},e.prototype.removeItemSync=function(e){window.localStorage.removeItem("".concat(e).concat(this._env))},e.prototype.setItemSync=function(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)},e}();t.defaultStorage=new b;var _=function(){function e(e){var t=this;this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new h.SinglePromise({clientId:this.clientId,getScope:function(){var e;return(null===(e=t.accessKeyCredentials)||void 0===e?void 0:e.access_token)?"".concat(t.clientId,"_").concat(t.accessKeyCredentials.access_token):t.clientId}}),this.credentials=e.credentials||null,this.onCredentialsChange=e.onCredentialsChange}return e.prototype.syncMemoryCredentials=function(e){this.credentials=e},e.prototype.getMemoryCredentials=function(){return this.credentials},e.prototype.getStorageCredentialsSync=function(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e},e.prototype.setCredentials=function(e,t){var n;return o(this,void 0,Promise,function(){var r,o;return i(this,function(i){switch(i.label){case 0:return r=!(!this.credentials||!this.credentials.access_token),(null==e?void 0:e.expires_in)?((null==e?void 0:e.expires_at)||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),this.storage?(o=JSON.stringify(e),[4,this.storage.setItem(this.tokenSectionName,o)]):[3,2]):[3,3];case 1:i.sent(),i.label=2;case 2:return this.credentials=e,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:i.sent(),i.label=5;case 5:this.credentials=null,i.label=6;case 6:return this.onCredentialsChange&&this.onCredentialsChange(e||null,{isInit:null!==(n=null==t?void 0:t.isInit)&&void 0!==n&&n,hadCredentials:r}),[2]}})})},e.prototype.setAccessKeyCredentials=function(e){this.accessKeyCredentials=e,e.scope===c.DEFAULT_NODE_ACCESS_SCOPE&&(this.credentials=e)},e.prototype.getCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return[2,this.singlePromise.run("getCredentials",function(){return o(e,void 0,void 0,function(){var e,t;return i(this,function(n){switch(n.label){case 0:return[4,this.getStorageCredentials()];case 1:return e=n.sent(),t=e.credentials,e.isAccessKeyCredentials?[2,t]:(this.credentials=t,[2,this.credentials])}})})})]})})},e.prototype.getStorageCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return[2,this.singlePromise.run("_getStorageCredentials",function(){return o(e,void 0,void 0,function(){var e,t,n;return i(this,function(r){switch(r.label){case 0:return e=null,t=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(n=r.sent()))return[3,6];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(e=JSON.parse(n))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),[3,5];case 3:return r.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),e=null,[3,5];case 5:return[3,7];case 6:e=this.accessKeyCredentials||null,t=!0,r.label=7;case 7:return[2,{credentials:e,isAccessKeyCredentials:t}]}})})})]})})},e}();t.OAuth2Client=function(){function e(n){var r,o=this;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,this._initSessionEmitted=!1,n.clientSecret||(n.clientSecret=""),!n.clientId&&n.env&&(n.clientId=n.env),this.apiOrigin=n.apiOrigin,this.getApiOriginFunc=n.getApiOrigin,this.apiPath=n.apiPath||c.AUTH_API_PREFIX,this.clientId=n.clientId,this.i18n=n.i18n,this.eventBus=n.eventBus,this.singlePromise=new h.SinglePromise({clientId:this.clientId}),this.retry=this.formatRetry(n.retry,e.defaultRetry),n.baseRequest?this.baseRequest=n.baseRequest:this.baseRequest=t.defaultRequest,this.tokenInURL=n.tokenInURL,this.headers=n.headers,this.storage=n.storage||t.defaultStorage,this.localCredentials=new _({tokenSectionName:"credentials_".concat(n.clientId),storage:this.storage,clientId:n.clientId,onCredentialsChange:this._handleCredentialsChange.bind(this)}),this.clientSecret=n.clientSecret,n.clientId&&(this.basicAuth="Basic ".concat((0,d.weBtoa)("".concat(n.clientId,":").concat(this.clientSecret)))),this.wxCloud=n.wxCloud;try{(0,f.isMp)()&&(this.useWxCloud=n.useWxCloud,void 0===this.wxCloud&&n.env&&(wx.cloud.init({env:n.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=n.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=n.anonymousSignInFunc,this.onCredentialsError=n.onCredentialsError,this.getInitialSession=n.getInitialSession,this.onInitialSessionObtained=n.onInitialSessionObtained,this.logDebugMessages=null!==(r=n.debug)&&void 0!==r&&r,p.langEvent.bus.on(p.langEvent.LANG_CHANGE_EVENT,function(e){var t;o.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||o.i18n}),this._initBroadcastChannel(),this._initVisibilityListener()}return e.prototype.setGetInitialSession=function(e){this.getInitialSession=e},e.prototype.setOnInitialSessionObtained=function(e){this.onInitialSessionObtained=e},e.prototype.initialize=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){switch(n.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,n.sent()];case 2:return void 0===e?[3,4]:(this.initializePromise=e,[4,this.initializePromise]);case 4:return this.initializePromise=o(t,void 0,void 0,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return[4,this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this._initialize()];case 1:return[2,e.sent()]}})})})];case 1:return[2,t.sent()]}})}),[4,this.initializePromise]}})})},e.prototype.setCredentials=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,function(){return o(t,void 0,void 0,function(){return i(this,function(t){return[2,this.localCredentials.setCredentials(e)]})})})]}})})},Object.defineProperty(e.prototype,"initSessionEmitted",{get:function(){return this._initSessionEmitted},enumerable:!1,configurable:!0}),e.prototype.destroy=function(){try{this.broadcastChannel&&"function"==typeof this.broadcastChannel.close&&this.broadcastChannel.close()}catch(e){this._debug("#destroy","close BroadcastChannel error",e)}finally{this.broadcastChannel=null}try{var e=this.visibilityEventHandler;this.visibilityEventHandler=void 0,e&&"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof window.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(e){this._debug("#destroy","remove visibility listener error",e)}},e.prototype.setAccessKeyCredentials=function(e){return this.localCredentials.setAccessKeyCredentials(e)},e.prototype.getAccessToken=function(){return o(this,void 0,Promise,function(){var e,t;return i(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[4,this.getCredentials()];case 2:return(null==(e=n.sent())?void 0:e.scope)===c.DEFAULT_NODE_ACCESS_SCOPE||(null==e?void 0:e.access_token)?[2,Promise.resolve(e.access_token)]:(t={error:a.ErrorType.UNAUTHENTICATED},[2,Promise.reject(t)])}})})},e.prototype.request=function(t,n){var s,c;return o(this,void 0,Promise,function(){var o,u,l,h,d,f,p,g,b,_;return i(this,function(i){switch(i.label){case 0:return n||(n={}),o=this.formatRetry(n.retry,this.retry),n.headers=r(r({},n.headers),((_={})[null===(s=this.i18n)||void 0===s?void 0:s.LANG_HEADER_KEY]=null===(c=this.i18n)||void 0===c?void 0:c.lang,_)),this.headers&&(n.headers=r(r({},this.headers),n.headers)),n.headers[v]||(n.headers[v]=m()),n.headers[y]?[3,2]:[4,this.getDeviceId()];case 1:u=i.sent(),n.headers[y]=u,i.label=2;case 2:return(null==n?void 0:n.withBasicAuth)&&this.basicAuth&&(n.headers.Authorization=this.basicAuth),(null==n?void 0:n.withCredentials)?n.getCredentials?[4,n.getCredentials()]:[3,4]:[3,7];case 3:return h=i.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:h=i.sent(),i.label=6;case 6:return(l=h)&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(l.access_token)):n.headers.Authorization="".concat(l.token_type," ").concat(l.access_token)),[3,8];case 7:this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(this.clientId)),i.label=8;case 8:t.startsWith("/")&&(d=this.getApiOriginFunc?this.getApiOriginFunc():this.apiOrigin,t="".concat(d).concat(this.apiPath).concat(t)),f=null,p=o+1,g=0,i.label=9;case 9:if(!(g<p))return[3,21];i.label=10;case 10:return i.trys.push([10,15,,18]),n.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(t,n)]:[3,12];case 11:return f=i.sent(),[3,14];case 12:return[4,this.baseRequest(t,n)];case 13:f=i.sent(),i.label=14;case 14:if(null==f?void 0:f.code)throw{error:f.code,error_description:f.message,error_uri:new URL(t).pathname};return[3,21];case 15:b=i.sent();try{b.requestId=b.requestId||n.headers[v]||""}catch(e){}return n.withCredentials&&b&&b.error===a.ErrorType.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return i.sent(),[2,Promise.reject(b)];case 17:return g!==o&&b&&"unreachable"===b.error?[3,18]:[2,Promise.reject(b)];case 18:return[4,this.sleep(e.retryInterval)];case 19:i.sent(),i.label=20;case 20:return g++,[3,9];case 21:return[2,f]}})})},e.prototype.wxCloudCallFunction=function(e,t){var n;return o(this,void 0,Promise,function(){var o,s,c,u,h;return i(this,function(i){switch(i.label){case 0:o=null,s=null,i.label=1;case 1:i.trys.push([1,7,,8]),c="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return c=i.sent(),[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:r({origin:"https://servicewechat.com","User-Agent":c},t.headers),body:t.body}})];case 6:return u=i.sent().result,(null===(n=null==u?void 0:u.body)||void 0===n?void 0:n.error_code)?(s=null==u?void 0:u.body).error_uri=(0,l.getPathName)(e):o=null==u?void 0:u.body,[3,8];case 7:return h=i.sent(),s={error:a.ErrorType.UNREACHABLE,error_description:h.message,error_uri:(0,l.getPathName)(e)},[3,8];case 8:if(s)throw s;return[2,o]}})})},e.prototype.getCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return[4,this.initializePromise];case 1:return t.sent(),[2,this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){return i(this,function(e){return[2,this._getCredentials()]})})})]}})})},e.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},e.prototype.getCredentialsAsync=function(){return this.getCredentials()},e.prototype.getScope=function(){var e;return o(this,void 0,Promise,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=r.sent())?[2,t.scope]:(n="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:n}),[2,this.unAuthenticatedError(n)])}})})},e.prototype.getGroups=function(){var e;return o(this,void 0,Promise,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=r.sent())?[2,t.groups]:(n="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:n}),[2,this.unAuthenticatedError(n)])}})})},e.prototype.refreshToken=function(e,t){return o(this,void 0,Promise,function(){var n=this;return i(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,function(){return o(n,void 0,void 0,function(){return i(this,function(n){return[2,this._refreshToken(e,t)]})})})]}})})},e.prototype._refreshToken=function(e,t){return o(this,void 0,Promise,function(){var n=this;return i(this,function(r){return[2,this.singlePromise.run("_refreshToken",function(){return o(n,void 0,void 0,function(){var n,r,o,s,u,l;return i(this,function(i){switch(i.label){case 0:if((null==e?void 0:e.scope)===c.DEFAULT_NODE_ACCESS_SCOPE)return[2,e];if(!e||!e.refresh_token)return o="no refresh token found in credentials",null===(s=this.onCredentialsError)||void 0===s||s.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];i.label=1;case 1:return i.trys.push([1,4,,7]),[4,this.refreshTokenFunc(e.refresh_token,e)];case 2:return n=i.sent(),[4,this.localCredentials.setCredentials(n)];case 3:return i.sent(),[2,n];case 4:if(r=i.sent(),null==t?void 0:t.throwError)throw r;return r.error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return i.sent(),o=r.error_description,null===(u=this.onCredentialsError)||void 0===u||u.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];case 6:return null===(l=this.onCredentialsError)||void 0===l||l.call(this,{msg:r.error_description}),[2,Promise.reject(r)];case 7:return[2]}})})})]})})},e.prototype.anonymousLogin=function(e){return o(this,void 0,void 0,function(){var t=this;return i(this,function(n){return[2,this.singlePromise.run("_anonymousLogin",function(){return o(t,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(e)]:[3,4];case 1:return t=r.sent(),(n=t)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:n=r.sent(),r.label=3;case 3:return e=n,[3,6];case 4:return[4,this.anonymousSignIn(e)];case 5:e=r.sent(),r.label=6;case 6:return[2,e]}})})})]})})},e.prototype.checkRetry=function(t){var n=null;if(("number"!=typeof t||t<e.minRetry||t>e.maxRetry)&&(n={error:a.ErrorType.UNREACHABLE,error_description:"wrong options param: retry"}),n)throw n;return t},e.prototype.formatRetry=function(e,t){return void 0===e?t:this.checkRetry(e)},e.prototype.sleep=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,new Promise(function(t){setTimeout(function(){t()},e)})]})})},e.prototype.anonymousSignIn=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){return[2,this.singlePromise.run("_anonymous",function(){return o(t,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:if(!e||"anonymous"!==e.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.request(c.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return t=r.sent(),[4,this.localCredentials.setCredentials(t)];case 3:return r.sent(),[2,t];case 4:return(n=r.sent()).error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}})})})]})})},e.prototype.defaultRefreshTokenFunc=function(e,t){var n;return o(this,void 0,Promise,function(){var o,s,a;return i(this,function(i){switch(i.label){case 0:return void 0===e||""===e?(o="refresh token not found",null===(n=this.onCredentialsError)||void 0===n||n.call(this,{msg:o}),[2,this.unAuthenticatedError(o)]):(s=c.ApiUrls.AUTH_TOKEN_URL,"v2"===(null==t?void 0:t.version)&&(s=c.ApiUrlsV2.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:e}})]);case 1:return a=i.sent(),[2,r(r({},a),{version:(null==t?void 0:t.version)||"v1"})]}})})},e.prototype.getDeviceId=function(){return o(this,void 0,Promise,function(){var e;return i(this,function(t){switch(t.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(g)];case 1:return"string"==typeof(e=t.sent())&&e.length>=16&&e.length<=48?[3,3]:(e=(0,u.uuidv4)(),[4,this.storage.setItem(g,e)]);case 2:t.sent(),t.label=3;case 3:return this.deviceID=e,[2,e]}})})},e.prototype.unAuthenticatedError=function(e){var t={error:a.ErrorType.UNAUTHENTICATED,error_description:e};return Promise.reject(t)},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logDebugMessages&&console.log.apply(console,s(["[OAuth2Client]"],e,!1))},e.prototype._initialize=function(){return o(this,void 0,Promise,function(){var e,t,n,r,o,s;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),i.label=1;case 1:return i.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return s=i.sent(),e=s.data,t=s.error,(null==e?void 0:e.session)?(this._debug("#_initialize()","session obtained from getInitialSession",e.session),this._initSessionEmitted=!0,[4,this.localCredentials.setCredentials(null==e?void 0:e.session,{isInit:!0})]):[3,4];case 3:i.sent(),i.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),i.label=5;case 5:return i.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(e,t)];case 6:return i.sent(),[3,8];case 7:return n=i.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",n),[3,8];case 8:return t?(this._debug("#_initialize()","error from getInitialSession",t),[2,{error:t}]):[2,{error:null}];case 9:return r=i.sent(),this._debug("#_initialize()","exception during getInitialSession",r),[2,{error:r instanceof Error?r:new Error(String(r))}];case 10:return[3,13];case 11:return o=i.sent(),this._debug("#_initialize()","unexpected error",o),[2,{error:o instanceof Error?o:new Error(String(o))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}})})},e.prototype._acquireLock=function(e,t){return o(this,void 0,Promise,function(){var n,r,a,c,u=this;return i(this,function(l){switch(l.label){case 0:this._debug("#_acquireLock","begin",e),l.label=1;case 1:if(l.trys.push([1,,10,11]),this.lockAcquired)return n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=o(u,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,n];case 1:return e.sent(),[4,t()];case 2:return[2,e.sent()]}})}),this.pendingInLock.push(o(u,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,r];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[2,r];this._debug("#_acquireLock","acquiring lock for client",this.clientId),l.label=2;case 2:return l.trys.push([2,,8,9]),this.lockAcquired=!0,a=t(),this.pendingInLock.push(o(u,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[4,a];case 3:l.sent(),l.label=4;case 4:return this.pendingInLock.length?(c=s([],this.pendingInLock,!0),[4,Promise.all(c)]):[3,6];case 5:return l.sent(),this.pendingInLock.splice(0,c.length),[3,4];case 6:return[4,a];case 7:return[2,l.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}})})},e.prototype._getCredentials=function(){var e,t,n;return o(this,void 0,Promise,function(){var r,o,s;return i(this,function(i){switch(i.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(r=i.sent())?void 0:r.scope)===c.DEFAULT_NODE_ACCESS_SCOPE)return[2,r];if(!r)return s="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];if(!function(e){var t=!0;return(null==e?void 0:e.expires_at)&&(null==e?void 0:e.access_token)&&(t=e.expires_at<new Date),t}(r))return[3,12];if(!r.refresh_token)return[3,9];i.label=2;case 2:return i.trys.push([2,4,,8]),[4,this._refreshToken(r)];case 3:return r=i.sent(),[3,8];case 4:return o=i.sent(),"anonymous"!==r.scope?[3,6]:[4,this.anonymousLogin(r)];case 5:return r=i.sent(),[3,7];case 6:return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:o.error_description}),[2,Promise.reject(o)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==r.scope?[3,11]:[4,this.anonymousLogin(r)];case 10:return r=i.sent(),[3,12];case 11:return s="no refresh token found in credentials",null===(n=this.onCredentialsError)||void 0===n||n.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];case 12:return[2,r]}})})},e.prototype._isUserCredentials=function(e){return!!(null==e?void 0:e.access_token)&&"accessKey"!==e.scope&&e.scope!==c.DEFAULT_NODE_ACCESS_SCOPE},e.prototype._fireCredentialsEvents=function(e,t,n){var r,o,i,s,a,u;this._isUserCredentials(e)?t?null===(i=this.eventBus)||void 0===i||i.fire(c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION}):n?null===(s=this.eventBus)||void 0===s||s.fire(c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED}):(null===(a=this.eventBus)||void 0===a||a.fire(c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),null===(u=this.eventBus)||void 0===u||u.fire(c.EVENTS.LOGIN_STATE_CHANGED,{eventType:c.LOGIN_STATE_CHANGED_TYPE.SIGN_IN})):n&&(null===(r=this.eventBus)||void 0===r||r.fire(c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),null===(o=this.eventBus)||void 0===o||o.fire(c.EVENTS.LOGIN_STATE_CHANGED,{eventType:c.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}))},e.prototype._handleCredentialsChange=function(e,t){this._fireCredentialsEvents(e,t.isInit,t.hadCredentials),this._broadcastCredentials(e,t)},e.prototype._initBroadcastChannel=function(){var e=this;if(void 0===this.broadcastChannel)try{"undefined"!=typeof BroadcastChannel&&(this.broadcastChannelName="credentials_".concat(this.clientId),this.broadcastChannel=new BroadcastChannel(this.broadcastChannelName),this.broadcastChannel.addEventListener("message",function(t){e._handleBroadcastMessage(t.data)}),this._debug("#_initBroadcastChannel","channel created: ".concat(this.broadcastChannelName)))}catch(e){this.broadcastChannel=null,this._debug("#_initBroadcastChannel","BroadcastChannel not available, skip",e)}},e.prototype._broadcastCredentials=function(e,t){if(this.broadcastChannel)try{this.broadcastChannel.postMessage({type:"credentials_changed",credentials:e,context:t})}catch(e){this._debug("#_broadcastCredentials","postMessage error",e)}},e.prototype._handleBroadcastMessage=function(e){var t,n;try{if(!e||"credentials_changed"!==e.type)return;var o=e.context,i=e.credentials;if((null==i?void 0:i.expires_at)&&"string"==typeof i.expires_at&&(i=r(r({},i),{expires_at:new Date(i.expires_at)})),(null==i?void 0:i.access_token)===(null===(t=this.localCredentials.getMemoryCredentials())||void 0===t?void 0:t.access_token))return;var s=!!(null===(n=this.localCredentials.getMemoryCredentials())||void 0===n?void 0:n.access_token);this.localCredentials.syncMemoryCredentials(i),this._fireCredentialsEvents(i,o.isInit,s)}catch(e){this._debug("#_handleBroadcastMessage","error",e)}},e.prototype._initVisibilityListener=function(){var e=this;try{if("undefined"==typeof window||"undefined"==typeof document||"function"!=typeof window.addEventListener)return;this.visibilityEventHandler=function(){return o(e,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._onVisibilityChanged()];case 1:return t.sent(),[3,3];case 2:return e=t.sent(),this._debug("#visibilityChangedCallback","error",e),[3,3];case 3:return[2]}})})},window.addEventListener("visibilitychange",this.visibilityEventHandler)}catch(e){this._debug("#_initVisibilityListener",e)}},e.prototype._onVisibilityChanged=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return"visible"!==document.visibilityState||this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){var e,t,n,r,o,s;return i(this,function(i){switch(i.label){case 0:if("visible"!==document.visibilityState)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),e=this.localCredentials.getMemoryCredentials(),[4,this.localCredentials.getCredentials()];case 2:return t=i.sent(),n=null==e?void 0:e.access_token,r=null==t?void 0:t.access_token,n===r?[2]:(o=!!n,this._fireCredentialsEvents(t,!1,o),[3,4]);case 3:return s=i.sent(),this._debug("#_onVisibilityChanged","reload credentials error",s),[3,4];case 4:return[2]}})})}),[2]})})},e.defaultRetry=2,e.minRetry=0,e.maxRetry=5,e.retryInterval=1e3,e}()},2344:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.weAppJwtDecodeAll=t.weappJwtDecode=t.base64_url_decode=t.weAtob=t.weBtoa=void 0;var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function o(e){var n=e.replace(/-/g,"+").replace(/_/g,"/");switch(n.length%4){case 0:break;case 2:n+="==";break;case 3:n+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent((0,t.weAtob)(e).replace(/(.)/g,function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)}))}(n)}catch(e){return(0,t.weAtob)(n)}}t.weBtoa=function(e){for(var t,r,o,i,s="",a=0,c=(e=String(e)).length%3;a<e.length;){if((r=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=n.charAt((t=r<<16|o<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t)}return c?s.slice(0,c-3)+"===".substring(c):s},t.weAtob=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!r.test(e))throw new TypeError("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 o,i,s="",a=0;a<e.length;)t=n.indexOf(e.charAt(a++))<<18|n.indexOf(e.charAt(a++))<<12|(o=n.indexOf(e.charAt(a++)))<<6|(i=n.indexOf(e.charAt(a++))),s+=64===o?String.fromCharCode(t>>16&255):64===i?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return s},t.base64_url_decode=o,t.weappJwtDecode=function(e,t){if("string"!=typeof e)throw new Error("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(o(e.split(".")[n]))}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}},t.weAppJwtDecodeAll=function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{var t=e.split(".").map(function(e,t){return 2===t?e:JSON.parse(o(e))});return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}}},5814:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getEncryptInfo=void 0;var o=r(n(1012)),i=n(2631);t.getEncryptInfo=function(e){var t=void 0===e?{}:e,n=t.publicKey,r=void 0===n?"":n,s=t.payload,a=void 0===s?{}:s;if(!r)return"";try{var c=(0,i.deepClone)(a),u=new o.default;return u.setPublicKey(r),u.encryptLong("object"==typeof c?JSON.stringify(c):c)}catch(e){console.error("encrypt error:",e)}return""}},8547:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SinglePromise=void 0;var o=new Map,i=function(){function e(e){this.clientId=(null==e?void 0:e.clientId)||"",this.getScope=null==e?void 0:e.getScope,o=o||new Map}return e.prototype.run=function(e,t){return n(this,void 0,Promise,function(){var i,s,a=this;return r(this,function(c){return i=this.getScope?this.getScope():this.clientId,e="".concat(i,"_").concat(e),(s=o.get(e))||(s=new Promise(function(i,s){n(a,void 0,void 0,function(){var n,a,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return r.sent(),n=t(),a=i,[4,n];case 2:return a.apply(void 0,[r.sent()]),[3,5];case 3:return c=r.sent(),s(c),[3,5];case 4:return o.delete(e),[7];case 5:return[2]}})})}),o.set(e,s)),[2,s]})})},e.prototype.runIdlePromise=function(){return Promise.resolve()},e}();t.SinglePromise=i},2631:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getPathName=t.deepClone=void 0,t.deepClone=function(e){var n=function(n){for(var r in e)e.hasOwnProperty(r)&&(n[r]=(0,t.deepClone)(e[r]));return n},r=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return e.slice();switch(r){case"Object":return n(Object.create(Object.getPrototypeOf(e)));case"Array":return n([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},t.getPathName=function(e){var t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""}},7425:function(e,t){"use strict";function n(){if("undefined"==typeof globalThis)return!1;var e=globalThis.wx;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.isInMpWebView=t.isMp=void 0,t.isMp=n;var r=!1;function o(){r=r||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{n()||(r=r||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?o():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",o,!1))}catch(e){}t.isInMpWebView=function(){return r}},9639:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}return e.prototype.parse=function(e){var t=this;e.split("&").forEach(function(e){var n=e.split("=").map(decodeURIComponent),r=n[0],o=n[1];t.append(r,o)})},e.prototype.append=function(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]},e.prototype.get=function(e){return this.params[e]?this.params[e][0]:null},e.prototype.getAll=function(e){return this.params[e]||[]},e.prototype.delete=function(e){delete this.params[e]},e.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this.params,e)},e.prototype.set=function(e,t){this.params[e]=[t]},e.prototype.toString=function(){var e=[],t=function(t){Object.prototype.hasOwnProperty.call(n.params,t)&&n.params[t].forEach(function(n){e.push("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(n)))})},n=this;for(var r in this.params)t(r);return e.join("&")},e}();t.default=n},873:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=void 0,t.uuidv4=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}},317:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.REALTIME_CHANNEL_STATES=t.REALTIME_SUBSCRIBE_STATES=t.REALTIME_LISTEN_TYPES=t.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=t.postgresChangesFilter=t.RealtimePostgresFilterBuilder=void 0;var l,h,d,f=n(5633),p=u(n(4666)),v=s(n(8206)),y=n(8206),g=n(240),m=u(n(4663)),b=n(8352),_=n(8352);Object.defineProperty(t,"RealtimePostgresFilterBuilder",{enumerable:!0,get:function(){return _.RealtimePostgresFilterBuilder}}),Object.defineProperty(t,"postgresChangesFilter",{enumerable:!0,get:function(){return _.postgresChangesFilter}}),(d=t.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT||(t.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT={})).ALL="*",d.INSERT="INSERT",d.UPDATE="UPDATE",d.DELETE="DELETE",function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"}(l=t.REALTIME_LISTEN_TYPES||(t.REALTIME_LISTEN_TYPES={})),function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"}(h=t.REALTIME_SUBSCRIBE_STATES||(t.REALTIME_SUBSCRIBE_STATES={})),t.REALTIME_CHANNEL_STATES=f.CHANNEL_STATES;var E=function(){function e(e,t,n){void 0===t&&(t={config:{}});var o,i,s=this;if(this.topic=e,this.params=t,this.socket=n,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=r({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config),this.channelAdapter=new m.default(this.socket.socketAdapter,e,this.params),this.presence=new p.default(this),this._onClose(function(){s.socket._remove(s)}),this._updateFilterTransform(),this.private=this.params.config.private||!1,!this.private&&(null===(i=null===(o=this.params.config)||void 0===o?void 0:o.broadcast)||void 0===i?void 0:i.replay))throw new Error("tried to use replay on public channel '".concat(this.topic,"'. It must be a private channel."))}return Object.defineProperty(e.prototype,"state",{get:function(){return this.channelAdapter.state},set:function(e){this.channelAdapter.state=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"joinedOnce",{get:function(){return this.channelAdapter.joinedOnce},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timeout",{get:function(){return this.socket.timeout},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"broadcastEndpointURL",{get:function(){return(0,y.httpEndpointURL)(this.socket.socketAdapter.endPointURL())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"joinPush",{get:function(){return this.channelAdapter.joinPush},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rejoinTimer",{get:function(){return this.channelAdapter.rejoinTimer},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e,t){var n,o,i,s;if(void 0===t&&(t=this.timeout),this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){var a=this.params.config,c=a.broadcast,u=a.presence,h=a.private,d=a.postgres_changes_options,p=null!==(o=null===(n=this.bindings.postgres_changes)||void 0===n?void 0:n.map(function(e){return e.filter}))&&void 0!==o?o:[],v=!!this.bindings[l.PRESENCE]&&this.bindings[l.PRESENCE].length>0||!0===(null===(i=this.params.config.presence)||void 0===i?void 0:i.enabled),y=r({broadcast:c,presence:r(r({},u),{enabled:v}),postgres_changes:p,private:h},d?{postgres_changes_options:d}:{});this._subscribeCallback=e,this._subscribeTimeout=t,this._bindSubscribeLifecycle(),this.updateJoinPayload({config:y}),this._updateFilterMessage();var g=(null==d?void 0:d.wait)&&p.length>0?Math.max(t,(null!==(s=d.timeout)&&void 0!==s?s:f.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT)+f.POSTGRES_CHANGES_WAIT_ERROR_GRACE):t;this._subscribeJoinTimeout=g,this.channelAdapter.subscribe(g),this._bindJoinPushReceivers()}return this},e.prototype._warmupOn=function(e){var t=this,n=new m.default(e,this.topic,this.params);return n.updateJoinPayload(this.channelAdapter.joinPush.payload()),new Promise(function(e,r){var o,i;n.subscribe(null!==(i=null!==(o=t._subscribeJoinTimeout)&&void 0!==o?o:t._subscribeTimeout)&&void 0!==i?i:t.timeout).receive("ok",function(o){var i=o.postgres_changes;void 0===i||t._postgresBindingsAlign(i)?e({adapter:n,postgres_changes:i}):r(new Error("mismatch between server and client bindings for postgres changes"))}).receive("error",function(e){var t=Object.values(e).join(", ")||"error";r(new Error(t,{cause:e}))}).receive("timeout",function(){r(new Error("standby channel join timed out"))})})},e.prototype._adopt=function(e){var t=this,n=this.channelAdapter;n.detachLifecycleHooks(),n.teardown(),this.channelAdapter=e.adapter;for(var r=0,o=Object.keys(this.bindings);r<o.length;r++)for(var i=o[r],s=0,a=this.bindings[i];s<a.length;s++){var c=a[s];c.ref=this.channelAdapter.on(c.type,c.callback)}this._updateFilterMessage(),this._updateFilterTransform(),void 0!==e.postgres_changes&&this._applyPostgresBindingIds(e.postgres_changes),this._onClose(function(){t.socket._remove(t)}),this._bindSubscribeLifecycle(),this._bindJoinPushReceivers({skipImmediate:!0}),this.presence=new p.default(this)},e.prototype._bindSubscribeLifecycle=function(){if(this._subscribeCallback){var e=this._subscribeCallback;this._onError(function(t){e(h.CHANNEL_ERROR,(0,g.normalizeChannelError)(t))}),this._onClose(function(){return e(h.CLOSED)})}},e.prototype._bindJoinPushReceivers=function(e){var t,n=this,r=function(e){var t=e.postgres_changes;return a(n,void 0,void 0,function(){var e;return c(this,function(n){return this.socket._isManualToken()||this.socket.setAuth(),void 0===t?(null===(e=this._subscribeCallback)||void 0===e||e.call(this,h.SUBSCRIBED),[2]):(this._updatePostgresBindings(t,this._subscribeCallback),[2])})})},o=function(e){var t;n.state=f.CHANNEL_STATES.errored;var r=Object.values(e).join(", ")||"error";null===(t=n._subscribeCallback)||void 0===t||t.call(n,h.CHANNEL_ERROR,new Error(r,{cause:e}))},i=function(){var e;null===(e=n._subscribeCallback)||void 0===e||e.call(n,h.TIMED_OUT)},s=this.channelAdapter.joinPush;if((null==e?void 0:e.skipImmediate)&&"ok"===(null===(t=s.receivedResp)||void 0===t?void 0:t.status))return s.recHooks.push({status:"ok",callback:r}),s.recHooks.push({status:"error",callback:o}),void s.recHooks.push({status:"timeout",callback:i});this.channelAdapter.joinPush.receive("ok",r),this.channelAdapter.joinPush.receive("error",o),this.channelAdapter.joinPush.receive("timeout",i)},e.prototype._postgresBindingsAlign=function(t){for(var n,r=this.bindings.postgres_changes,o=null!==(n=null==r?void 0:r.length)&&void 0!==n?n:0,i=0;i<o;i++){var s=r[i].filter,a=s.event,c=s.schema,u=s.table,l=s.filter,h=t&&t[i];if(!(h&&h.event===a&&e.isFilterValueEqual(h.schema,c)&&e.isFilterValueEqual(h.table,u)&&e.isFilterValueEqual(h.filter,l)))return!1}return!0},e.prototype._applyPostgresBindingIds=function(e){for(var t,n=this.bindings.postgres_changes,o=null!==(t=null==n?void 0:n.length)&&void 0!==t?t:0,i=[],s=0;s<o;s++){var a=n[s],c=e&&e[s];i.push(r(r({},a),{id:null==c?void 0:c.id}))}this.bindings.postgres_changes=i},e.prototype._updatePostgresBindings=function(e,t){if(!this._postgresBindingsAlign(e))return this.unsubscribe(),this.state=f.CHANNEL_STATES.errored,void(null==t||t(h.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes")));this._applyPostgresBindingIds(e),this.state!=f.CHANNEL_STATES.errored&&t&&t(h.SUBSCRIBED)},e.prototype.presenceState=function(){return this.presence.state},e.prototype.track=function(e,t){return void 0===t&&(t={}),a(this,void 0,Promise,function(){return c(this,function(n){switch(n.label){case 0:return[4,this.send({type:"presence",event:"track",payload:e},t)];case 1:return[2,n.sent()]}})})},e.prototype.untrack=function(e){return void 0===e&&(e={}),a(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.send({type:"presence",event:"untrack"},e)];case 1:return[2,t.sent()]}})})},e.prototype.on=function(e,t,n){var r=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),o=e===l.PRESENCE||e===l.POSTGRES_CHANGES;if(r&&o)throw this.socket.log("channel","cannot add `".concat(e,"` callbacks for ").concat(this.topic," after `subscribe()`.")),new Error("cannot add `".concat(e,"` callbacks for ").concat(this.topic," after `subscribe()`."));return this._on(e,t,n)},e.prototype.httpSend=function(e,t,n){var r;return void 0===n&&(n={}),a(this,void 0,Promise,function(){var o,i,s,a,u,l,h;return c(this,function(c){switch(c.label){case 0:return null==t?[2,Promise.reject(new Error("Payload is required for httpSend()"))]:[4,this.socket.setAuth()];case 1:return c.sent(),o=t instanceof ArrayBuffer||ArrayBuffer.isView(t),i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":o?"application/octet-stream":"application/json"},this.socket.accessTokenValue&&(i.Authorization="Bearer ".concat(this.socket.accessTokenValue)),s=(0,y.joinBroadcastEventUrl)(this.broadcastEndpointURL,this.subTopic,e,this.private?{private:"true"}:void 0),a={method:"POST",headers:i,body:o?t:JSON.stringify(t)},[4,this._fetchWithTimeout(s,a,null!==(r=n.timeout)&&void 0!==r?r:this.timeout)];case 2:if(202===(u=c.sent()).status)return[2,{success:!0}];if(404===u.status)return[2,Promise.reject(new Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. See https://github.com/TencentCloudBase/cloudbase-js-sdk/blob/master/packages/realtime-js/migrations/httpsend-server-version.md"))];l=u.statusText,c.label=3;case 3:return c.trys.push([3,5,,6]),[4,u.json()];case 4:return h=c.sent(),l=h.error||h.message||l,[3,6];case 5:return c.sent(),[3,6];case 6:return[2,Promise.reject(new Error(l))]}})})},e.prototype.send=function(e,t){var n,r;return void 0===t&&(t={}),a(this,void 0,Promise,function(){var o,i,s,a,u,l,h,d=this;return c(this,function(c){switch(c.label){case 0:return this.channelAdapter.canPush()||"broadcast"!==e.type?[3,7]:(o="Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.",this.socket.hasLogger()?this.socket.log("channel",o):console.warn(o),i=e.event,s=e.payload,[4,this.socket.setAuth()]);case 1:c.sent(),a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},this.socket.accessTokenValue&&(a.Authorization="Bearer ".concat(this.socket.accessTokenValue)),u={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:s,private:this.private}]})},c.label=2;case 2:return c.trys.push([2,5,,6]),[4,this._fetchWithTimeout(this.broadcastEndpointURL,u,null!==(n=t.timeout)&&void 0!==n?n:this.timeout)];case 3:return l=c.sent(),[4,null===(r=l.body)||void 0===r?void 0:r.cancel()];case 4:return c.sent(),[2,l.ok?"ok":"error"];case 5:return(h=c.sent())instanceof Error&&"AbortError"===h.name?[2,"timed out"]:[2,"error"];case 6:return[3,8];case 7:return[2,new Promise(function(n){var r,o,i,s=d.channelAdapter.push(e.type,e,t.timeout||d.timeout);"broadcast"!==e.type||(null===(i=null===(o=null===(r=d.params)||void 0===r?void 0:r.config)||void 0===o?void 0:o.broadcast)||void 0===i?void 0:i.ack)||n("ok"),s.receive("ok",function(){return n("ok")}),s.receive("error",function(){return n("error")}),s.receive("timeout",function(){return n("timed out")})})];case 8:return[2]}})})},e.prototype.updateJoinPayload=function(e){this.channelAdapter.updateJoinPayload(e)},e.prototype.unsubscribe=function(e){return void 0===e&&(e=this.timeout),a(this,void 0,void 0,function(){var t=this;return c(this,function(n){return[2,new Promise(function(n){t.channelAdapter.unsubscribe(e).receive("ok",function(){return n("ok")}).receive("timeout",function(){return n("timed out")}).receive("error",function(){return n("error")})})]})})},e.prototype.teardown=function(){this.channelAdapter.teardown()},e.prototype._fetchWithTimeout=function(e,t,n){return a(this,void 0,void 0,function(){var o,i,s,a;return c(this,function(c){switch(c.label){case 0:if(o=function(){var e=new Error("The operation was aborted");return e.name="AbortError",e},"undefined"!=typeof AbortController)return[3,4];c.label=1;case 1:return c.trys.push([1,,3,4]),[4,Promise.race([this.socket.fetch(e,t),new Promise(function(e,t){i=setTimeout(function(){return t(o())},n)})])];case 2:return[2,c.sent()];case 3:return i&&clearTimeout(i),[7];case 4:s=new AbortController,a=setTimeout(function(){return s.abort()},n),c.label=5;case 5:return c.trys.push([5,,7,8]),[4,this.socket.fetch(e,r(r({},t),{signal:s.signal}))];case 6:return[2,c.sent()];case 7:return clearTimeout(a),[7];case 8:return[2]}})})},e.prototype._on=function(t,n,o){var i,s=t.toLocaleLowerCase(),a=null==n?void 0:n.filter;if((a instanceof b.RealtimePostgresFilterBuilder||"object"==typeof a&&null!==a&&"function"==typeof a.build)&&(n=r(r({},n),{filter:a.build()})),s===l.POSTGRES_CHANGES&&(null===(i=this.bindings[s])||void 0===i?void 0:i.find(function(t){return e.isSamePostgresFilter(t.filter,n)})))return this.socket.log("error","duplicate `postgres_changes` binding for ".concat(this.topic," ignored"),n),this;var c=this.channelAdapter.on(t,o),u={type:s,filter:n,callback:o,ref:c};return this.bindings[s]?this.bindings[s].push(u):this.bindings[s]=[u],this._updateFilterMessage(),this},e.prototype._onClose=function(e){this.channelAdapter.onClose(e)},e.prototype._onError=function(e){this.channelAdapter.onError(e)},e.prototype._updateFilterMessage=function(){var e=this;this.channelAdapter.updateFilterBindings(function(t,n,r){var o,i,s,a,c,u,l,h=t.event.toLocaleLowerCase();if(e._notThisChannelEvent(h,r))return!1;var d=null===(o=e.bindings[h])||void 0===o?void 0:o.find(function(e){return e.ref===t.ref});if(!d)return!0;if(["broadcast","presence","postgres_changes"].includes(h)){if("id"in d){var f=d.id,p=null===(i=d.filter)||void 0===i?void 0:i.event;return f&&(null===(s=n.ids)||void 0===s?void 0:s.includes(f))&&("*"===p||(null==p?void 0:p.toLocaleLowerCase())===(null===(a=n.data)||void 0===a?void 0:a.type.toLocaleLowerCase()))}return"*"===(p=null===(u=null===(c=null==d?void 0:d.filter)||void 0===c?void 0:c.event)||void 0===u?void 0:u.toLocaleLowerCase())||p===(null===(l=null==n?void 0:n.event)||void 0===l?void 0:l.toLocaleLowerCase())}return d.type.toLocaleLowerCase()===h})},e.prototype._notThisChannelEvent=function(e,t){var n=f.CHANNEL_EVENTS.close,r=f.CHANNEL_EVENTS.error,o=f.CHANNEL_EVENTS.leave,i=f.CHANNEL_EVENTS.join;return t&&[n,r,o,i].includes(e)&&t!==this.joinPush.ref},e.prototype._updateFilterTransform=function(){var e=this;this.channelAdapter.updatePayloadTransform(function(t,n,o){if("object"==typeof n&&"ids"in n){var i=n.data,s=i.schema,a=i.table,c=i.commit_timestamp,u=i.type,l=i.errors;return r(r({},{schema:s,table:a,commit_timestamp:c,eventType:u,new:{},old:{},errors:l}),e._getPayloadRecords(i))}return n})},e.prototype.copyBindings=function(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(var t in e.bindings)for(var n=0,r=e.bindings[t];n<r.length;n++){var o=r[n];this._on(o.type,o.filter,o.callback)}},e.isFilterValueEqual=function(e,t){return(null!=e?e:void 0)===(null!=t?t:void 0)},e.isSamePostgresFilter=function(t,n){var r,o,i,s,a=null!==(o=null===(r=null==t?void 0:t.select)||void 0===r?void 0:r.join())&&void 0!==o?o:void 0,c=null!==(s=null===(i=null==n?void 0:n.select)||void 0===i?void 0:i.join())&&void 0!==s?s:void 0;return(null==t?void 0:t.event)===(null==n?void 0:n.event)&&e.isFilterValueEqual(null==t?void 0:t.schema,null==n?void 0:n.schema)&&e.isFilterValueEqual(null==t?void 0:t.table,null==n?void 0:n.table)&&e.isFilterValueEqual(null==t?void 0:t.filter,null==n?void 0:n.filter)&&a===c},e.prototype._getPayloadRecords=function(e){var t={new:{},old:{}};return"INSERT"!==e.type&&"UPDATE"!==e.type||(t.new=v.convertChangeData(e.columns,e.record)),"UPDATE"!==e.type&&"DELETE"!==e.type||(t.old=v.convertChangeData(e.columns,e.old_record)),t},e}();t.default=E},539:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=s(n(1606)),c=n(5633),u=s(n(7135)),l=n(8206),h=s(n(317)),d=s(n(1563)),f=[1e3,2e3,5e3,1e4];var p=function(){function e(e,t){var n;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new u.default,this._manuallySetToken=!1,this._authPromise=null,this._authGeneration=0,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._endPoint="",this._socketOptions={},this._openingActive=!1,this._handlersAdapter=null,this._standbyAdapter=null,this._rotating=!1,this._cutoverStarted=!1,this._refreshTimer=null,this._rotateRetryTimer=null,this.connectionMaxAgeMs=0,this.connectionRefreshJitterMs=c.DEFAULT_CONNECTION_REFRESH_JITTER_MS,this._resolveFetch=function(e){return e?function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.apply(void 0,t)}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if("undefined"==typeof fetch)throw new Error("httpSend() requires a fetch implementation. Pass options.fetch, or use app.realtime() after registering a platform adapter that provides reqClass.");return fetch.apply(void 0,e)}},!(null===(n=null==t?void 0:t.params)||void 0===n?void 0:n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey;var r=this._initializeOptions(t);this._endPoint=e,this._socketOptions=r,this.socketAdapter=this._createSocketAdapter(),this.httpEndpoint=(0,l.httpEndpointURL)(e),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}return Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.socketAdapter.endPoint},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timeout",{get:function(){return this.socketAdapter.timeout},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){return this.socketAdapter.transport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatCallback",{get:function(){return this.socketAdapter.heartbeatCallback},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatIntervalMs",{get:function(){return this.socketAdapter.heartbeatIntervalMs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatTimer",{get:function(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingHeartbeatRef",{get:function(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reconnectTimer",{get:function(){return this.socketAdapter.reconnectTimer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vsn",{get:function(){return this.socketAdapter.vsn},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"encode",{get:function(){return this.socketAdapter.encode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"decode",{get:function(){return this.socketAdapter.decode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reconnectAfterMs",{get:function(){return this.socketAdapter.reconnectAfterMs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sendBuffer",{get:function(){return this.socketAdapter.sendBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stateChangeCallbacks",{get:function(){return this.socketAdapter.stateChangeCallbacks},enumerable:!1,configurable:!0}),e.prototype.connect=function(){var e=this;if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected()||this._openingActive)){if(this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._beforeTransportConnect)return this._openingActive=!0,void this._openActiveSocket().catch(function(t){e.log("error","failed to open socket",t)});this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(e){var t=e.message;throw new Error("WebSocket not available: ".concat(t))}this._handleNodeJsRaceCondition()}},e.prototype.endpointURL=function(){return this.socketAdapter.endPointURL()},e.prototype.disconnect=function(e,t){return o(this,void 0,void 0,function(){var n,r,o=this;return i(this,function(i){switch(i.label){case 0:return this._cancelPendingDisconnect(),this._cancelConnectionRefresh(),this._cancelRotateRetry(),this._rotating=!1,this._cutoverStarted=!1,n=this._standbyAdapter,this._standbyAdapter=null,this.isDisconnecting()?n?[4,n.disconnect(function(){},1e3,"connection refresh abort")]:[3,2]:[3,3];case 1:i.sent(),i.label=2;case 2:return[2,"ok"];case 3:return[4,this.socketAdapter.disconnect(function(){clearInterval(o._workerHeartbeatTimer),o._terminateWorker()},e,t)];case 4:return r=i.sent(),n?[4,n.disconnect(function(){},1e3,"connection refresh abort")]:[3,6];case 5:i.sent(),i.label=6;case 6:return[2,r]}})})},e.prototype.getChannels=function(){return this.channels},e.prototype.removeChannel=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,e.unsubscribe()];case 1:return"ok"===(t=n.sent())&&e.teardown(),[2,t]}})})},e.prototype.removeAllChannels=function(){return o(this,void 0,Promise,function(){var e,t,n=this;return i(this,function(r){switch(r.label){case 0:return e=this.channels.map(function(e){return o(n,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,e.unsubscribe()];case 1:return t=n.sent(),e.teardown(),[2,t]}})})}),[4,Promise.all(e)];case 1:return t=r.sent(),[4,this.disconnect()];case 2:return r.sent(),[2,t]}})})},e.prototype.log=function(e,t,n){this.socketAdapter.log(e,t,n)},e.prototype.hasLogger=function(){return this.socketAdapter.hasLogger()},e.prototype.connectionState=function(){return this.socketAdapter.connectionState()||c.CONNECTION_STATE.closed},e.prototype.isConnected=function(){return this.socketAdapter.isConnected()},e.prototype.isConnecting=function(){return this.socketAdapter.isConnecting()},e.prototype.isDisconnecting=function(){return this.socketAdapter.isDisconnecting()},e.prototype.channel=function(e,t){void 0===t&&(t={config:{}});var n="realtime:".concat(e),r=this.getChannels().find(function(e){return e.topic===n});if(r)return r;var o=new h.default("realtime:".concat(e),t,this);return this._cancelPendingDisconnect(),this.channels.push(o),o},e.prototype.push=function(e){this.socketAdapter.push(e)},e.prototype.setAuth=function(e){return void 0===e&&(e=null),o(this,void 0,Promise,function(){var t,n;return i(this,function(r){switch(r.label){case 0:t=++this._authGeneration,n=this._performAuth(e,t),t===this._authGeneration&&(this._authPromise=n),r.label=1;case 1:return r.trys.push([1,,3,4]),[4,n];case 2:return r.sent(),[3,4];case 3:return this._authPromise===n&&(this._authPromise=null),[7];case 4:return[2]}})})},e.prototype._isManualToken=function(){return this._manuallySetToken},e.prototype.sendHeartbeat=function(){return o(this,void 0,void 0,function(){return i(this,function(e){return this.socketAdapter.sendHeartbeat(),[2]})})},e.prototype.onHeartbeat=function(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)},e.prototype._makeRef=function(){return this.socketAdapter.makeRef()},e.prototype._remove=function(e){this.channels=this.channels.filter(function(t){return t.topic!==e.topic}),0===this.channels.length&&(this.log("transport","no channels remaining, scheduling disconnect"),this._cancelConnectionRefresh(),this._cancelRotateRetry(),this._abortRotate(),this._schedulePendingDisconnect())},e.prototype._schedulePendingDisconnect=function(){var e=this;if(this._cancelPendingDisconnect(),0===this._disconnectOnEmptyChannelsAfterMs)return this.log("transport","disconnecting immediately - no channels"),void this.disconnect();this._pendingDisconnectTimer=setTimeout(function(){e._pendingDisconnectTimer=null,0===e.channels.length&&(e.log("transport","deferred disconnect fired - no channels, disconnecting"),e.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport","deferred disconnect scheduled in ".concat(this._disconnectOnEmptyChannelsAfterMs,"ms"))},e.prototype._cancelPendingDisconnect=function(){null!==this._pendingDisconnectTimer&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)},e.prototype._performAuth=function(e,t){return o(this,void 0,Promise,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return r=!1,e?(n=e,r=!0,[3,7]):[3,1];case 1:if(!this.accessToken)return[3,6];i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.accessToken()];case 3:return n=i.sent(),[3,5];case 4:return o=i.sent(),this.log("error","Error fetching access token from callback",o),n=this.accessTokenValue,[3,5];case 5:return[3,7];case 6:n=this.accessTokenValue,i.label=7;case 7:return t!==this._authGeneration||(this.accessToken?this._manuallySetToken=!1:r&&(this._manuallySetToken=!0),this.accessTokenValue!=n&&(this.accessTokenValue=n)),[2]}})})},e.prototype._waitForAuthIfNeeded=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return this._authPromise?[4,this._authPromise]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},e.prototype._setAuthSafely=function(e){var t=this;void 0===e&&(e="general"),this._isManualToken()||this.setAuth().catch(function(n){t.log("error","Error setting auth in ".concat(e),n)})},e.prototype._setupConnectionHandlers=function(){var e=this;if(this._handlersAdapter!==this.socketAdapter){this._handlersAdapter=this.socketAdapter;var t=this.socketAdapter;t.onOpen(function(){e.socketAdapter===t&&((e._authPromise||(e.accessToken&&!e.accessTokenValue?e.setAuth():Promise.resolve())).catch(function(t){e.log("error","error waiting for auth on connect",t)}),e.worker&&!e.workerRef&&e._startWorkerHeartbeat(),e._scheduleConnectionRefresh())}),t.onClose(function(){e.socketAdapter===t&&(e.worker&&e.workerRef&&e._terminateWorker(),e._rotating&&!e._cutoverStarted&&(e.log("transport","active socket closed during refresh, aborting standby"),e._abortRotate()),e._rotating||e._cancelConnectionRefresh())}),t.onMessage(function(n){e.socketAdapter===t&&n.ref&&n.ref===e._pendingWorkerHeartbeatRef&&(e._pendingWorkerHeartbeatRef=null)})}},e.prototype._handleNodeJsRaceCondition=function(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()},e.prototype._wrapHeartbeatCallback=function(e){var t=this;return function(n,r){"disconnected"!==n&&("sent"==n&&t._setAuthSafely(),e&&e(n,r))}},e.prototype._startWorkerHeartbeat=function(){var e=this;this.workerUrl?this.log("worker","starting worker for from ".concat(this.workerUrl)):this.log("worker","starting default worker");var t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=function(t){e.log("worker","worker error",t.message),e._terminateWorker(),e.disconnect()},this.workerRef.onmessage=function(t){"keepAlive"===t.data.event&&e.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})},e.prototype._terminateWorker=function(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)},e.prototype._workerObjectUrl=function(e){var t;if(e)t=e;else{var n=new Blob(['\n addEventListener("message", (e) => {\n if (e.data.event === "start") {\n setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);\n }\n });'],{type:"application/javascript"});t=URL.createObjectURL(n)}return t},e.prototype._initializeOptions=function(e){var t,n,o,i,s,u,l,h,d,p,v,y,g,m;this.worker=null!==(t=null==e?void 0:e.worker)&&void 0!==t&&t,this.accessToken=null!==(n=null==e?void 0:e.accessToken)&&void 0!==n?n:null,this.connectionMaxAgeMs=null!==(o=null==e?void 0:e.connectionMaxAgeMs)&&void 0!==o?o:0,this.connectionRefreshJitterMs=null!==(i=null==e?void 0:e.connectionRefreshJitterMs)&&void 0!==i?i:c.DEFAULT_CONNECTION_REFRESH_JITTER_MS,this._beforeTransportConnect=null==e?void 0:e.beforeTransportConnect;var b,_,E={};E.timeout=null!==(s=null==e?void 0:e.timeout)&&void 0!==s?s:c.DEFAULT_TIMEOUT,E.heartbeatIntervalMs=null!==(u=null==e?void 0:e.heartbeatIntervalMs)&&void 0!==u?u:25e3,this._disconnectOnEmptyChannelsAfterMs=null!==(l=null==e?void 0:e.disconnectOnEmptyChannelsAfterMs)&&void 0!==l?l:2*(null!==(h=null==e?void 0:e.heartbeatIntervalMs)&&void 0!==h?h:25e3),E.transport=null!==(d=null==e?void 0:e.transport)&&void 0!==d?d:a.default.getWebSocketConstructor(),E.params=null==e?void 0:e.params,E.logger=null==e?void 0:e.logger,E.heartbeatCallback=this._wrapHeartbeatCallback(null==e?void 0:e.heartbeatCallback),E.sessionStorage=null!==(p=null==e?void 0:e.sessionStorage)&&void 0!==p?p:function(){try{if("undefined"!=typeof globalThis&&globalThis.sessionStorage)return globalThis.sessionStorage}catch(e){}return e=new Map,{get length(){return e.size},clear:function(){e.clear()},getItem:function(t){return e.has(t)?e.get(t):null},key:function(t){var n;return null!==(n=Array.from(e.keys())[t])&&void 0!==n?n:null},removeItem:function(t){e.delete(t)},setItem:function(t,n){e.set(t,String(n))}};var e}(),E.reconnectAfterMs=null!==(v=null==e?void 0:e.reconnectAfterMs)&&void 0!==v?v:function(e){return f[e-1]||1e4};var w=null!==(y=null==e?void 0:e.vsn)&&void 0!==y?y:c.DEFAULT_VSN;switch(w){case c.VSN_1_0_0:b=function(e,t){return t(JSON.stringify(e))},_=function(e,t){return t(JSON.parse(e))};break;case c.VSN_2_0_0:b=this.serializer.encode.bind(this.serializer),_=this.serializer.decode.bind(this.serializer);break;default:throw new Error("Unsupported serializer version: ".concat(E.vsn))}if(E.vsn=w,E.encode=null!==(g=null==e?void 0:e.encode)&&void 0!==g?g:b,E.decode=null!==(m=null==e?void 0:e.decode)&&void 0!==m?m:_,E.beforeReconnect=this._reconnectAuth.bind(this),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,E.params=r(r({},E.params),{log_level:this.logLevel})),this.worker){if("undefined"!=typeof window&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl,E.autoSendHeartbeat=!this.worker}return E},e.prototype._reconnectAuth=function(){return o(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this._waitForAuthIfNeeded()];case 1:return e.sent(),this.isConnected()||this.connect(),[2]}})})},e.prototype._createSocketAdapter=function(){return new d.default(this._endPoint,this._socketOptions)},e.prototype._openActiveSocket=function(){return o(this,void 0,void 0,function(){var e,t;return i(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),this._beforeTransportConnect?[4,this._beforeTransportConnect()]:[3,2];case 1:n.sent(),n.label=2;case 2:return this.isConnecting()||this.isDisconnecting()||this.isConnected()?[2]:(this._setupConnectionHandlers(),this.socketAdapter.connect(),this._handleNodeJsRaceCondition(),[3,5]);case 3:throw e=n.sent(),t=e.message,new Error("WebSocket not available: ".concat(t));case 4:return this._openingActive=!1,[7];case 5:return[2]}})})},e.prototype._scheduleConnectionRefresh=function(){var e=this;if(this._cancelConnectionRefresh(),!(this.connectionMaxAgeMs<=0)){var t=this.connectionRefreshJitterMs>0?Math.floor(Math.random()*this.connectionRefreshJitterMs):0,n=this.connectionMaxAgeMs+t;this._refreshTimer=setTimeout(function(){e._refreshTimer=null,e._rotateConnection()},n),this.log("transport","connection refresh scheduled in ".concat(n,"ms"))}},e.prototype._cancelConnectionRefresh=function(){null!==this._refreshTimer&&(clearTimeout(this._refreshTimer),this._refreshTimer=null)},e.prototype._scheduleRotateRetry=function(){var e=this;this._cancelRotateRetry(),this._rotateRetryTimer=setTimeout(function(){e._rotateRetryTimer=null,e.isConnected()&&!e._rotating&&e._rotateConnection()},c.CONNECTION_REFRESH_RETRY_MS),this.log("transport","connection refresh retry scheduled in ".concat(c.CONNECTION_REFRESH_RETRY_MS,"ms"))},e.prototype._cancelRotateRetry=function(){null!==this._rotateRetryTimer&&(clearTimeout(this._rotateRetryTimer),this._rotateRetryTimer=null)},e.prototype._rotateConnection=function(){return o(this,void 0,void 0,function(){var e,t,n,r;return i(this,function(o){switch(o.label){case 0:if(this._rotating||!this.isConnected()||0===this.channels.length)return[2];this._rotating=!0,this._cutoverStarted=!1,this._cancelConnectionRefresh(),this.log("transport","starting connection refresh"),o.label=1;case 1:return o.trys.push([1,6,,8]),this._beforeTransportConnect?[4,this._beforeTransportConnect()]:[3,3];case 2:o.sent(),o.label=3;case 3:if(!this.isConnected()||0===this.channels.length)throw new Error("active connection lost before standby connect");return e=this._createSocketAdapter(),this._standbyAdapter=e,[4,this._connectAndWaitOpen(e)];case 4:return o.sent(),t=this.channels.filter(function(e){return e.joinedOnce&&!e.channelAdapter.isClosed()&&!e.channelAdapter.isLeaving()}),[4,Promise.all(t.map(function(t){return t._warmupOn(e)}))];case 5:return n=o.sent(),this._cutover(t,n,e),[3,8];case 6:return r=o.sent(),this.log("transport","connection refresh failed",r),[4,this._teardownStandby()];case 7:return o.sent(),this._rotating=!1,this._cutoverStarted=!1,this.isConnected()&&this.channels.length>0&&this._scheduleRotateRetry(),[3,8];case 8:return[2]}})})},e.prototype._cutover=function(e,t,n){this._cutoverStarted=!0;for(var r=this.socketAdapter,o=0;o<e.length;o++)e[o]._adopt(t[o]);this.socketAdapter=n,this._standbyAdapter=null,this._setupConnectionHandlers(),this.worker&&(this._terminateWorker(),this._startWorkerHeartbeat()),this._rotating=!1,this._scheduleConnectionRefresh(),r.disconnect(function(){},1e3,"connection refresh"),this.log("transport","connection refresh complete")},e.prototype._connectAndWaitOpen=function(e,t){return void 0===t&&(t=c.STANDBY_CONNECT_TIMEOUT_MS),o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n,r){var o=setTimeout(function(){r(new Error("standby connect timed out"))},t);e.onOpen(function(){clearTimeout(o),n()}),e.onError(function(e){clearTimeout(o),r(e instanceof Error?e:new Error(String(e)))});try{e.connect()}catch(e){clearTimeout(o),r(e)}})];case 1:return n.sent(),[2]}})})},e.prototype._teardownStandby=function(){return o(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:if(e=this._standbyAdapter,this._standbyAdapter=null,!e)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.disconnect(function(){},1e3,"connection refresh abort")];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}})})},e.prototype._abortRotate=function(){return o(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return this._cancelRotateRetry(),[4,this._teardownStandby()];case 1:return e.sent(),this._rotating=!1,this._cutoverStarted=!1,[2]}})})},e}();t.default=p},8352:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postgresChangesFilter=t.RealtimePostgresFilterBuilder=void 0;var n=/[,()"\\]/,r=function(e){var t=null===e?"null":String(e);return function(e){return n.test(e)||e!==e.trim()}(t)?function(e){return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}(t):t},o=function(){function e(){this.filters=[]}return e.prototype.add=function(e,t,n,o){void 0===o&&(o=!1);var i=o?"not.":"";return this.filters.push("".concat(e,"=").concat(i).concat(function(e,t){if("in"===e){var n=Array.isArray(t)?t:[t];if(0===n.length)throw new Error("Realtime `in` filter requires at least one value.");var o=Array.from(new Set(n)).map(function(e){return r(e)}).join(",");return"in.(".concat(o,")")}return"is"===e?"is.".concat(function(e){return null===e?"null":String(e)}(t)):"".concat(e,".").concat(r(t))}(t,n))),this},e.prototype.eq=function(e,t){return this.add(e,"eq",t)},e.prototype.neq=function(e,t){return this.add(e,"neq",t)},e.prototype.gt=function(e,t){return this.add(e,"gt",t)},e.prototype.gte=function(e,t){return this.add(e,"gte",t)},e.prototype.lt=function(e,t){return this.add(e,"lt",t)},e.prototype.lte=function(e,t){return this.add(e,"lte",t)},e.prototype.in=function(e,t){return this.add(e,"in",t)},e.prototype.like=function(e,t){return this.add(e,"like",t)},e.prototype.ilike=function(e,t){return this.add(e,"ilike",t)},e.prototype.match=function(e,t){return this.add(e,"match",t)},e.prototype.imatch=function(e,t){return this.add(e,"imatch",t)},e.prototype.is=function(e,t){return this.add(e,"is",t)},e.prototype.isDistinct=function(e,t){return this.add(e,"isdistinct",t)},e.prototype.not=function(e,t,n){return this.add(e,t,n,!0)},e.prototype.build=function(){return this.filters.join(",")},e.prototype.toString=function(){return this.build()},e}();t.RealtimePostgresFilterBuilder=o,t.postgresChangesFilter=function(){return new o}},4666:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.REALTIME_PRESENCE_LISTEN_EVENTS=void 0;var o,i=r(n(1732));(o=t.REALTIME_PRESENCE_LISTEN_EVENTS||(t.REALTIME_PRESENCE_LISTEN_EVENTS={})).SYNC="sync",o.JOIN="join",o.LEAVE="leave";var s=function(){function e(e,t){this.channel=e,this.presenceAdapter=new i.default(this.channel.channelAdapter,t)}return Object.defineProperty(e.prototype,"state",{get:function(){return this.presenceAdapter.state},enumerable:!1,configurable:!0}),e}();t.default=s},9203:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerRealtimeJs=t.createRealtimeClient=t.bindRealtimeAuthEvents=t.buildRealtimeEndPoint=void 0;var s=i(n(539)),a=n(5633),c=n(4508),u=new Set(["TOKEN_REFRESHED","SIGNED_IN","INITIAL_SESSION"]),l=new WeakSet,h=new WeakMap;function d(e){var t=e.getEndPointWithKey("GATEWAY"),n=t.BASE_URL,r=t.PROTOCOL,o=/^https:?$/i.test(r)?"wss:":"ws:",i=String(n||"").replace(/\/+$/,"");return"".concat(o).concat(i,"/realtime")}function f(e){var t,n;return r(this,void 0,Promise,function(){var r;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,null===(n=null===(t=e.request)||void 0===t?void 0:t.getAccessToken)||void 0===n?void 0:n.call(t)];case 1:return(r=o.sent())?(l.delete(e),[2,r]):[3,3];case 2:return o.sent(),[3,3];case 3:return function(e){l.has(e)||(l.add(e),console.warn("[CloudBase Realtime] 当前没有登录态,无法使用 realtime 能力。\n请确认以下各项:\n 1 - 是否已调用 app.auth() 初始化认证\n 2 - 是否已完成登录(如 auth.signInAnonymously() / auth.signInWithPassword())\n 3 - 登录态是否已过期,需要重新登录"))}(e),[2,null]}})})}function p(e){return!!e&&"function"==typeof e.onAuthStateChange}t.buildRealtimeEndPoint=d;var v=new WeakSet,y=new WeakMap,g=new WeakSet;function m(e,t){var n;v.has(e)||(v.add(e),t.onAuthStateChange(function(t,r){var o,i=null!==(o=null==r?void 0:r.access_token)&&void 0!==o?o:void 0;if(u.has(t)&&i&&n!==i)return n=i,void e.setAuth(i).catch(function(t){e.log("error","Error setting auth from auth state change",t)});"SIGNED_OUT"===t&&(n=void 0,e.setAuth().catch(function(t){e.log("error","Error clearing auth from SIGNED_OUT",t)}))}))}function b(e){var t,n,i,u,l,h,v=this,b=d(e),_={apikey:(null===(t=e.config)||void 0===t?void 0:t.env)||"cloudbase"},E=function(e){return e&&(h.apiKey=e,_.apikey=e),e},w={params:_,vsn:a.VSN_1_0_0,accessToken:function(){return r(v,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return t=E,[4,f(e)];case 1:return[2,t.apply(void 0,[n.sent()])]}})})},connectionMaxAgeMs:a.CLOUDBASE_CONNECTION_MAX_AGE_MS,beforeTransportConnect:function(){return r(v,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,h.setAuth()];case 1:return e.sent(),[2]}})})}},S=null===(i=null===(n=e.platform)||void 0===n?void 0:n.adapter)||void 0===i?void 0:i.wsClass;S&&(w.transport=S);var I=null===(l=null===(u=e.platform)||void 0===u?void 0:u.adapter)||void 0===l?void 0:l.reqClass;return I&&(w.fetch=(0,c.wrapReqClassFetch)(I)),h=new s.default(b,w),function(e,t){var n=function(e){try{if(p(e.auth))return e.auth;if(p(e.authInstance))return e.authInstance}catch(e){}return null}(e);if(n)m(t,n);else{var r=e.auth;if("function"==typeof r){var o=y.get(e);if(o||(o=new Set,y.set(e,o)),o.add(t),!g.has(e)){g.add(e);var i=function(t){var n=r.call(null!=this?this:e,t);return p(n)&&function(e,t){var n=y.get(e);if(n){for(var r=0,o=n;r<o.length;r++)m(o[r],t);n.clear(),y.delete(e)}}(e,n),n};try{Object.defineProperty(e,"auth",{configurable:!0,enumerable:!0,writable:!0,value:i})}catch(t){e.auth=i}}}}}(e,h),h}t.bindRealtimeAuthEvents=m,t.createRealtimeClient=b;var _={name:"realtime-js",entity:{realtime:function(){return function(e){var t=h.get(e);if(t)return t;var n=b(e);return h.set(e,n),n}(this)}}};try{cloudbase.registerComponent(_)}catch(e){}function E(e){try{e.registerComponent(_)}catch(e){console.warn(e)}}t.registerRealtimeJs=E;try{window.registerRealtimeJs=E}catch(e){}},7397:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.bindRealtimeAuthEvents=t.buildRealtimeEndPoint=t.createRealtimeClient=t.registerRealtimeJs=t.WebSocketLikeConstructor=t.WebSocketLike=t.WebSocketFactory=t.REALTIME_CHANNEL_STATES=t.REALTIME_SUBSCRIBE_STATES=t.REALTIME_PRESENCE_LISTEN_EVENTS=t.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=t.REALTIME_LISTEN_TYPES=t.RealtimeRemoveChannelResponse=t.RealtimePresenceState=t.RealtimePresenceLeavePayload=t.RealtimePresenceJoinPayload=t.RealtimeSystemPayload=t.RealtimePostgresDeletePayload=t.RealtimePostgresUpdatePayload=t.RealtimePostgresInsertPayload=t.RealtimePostgresChangesPayload=t.postgresChangesFilter=t.RealtimePostgresFilterBuilder=t.RealtimePostgresChangesFilterOperator=t.RealtimePostgresChangesFilter=t.RealtimeMessage=t.RealtimeClientOptions=t.RealtimeClient=t.RealtimeChannelSendResponse=t.RealtimeChannelOptions=t.RealtimeChannel=t.RealtimePresence=void 0;var s=i(n(539));t.RealtimeClient=s.default,Object.defineProperty(t,"RealtimeClientOptions",{enumerable:!0,get:function(){return s.RealtimeClientOptions}}),Object.defineProperty(t,"RealtimeMessage",{enumerable:!0,get:function(){return s.RealtimeMessage}}),Object.defineProperty(t,"RealtimeRemoveChannelResponse",{enumerable:!0,get:function(){return s.RealtimeRemoveChannelResponse}}),Object.defineProperty(t,"WebSocketLikeConstructor",{enumerable:!0,get:function(){return s.WebSocketLikeConstructor}});var a=i(n(317));t.RealtimeChannel=a.default,Object.defineProperty(t,"RealtimeChannelOptions",{enumerable:!0,get:function(){return a.RealtimeChannelOptions}}),Object.defineProperty(t,"RealtimeChannelSendResponse",{enumerable:!0,get:function(){return a.RealtimeChannelSendResponse}}),Object.defineProperty(t,"RealtimePostgresChangesFilter",{enumerable:!0,get:function(){return a.RealtimePostgresChangesFilter}}),Object.defineProperty(t,"RealtimePostgresChangesFilterOperator",{enumerable:!0,get:function(){return a.RealtimePostgresChangesFilterOperator}}),Object.defineProperty(t,"RealtimePostgresFilterBuilder",{enumerable:!0,get:function(){return a.RealtimePostgresFilterBuilder}}),Object.defineProperty(t,"postgresChangesFilter",{enumerable:!0,get:function(){return a.postgresChangesFilter}}),Object.defineProperty(t,"RealtimePostgresChangesPayload",{enumerable:!0,get:function(){return a.RealtimePostgresChangesPayload}}),Object.defineProperty(t,"RealtimePostgresInsertPayload",{enumerable:!0,get:function(){return a.RealtimePostgresInsertPayload}}),Object.defineProperty(t,"RealtimePostgresUpdatePayload",{enumerable:!0,get:function(){return a.RealtimePostgresUpdatePayload}}),Object.defineProperty(t,"RealtimePostgresDeletePayload",{enumerable:!0,get:function(){return a.RealtimePostgresDeletePayload}}),Object.defineProperty(t,"RealtimeSystemPayload",{enumerable:!0,get:function(){return a.RealtimeSystemPayload}}),Object.defineProperty(t,"REALTIME_LISTEN_TYPES",{enumerable:!0,get:function(){return a.REALTIME_LISTEN_TYPES}}),Object.defineProperty(t,"REALTIME_POSTGRES_CHANGES_LISTEN_EVENT",{enumerable:!0,get:function(){return a.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT}}),Object.defineProperty(t,"REALTIME_SUBSCRIBE_STATES",{enumerable:!0,get:function(){return a.REALTIME_SUBSCRIBE_STATES}}),Object.defineProperty(t,"REALTIME_CHANNEL_STATES",{enumerable:!0,get:function(){return a.REALTIME_CHANNEL_STATES}});var c=i(n(4666));t.RealtimePresence=c.default,Object.defineProperty(t,"RealtimePresenceState",{enumerable:!0,get:function(){return c.RealtimePresenceState}}),Object.defineProperty(t,"RealtimePresenceJoinPayload",{enumerable:!0,get:function(){return c.RealtimePresenceJoinPayload}}),Object.defineProperty(t,"RealtimePresenceLeavePayload",{enumerable:!0,get:function(){return c.RealtimePresenceLeavePayload}}),Object.defineProperty(t,"REALTIME_PRESENCE_LISTEN_EVENTS",{enumerable:!0,get:function(){return c.REALTIME_PRESENCE_LISTEN_EVENTS}});var u=i(n(1606));t.WebSocketFactory=u.default,Object.defineProperty(t,"WebSocketLike",{enumerable:!0,get:function(){return u.WebSocketLike}});var l=n(9203);Object.defineProperty(t,"registerRealtimeJs",{enumerable:!0,get:function(){return l.registerRealtimeJs}}),Object.defineProperty(t,"createRealtimeClient",{enumerable:!0,get:function(){return l.createRealtimeClient}}),Object.defineProperty(t,"buildRealtimeEndPoint",{enumerable:!0,get:function(){return l.buildRealtimeEndPoint}}),Object.defineProperty(t,"bindRealtimeAuthEvents",{enumerable:!0,get:function(){return l.bindRealtimeAuthEvents}})},5633:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CONNECTION_STATE=t.TRANSPORTS=t.CHANNEL_EVENTS=t.CHANNEL_STATES=t.SOCKET_STATES=t.MAX_PUSH_BUFFER_SIZE=t.WS_CLOSE_NORMAL=t.POSTGRES_CHANGES_WAIT_ERROR_GRACE=t.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT=t.STANDBY_CONNECT_TIMEOUT_MS=t.CONNECTION_REFRESH_RETRY_MS=t.DEFAULT_CONNECTION_REFRESH_JITTER_MS=t.CLOUDBASE_CONNECTION_MAX_AGE_MS=t.DEFAULT_TIMEOUT=t.VERSION=t.DEFAULT_VSN=t.VSN_2_0_0=t.VSN_1_0_0=t.DEFAULT_VERSION=void 0;var r=n(2986);t.DEFAULT_VERSION="realtime-js/".concat(r.version),t.VSN_1_0_0="1.0.0",t.VSN_2_0_0="2.0.0",t.DEFAULT_VSN=t.VSN_2_0_0,t.VERSION=r.version,t.DEFAULT_TIMEOUT=1e4,t.CLOUDBASE_CONNECTION_MAX_AGE_MS=27e4,t.DEFAULT_CONNECTION_REFRESH_JITTER_MS=2e4,t.CONNECTION_REFRESH_RETRY_MS=1e4,t.STANDBY_CONNECT_TIMEOUT_MS=1e4,t.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT=15e3,t.POSTGRES_CHANGES_WAIT_ERROR_GRACE=1e4,t.WS_CLOSE_NORMAL=1e3,t.MAX_PUSH_BUFFER_SIZE=100,t.SOCKET_STATES={connecting:0,open:1,closing:2,closed:3},t.CHANNEL_STATES={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},t.CHANNEL_EVENTS={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},t.TRANSPORTS={websocket:"websocket"},t.CONNECTION_STATE={connecting:"connecting",open:"open",closing:"closing",closed:"closed"}},240:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeChannelError=void 0,t.normalizeChannelError=function(e){if(e instanceof Error)return e;if("string"==typeof e)return new Error(e);if(e&&"object"==typeof e){var t=e;if("number"==typeof t.code){var n="string"==typeof t.reason&&t.reason?" (".concat(t.reason,")"):"";return new Error("socket closed: ".concat(t.code).concat(n),{cause:e})}return new Error("channel error: transport failure",{cause:e})}return new Error("channel error: connection lost")}},4508:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};function o(e){if(!e)return{};if("undefined"!=typeof Headers&&e instanceof Headers){var t={};return e.forEach(function(e,n){t[n]=e}),t}if(Array.isArray(e)){for(var n={},r=0,o=e;r<o.length;r++){var i=o[r],s=i[0],a=i[1];n[s]=String(a)}return n}for(var c={},u=0,l=Object.entries(e);u<l.length;u++){var h=l[u];s=h[0],null!=(a=h[1])&&(c[s]=String(a))}return c}function i(e){var t;return"string"==typeof e?e:"undefined"!=typeof URL&&e instanceof URL?e.toString():"undefined"!=typeof Request&&e instanceof Request?e.url:String(null!==(t=e.url)&&void 0!==t?t:e)}function s(e){return n(this,void 0,Promise,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,e];case 1:if(null==(t=n.sent())||""===t)return[2,{}];if("string"==typeof t)try{return[2,JSON.parse(t)]}catch(e){return[2,{message:t}]}return[2,t]}})})}function a(e){var t,o,i,a,c=this;if(e&&"object"==typeof e&&"number"==typeof e.status&&"function"==typeof e.json)return e;var u=null!=e?e:{},l=null!==(o=null!==(t=u.statusCode)&&void 0!==t?t:u.status)&&void 0!==o?o:0,h=u.data;return{ok:l>=200&&l<300,status:l,statusText:u.statusMessage||u.statusText||u.errMsg||"",headers:null!==(a=null!==(i=u.header)&&void 0!==i?i:u.headers)&&void 0!==a?a:{},json:function(){return n(c,void 0,void 0,function(){return r(this,function(e){return[2,s(h)]})})},text:function(){return n(c,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return[4,h];case 1:return"string"==typeof(e=t.sent())?[2,e]:null==e?[2,""]:[2,JSON.stringify(e)]}})})}}}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapReqClassFetch=void 0,t.wrapReqClassFetch=function(e,t){var s=this;void 0===t&&(t={});var c=new e(t);return function(e,t){return void 0===t&&(t={}),n(s,void 0,void 0,function(){var n;return r(this,function(r){switch(r.label){case 0:return[4,c.fetch({url:i(e),method:t.method||"GET",headers:o(t.headers),body:t.body,data:t.body,signal:null!==(n=t.signal)&&void 0!==n?n:void 0,shouldThrowOnError:!1})];case 1:return[2,a(r.sent())]}})})}}},7135:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=null!=e?e:[]}return e.prototype.encode=function(e,t){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&"string"==typeof e.payload.event)return t(this._binaryEncodeUserBroadcastPush(e));var n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))},e.prototype._binaryEncodeUserBroadcastPush=function(e){var t;return this._isArrayBuffer(null===(t=e.payload)||void 0===t?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)},e.prototype._encodeBinaryUserBroadcastPush=function(e){var t,n,r=null!==(n=null===(t=e.payload)||void 0===t?void 0:t.payload)&&void 0!==n?n:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,r)},e.prototype._encodeJsonUserBroadcastPush=function(e){var t,n,r=null!==(n=null===(t=e.payload)||void 0===t?void 0:t.payload)&&void 0!==n?n:{},o=(new TextEncoder).encode(JSON.stringify(r)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,o)},e.prototype._encodeUserBroadcastPush=function(e,t,n){var r,o,i=new TextEncoder,s=i.encode(e.topic),a=i.encode(null!==(r=e.ref)&&void 0!==r?r:""),c=i.encode(null!==(o=e.join_ref)&&void 0!==o?o:""),u=i.encode(e.payload.event),l=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},h=i.encode(0===Object.keys(l).length?"":JSON.stringify(l));if(c.length>255)throw new Error("joinRef length ".concat(c.length," exceeds maximum of 255"));if(a.length>255)throw new Error("ref length ".concat(a.length," exceeds maximum of 255"));if(s.length>255)throw new Error("topic length ".concat(s.length," exceeds maximum of 255"));if(u.length>255)throw new Error("userEvent length ".concat(u.length," exceeds maximum of 255"));if(h.length>255)throw new Error("metadata length ".concat(h.length," exceeds maximum of 255"));var d=this.USER_BROADCAST_PUSH_META_LENGTH+c.length+a.length+s.length+u.length+h.length,f=new ArrayBuffer(this.HEADER_LENGTH+d),p=new DataView(f),v=new Uint8Array(f),y=0;p.setUint8(y++,this.KINDS.userBroadcastPush),p.setUint8(y++,c.length),p.setUint8(y++,a.length),p.setUint8(y++,s.length),p.setUint8(y++,u.length),p.setUint8(y++,h.length),p.setUint8(y++,t),v.set(c,y),y+=c.length,v.set(a,y),y+=a.length,v.set(s,y),y+=s.length,v.set(u,y),y+=u.length,v.set(h,y),y+=h.length;var g=new Uint8Array(f.byteLength+n.byteLength);return g.set(new Uint8Array(f),0),g.set(new Uint8Array(n),f.byteLength),g.buffer},e.prototype.decode=function(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){var n=JSON.parse(e);return t({join_ref:n[0],ref:n[1],topic:n[2],event:n[3],payload:n[4]})}return t({})},e.prototype._binaryDecode=function(e){var t=new DataView(e),n=t.getUint8(0),r=new TextDecoder;if(n===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,t,r)},e.prototype._decodeUserBroadcast=function(e,t,n){var r=t.getUint8(1),o=t.getUint8(2),i=t.getUint8(3),s=t.getUint8(4),a=this.HEADER_LENGTH+4,c=n.decode(e.slice(a,a+r));a+=r;var u=n.decode(e.slice(a,a+o));a+=o;var l=n.decode(e.slice(a,a+i));a+=i;var h=e.slice(a,e.byteLength),d=s===this.JSON_ENCODING?JSON.parse(n.decode(h)):h,f={type:this.BROADCAST_EVENT,event:u,payload:d};return i>0&&(f.meta=JSON.parse(l)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:f}},e.prototype._isArrayBuffer=function(e){var t;return e instanceof ArrayBuffer||"ArrayBuffer"===(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)},e.prototype._pick=function(e,t){return e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(function(e){var n=e[0];return t.includes(n)})):{}},e}();t.default=n},8206:function(e,t){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.joinBroadcastEventUrl=t.httpEndpointURL=t.toTimestampString=t.toArray=t.toJson=t.toNumber=t.toBoolean=t.convertCell=t.convertColumn=t.convertChangeData=t.PostgresTypes=void 0,function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(n=t.PostgresTypes||(t.PostgresTypes={})),t.convertChangeData=function(e,n,r){var o;void 0===r&&(r={});var i=null!==(o=r.skipTypes)&&void 0!==o?o:[];return n?Object.keys(n).reduce(function(r,o){return r[o]=(0,t.convertColumn)(o,e,n,i),r},{}):{}},t.convertColumn=function(e,n,o,i){var s=n.find(function(t){return t.name===e}),a=null==s?void 0:s.type,c=o[e];return a&&!i.includes(a)?(0,t.convertCell)(a,c):r(c)},t.convertCell=function(e,o){if("_"===e.charAt(0)){var i=e.slice(1,e.length);return(0,t.toArray)(o,i)}switch(e){case n.bool:return(0,t.toBoolean)(o);case n.float4:case n.float8:case n.int2:case n.int4:case n.int8:case n.numeric:case n.oid:return(0,t.toNumber)(o);case n.json:case n.jsonb:return(0,t.toJson)(o);case n.timestamp:return(0,t.toTimestampString)(o);case n.abstime:case n.date:case n.daterange:case n.int4range:case n.int8range:case n.money:case n.reltime:case n.text:case n.time:case n.timestamptz:case n.timetz:case n.tsrange:case n.tstzrange:default:return r(o)}};var r=function(e){return e};function o(e){var t=e.indexOf("#"),n=-1===t?e:e.slice(0,t),r=-1===t?"":e.slice(t),o=n.indexOf("?");return{base:-1===o?n:n.slice(0,o),query:-1===o?"":n.slice(o),hash:r}}t.toBoolean=function(e){switch(e){case"t":return!0;case"f":return!1;default:return e}},t.toNumber=function(e){if("string"==typeof e){var t=parseFloat(e);if(!Number.isNaN(t))return t}return e},t.toJson=function(e){if("string"==typeof e)try{return JSON.parse(e)}catch(t){return e}return e},t.toArray=function(e,n){if("string"!=typeof e)return e;var r=e.length-1,o=e[r];if("{"===e[0]&&"}"===o){var i=void 0,s=e.slice(1,r);try{i=JSON.parse("["+s+"]")}catch(e){i=s?s.split(","):[]}return i.map(function(e){return(0,t.convertCell)(n,e)})}return e},t.toTimestampString=function(e){return"string"==typeof e?e.replace(" ","T"):e},t.httpEndpointURL=function(e){var t=o(e),n=t.base,r=t.query,i=t.hash,s=n.replace(/^ws/i,"http").replace(/\/+$/,"");return(s=(s=s.replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,"")).replace(/\/+$/,"")+"/api/broadcast")+r+i},t.joinBroadcastEventUrl=function(e,t,n,r){var i=o(e),s=i.base,a=i.query,c=i.hash,u="/".concat(encodeURIComponent(t),"/events/").concat(encodeURIComponent(n)),l=s.replace(/\/+$/,"")+u,h=[];if(a.startsWith("?")&&a.length>1&&h.push(a.slice(1)),r)for(var d=0,f=Object.entries(r);d<f.length;d++){var p=f[d],v=p[0],y=p[1];h.push("".concat(encodeURIComponent(v),"=").concat(encodeURIComponent(y)))}return l+(h.length?"?".concat(h.join("&")):"")+c}},2986:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="1.0.0-alpha.0"},1606:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketFactory=void 0;var r=function(){function e(){}return e.detectEnvironment=function(){var e;if("undefined"!=typeof WebSocket)return{type:"native",wsConstructor:WebSocket};var t=globalThis;if("undefined"!=typeof globalThis&&void 0!==t.WebSocket)return{type:"native",wsConstructor:t.WebSocket};var r=void 0!==n.g?n.g:void 0;if(r&&void 0!==r.WebSocket)return{type:"native",wsConstructor:r.WebSocket};if("undefined"!=typeof globalThis&&void 0!==t.WebSocketPair&&void 0===globalThis.WebSocket)return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if("undefined"!=typeof globalThis&&t.EdgeRuntime||"undefined"!=typeof navigator&&(null===(e=navigator.userAgent)||void 0===e?void 0:e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};var o=globalThis.process;if(o){var i=o.versions;if(i&&i.node)return{type:"unsupported",error:"Node.js detected but native WebSocket not found.",workaround:"Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}},e.getWebSocketConstructor=function(){var e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;var t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+="\n\nSuggested solution: ".concat(e.workaround)),new Error(t)},e.isWebSocketSupported=function(){try{return"native"===this.detectEnvironment().type}catch(e){return!1}},e}();t.WebSocketFactory=r,t.default=r},4663:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o=n(5633),i=function(){function e(e,t,n){var o={config:r({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config)};this.channel=e.getSocket().channel(t,o),this.socket=e}return Object.defineProperty(e.prototype,"state",{get:function(){return this.channel.state},set:function(e){this.channel.state=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"joinedOnce",{get:function(){return this.channel.joinedOnce},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"joinPush",{get:function(){return this.channel.joinPush},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rejoinTimer",{get:function(){return this.channel.rejoinTimer},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return this.channel.on(e,t)},e.prototype.off=function(e,t){this.channel.off(e,t)},e.prototype.subscribe=function(e){return this.channel.join(e)},e.prototype.unsubscribe=function(e){return this.channel.leave(e)},e.prototype.teardown=function(){this.channel.teardown()},e.prototype.detachLifecycleHooks=function(){this.channel.off(o.CHANNEL_EVENTS.close),this.channel.off(o.CHANNEL_EVENTS.error)},e.prototype.onClose=function(e){this.channel.onClose(e)},e.prototype.onError=function(e){return this.channel.onError(e)},e.prototype.push=function(e,t,n){var r;try{r=this.channel.push(e,t,n)}catch(t){throw new Error("tried to push '".concat(e,"' to '").concat(this.channel.topic,"' before joining. Use channel.subscribe() before pushing events"))}if(this.channel.pushBuffer.length>o.MAX_PUSH_BUFFER_SIZE){var i=this.channel.pushBuffer.shift();i.cancelTimeout(),this.socket.log("channel","discarded push due to buffer overflow: ".concat(i.event),i.payload())}return r},e.prototype.updateJoinPayload=function(e){var t=this.channel.joinPush.payload();this.channel.joinPush.payload=function(){return r(r({},t),e)}},e.prototype.canPush=function(){return this.socket.isConnected()&&this.state===o.CHANNEL_STATES.joined},e.prototype.isJoined=function(){return this.state===o.CHANNEL_STATES.joined},e.prototype.isJoining=function(){return this.state===o.CHANNEL_STATES.joining},e.prototype.isClosed=function(){return this.state===o.CHANNEL_STATES.closed},e.prototype.isLeaving=function(){return this.state===o.CHANNEL_STATES.leaving},e.prototype.updateFilterBindings=function(e){this.channel.filterBindings=e},e.prototype.updatePayloadTransform=function(e){this.channel.onMessage=e},e.prototype.getChannel=function(){return this.channel},e}();t.default=i},1732:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2772),o=function(){function e(t,n){var o=function(e){return(null==e?void 0:e.events)&&{events:e.events}}(n);this.presence=new r.Presence(t.getChannel(),o),this.presence.onJoin(function(n,r,o){var i=e.onJoinPayload(n,r,o);t.getChannel().trigger("presence",i)}),this.presence.onLeave(function(n,r,o){var i=e.onLeavePayload(n,r,o);t.getChannel().trigger("presence",i)}),this.presence.onSync(function(){t.getChannel().trigger("presence",{event:"sync"})})}return Object.defineProperty(e.prototype,"state",{get:function(){return e.transformState(this.presence.state)},enumerable:!1,configurable:!0}),e.transformState=function(e){return e=function(e){return JSON.parse(JSON.stringify(e))}(e),Object.getOwnPropertyNames(e).reduce(function(t,n){var r=e[n];return t[n]=i(r),t},{})},e.onJoinPayload=function(e,t,n){return{event:"join",key:e,currentPresences:s(t),newPresences:i(n)}},e.onLeavePayload=function(e,t,n){return{event:"leave",key:e,currentPresences:s(t),leftPresences:i(n)}},e}();function i(e){return e.metas.map(function(e){var t=Object.getOwnPropertyDescriptors(e),n=Object.defineProperties({},t);return n.presence_ref=n.phx_ref,delete n.phx_ref,delete n.phx_ref_prev,n})}function s(e){return(null==e?void 0:e.metas)?i(e):[]}t.default=o},1563:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2772),o=n(5633),i=function(){function e(e,t){this.socket=new r.Socket(e,t)}return Object.defineProperty(e.prototype,"timeout",{get:function(){return this.socket.timeout},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.socket.endPoint},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){return this.socket.transport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatIntervalMs",{get:function(){return this.socket.heartbeatIntervalMs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatCallback",{get:function(){return this.socket.heartbeatCallback},set:function(e){this.socket.heartbeatCallback=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatTimer",{get:function(){return this.socket.heartbeatTimer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingHeartbeatRef",{get:function(){return this.socket.pendingHeartbeatRef},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reconnectTimer",{get:function(){return this.socket.reconnectTimer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vsn",{get:function(){return this.socket.vsn},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"encode",{get:function(){return this.socket.encode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"decode",{get:function(){return this.socket.decode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reconnectAfterMs",{get:function(){return this.socket.reconnectAfterMs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sendBuffer",{get:function(){return this.socket.sendBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stateChangeCallbacks",{get:function(){return this.socket.stateChangeCallbacks},enumerable:!1,configurable:!0}),e.prototype.connect=function(){this.socket.connect()},e.prototype.disconnect=function(e,t,n,r){var o=this;return void 0===r&&(r=1e4),new Promise(function(i){setTimeout(function(){return i("timeout")},r),o.socket.disconnect(function(){e(),i("ok")},t,n)})},e.prototype.push=function(e){this.socket.push(e)},e.prototype.log=function(e,t,n){this.socket.log(e,t,n)},e.prototype.hasLogger=function(){return this.socket.hasLogger()},e.prototype.makeRef=function(){return this.socket.makeRef()},e.prototype.onOpen=function(e){this.socket.onOpen(e)},e.prototype.onClose=function(e){this.socket.onClose(e)},e.prototype.onError=function(e){this.socket.onError(e)},e.prototype.onMessage=function(e){this.socket.onMessage(e)},e.prototype.isConnected=function(){return this.socket.isConnected()},e.prototype.isConnecting=function(){return this.socket.connectionState()==o.CONNECTION_STATE.connecting},e.prototype.isDisconnecting=function(){return this.socket.connectionState()==o.CONNECTION_STATE.closing},e.prototype.connectionState=function(){return this.socket.connectionState()},e.prototype.endPointURL=function(){return this.socket.endPointURL()},e.prototype.sendHeartbeat=function(){this.socket.sendHeartbeat()},e.prototype.getSocket=function(){return this.socket},e}();t.default=i},6511:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setRuntime=t.getRuntime=t.setWsClass=t.getWsClass=void 0;var n=null,r="web";t.getWsClass=function(){return n},t.setWsClass=function(e){n=e},t.getRuntime=function(){return r},t.setRuntime=function(e){r=e}},2917:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.ERR_CODE=t.CloudSDKError=t.isCancelledError=t.CancelledError=t.isTimeoutError=t.TimeoutError=t.isRealtimeErrorMessageError=t.RealtimeErrorMessageError=void 0;var o=function(e){function t(t){var n=e.call(this,"Watch Error ".concat(JSON.stringify(t.msgData)," (requestid: ").concat(t.requestId,")"))||this;return n.isRealtimeErrorMessageError=!0,n.payload=t,n}return r(t,e),t}(Error);t.RealtimeErrorMessageError=o,t.isRealtimeErrorMessageError=function(e){return null==e?void 0:e.isRealtimeErrorMessageError};var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="timeout",t.payload=null,t.generic=!0,t}return r(t,e),t}(Error);t.TimeoutError=i,t.isTimeoutError=function(e){return"timeout"===e.type};var s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="cancelled",t.payload=null,t.generic=!0,t}return r(t,e),t}(Error);t.CancelledError=s,t.isCancelledError=function(e){return"cancelled"===e.type};var a=function(e){function n(n){var r=e.call(this,n.errMsg)||this;return r.errCode="UNKNOWN_ERROR",Object.defineProperties(r,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(t.ERR_CODE[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e}}}),r.errCode=n.errCode||"UNKNOWN_ERROR",r.errMsg=n.errMsg,r}return r(n,e),Object.defineProperty(n.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),n}(Error);t.CloudSDKError=a,t.ERR_CODE={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"}},7209:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RealtimeWebSocketClient=t.registerRealtime=void 0;var r=n(2347);Object.defineProperty(t,"RealtimeWebSocketClient",{enumerable:!0,get:function(){return r.RealtimeWebSocketClient}});var o=n(6511),i={target:"database",entity:function(){var e=this.platform,t=e.adapter,n=e.runtime;(0,o.setWsClass)(t.wsClass),(0,o.setRuntime)(n)}},s={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=r.RealtimeWebSocketClient}};try{cloudbase.registerComponent(s),cloudbase.registerHook(i)}catch(e){}t.registerRealtime=function(e){try{e.registerComponent(s),e.registerHook(i)}catch(e){console.warn(e)}}},1601:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RealtimeListener=void 0;t.RealtimeListener=function(e){this.close=e.close,this.onChange=e.onChange,this.onError=e.onError,e.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return e.virtualClient}})}},3994:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInitEventMessage=t.genRequestId=void 0,t.genRequestId=function(e){return void 0===e&&(e=""),"".concat(e?"".concat(e,"_"):"").concat(+new Date,"_").concat(Math.random())},t.isInitEventMessage=function(e){return"INIT_EVENT"===e.msgType}},9770:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Snapshot=void 0;t.Snapshot=function(e){var t,n,r=e.id,o=e.docChanges,i=e.docs,s=e.msgType,a=e.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return t||(t=JSON.parse(JSON.stringify(o))),t},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})}},7589:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0,t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})}},4151:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VirtualWebSocketClient=void 0;var a,c=s(n(6765)),u=s(n(7195)),l=s(n(9850)),h=n(3994),d=n(1601),f=n(9770),p=n(2917),v=n(7589);!function(e){e.LOGGINGIN="LOGGINGIN",e.INITING="INITING",e.REBUILDING="REBUILDING",e.ACTIVE="ACTIVE",e.ERRORED="ERRORED",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.PAUSED="PAUSED",e.RESUMING="RESUMING"}(a||(a={}));var y=function(){function e(e){var t=this;this.watchStatus=a.INITING,this.wsLogin=function(e,n){return r(t,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return this.watchStatus=a.LOGGINGIN,[4,this.login(e,n)];case 1:return t=r.sent(),this.envId||(this.envId=t.envId),[2,t]}})})},this.initWatch=function(e){return r(t,void 0,Promise,function(){var t,n=this;return o(this,function(i){switch(i.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise(function(t,i){r(n,void 0,void 0,function(){var n,r,s,c,u,l,d,p,v,y;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.watchStatus===a.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:return n=o.sent().envId,this.watchStatus===a.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=a.INITING,r={watchId:this.watchId,requestId:(0,h.genRequestId)(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:r,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(s=o.sent(),c=s.msgData,u=c.events,l=c.currEvent,this.sessionInfo={queryID:s.msgData.queryID,currentEventId:l-1,currentDocs:[]},u.length>0){for(d=0,p=u;d<p.length;d++)p[d].ID=l;this.handleServerEvents(s)}else this.sessionInfo.currentEventId=l,v=new f.Snapshot({id:l,docChanges:[],docs:[],type:"init"}),this.listener.onChange(v),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=a.ACTIVE,this.availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return y=o.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:t,reject:i}),[3,4];case 4:return[2]}})})}),t=!1,i.label=1;case 1:return i.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return i.sent(),t=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(t?"success":"fail")),[2]}})})},this.rebuildWatch=function(e){return r(t,void 0,Promise,function(){var t,n=this;return o(this,function(i){switch(i.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise(function(t,i){r(n,void 0,void 0,function(){var n,r,s,c;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.watchStatus===a.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:if(n=o.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===a.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=a.REBUILDING,r={watchId:this.watchId,requestId:(0,h.genRequestId)(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:r,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return s=o.sent(),this.handleServerEvents(s),this.watchStatus=a.ACTIVE,this.availableRetries.REBUILD_WATCH=2,t(),[3,4];case 3:return c=o.sent(),this.handleWatchEstablishmentError(c,{operationName:"REBUILD_WATCH",resolve:t,reject:i}),[3,4];case 4:return[2]}})})}),t=!1,i.label=1;case 1:return i.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return i.sent(),t=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(t?"success":"fail")),[2]}})})},this.handleWatchEstablishmentError=function(e,n){return r(t,void 0,void 0,function(){var t,i,s,c=this;return o(this,function(u){return t="INIT_WATCH"===n.operationName,i=function(){c.closeWithError(new p.CloudSDKError({errCode:t?p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),n.reject(e)},s=function(e){c.useRetryTicket(n.operationName)?t?(c.initWatchPromise=void 0,n.resolve(c.initWatch(e))):(c.rebuildWatchPromise=void 0,n.resolve(c.rebuildWatch(e))):i()},this.handleCommonError(e,{onSignError:function(){return s(!0)},onTimeoutError:function(){return s(!1)},onNotRetryableError:i,onCancelledError:n.reject,onUnknownError:function(){r(c,void 0,void 0,function(){var e,t=this;return o(this,function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),e=function(){return r(t,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),s(!0),[2]}})})},this.isWSConnected()?[3,2]:[4,e()];case 1:return i.sent(),[3,7];case 2:return[4,(0,v.sleep)(100)];case 3:return i.sent(),this.watchStatus!==a.PAUSED?[3,4]:(n.reject(new p.CancelledError("".concat(n.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];case 5:return i.sent(),[3,7];case 6:s(!1),i.label=7;case 7:return[3,9];case 8:return i.sent(),s(!0),[3,9];case 9:return[2]}})})}}),[2]})})},this.closeWatch=function(){return r(t,void 0,void 0,function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==a.ACTIVE)return this.watchStatus=a.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=a.CLOSING,t={watchId:this.watchId,requestId:(0,h.genRequestId)(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=a.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,e),[7];case 5:return[2]}})})},this.scheduleSendACK=function(){t.clearACKSchedule(),t.ackTimeoutId=setTimeout(function(){t.waitExpectedTimeoutId?t.scheduleSendACK():t.sendACK()},1e4)},this.clearACKSchedule=function(){t.ackTimeoutId&&clearTimeout(t.ackTimeoutId)},this.sendACK=function(){return r(t,void 0,Promise,function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==a.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:(0,h.genRequestId)(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:e})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(t=r.sent(),(0,p.isRealtimeErrorMessageError)(t))switch((n=t.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}})})},this.handleCommonError=function(e,t){if((0,p.isRealtimeErrorMessageError)(e))switch(e.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void t.onSignError(e);default:return void t.onNotRetryableError(e)}else{if((0,p.isTimeoutError)(e))return void t.onTimeoutError(e);if((0,p.isCancelledError)(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=e.envId,this.collectionName=e.collectionName,this.query=e.query,this.limit=e.limit,this.orderBy=e.orderBy,this.send=e.send,this.login=e.login,this.isWSConnected=e.isWSConnected,this.onceWSConnected=e.onceWSConnected,this.getWaitExpectedTimeoutLength=e.getWaitExpectedTimeoutLength,this.onWatchStart=e.onWatchStart,this.onWatchClose=e.onWatchClose,this.debug=e.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new d.RealtimeListener({close:function(){t.closeWatch()},onChange:e.onChange,onError:e.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return e.prototype.onMessage=function(e){var t=this;switch(this.watchStatus){case a.PAUSED:if("ERROR"!==e.msgType)return;break;case a.LOGGINGIN:case a.INITING:case a.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while ".concat(this.watchStatus));case a.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case a.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),e.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(e.msgData.currEvent," ignored"),e),this.handleServerEvents(e);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<e.msgData.currEvent&&(this.sessionInfo.expectEventId=e.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout(function(){t.rebuildWatch()},this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength ".concat(this.getWaitExpectedTimeoutLength())));break;case"ERROR":this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:"".concat(e.msgData.code," - ").concat(e.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(e.msgType,": "),e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){var t;this.watchStatus=a.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,(null===(t=this.sessionInfo)||void 0===t?void 0:t.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.pause=function(){this.watchStatus=a.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.resume=function(){return r(this,void 0,Promise,function(){var e;return o(this,function(t){switch(t.label){case 0:this.watchStatus=a.RESUMING,console.log("[realtime] client resuming with ".concat(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH"," (").concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return t.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),e),[3,4];case 4:return[2]}})})},e.prototype.useRetryTicket=function(e){return!!(this.availableRetries[e]&&this.availableRetries[e]>0)&&(this.availableRetries[e]-=1,console.log("[realtime] ".concat(e," use a retry ticket, now only ").concat(this.availableRetries[e]," retry left")),!0)},e.prototype.handleServerEvents=function(e){return r(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(e)];case 1:return n.sent(),this.postHandleServerEventsValidityCheck(e),[3,3];case 2:throw t=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",t),t;case 3:return[2]}})})},e.prototype.handleServerEventsInternel=function(e){return r(this,void 0,void 0,function(){var t,n,r,s,a,h,d,v,y,m,b,_;return o(this,function(E){switch(E.label){case 0:if(t=e.requestId,n=e.msgData.events,r=e.msgType,!n.length||!this.sessionInfo)return[2];s=this.sessionInfo;try{a=n.map(g)}catch(e){return this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}h=i([],s.currentDocs,!0),d=!1,v=function(n,v){var g,m,b,_,E,w,S,I,O,A,T,P;return o(this,function(o){switch(o.label){case 0:return g=a[n],s.currentEventId>=g.id?(!a[n-1]||g.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur ".concat(s.currentEventId," but got ").concat(g.id)):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId ".concat(t,")")),[2,"continue"]):[3,1];case 1:if(s.currentEventId!==g.id-1)return[3,2];switch(g.dataType){case"update":if(!g.doc)switch(g.queueType){case"update":case"dequeue":if(m=h.find(function(e){return e._id===g.docId}),m){if(b=(0,l.default)(m),g.updatedFields&&Object.keys(g.updatedFields).forEach(function(e){(0,c.default)(b,e,g.updatedFields[e])}),g.removedFields)for(_=0,E=g.removedFields;_<E.length;_++)w=E[_],(0,u.default)(b,w);g.doc=b}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw I=new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '.concat(e.requestId,")")}),y.closeWithError(I),I}break;case"replace":if(!g.doc)throw I=new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '.concat(e.requestId,")")}),y.closeWithError(I),I;break;case"remove":(S=h.find(function(e){return e._id===g.docId}))?g.doc=S:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!g.doc)switch(g.queueType){case"dequeue":(S=h.find(function(e){return e._id===g.docId}))?g.doc=S:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw I=new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '.concat(e.requestId,")")}),y.closeWithError(I),I}}switch(g.queueType){case"init":d?h.push(g.doc):(d=!0,h=[g.doc]);break;case"enqueue":h.push(g.doc);break;case"dequeue":O=h.findIndex(function(e){return e._id===g.docId}),O>-1?h.splice(O,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":O=h.findIndex(function(e){return e._id===g.docId}),O>-1?h[O]=g.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===v-1||a[n+1]&&a[n+1].id!==g.id)&&(A=i([],h,!0),T=a.slice(0,n+1).filter(function(e){return e.id===g.id}),y.sessionInfo.currentEventId=g.id,y.sessionInfo.currentDocs=h,P=new f.Snapshot({id:g.id,docChanges:T,docs:A,msgType:r}),y.listener.onChange(P)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(y.sessionInfo.currentEventId," but got ").concat(g.id)),[4,y.rebuildWatch()];case 3:return o.sent(),[2,{value:void 0}];case 4:return[2]}})},y=this,m=0,b=a.length,E.label=1;case 1:return m<b?[5,v(m,b)]:[3,4];case 2:if("object"==typeof(_=E.sent()))return[2,_.value];E.label=3;case 3:return m++,[3,1];case 4:return[2]}})})},e.prototype.postHandleServerEventsValidityCheck=function(e){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<e.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},e.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},e}();function g(e){var t={id:e.ID,dataType:e.DataType,queueType:e.QueueType,docId:e.DocID,doc:e.Doc&&"{}"!==e.Doc?JSON.parse(e.Doc):void 0};return"update"===e.DataType&&(e.UpdatedFields&&(t.updatedFields=JSON.parse(e.UpdatedFields)),(e.removedFields||e.RemovedFields)&&(t.removedFields=JSON.parse(e.removedFields))),t}t.VirtualWebSocketClient=y},2347:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.RealtimeWebSocketClient=void 0;var s=n(4151),a=n(3994),c=n(636),u=n(2917),l=n(6511),h=n(7589),d=function(){function e(e){var t=this;this.virtualWSClient=new Set,this.queryIdClientMap=new Map,this.watchIdClientMap=new Map,this.pingFailed=0,this.pongMissed=0,this.logins=new Map,this.wsReadySubsribers=[],this.wsResponseWait=new Map,this.rttObserved=[],this.send=function(e){return o(t,void 0,Promise,function(){var t=this;return i(this,function(n){return[2,new Promise(function(n,r){o(t,void 0,void 0,function(){var t,s,a,c,l,d,f,p,v=this;return i(this,function(y){switch(y.label){case 0:s=!1,a=!1,c=function(e){s=!0,t&&clearTimeout(t),n(e)},l=function(e){a=!0,t&&clearTimeout(t),r(e)},e.timeout&&(t=setTimeout(function(){o(v,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return s&&a?[3,2]:[4,(0,h.sleep)(0)];case 1:e.sent(),s&&a||l(new u.TimeoutError("wsclient.send timedout")),e.label=2;case 2:return[2]}})})},e.timeout)),y.label=1;case 1:return y.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:y.sent(),y.label=3;case 3:if(!this.ws)return l(new Error("invalid state: ws connection not exists, can not send message")),[2];if(1!==this.ws.readyState)return l(new Error("ws readyState invalid: ".concat(this.ws.readyState,", can not send message"))),[2];e.waitResponse&&(d={resolve:c,reject:l,skipOnMessage:e.skipOnMessage},this.wsResponseWait.set(e.msg.requestId,d)),y.label=4;case 4:return y.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(e.msg))];case 5:return y.sent(),e.waitResponse||c(void 0),[3,7];case 6:return(f=y.sent())&&(l(f),e.waitResponse&&this.wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return p=y.sent(),l(p),[3,9];case 9:return[2]}})})})]})})},this.closeAllClients=function(e){t.virtualWSClient.forEach(function(t){t.closeWithError(e)})},this.pauseClients=function(e){(e||t.virtualWSClient).forEach(function(e){e.pause()})},this.resumeClients=function(e){(e||t.virtualWSClient).forEach(function(e){e.resume()})},this.initWebSocketConnection=function(e,n){return void 0===n&&(n=t.maxReconnect),o(t,void 0,Promise,function(){var t=this;return i(this,function(r){switch(r.label){case 0:if(e&&this.reconnectState)return[2];if(e&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];e&&this.pauseClients(),this.close(c.CloseEventCode.ReconnectWebSocket),this.wsInitPromise=new Promise(function(r,s){o(t,void 0,void 0,function(){var t,o,a=this;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=i.sent(),[4,new Promise(function(e){var n=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=(0,l.getWsClass)();a.ws=r?new r(n):new WebSocket(n),e(void 0)})];case 2:return i.sent(),this.ws.connect?[4,this.ws.connect()]:[3,4];case 3:i.sent(),i.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return i.sent(),r(),e&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return o=i.sent(),console.error("[realtime] initWebSocketConnection connect fail",o),n>0?(this.wsInitPromise=void 0,[4,(0,h.sleep)(this.reconnectInterval)]):[3,9];case 7:i.sent(),e&&(this.reconnectState=!1),i.label=8;case 8:return r(this.initWebSocketConnection(e,n-1)),[3,10];case 9:s(o),e&&this.closeAllClients(new u.CloudSDKError({errCode:u.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:o})),i.label=10;case 10:return[3,11];case 11:return[2]}})})}),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return r.sent(),this.wsReadySubsribers.forEach(function(e){return(0,e.resolve)()}),[3,5];case 3:return r.sent(),this.wsReadySubsribers.forEach(function(e){return(0,e.reject)()}),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}})})},this.initWebSocketEvent=function(){return new Promise(function(e,n){if(!t.ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;t.ws.onopen=function(t){console.warn("[realtime] ws event: open",t),r=!0,e()},t.ws.onerror=function(e){t.logins=new Map,r?(console.error("[realtime] ws event: error",e),t.clearHeartbeat(),t.virtualWSClient.forEach(function(t){return t.closeWithError(new u.CloudSDKError({errCode:u.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:e}))})):(console.error("[realtime] ws open failed with ws event: error",e),n(e))},t.ws.onclose=function(e){switch(console.warn("[realtime] ws event: close",e),t.logins=new Map,t.clearHeartbeat(),e.code){case c.CloseEventCode.ReconnectWebSocket:case c.CloseEventCode.NoRealtimeListeners:break;case c.CloseEventCode.HeartbeatPingError:case c.CloseEventCode.HeartbeatPongTimeoutError:case c.CloseEventCode.NormalClosure:case c.CloseEventCode.AbnormalClosure:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients((0,c.getWSCloseError)(e.code));break;case c.CloseEventCode.NoAuthentication:t.closeAllClients((0,c.getWSCloseError)(e.code,e.reason));break;default:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients((0,c.getWSCloseError)(e.code))}},t.ws.onmessage=function(e){var n,r,o=(null===(n=e.data)||void 0===n?void 0:n.data)||e.data;t.heartbeat();try{r="string"==typeof o?JSON.parse(o):o}catch(e){throw new Error("[realtime] onMessage parse res.data error: ".concat(e))}if("ERROR"===r.msgType){var i=null;t.virtualWSClient.forEach(function(e){e.watchId===r.watchId&&(i=e)}),i&&i.listener.onError(r)}var s=t.wsResponseWait.get(r.requestId);if(s){try{"ERROR"===r.msgType?s.reject(new u.RealtimeErrorMessageError(r)):s.resolve(r)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t.wsResponseWait.delete(r.requestId)}if(s.skipOnMessage)return}if("PONG"!==r.msgType){var a=r.watchId&&t.watchIdClientMap.get(r.watchId);if(a)a.onMessage(r);else switch(console.error("[realtime] no realtime listener found responsible for watchId ".concat(r.watchId,": "),r),r.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(a=t.queryIdClientMap.get(r.msgData.queryID))&&a.onMessage(r);break;default:for(var c=0,l=Array.from(t.watchIdClientMap.entries());c<l.length;c++){l[c][1].onMessage(r);break}}}else if(t.lastPingSendTS){var h=Date.now()-t.lastPingSendTS;if(h>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(h));t.rttObserved.length>=3&&t.rttObserved.splice(0,t.rttObserved.length-3+1),t.rttObserved.push(h)}},t.heartbeat()})},this.isWSConnected=function(){return Boolean(t.ws&&1===t.ws.readyState)},this.onceWSConnected=function(){return o(t,void 0,Promise,function(){var e=this;return i(this,function(t){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise(function(t,n){e.wsReadySubsribers.push({resolve:t,reject:n})})]})})},this.webLogin=function(e,n){return o(t,void 0,Promise,function(){var t,r,s,c,u,h,d,f,p=this;return i(this,function(v){switch(v.label){case 0:if(!n)if(e){if(t=this.logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(null!==t.loggingInPromise&&void 0!==t.loggingInPromise)return[2,t.loggingInPromise]}}else if(null!==(null==(r=this.logins.get(""))?void 0:r.loggingInPromise)&&void 0!==(null==r?void 0:r.loggingInPromise))return[2,r.loggingInPromise];s=new Promise(function(e,t){o(p,void 0,void 0,function(){var n,r,o,s,c;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=i.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:(0,a.genRequestId)(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:(0,l.getRuntime)(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(s=i.sent()).msgData.code?t(new Error("".concat(s.msgData.code," ").concat(s.msgData.message))):e({envId:n.envId}),[3,4];case 3:return c=i.sent(),t(c),[3,4];case 4:return[2]}})})}),c=e&&this.logins.get(e),u=Date.now(),c?(c.loggedIn=!1,c.loggingInPromise=s,c.loginStartTS=u):(c={loggedIn:!1,loggingInPromise:s,loginStartTS:u},this.logins.set(e||"",c)),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,s];case 2:if(h=v.sent(),(d=e&&this.logins.get(e))&&d===c&&d.loginStartTS===u)return c.loggedIn=!0,c.loggingInPromise=void 0,c.loginStartTS=void 0,c.loginResult=h,[2,h];if(d){if(d.loggedIn&&d.loginResult)return[2,d.loginResult];if(null!==d.loggingInPromise&&void 0!==d.loggingInPromise)return[2,d.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=v.sent(),c.loggedIn=!1,c.loggingInPromise=void 0,c.loginStartTS=void 0,c.loginResult=void 0,f;case 4:return[2]}})})},this.getWsSign=function(){return o(t,void 0,Promise,function(){var e,t,n,r,o,s,a;return i(this,function(i){switch(i.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(e=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:(0,l.getRuntime)()})]);case 1:if((t=i.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(t.code));if(t.data)return n=t.data,r=n.signStr,o=n.wsUrl,s=n.secretVersion,a=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:s,envId:a,expiredTs:e}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}})})},this.getWaitExpectedTimeoutLength=function(){return t.rttObserved.length?t.rttObserved.reduce(function(e,t){return e+t})/t.rttObserved.length*1.5:5e3},this.ping=function(){return o(t,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:(0,a.genRequestId)(),msgType:"PING",msgData:null},[4,this.send({msg:e})];case 1:return t.sent(),[2]}})})},this.onWatchStart=function(e,n){t.queryIdClientMap.set(n,e)},this.onWatchClose=function(e,n){n&&t.queryIdClientMap.delete(n),t.watchIdClientMap.delete(e.watchId),t.virtualWSClient.delete(e),t.virtualWSClient.size||t.close(c.CloseEventCode.NoRealtimeListeners)},this.maxReconnect=e.maxReconnect||5,this.reconnectInterval=e.reconnectInterval||1e4,this.context=e.context}return e.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},e.prototype.close=function(e){this.clearHeartbeat(),this.ws&&(this.ws.close(e,c.CLOSE_EVENT_CODE_INFO[e].name),this.ws=void 0)},e.prototype.watch=function(e){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var t=new s.VirtualWebSocketClient(r(r({},e),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this.virtualWSClient.add(t),this.watchIdClientMap.set(t.watchId,t),t.listener},e.prototype.heartbeat=function(e){var t=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout(function(){o(t,void 0,void 0,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.ws&&1===this.ws.readyState?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return t.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout(function(){console.error("pong timed out"),e.pongMissed<2?(e.pongMissed+=1,e.heartbeat(!0)):e.initWebSocketConnection(!0)},this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(c.CloseEventCode.HeartbeatPingError),[3,3];case 3:return[2]}})})},e?0:this.context.appConfig.realtimePingInterval)},e}();t.RealtimeWebSocketClient=d},636:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWSCloseError=t.CloseEventCode=t.CLOSE_EVENT_CODE_INFO=void 0;var r,o=n(2917);t.CLOSE_EVENT_CODE_INFO={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}},(r=t.CloseEventCode||(t.CloseEventCode={}))[r.NormalClosure=1e3]="NormalClosure",r[r.GoingAway=1001]="GoingAway",r[r.ProtocolError=1002]="ProtocolError",r[r.UnsupportedData=1003]="UnsupportedData",r[r.NoStatusReceived=1005]="NoStatusReceived",r[r.AbnormalClosure=1006]="AbnormalClosure",r[r.InvalidFramePayloadData=1007]="InvalidFramePayloadData",r[r.PolicyViolation=1008]="PolicyViolation",r[r.MessageTooBig=1009]="MessageTooBig",r[r.MissingExtension=1010]="MissingExtension",r[r.InternalError=1011]="InternalError",r[r.ServiceRestart=1012]="ServiceRestart",r[r.TryAgainLater=1013]="TryAgainLater",r[r.BadGateway=1014]="BadGateway",r[r.TLSHandshake=1015]="TLSHandshake",r[r.ReconnectWebSocket=3e3]="ReconnectWebSocket",r[r.NoRealtimeListeners=3001]="NoRealtimeListeners",r[r.HeartbeatPingError=3002]="HeartbeatPingError",r[r.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",r[r.NoAuthentication=3050]="NoAuthentication",t.getWSCloseError=function(e,n){var r=t.CLOSE_EVENT_CODE_INFO[e],i=r?"".concat(r.name,", code ").concat(e,", reason ").concat(n||r.description):"code ".concat(e);return new o.CloudSDKError({errCode:o.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:i})}},5891:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseStorage=t.isValidTempUrlMaxAge=t.TEMP_URL_MAX_AGE_MAX=t.TEMP_URL_MAX_AGE_MIN=t.COMPONENT_NAME=t.EUploadMethod=void 0;var c,u=n(2877),l=n(7090),h=n(3388);!function(e){e.put="put",e.post="post"}(c=t.EUploadMethod||(t.EUploadMethod={}));var d=u.constants.getSdkName,f=u.constants.ERRORS,p=u.constants.COMMUNITY_SITE_URL,v=u.utils.isArray,y=u.utils.isString,g=u.utils.isPalinObject,m=u.utils.execCallback,b=u.utils.maybeThrow,_=u.utils.printWarn,E=u.helpers.catchErrorsDecorator;function w(e,t){return t&&"function"!=typeof t?[r(r({},e),{customReqOpts:t}),void 0]:[e,t]}t.COMPONENT_NAME="storage";var S=function(e,t,n){return s(void 0,void 0,void 0,function(){var o,i,s;return a(this,function(a){switch(a.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-upload-info",data:[r({objectId:t.path},t.signedHeader?{signedHeader:t.signedHeader}:{})]},n)];case 1:return o=a.sent(),o=u.utils.promoteGatewayError(o),i=(null===(s=o.data)||void 0===s?void 0:s[0])||{},[2,r(r({},o),{data:r(r({},i.code?r({},i):{}),{authorization:i.authorization,token:i.token,url:i.uploadUrl,fileId:i.cloudObjectId,cosFileId:i.cloudObjectMeta,download_url:i.downloadUrl})})]}})})},I=function(e,t,n){return s(void 0,void 0,void 0,function(){var o;return a(this,function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-download-info",data:t.convertedFileList.map(function(e){return r({cloudObjectId:e.fileid},null!=e.max_age?{maxAge:e.max_age}:{})})},n)];case 1:return o=i.sent(),o=u.utils.promoteGatewayError(o),[2,r(r({},o),{data:{download_list:Array.isArray(o.data)?o.data.map(function(e){return{code:e.code||"SUCCESS",message:e.message,fileid:e.cloudObjectId,download_url:e.downloadUrl,fileID:e.cloudObjectId,tempFileURL:e.downloadUrl,mime_type:e.contentType||P(null,e.cloudObjectId||"")}}):[]}})]}})})},O=function(e,t,n){return s(void 0,void 0,void 0,function(){var o;return a(this,function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"delete-objects",data:t.fileList.map(function(e){return{cloudObjectId:e}})},n)];case 1:return o=i.sent(),o=u.utils.promoteGatewayError(o),[2,r(r({},o),{data:{delete_list:Array.isArray(o.data)?o.data.map(function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,message:e.message}}):[]}})]}})})},A=function(e,t,n){return s(void 0,void 0,void 0,function(){var o;return a(this,function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"copy-objects",data:t.convertedFileList.map(function(e){return{srcPath:e.src_path,dstPath:e.dst_path,overwrite:e.overwrite,removeOriginal:e.remove_original}})},n)];case 1:return o=i.sent(),o=u.utils.promoteGatewayError(o),[2,r(r({},o),{data:{copy_list:Array.isArray(o.data)?o.data.map(function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,fileId:e.cloudObjectId,message:e.message}}):[]}})]}})})},T={txt:"text/plain",json:"application/json",html:"text/html",htm:"text/html",css:"text/css",js:"application/javascript",csv:"text/csv",xml:"application/xml",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",pdf:"application/pdf",zip:"application/zip",gz:"application/gzip",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav"};function P(e,t){if("undefined"!=typeof Blob&&e instanceof Blob&&e.type)return e.type;var n=/\.([a-zA-Z0-9]+)$/.exec(t||""),r=n?n[1].toLowerCase():"";return T[r]||"application/octet-stream"}function C(){var e=globalThis.wx;return"function"==typeof(null==e?void 0:e.getFileSystemManager)}function R(e,t){var n=t.toLowerCase();return Object.keys(e).some(function(e){return e.toLowerCase()===n})}function N(e){return Object.keys(e).reduce(function(t,n){var o;return r(r({},t),((o={})[n]=[e[n]],o))},{})}function k(e){return"number"==typeof e&&Number.isInteger(e)&&e>=t.TEMP_URL_MAX_AGE_MIN}t.TEMP_URL_MAX_AGE_MIN=1,t.TEMP_URL_MAX_AGE_MAX=3600,t.isValidTempUrlMaxAge=k,t.CloudbaseStorage=function(){function e(e){this.context=e}var n,u,T,U,D,L,j,x,M,q,F,B,W,H,G,V,K;return Object.defineProperty(e.prototype,"config",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.request},enumerable:!1,configurable:!0}),e.prototype.isGateWay=function(){return"GATEWAY"===(this.config.endPointMode||"CLOUD_API")},e.prototype.uploadFile=function(e,n){var o,i;return s(this,void 0,Promise,function(){var s,u,h,p,v,g,_,E,S,I,O,A,T,k,U,D,L,j,x,M,q,F,B,W,H,G,V,K,J,Y,z,$,Q,X;return a(this,function(a){switch(a.label){case 0:if(z=w(e,n),e=z[0],n=z[1],s=e.cloudPath,u=e.filePath,h=e.onUploadProgress,$=e.method,p=void 0===$?"put":$,Q=e.headers,v=void 0===Q?{}:Q,g=e.fileContent,!y(s)||!u&&!g)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".uploadFile] invalid params")})];if(u&&g&&console.warn("[".concat(d(),"][").concat(t.COMPONENT_NAME,".uploadFile] fileContent 是兼容字段,与 filePath 同时传入时忽略,实际使用 filePath")),_=null!=u?u:g,(E={put:c.put,post:c.post}[p.toLocaleLowerCase()]||c.put)===c.post&&console.warn("[".concat(d(),"][").concat(t.COMPONENT_NAME,".uploadFile] method: 'post' 已废弃,请改用 'put'")),S=this.isGateWay(),I=r({},v),O=Object.keys(v).reduce(function(e,t){return"content-length"!==t.toLowerCase()&&(e[t]=v[t]),e},{}),E===c.put&&S){if(!R(I,"content-length")){if(A=null===(i=null===(o=this.request)||void 0===o?void 0:o.getUploadByteLength)||void 0===i?void 0:i.call(o,_),T="number"==typeof A?A:function(e){if((!C()||"string"!=typeof e)&&null!==e){if("undefined"!=typeof Blob&&e instanceof Blob)return e.size;if("undefined"!=typeof ArrayBuffer){if(e instanceof ArrayBuffer)return e.byteLength;if("function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e))return e.byteLength}if("string"==typeof e){if("undefined"!=typeof Blob)return new Blob([e]).size;var t=(0,l.getStringByteLength)(e);return"number"==typeof t?t:e.length}return"object"==typeof e&&"number"==typeof e.size?e.size:void 0}}(_),"number"!=typeof T)return[2,b(this.config,{code:f.INVALID_PARAMS,message:C()?"[".concat(t.COMPONENT_NAME,".uploadFile] 无法计算 content-length,请确认上传内容为有效的本地临时路径,或传入 ArrayBuffer"):"[".concat(t.COMPONENT_NAME,".uploadFile] 无法计算 content-length,请传入 File/Blob/Buffer/ArrayBuffer,或在 headers 中提供 content-length")})];I["content-length"]=String(T)}R(I,"content-type")||(I["content-type"]=P(_,s)),R(O,"content-type")||(O["content-type"]=P(_,s))}return[4,this.getUploadMetadata({cloudPath:s,method:E,headers:E!==c.put||S?void 0:O,signedHeader:E===c.put&&S?N(I):void 0,customReqOpts:e.customReqOpts})];case 1:return k=a.sent(),U=k.data,D=k.requestId,(null==(L=U)?void 0:L.code)||!(null==L?void 0:L.url)?(j=(null==L?void 0:L.code)||f.OPERATION_FAIL,x=(null==L?void 0:L.message)||"get upload info failed",[2,m(n,new Error("[".concat(d(),"][").concat(j,"][").concat(t.COMPONENT_NAME,"]:").concat(x)))]):(M=U.url,q=U.authorization,F=U.token,B=U.fileId,W=U.cosFileId,H=U.download_url,V=r(r({},G={url:M,file:_,name:s,onUploadProgress:h,fileId:B,requestId:D}),{method:c.put,headers:r(r({},O),{authorization:q,"x-cos-meta-fileid":W,"x-cos-security-token":F})}),K=r(r({},G),{method:c.post,data:{key:s,signature:q,"x-cos-meta-fileid":W,success_action_status:"201","x-cos-security-token":F}}),(X={})[c.put]={params:V,isSuccess:function(e){return e>=200&&e<300}},X[c.post]={params:K,isSuccess:function(e){return 201===e}},J=X,[4,this.request.upload(J[E].params)]);case 2:return Y=a.sent(),J[E].isSuccess(Y.statusCode)?[2,m(n,null,{fileID:B,download_url:H,requestId:D})]:[2,m(n,new Error("[".concat(d(),"][").concat(f.OPERATION_FAIL,"][").concat(t.COMPONENT_NAME,"]:").concat(Y.data)))]}})})},e.prototype.getUploadMetadata=function(e,n){return s(this,void 0,Promise,function(){var r,o,i,s,u,l,h,d,p,v;return a(this,function(a){switch(a.label){case 0:if(r=e.cloudPath,o=e.method,i=e.headers,s=e.signedHeader,!y(r))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getUploadMetadata] invalid cloudPath")})];u=this.request,l="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,6,,7]),h=void 0,d={path:r},p=this.isGateWay(),o&&(d.method=o),o===c.put&&(p&&s?d.signedHeader=s:!p&&i&&(d.headers=i)),o!==c.post&&p?[3,3]:[4,u.send(l,d,{endPointMode:"CLOUD_API"},e.customReqOpts)];case 2:return h=a.sent(),[3,5];case 3:return[4,S(u,d,e.customReqOpts)];case 4:h=a.sent(),a.label=5;case 5:return[2,m(n,null,h)];case 6:return v=a.sent(),[2,m(n,v)];case 7:return[2]}})})},e.prototype.deleteFile=function(e,n){return s(this,void 0,Promise,function(){var r,o,i,s,c,u,l,h,d;return a(this,function(a){switch(a.label){case 0:if(d=w(e,n),e=d[0],n=d[1],!(r=e.fileList)||!v(r)||0===r.length)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".deleteFile] fileList must not be empty")})];for(o=0,i=r;o<i.length;o++)if(!(s=i[o])||!y(s))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".deleteFile] fileID must be string")})];return c="storage.batchDeleteFile",u=this.request,l={},this.isGateWay()?[4,O(u,{fileList:r},e.customReqOpts)]:[3,2];case 1:return l=a.sent(),[3,4];case 2:return[4,u.send(c,{fileid_list:r},e.customReqOpts)];case 3:l=a.sent(),a.label=4;case 4:return l.code?[2,m(n,null,l)]:(h={fileList:l.data.delete_list,requestId:l.requestId},[2,m(n,null,h)])}})})},e.prototype.getTempFileURL=function(e,n){var r;return s(this,void 0,Promise,function(){var o,i,s,c,u,l,h,d,p,E,S,O;return a(this,function(a){switch(a.label){case 0:if(O=w(e,n),e=O[0],n=O[1],!(o=e.fileList)||!v(o)||0===o.length)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] fileList must not be empty")})];for(i=[],s=!1,c=0,u=o;c<u.length;c++)if(l=u[c],g(l)){if(!Object.prototype.hasOwnProperty.call(l,"fileID"))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] file info must include fileID")})];if(h={fileid:l.fileID},Object.prototype.hasOwnProperty.call(l,"maxAge")){if(!k(d=l.maxAge))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] maxAge must be an integer greater than or equal to ").concat(t.TEMP_URL_MAX_AGE_MIN)})];d>t.TEMP_URL_MAX_AGE_MAX&&!s&&(_(f.INVALID_PARAMS,"[".concat(t.COMPONENT_NAME,".getTempFileURL] maxAge ").concat(d," 大于 ").concat(t.TEMP_URL_MAX_AGE_MAX,",仍按原值下发")),s=!0),h.max_age=d}i.push(h)}else{if(!y(l))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] invalid fileList")})];i.push({fileid:l})}return p="storage.batchGetDownloadUrl",E=this.request,S={},this.isGateWay()?[4,I(E,{convertedFileList:i},e.customReqOpts)]:[3,2];case 1:return S=a.sent(),[3,4];case 2:return[4,E.send(p,{file_list:i},e.customReqOpts)];case 3:S=a.sent(),a.label=4;case 4:return S.code?[2,m(n,null,S)]:[2,m(n,null,{fileList:Array.isArray(null===(r=S.data)||void 0===r?void 0:r.download_list)?S.data.download_list:[],requestId:S.requestId})]}})})},e.prototype.downloadFile=function(e,n){return s(this,void 0,Promise,function(){var r,o,i,s,c,u,l;return a(this,function(a){switch(a.label){case 0:return l=w(e,n),e=l[0],n=l[1],r=e.fileID,y(r)?[4,this.getTempFileURL.call(this,{fileList:[{fileID:r,maxAge:600}],customReqOpts:e.customReqOpts})]:[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] fileID must be string")})];case 1:return o=a.sent(),"SUCCESS"!==(i=o.fileList[0]).code?[2,m(n,i)]:(s=this.request,c=encodeURI(i.download_url),[4,s.download({url:c,tempFilePath:e.tempFilePath})]);case 2:return u=a.sent(),[2,m(n,null,u)]}})})},e.prototype.copyFile=function(e,n){return s(this,void 0,Promise,function(){var r,o,i,s,c,u,l,h,d,p;return a(this,function(a){switch(a.label){case 0:if(p=w(e,n),e=p[0],n=p[1],!(r=e.fileList)||!v(r)||0===r.length)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".copyFile] fileList must not be empty")})];for(o=[],i=0,s=r;i<s.length;i++){if(c=s[i],u=c.srcPath,l=c.dstPath,!u||!l||"string"!=typeof u||"string"!=typeof l)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".copyFile] srcPath and dstPath may not be empty")})];if(u===l)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".copyFile] srcPath and dstPath can not be the same")})];o.push({src_path:u,dst_path:l,overwrite:c.overwrite,remove_original:c.removeOriginal})}return h=this.request,d={},this.isGateWay()?[4,A(h,{convertedFileList:o},e.customReqOpts)]:[3,2];case 1:return d=a.sent(),[3,4];case 2:return[4,h.send("storage.batchCopyFile",{file_list:o},e.customReqOpts)];case 3:d=a.sent(),a.label=4;case 4:return d.code?[2,m(n,null,d)]:[2,m(n,null,{fileList:d.data.copy_list,requestId:d.requestId})]}})})},e.prototype.getFileInfo=function(e){var t;return s(this,void 0,Promise,function(){var n,r=this;return a(this,function(o){switch(o.label){case 0:return[4,this.getTempFileURL(e)];case 1:return(null==(n=o.sent())?void 0:n.fileList)&&(null===(t=null==n?void 0:n.fileList)||void 0===t?void 0:t.length)>0?[4,Promise.all(n.fileList.map(function(e){return s(r,void 0,void 0,function(){var t,n,r,o,i,s,c;return a(this,function(a){switch(a.label){case 0:if("SUCCESS"!==e.code)return[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,message:e.message}];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.request.fetch({url:e.tempFileURL,method:"HEAD"})];case 2:return t=a.sent(),n=t.header,"undefined"!=typeof Headers&&n instanceof Headers&&(r={},n.forEach(function(e,t){r[t]=e}),n=r),o=parseInt(n["content-length"])||0,i=n["content-type"]||"",[400,404].includes(Number(t.statusCode))?[2,{code:"FILE_NOT_FOUND",fileID:e.fileID,tempFileURL:e.tempFileURL,message:"file not found"}]:[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,cloudId:e.fileID,fileName:e.fileID.split("/").pop(),contentType:i,mime:i.split(";")[0].trim(),size:o,etag:n.etag||"",lastModified:n["last-modified"]||"",cacheControl:n["cache-control"]||""}];case 3:return s=a.sent(),c="object"==typeof s&&null!==s&&"message"in s?String(s.message):void 0,[2,{code:"FETCH_FILE_INFO_ERROR",fileID:e.fileID,tempFileURL:e.tempFileURL,message:c}];case 4:return[2]}})})}))]:[3,3];case 2:return[2,{fileList:o.sent(),requestId:n.requestId}];case 3:return[2,{fileList:[],requestId:n.requestId}]}})})},o([E({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(n=void 0!==h.ICloudbaseUploadFileParams&&h.ICloudbaseUploadFileParams)?n:Object,"function"==typeof(u="undefined"!=typeof Function&&Function)?u:Object]),i("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],e.prototype,"uploadFile",null),o([E({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",[Object,"function"==typeof(U="undefined"!=typeof Function&&Function)?U:Object]),i("design:returntype","function"==typeof(D="undefined"!=typeof Promise&&Promise)?D:Object)],e.prototype,"getUploadMetadata",null),o([E({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(L=void 0!==h.ICloudbaseDeleteFileParams&&h.ICloudbaseDeleteFileParams)?L:Object,"function"==typeof(j="undefined"!=typeof Function&&Function)?j:Object]),i("design:returntype","function"==typeof(x="undefined"!=typeof Promise&&Promise)?x:Object)],e.prototype,"deleteFile",null),o([E({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(M=void 0!==h.ICloudbaseGetTempFileURLParams&&h.ICloudbaseGetTempFileURLParams)?M:Object,"function"==typeof(q="undefined"!=typeof Function&&Function)?q:Object]),i("design:returntype","function"==typeof(F="undefined"!=typeof Promise&&Promise)?F:Object)],e.prototype,"getTempFileURL",null),o([E({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(B=void 0!==h.ICloudbaseDownloadFileParams&&h.ICloudbaseDownloadFileParams)?B:Object,"function"==typeof(W="undefined"!=typeof Function&&Function)?W:Object]),i("design:returntype","function"==typeof(H="undefined"!=typeof Promise&&Promise)?H:Object)],e.prototype,"downloadFile",null),o([E({customInfo:{className:"Cloudbase",methodName:"copyFile"},title:"批量复制文件",messages:["请确认以下各项:"," 1 - 调用 copyFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(G=void 0!==h.ICloudbaseCopyFileParams&&h.ICloudbaseCopyFileParams)?G:Object,"function"==typeof(V="undefined"!=typeof Function&&Function)?V:Object]),i("design:returntype","function"==typeof(K="undefined"!=typeof Promise&&Promise)?K:Object)],e.prototype,"copyFile",null),e}()},9656:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DownloadBuilder=t.StreamDownloadBuilder=void 0;var s=n(7957),a=n(7090);function c(e){return(0,s.isStorageError)(e)?e:new s.StorageError((null==e?void 0:e.message)||String(e))}function u(e){var t={};return void 0!==(null==e?void 0:e.download)&&(t.download=!0===e.download?"":e.download),void 0!==(null==e?void 0:e.cacheNonce)&&(t.cacheNonce=String(e.cacheNonce)),{headers:{},query:t}}var l=function(){function e(e){this.ctx=e}return e.prototype.then=function(e,t){return this.execute().then(e,t)},e.prototype.execute=function(){var e,t;return o(this,void 0,Promise,function(){var n,o,l,h,d;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=u(this.ctx.options),o=n.headers,l=n.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,a.encodeObjectName)(this.ctx.cleanName)),headers:r(r({},this.ctx.headers),o),query:l,signal:null===(e=this.ctx.parameters)||void 0===e?void 0:e.signal,cache:null===(t=this.ctx.parameters)||void 0===t?void 0:t.cache})];case 1:if(!(h=i.sent().response).body)throw new s.StorageApiError("Response body is empty",h.status,"STORAGE_PG_EMPTY_BODY");return[2,{data:h.body,error:null}];case 2:if(d=i.sent(),this.ctx.shouldThrowOnError)throw d;return[2,{data:null,error:c(d)}];case 3:return[2]}})})},e}();t.StreamDownloadBuilder=l;var h=function(){function e(e){this.ctx=e}return e.prototype.asStream=function(){return new l(this.ctx)},e.prototype.then=function(e,t){return this.execute().then(e,t)},e.prototype.execute=function(){var e,t;return o(this,void 0,Promise,function(){var n,o,s,l,h,d;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),n=u(this.ctx.options),o=n.headers,s=n.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,a.encodeObjectName)(this.ctx.cleanName)),headers:r(r({},this.ctx.headers),o),query:s,signal:null===(e=this.ctx.parameters)||void 0===e?void 0:e.signal,cache:null===(t=this.ctx.parameters)||void 0===t?void 0:t.cache})];case 1:return l=i.sent().response,d={},[4,l.blob()];case 2:return[2,(d.data=i.sent(),d.error=null,d)];case 3:if(h=i.sent(),this.ctx.shouldThrowOnError)throw h;return[2,{data:null,error:c(h)}];case 4:return[2]}})})},e}();t.DownloadBuilder=h},7090:function(e,t){"use strict";function n(){return globalThis.Buffer}Object.defineProperty(t,"__esModule",{value:!0}),t.encodeObjectName=t.toBase64=t.getStringByteLength=void 0,t.getStringByteLength=function(e){var t;return null===(t=n())||void 0===t?void 0:t.byteLength(e)},t.toBase64=function(e){var t=n();return t?t.from(e).toString("base64"):btoa(e)},t.encodeObjectName=function(e){return e.split("/").map(function(e){return encodeURIComponent(e)}).join("/")}},5098:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Http=t.handleOperation=void 0;var s=n(7957),a="/v1/storages";t.handleOperation=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e()];case 1:return[2,{data:r.sent(),error:null}];case 2:if(n=r.sent(),t)throw n;return(0,s.isStorageError)(n)?[2,{data:null,error:n}]:[2,{data:null,error:new s.StorageError((null==n?void 0:n.message)||String(n))}];case 3:return[2]}})})};var c=function(){function e(e){this.ctx=e}return Object.defineProperty(e.prototype,"request",{get:function(){return this.ctx.request},enumerable:!1,configurable:!0}),e.prototype.gatewayOrigin=function(){return this.request.getBaseEndPoint("GATEWAY")},e.prototype.buildUrl=function(e,t){var n="".concat(this.gatewayOrigin()).concat(a).concat(e),r=function(e){if(!e)return"";var t=[];return Object.keys(e).forEach(function(n){var r=e[n];null!=r&&t.push("".concat(encodeURIComponent(n),"=").concat(encodeURIComponent(String(r))))}),t.join("&")}(t);return r&&(n+=(n.includes("?")?"&":"?")+r),n},e.prototype.toFullUrl=function(e){return e?/^https?:\/\//.test(e)||e.startsWith("//")?e:"".concat(this.gatewayOrigin()).concat(a).concat(e.startsWith("/")?"":"/").concat(e):e},e.prototype.send=function(e){return o(this,void 0,Promise,function(){var t,n,o,s,a,c;return i(this,function(i){switch(i.label){case 0:return t=this.buildUrl(e.path,e.query),n=e.method.toUpperCase(),o=["GET","HEAD"].includes(n),s=r({},e.headers||{}),o||(void 0!==e.rawBody?a=e.rawBody:void 0!==e.json&&(s["Content-Type"]=s["Content-Type"]||"application/json",a=JSON.stringify(e.json))),[4,this.request.fetch(r(r(r(r({url:t,method:n,headers:s},void 0!==a?{body:a}:{}),{withCredentials:!1!==e.withCredentials,shouldThrowOnError:!1}),e.signal?{signal:e.signal}:{}),e.cache?{cache:e.cache}:{}))];case 1:return c=i.sent(),[2,this.unwrap(c,t)]}})})},e.prototype.download=function(e){var t,n;return o(this,void 0,Promise,function(){var o,a,c,u;return i(this,function(i){switch(i.label){case 0:return o=this.buildUrl(e.path,e.query),[4,this.request.fetch(r(r({url:o,method:"GET",headers:r({},e.headers||{}),stream:!0,withCredentials:!1!==e.withCredentials,shouldThrowOnError:!1},e.signal?{signal:e.signal}:{}),e.cache?{cache:e.cache}:{}))];case 1:if(a=i.sent(),null===(t=e.signal)||void 0===t?void 0:t.aborted)throw new s.StorageApiError("The download was aborted",0,"STORAGE_PG_ABORTED");if(304===(c=Number(null!==(n=null==a?void 0:a.statusCode)&&void 0!==n?n:200)))throw new s.StorageApiError("Not Modified",c,"STORAGE_PG_NOT_MODIFIED");if(c>=400)throw new s.StorageApiError("Download failed with status ".concat(c),c,"STORAGE_PG_REQUEST_FAIL");if(!(u=null==a?void 0:a.response))throw new s.StorageApiError("Underlying adapter did not expose the raw Response",c,"STORAGE_PG_NO_RESPONSE");return[2,{response:u,status:c,header:null==a?void 0:a.header}]}})})},e.prototype.unwrap=function(e,t){var n,r;return o(this,void 0,Promise,function(){var o,a,c,u;return i(this,function(i){switch(i.label){case 0:o=Number(null!==(r=null!==(n=null==e?void 0:e.statusCode)&&void 0!==n?n:null==e?void 0:e.status)&&void 0!==r?r:200),a=null==e?void 0:e.data,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,a];case 2:return a=i.sent(),[3,4];case 3:return i.sent(),a=void 0,[3,4];case 4:if(o>=200&&o<300)return[2,a];throw c=(null==a?void 0:a.code)||(null==a?void 0:a.error)||"STORAGE_PG_REQUEST_FAIL",u=(null==a?void 0:a.message)||"Storage request failed with status ".concat(o,": ").concat(t),new s.StorageApiError(u,o,c)}})})},e}();t.Http=c},3456:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.registerStorage=t.StorageClient=t.StorageFileApi=t.ClassicStorageFileApi=t.CloudbaseStorage=t.COMPONENT_NAME=void 0;var i=n(1502),s=n(2014),a=n(5504),c=n(5891),u=n(3077),l=n(5891);Object.defineProperty(t,"COMPONENT_NAME",{enumerable:!0,get:function(){return l.COMPONENT_NAME}}),Object.defineProperty(t,"CloudbaseStorage",{enumerable:!0,get:function(){return l.CloudbaseStorage}});var h=n(3077);Object.defineProperty(t,"ClassicStorageFileApi",{enumerable:!0,get:function(){return h.ClassicStorageFileApi}});var d=n(1502);Object.defineProperty(t,"StorageFileApi",{enumerable:!0,get:function(){return d.StorageFileApi}});var f=new c.CloudbaseStorage,p={name:c.COMPONENT_NAME,entity:{uploadFile:f.uploadFile,deleteFile:f.deleteFile,getTempFileURL:f.getTempFileURL,downloadFile:f.downloadFile,getUploadMetadata:f.getUploadMetadata,copyFile:f.copyFile,getFileInfo:f.getFileInfo,isGateWay:f.isGateWay}},v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.from=function(e){return e?((0,a.assertValidBucketId)(e,"from"),new i.StorageFileApi(this.http,e,this.shouldThrowOnError)):new u.ClassicStorageFileApi(this.http.ctx,this.shouldThrowOnError)},t}(s.StorageBucketApi);t.StorageClient=v;var y={name:"".concat(c.COMPONENT_NAME,"/supabase"),IIFE:!0,entity:function(){var e=new WeakMap;Object.defineProperty(this.prototype,"storage",{get:function(){if(e.has(this))return e.get(this);var t=this,n=new Proxy({},{get:function(e,n){return"config"===n?t.config:"request"===n?t.request:void 0}}),r=new v(n);return e.set(this,r),r},configurable:!0,enumerable:!0})}};try{cloudbase.registerComponent(p),cloudbase.registerComponent(y)}catch(e){}function g(e){try{e.registerComponent(p),e.registerComponent(y)}catch(e){console.warn(e)}}t.registerStorage=g;try{window.registerStorage=g}catch(e){}},2014:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.StorageBucketApi=void 0;var i=n(5098),s=n(5504),a=function(){function e(e,t){void 0===t&&(t=!1),this.http=new i.Http(e),this.shouldThrowOnError=t}return e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.listBuckets=function(e){return r(this,void 0,Promise,function(){var t=this;return o(this,function(n){return[2,(0,i.handleOperation)(function(){var n={};return void 0!==(null==e?void 0:e.limit)&&(n.limit=e.limit),void 0!==(null==e?void 0:e.offset)&&(n.offset=e.offset),(null==e?void 0:e.sortColumn)&&(n.sortColumn=e.sortColumn),(null==e?void 0:e.sortOrder)&&(n.sortOrder=e.sortOrder),(null==e?void 0:e.search)&&(n.search=e.search),t.http.send({method:"GET",path:"/bucket/",query:n})},this.shouldThrowOnError)]})})},e.prototype.getBucket=function(e){return r(this,void 0,Promise,function(){var t=this;return o(this,function(n){return[2,(0,i.handleOperation)(function(){return(0,s.assertValidBucketId)(e,"getBucket"),t.http.send({method:"GET",path:"/bucket/".concat(e)})},this.shouldThrowOnError)]})})},e.prototype.createBucket=function(e,t){return r(this,void 0,Promise,function(){var n=this;return o(this,function(r){return[2,(0,i.handleOperation)(function(){var r;return(0,s.assertValidBucketId)(e,"createBucket"),n.http.send({method:"POST",path:"/bucket/",json:{id:e,name:e,public:null!==(r=null==t?void 0:t.public)&&void 0!==r&&r,type:null==t?void 0:t.type,file_size_limit:null==t?void 0:t.fileSizeLimit,allowed_mime_types:null==t?void 0:t.allowedMimeTypes}})},this.shouldThrowOnError)]})})},e.prototype.updateBucket=function(e,t){return r(this,void 0,Promise,function(){var n=this;return o(this,function(r){return[2,(0,i.handleOperation)(function(){return(0,s.assertValidBucketId)(e,"updateBucket"),n.http.send({method:"PUT",path:"/bucket/".concat(e),json:{public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes}})},this.shouldThrowOnError)]})})},e.prototype.deleteBucket=function(e){return r(this,void 0,Promise,function(){var t=this;return o(this,function(n){return[2,(0,i.handleOperation)(function(){return(0,s.assertValidBucketId)(e,"deleteBucket"),t.http.send({method:"DELETE",path:"/bucket/".concat(e)})},this.shouldThrowOnError)]})})},e}();t.StorageBucketApi=a},3077:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ClassicStorageFileApi=void 0;var s=n(2877),a=n(7957),c=n(5891),u=n(7090),l=s.constants.ERRORS,h=function(){function e(e,t){void 0===t&&(t=!1),this.shouldThrowOnError=!1,this.bucketId="",this.context=e,this.shouldThrowOnError=t,this.storage=new c.CloudbaseStorage(e)}return Object.defineProperty(e.prototype,"config",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.request},enumerable:!1,configurable:!0}),e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.upload=function(e,t,n){return o(this,void 0,Promise,function(){var o,s,u,h,d,f,p,v,y;return i(this,function(i){switch(i.label){case 0:o=r({upsert:!0},n),s=o.cacheControl,u=o.contentType,h=o.metadata,i.label=1;case 1:return i.trys.push([1,3,,4]),d=this.getCloudPath(e),f={cloudPath:d,filePath:t},(s||u||h)&&(p={},s&&(p["cache-control"]=s),u&&(p["content-type"]=u),h&&(p["x-cos-metadata-metadata"]=this.toBase64(JSON.stringify(h))),f.headers=p),[4,this.storage.uploadFile(f)];case 2:if(!(v=i.sent()).fileID)throw new Error(JSON.stringify({code:l.OPERATION_FAIL,msg:"[".concat(c.COMPONENT_NAME,".update] no fileID returned")}));return[2,{data:{id:v.fileID,path:e,fullPath:e},error:null}];case 3:if(y=i.sent(),this.shouldThrowOnError)throw y;if((0,a.isStorageError)(y))return[2,{data:null,error:y}];throw y;case 4:return[2]}})})},e.prototype.uploadToSignedUrl=function(e,t,n,r){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.upload(e,n,r)]})})},e.prototype.createSignedUploadUrl=function(e){return o(this,void 0,Promise,function(){var t,n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this.getCloudPath(e),[4,this.storage.getUploadMetadata({cloudPath:t})];case 1:return[2,{data:{signedUrl:(n=o.sent().data).url,token:n.token,path:e,authorization:n.authorization,id:n.fileId,cosFileId:n.cosFileId,downloadUrl:n.download_url},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;return[2,{data:null,error:r instanceof a.StorageError?r:new a.StorageError(r.message)}];case 3:return[2]}})})},e.prototype.update=function(e,t,n){return o(this,void 0,Promise,function(){return i(this,function(o){return[2,this.upload(e,t,r(r({},n),{upsert:!0}))]})})},e.prototype.move=function(e,t){return o(this,void 0,Promise,function(){var n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(e),dstPath:this.getCloudPath(t),overwrite:!0,removeOriginal:!0}]})];case 1:if((n=o.sent()).fileList[0].code&&"SUCCESS"!==n.fileList[0].code)throw new a.StorageError(n.fileList[0].message||"Move failed");return[2,{data:{message:"File moved from ".concat(e," to ").concat(t)},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}})})},e.prototype.copy=function(e,t){return o(this,void 0,Promise,function(){var n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(e),dstPath:this.getCloudPath(t),overwrite:!0,removeOriginal:!1}]})];case 1:if((n=o.sent()).fileList[0].code&&"SUCCESS"!==n.fileList[0].code)throw new a.StorageError(n.fileList[0].message||"Copy failed");return[2,{data:{path:this.getCloudPath(t)},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}})})},e.prototype.createSignedUrl=function(e,t,n){return o(this,void 0,Promise,function(){var r,o,s,u,l,h,d;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,2,,3]),!(0,c.isValidTempUrlMaxAge)(t))throw new a.StorageError("[".concat(c.COMPONENT_NAME,".createSignedUrl] expiresIn must be an integer greater than or equal to ").concat(c.TEMP_URL_MAX_AGE_MIN));return r=this.normalizeCloudId(e),[4,this.storage.getTempFileURL({fileList:[{fileID:r,maxAge:t}]})];case 1:if("SUCCESS"!==(o=i.sent()).fileList[0].code)throw new a.StorageError("Failed to create signed URL: [".concat(o.fileList[0].code,"] ").concat(o.fileList[0].fileID));return s=o.fileList[0].download_url,u=[],void 0!==(null==n?void 0:n.download)&&("string"==typeof n.download?u.push("download=".concat(encodeURIComponent(n.download))):!0===n.download&&u.push("download=true")),(null==n?void 0:n.transform)&&(l=this.transformOptsToQueryString(n.transform))&&u.push(l),u.length>0&&(h=s.includes("?")?"&":"?",s="".concat(s).concat(h).concat(u.join("&"))),[2,{data:{signedUrl:s},error:null}];case 2:if(d=i.sent(),this.shouldThrowOnError)throw d;if((0,a.isStorageError)(d))return[2,{data:null,error:d}];throw d;case 3:return[2]}})})},e.prototype.createSignedUrls=function(e,t){return o(this,void 0,Promise,function(){var n,r,o=this;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,2,,3]),!(0,c.isValidTempUrlMaxAge)(t))throw new a.StorageError("[".concat(c.COMPONENT_NAME,".createSignedUrls] expiresIn must be an integer greater than or equal to ").concat(c.TEMP_URL_MAX_AGE_MIN));return n=e.map(function(e){return{fileID:o.normalizeCloudId(e),maxAge:t}}),[4,this.storage.getTempFileURL({fileList:n})];case 1:return[2,{data:i.sent().fileList.map(function(t,n){return{path:e[n],signedUrl:t.tempFileURL||"",error:"SUCCESS"===t.code?null:t.message}}),error:null}];case 2:if(r=i.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}})})},e.prototype.download=function(e,t){return o(this,void 0,Promise,function(){var n,r,s=this;return i(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),r={},[4,o(s,void 0,void 0,function(){var n,r,o,s;return i(this,function(i){switch(i.label){case 0:return[4,this.createSignedUrl(e,600,{transform:t})];case 1:if((n=i.sent()).error)throw n.error;return r=encodeURI(null===(s=n.data)||void 0===s?void 0:s.signedUrl),[4,this.request.reqClass.get({url:r,headers:{},responseType:"blob"})];case 2:if(!(o=i.sent().data))throw new a.StorageError("Download failed: no file content");return[2,new Blob([o])]}})})];case 1:return[2,(r.data=c.sent(),r.error=null,r)];case 2:if(n=c.sent(),this.shouldThrowOnError)throw n;if((0,a.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}})})},e.prototype.info=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,c,u,l;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=e.startsWith("cloud://"),n=t?this.extractPathFromFileId(e):e,r=t?this.extractBucketFromFileId(e):this.bucketId,[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(e)]})];case 1:if(o=i.sent(),"SUCCESS"!==(s=o.fileList[0]).code)throw new a.StorageError(s.message);return c=(new Date).toISOString(),u=(s.lastModified?new Date(s.lastModified):new Date).toISOString(),[2,{data:{id:s.fileID,version:"1",name:n,bucketId:r,updatedAt:u,createdAt:u,lastAccessedAt:c,size:s.size,cacheControl:s.cacheControl,contentType:s.contentType,etag:s.etag,lastModified:u,metadata:{}},error:null}];case 2:if(l=i.sent(),this.shouldThrowOnError)throw l;return[2,{data:null,error:l instanceof a.StorageError?l:new a.StorageError(l.message)}];case 3:return[2]}})})},e.prototype.exists=function(e){return o(this,void 0,Promise,function(){var t,n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(e)]})];case 1:if(t=o.sent(),"FILE_NOT_FOUND"===(n=t.fileList[0]).code)return[2,{data:!1,error:null}];if("SUCCESS"!==n.code)throw new a.StorageError(n.message);return[2,{data:!0,error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}})})},e.prototype.getPublicUrl=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.createSignedUrl(e,600,t)];case 1:return(n=r.sent()).data?[2,{data:{publicUrl:n.data.signedUrl}}]:[2,{data:null,error:n.error}]}})})},e.prototype.remove=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,c,u,l,h,d,f=this;return i(this,function(i){switch(i.label){case 0:for(i.trys.push([0,3,,4]),t=10,n=[],r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return[4,Promise.all(n.map(function(e){return Promise.all(e.map(function(e){return f.info(e)}))}))];case 1:return o=i.sent(),s=new Map,o.forEach(function(n,r){n.forEach(function(n,o){n.data&&s.set(e[r*t+o],n.data)})}),c=e.map(function(e){return f.normalizeCloudId(e)}),[4,this.storage.deleteFile({fileList:c})];case 2:if(u=i.sent(),(l=u.fileList.filter(function(e){return"SUCCESS"!==e.code})).length>0)throw new a.StorageError("Delete failed for ".concat(l.length," file(s)"));return h=(new Date).toISOString(),[2,{data:e.map(function(e){var t=s.get(e);return{name:null==t?void 0:t.name,id:null==t?void 0:t.id,bucket_id:null==t?void 0:t.bucketId,owner:void 0,updated_at:(null==t?void 0:t.updatedAt)||h,created_at:null==t?void 0:t.createdAt,last_accessed_at:(null==t?void 0:t.lastAccessedAt)||h,metadata:(null==t?void 0:t.metadata)||{},buckets:{id:null==t?void 0:t.bucketId,name:null==t?void 0:t.bucketId,owner:void 0,public:!1,created_at:"",updated_at:h}}}),error:null}];case 3:if(d=i.sent(),this.shouldThrowOnError)throw d;if((0,a.isStorageError)(d))return[2,{data:null,error:d}];throw d;case 4:return[2]}})})},e.prototype.list=function(){return o(this,void 0,void 0,function(){return i(this,function(e){throw new a.StorageError("Not implemented")})})},e.prototype.getCloudPath=function(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")},e.prototype.normalizeCloudId=function(e){var t;if(/^cloud:\/\//.test(e))return e;var n=this.getCloudPath(e);if(!this.bucketId)throw new a.StorageError("bucketId is not set");var r=(null===(t=this.config)||void 0===t?void 0:t.env)||"";return r?"cloud://".concat(r,".").concat(this.bucketId,"/").concat(n):void 0},e.prototype.toBase64=function(e){return(0,u.toBase64)(e)},e.prototype.transformOptsToQueryString=function(e){var t=["imageMogr2"];if(e.width||e.height){var n=e.width||"",r=e.height||"";"fill"===e.resize?t.push("thumbnail/".concat(n,"x").concat(r,"!")):"contain"===e.resize?t.push("thumbnail/".concat(n,"x").concat(r)):t.push("thumbnail/".concat(n,"x").concat(r,"^"))}if(e.format&&"origin"!==e.format&&t.push("format/".concat(e.format)),void 0!==e.quality){var o=Math.max(1,Math.min(100,e.quality));t.push("quality/".concat(o))}return t.join("/")},e.prototype.extractPathFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");return t.length<2?e:t.slice(1).join("/")},e.prototype.extractBucketFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");if(t.length<1)return"";var n=t[0],r=n.indexOf(".");return-1===r?n:n.substring(r+1)},e}();t.ClassicStorageFileApi=h},1502:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.StorageFileApi=void 0;var s=n(7957),a=n(7090),c=n(5098),u=n(9656),l="3600",h=function(){function e(e,t,n){void 0===n&&(n=!1),this.headers={},this.http=e,this.bucketId=t,this.shouldThrowOnError=n}return e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.setHeader=function(e,t){var n;if("string"!=typeof e||""===e.trim())throw new s.StorageError("setHeader requires a non-empty header name");if(/[\r\n]/.test(e)||"string"==typeof t&&/[\r\n]/.test(t))throw new s.StorageError("setHeader does not allow CR/LF characters in header name or value");return this.headers=r(r({},this.headers),((n={})[e]=String(t),n)),this},e.prototype.upload=function(e,t,n){return o(this,void 0,Promise,function(){return i(this,function(r){return[2,this.uploadOrUpdate("POST",e,t,n)]})})},e.prototype.update=function(e,t,n){return o(this,void 0,Promise,function(){return i(this,function(r){return[2,this.uploadOrUpdate("PUT",e,t,n)]})})},e.prototype.download=function(e,t,n){return new u.DownloadBuilder({http:this.http,bucketId:this.bucketId,cleanName:this.cleanPath(e),options:t,parameters:n,headers:this.headers,shouldThrowOnError:this.shouldThrowOnError})},e.prototype.list=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){var r;return i(this,function(o){return r={prefix:e||""},void 0!==(null==t?void 0:t.limit)&&(r.limit=t.limit),void 0!==(null==t?void 0:t.cursor)&&(r.cursor=t.cursor),void 0!==(null==t?void 0:t.withDelimiter)&&(r.with_delimiter=t.withDelimiter),void 0!==(null==t?void 0:t.sortBy)&&(r.sortBy=t.sortBy),[2,this.send({method:"POST",path:"/object/list/".concat(this.bucketId),json:r,signal:null==n?void 0:n.signal,cache:null==n?void 0:n.cache})]})})},this.shouldThrowOnError)]})})},e.prototype.remove=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){return[2,(0,c.handleOperation)(function(){return o(t,void 0,void 0,function(){var t,n,r,o,s,a=this;return i(this,function(i){switch(i.label){case 0:t=e.map(function(e){return a.cleanPath(e)}),n=[],r=0,i.label=1;case 1:return r<t.length?(o=t.slice(r,r+100),[4,this.send({method:"DELETE",path:"/object/".concat(this.bucketId),json:{prefixes:o}})]):[3,4];case 2:s=i.sent(),Array.isArray(s)&&n.push.apply(n,s),i.label=3;case 3:return r+=100,[3,1];case 4:return[2,n]}})})},this.shouldThrowOnError)]})})},e.prototype.copy=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){var r;return i(this,function(o){switch(o.label){case 0:return r=this.buildCopyMoveHeaders(n),[4,this.send({method:"POST",path:"/object/copy",json:{bucketId:this.bucketId,sourceKey:this.cleanPath(e),destinationKey:this.cleanPath(t),destinationBucket:null==n?void 0:n.destinationBucket,copyMetadata:null==n?void 0:n.copyMetadata,metadata:null==n?void 0:n.metadata},headers:r})];case 1:return[2,{path:o.sent().Key}]}})})},this.shouldThrowOnError)]})})},e.prototype.move=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,this.send({method:"POST",path:"/object/move",json:{bucketId:this.bucketId,sourceKey:this.cleanPath(e),destinationKey:this.cleanPath(t),destinationBucket:null==n?void 0:n.destinationBucket}})];case 1:return[2,{message:r.sent().message||"Successfully moved"}]}})})},this.shouldThrowOnError)]})})},e.prototype.info=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){return[2,(0,c.handleOperation)(function(){return o(t,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return t=this.cleanPath(e),[4,this.send({method:"GET",path:"/object/info/".concat(this.bucketId,"/").concat(this.encodePath(t))})];case 1:return[2,{id:(n=r.sent()).id,name:n.name,version:n.version,bucketId:n.bucket_id,size:n.size,contentType:n.content_type,cacheControl:n.cache_control,etag:n.etag,metadata:n.metadata,lastModified:n.last_modified,createdAt:n.created_at}]}})})},this.shouldThrowOnError)]})})},e.prototype.exists=function(e){return o(this,void 0,Promise,function(){var t,n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this.cleanPath(e),[4,this.send({method:"GET",path:"/object/info/".concat(this.bucketId,"/").concat(this.encodePath(t))})];case 1:return o.sent(),[2,{data:!0,error:null}];case 2:if(n=o.sent(),void 0!==(r=null==n?void 0:n.status)&&[400,404].includes(Number(r)))return[2,{data:!1,error:null}];if(this.shouldThrowOnError)throw n;return[2,{data:null,error:n instanceof s.StorageError?n:new s.StorageError((null==n?void 0:n.message)||String(n))}];case 3:return[2]}})})},e.prototype.createSignedUrl=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){var r,o,s;return i(this,function(i){switch(i.label){case 0:return r=this.cleanPath(e),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId,"/").concat(this.encodePath(r)),json:{expiresIn:t}})];case 1:return o=i.sent(),s=o.fullSignedURL||this.http.toFullUrl(o.signedURL||""),[2,{fullSignedURL:this.appendUrlOptions(s,n)}]}})})},this.shouldThrowOnError)]})})},e.prototype.createSignedUrls=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){var r,o,s,a,c=this;return i(this,function(i){switch(i.label){case 0:r=e.map(function(e){return c.cleanPath(e)}),o=[],s=0,i.label=1;case 1:return s<r.length?(a=r.slice(s,s+500),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId),json:{expiresIn:t,paths:a}})]):[3,4];case 2:i.sent().forEach(function(e){var t,r=e.fullSignedURL||(e.signedURL?c.http.toFullUrl(e.signedURL):null);o.push({path:e.path,fullSignedURL:r?c.appendUrlOptions(r,n):null,error:null!==(t=e.error)&&void 0!==t?t:null})}),i.label=3;case 3:return s+=500,[3,1];case 4:return[2,o]}})})},this.shouldThrowOnError)]})})},e.prototype.createSignedUploadUrl=function(e,t){return o(this,void 0,Promise,function(){var n=this;return i(this,function(r){return[2,(0,c.handleOperation)(function(){return o(n,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=this.cleanPath(e),r={},(null==t?void 0:t.upsert)&&(r["x-upsert"]="true"),[4,this.send({method:"POST",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(n)),headers:r})];case 1:return[2,{fullSignedURL:(o=i.sent()).fullURL||this.http.toFullUrl(o.url||""),path:n,token:o.token}]}})})},this.shouldThrowOnError)]})})},e.prototype.uploadToSignedUrl=function(e,t,n,r){return o(this,void 0,Promise,function(){var s=this;return i(this,function(a){return[2,(0,c.handleOperation)(function(){return o(s,void 0,void 0,function(){var o,s,a,c,u;return i(this,function(i){switch(i.label){case 0:return o=this.cleanPath(e),s=this.buildUploadBody(n,r),a=s.body,c=s.headers,[4,this.send({method:"PUT",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(o)),query:{token:t},rawBody:a,headers:c,withCredentials:!1})];case 1:return u=i.sent(),[2,{path:o,fullPath:u.Key}]}})})},this.shouldThrowOnError)]})})},e.prototype.getPublicUrl=function(e,t){var n=this.cleanPath(e),r=this.http.buildUrl("/object/public/".concat(this.bucketId,"/").concat(this.encodePath(n)));return{data:{publicUrl:this.appendUrlOptions(r,t)}}},e.prototype.send=function(e){return this.http.send(r(r({},e),{headers:r(r({},this.headers),e.headers||{})}))},e.prototype.uploadOrUpdate=function(e,t,n,r){return o(this,void 0,Promise,function(){var s=this;return i(this,function(a){return[2,(0,c.handleOperation)(function(){return o(s,void 0,void 0,function(){var o,s,a,c,u;return i(this,function(i){switch(i.label){case 0:return o=this.cleanPath(t),s=this.buildUploadBody(n,r),a=s.body,c=s.headers,"POST"===e&&(c["x-upsert"]=String(Boolean(null==r?void 0:r.upsert))),[4,this.send({method:e,path:"/object/".concat(this.bucketId,"/").concat(this.encodePath(o)),rawBody:a,headers:c})];case 1:return[2,{id:(u=i.sent()).Id,path:o,fullPath:u.Key}]}})})},this.shouldThrowOnError)]})})},e.prototype.cleanPath=function(e){var t=e.replace(/^\/+|\/+$/g,"").replace(/\/+/g,"/");if(t.split("/").some(function(e){return".."===e}))throw new s.StorageError('invalid path: ".." segment is not allowed');return t},e.prototype.encodePath=function(e){return(0,a.encodeObjectName)(e)},e.prototype.buildUploadBody=function(e,t){var n,o,i,s,a,c=r({},(null==t?void 0:t.headers)||{}),u=e,h="undefined"!=typeof FormData&&e instanceof FormData;if("undefined"!=typeof Blob&&e instanceof Blob||h){var d=void 0,f={};if(h){var p=this.extractFromFormData(e);d=p.file,f=p.fields}else d=e;var v=null!==(o=null!==(n=null==t?void 0:t.cacheControl)&&void 0!==n?n:f.cacheControl)&&void 0!==o?o:l,y=null!==(i=null==t?void 0:t.contentType)&&void 0!==i?i:f.contentType,g=void 0!==(null==t?void 0:t.metadata)?JSON.stringify(t.metadata):f.metadata,m=new FormData;void 0!==v&&m.append("cacheControl",String(v)),void 0!==y&&m.append("contentType",y),void 0!==g&&m.append("metadata",g),m.append("",d),u=m}else u=e,v=null!==(s=null==t?void 0:t.cacheControl)&&void 0!==s?s:l,y=null!==(a=null==t?void 0:t.contentType)&&void 0!==a?a:"text/plain;charset=UTF-8",c["cache-control"]="max-age=".concat(v),y&&(c["content-type"]=y),(null==t?void 0:t.metadata)&&(c["x-metadata"]=this.toBase64(JSON.stringify(t.metadata)));return{body:u,headers:c}},e.prototype.extractFromFormData=function(e){var t,n={},r=0,o=[];if(e.forEach(function(e,i){if("undefined"!=typeof Blob&&e instanceof Blob)return t=e,void(r+=1);"cacheControl"!==i&&"contentType"!==i&&"metadata"!==i?o.push(i):n[i]=String(e)}),o.length>0&&console.warn("Ignored unsupported FormData field(s): [".concat(o.join(", "),"]. Only file, cacheControl, contentType and metadata are supported")),0===r||!t)throw new s.StorageError("FormData must contain a file");if(r>1)throw new s.StorageError("FormData must contain exactly one file");return{file:t,fields:n}},e.prototype.buildCopyMoveHeaders=function(e){var t={};return(null==e?void 0:e.upsert)&&(t["x-upsert"]="true"),!1===(null==e?void 0:e.copyMetadata)&&(null==e?void 0:e.metadata)&&(t["x-metadata"]=this.toBase64(JSON.stringify(e.metadata))),t},e.prototype.appendUrlOptions=function(e,t){var n=[];if(void 0!==(null==t?void 0:t.download)){var r=!0===t.download?"":String(t.download);n.push("download=".concat(encodeURIComponent(r)))}if(void 0!==(null==t?void 0:t.cacheNonce)&&n.push("cacheNonce=".concat(encodeURIComponent(String(t.cacheNonce)))),0===n.length)return e;var o=e.includes("?")?"&":"?";return"".concat(e).concat(o).concat(n.join("&"))},e.prototype.toBase64=function(e){return(0,a.toBase64)(e)},e}();t.StorageFileApi=h},7957:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.StorageUnknownError=t.StorageApiError=t.isStorageError=t.StorageError=void 0;var o=function(e){function t(t){var n=e.call(this,t)||this;return n.__isStorageError=!0,n.name="StorageError",n}return r(t,e),t}(Error);t.StorageError=o,t.isStorageError=function(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e};var i=function(e){function t(t,n,r){var o=e.call(this,t)||this;return o.name="StorageApiError",o.status=n,o.statusCode=r,o}return r(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}},t}(o);t.StorageApiError=i;var s=function(e){function t(t,n){var r=e.call(this,t)||this;return r.name="StorageUnknownError",r.originalError=n,r}return r(t,e),t}(o);t.StorageUnknownError=s},5504:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertValidBucketId=t.isValidBucketId=void 0;var r=n(7957),o=/[\x00-\x20\x7f/\\?#%]/;t.isValidBucketId=function(e){return"string"==typeof e&&e.length>0&&e.length<=256&&!o.test(e)},t.assertValidBucketId=function(e,t){if("string"!=typeof e||0===e.length)throw new r.StorageError("[storage.".concat(t,"] bucketId is required"));if(e.length>256)throw new r.StorageError("[storage.".concat(t,"] invalid bucketId: length must be 1-").concat(256));var n=o.exec(e);if(n){var i="[storage.".concat(t,'] invalid bucketId "').concat(e,'": ')+"contains forbidden character ".concat(JSON.stringify(n[0]),"; ")+'must not contain whitespace, control chars, "/", "\\", "?", "#" or "%"';throw new r.StorageError(i)}}},2563:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,c=s(n(92)),u=n(962);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var n=0,o=(0,u.isArray)(e)?e:[e];n<o.length;n++){var i=o[n],s=i.isMatch,a=i.genAdapter,c=i.runtime;if(s())return{adapter:r({isMatch:s},a(t)),runtime:c}}},t.useDefaultAdapter=function(){return{adapter:r({},c.genAdapter()),runtime:a.WEB}}},92:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var c=n(2764),u=n(962),l=n(8464);function h(e){try{return JSON.parse(e)}catch(t){return e}}var d=function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e,n=t.data,r=t.file,o=t.fileContent,s=t.name,a=t.method,c=t.headers,u=void 0===c?{}:c,l=null!=r?r:o,h={post:"post",put:"put"}[null==a?void 0:a.toLowerCase()]||"put",d=new FormData;return"post"===h?(Object.keys(n).forEach(function(e){d.append(e,n[e])}),d.append("key",s),d.append("file",l instanceof Blob?l:new Blob([l])),this.request(i(i({},e),{data:d,method:h}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:u,body:l}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,Promise,function(){var t,n,r,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(t){t({statusCode:200,tempFilePath:e.url})})]}})})},t.prototype.fetch=function(e){var t;return s(this,void 0,Promise,function(){var n,r,o,c,u,l,d,f,p,v,y,g,m,b,_,E=this;return a(this,function(w){switch(w.label){case 0:return n=new AbortController,r=e.url,o=e.enableAbort,c=void 0!==o&&o,u=e.stream,l=void 0!==u&&u,d=e.signal,f=e.timeout,p=e.shouldThrowOnError,v=void 0===p||p,y=null!=f?f:this.timeout,d&&(d.aborted&&n.abort(),d.addEventListener("abort",function(){return n.abort()})),g=null,c&&y&&(g=setTimeout(function(){console.warn(E.timeoutMsg),n.abort(new Error(E.timeoutMsg))},y)),[4,fetch(r,i(i({},e),{signal:n.signal})).then(function(e){return s(E,void 0,void 0,function(){var t,n,r;return a(this,function(o){switch(o.label){case 0:return clearTimeout(g),v?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,e.json()];case 2:t=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(g),Promise.reject(e)})];case 1:return m=w.sent(),l?(b=m.body,[3,5]):[3,2];case 2:return(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?(_=h,[4,m.text()]):[3,4];case 3:return b=_.apply(void 0,[w.sent()]),[3,5];case 4:b=m.text(),w.label=5;case 5:return[2,{data:b,statusCode:m.status,header:m.headers,response:m}]}})})},t.prototype.request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i=e.url,s=e.headers,a=void 0===s?{}:s,c=e.data,h=e.responseType,d=e.withCredentials,f=e.body,p=e.onUploadProgress,v=(0,u.formatUrl)((0,l.getProtocol)(),i,"get"===r?c:{}),y=new XMLHttpRequest;y.open(r,v),h&&(y.responseType=h);var g,m,b=e.signal;b&&(b.aborted?y.abort():b.addEventListener("abort",function(){return y.abort()},{once:!0})),Object.keys(a).forEach(function(e){y.setRequestHeader(e,a[e])}),p&&y.upload.addEventListener("progress",p),y.onreadystatechange=function(){var e={};if(4===y.readyState){var t=y.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach(function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o}),e.header=n,e.statusCode=y.status;try{e.data="blob"===h?y.response:JSON.parse(y.responseText)}catch(t){e.data="blob"===h?y.response:y.responseText}clearTimeout(g),o(e)}},t&&n.timeout&&(g=setTimeout(function(){console.warn(n.timeoutMsg),y.abort()},n.timeout)),m=(0,u.isFormData)(c)?c:"application/x-www-form-urlencoded"===a["content-type"]?(0,u.toQueryString)(c):f||(c?JSON.stringify(c):void 0),d&&(y.withCredentials=!0),y.send(m)})},t}(c.AbstractSDKRequest);t.WebRequest=d,t.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage:localStorage}}},8464:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var n="@cloudbase/js-sdk";t.setSdkName=function(e){n=e},t.getSdkName=function(){return n};var r="https:";t.setProtocol=function(e){r=e},t.getProtocol=function(){return r},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},3519:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},1778:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(n(8464),t),o(n(3519),t),t.OATUH_LOGINTYPE="constants"},9517:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=n(962),s=n(1778),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,n=e.className,r=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),h=s.findIndex(function(e){return c.test(e)});if(-1!==h){var d=s.filter(function(e,t){return t>h});d.unshift(s[h].replace(l,"".concat(n,".").concat(r)).replace(u,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,a=e.customInfo,h=void 0===a?{}:a,d=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=h.className||e.constructor.name,v=h.methodName||t,y=a.value,g=function(){var e="",t=(new Error).stack.split("\n"),n=t.findIndex(function(e){return c.test(e)});if(-1!==n){var r=u.exec(t[n+1]||"");e=r?r[0]:""}return e}();a.value="sync"===n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=l({err:new Error,className:f,methodName:v,sourceLink:g});try{return y.apply(this,e)}catch(e){var r=e,o=e.message,s=e.error,a=e.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(n?(n.code=u.code,n.msg=u.msg):(e.code=u.code,e.message=u.msg),r=n||e,c.content=p.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(c.subtitle=a,n?(n.code=s,n.msg=a):(e.code=s,e.message=a),r=n||e,c.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(c),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,function(){var t,n,r,s,a,c,u,h;return o(this,function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,c=n.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(h=JSON.parse(s),u.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(n.code=h.code,n.message=h.msg),r=t||n,u.content=p.map(function(e){return{type:"info",body:e}}))),a&&c&&(u.subtitle=c,t?(t.code=a,t.msg=c):(n.code=a,n.message=c),r=t||n,u.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(u),r;case 4:return[2]}})})}}}}},3260:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(9517),t)},2877:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.langEvent=t.AbortController=t.jwt=t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var a=i(n(1778));t.constants=a;var c=i(n(2563));t.adapters=c;var u=i(n(6865));t.cache=u;var l=i(n(6940));t.events=l;var h=i(n(3991));t.langEvent=h;var d=i(n(962));t.utils=d;var f=i(n(3260));t.helpers=f;var p=s(n(829));t.AbortController=p.default;var v={decode:s(n(3107)).default};t.jwt=v},829:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,n){"abort"===t&&e.listeners.push(n)}}}return e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach(function(e){return e()}))},e}();t.default=n},6865:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=n(2764),c=n(962),u=n(1778),l=function(e){function t(t){var n=e.call(this)||this;return n.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),h=function(){function e(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return i(this,void 0,void 0,function(){var r;return s(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var r=this.storage.getItem(e);return r&&r.indexOf(t)>=0?JSON.parse(r).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return i(this,void 0,void 0,function(){var r;return s(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(r=o.sent())&&r.indexOf(t)>=0?[2,JSON.parse(r).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}();t.CloudbaseCache=h},6940:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=n(962),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var c=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return o(t,e),t}(a);t.IErrorEvent=c;var u=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,c))return console.error(e.error),this;var n=(0,s.isString)(e)?new a(e,t||{}):e,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,u=this.listeners[r]?i([],this.listeners[r],!0):[];o<u.length;o++)u[o].call(this,n)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=u;var l=new u;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},3991:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LANG_CHANGE_EVENT=t.bus=void 0;var r=n(6940);t.bus=new r.CloudbaseEventEmitter,t.LANG_CHANGE_EVENT="lang_change"},962:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.errorToResult=t.promoteGatewayError=t.maybeThrow=t.resolveThrow=t.createCloudbaseError=t.CloudbaseError=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var a=n(1778);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var r=16*Math.random();return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:7&r|8).toString(16)})},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";return Object.keys(n).forEach(function(e){""===o?!r&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(n[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(n){t.push("".concat(n,"=").concat(encodeURIComponent(e[n])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||decodeURIComponent(window.location.search),r=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('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}var n=new Promise(function(t,n){e=function(e,r){return e?n(e):t(r)}});return e.promise=n,e},t.execCallback=function(e,t,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(t,n);if(t)throw t;return n},t.printWarn=function(e,t){console.warn("[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){var n=new Error(JSON.stringify({code:e,msg:"[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t)}));throw n.code=e,n};var c=function(e){function t(t){var n=e.call(this,t.msg||t.message||"")||this;return n.code=t.code||"",n.requestId=t.requestId||"",Object.defineProperty(n,"message",{value:t.msg||t.message||"",enumerable:!0,writable:!0,configurable:!0}),n}return o(t,e),t}(Error);t.CloudbaseError=c;var u=function(e){return new c(e)};function l(e,t){return(t||u)(e)}function h(e){return!e||"boolean"!=typeof e.throw||e.throw}t.createCloudbaseError=l,t.resolveThrow=h,t.maybeThrow=function(e,t){if(h(e))throw l(i(i({},t),{msg:t.message}),null==e?void 0:e.errorFactory);return i({code:t.code,message:t.message},t.requestId?{requestId:t.requestId}:{})},t.promoteGatewayError=function(e){if(e&&"object"==typeof e&&e.data&&"object"==typeof e.data){var t=e.data,n=t.code,r=t.message;if(!e.code&&n||!e.message&&r)return i(i(i({},e),!e.code&&n?{code:n}:{}),!e.message&&r?{message:r}:{})}return e},t.errorToResult=function(e){if(e instanceof Error&&"string"==typeof e.message)try{var t=JSON.parse(e.message);if(t&&"string"==typeof t.code)return{code:t.code,message:t.msg||t.message||"",requestId:t.requestId}}catch(e){}return e&&"string"==typeof e.code?{code:e.code,message:e.message||"",requestId:e.requestId}:{code:"UNKNOWN_ERROR",message:String((null==e?void 0:e.message)||e||"")}},t.printGroupLog=function(e){var t,n=e.title,r=e.subtitle,o=void 0===r?"":r,i=e.content,s=void 0===i?[]:i,a=e.printTrace,c=void 0!==a&&a,u=e.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var l=0,h=s;l<h.length;l++){var d=h[l],f=d.type,p=d.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}c&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var n=e.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(t[r]?Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]:t[r]=o)}),t},t.parseCaptcha=function(e){var n={},r=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){e=r[1];var o=r[2];o&&(n=(0,t.parseQueryString)(o))}var i=n.token,a=s(n,["token"]);return/^data:/.test(e)&&!i?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:i?{state:a.state,token:i,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},4954:function(e,t,n){"use strict";n.r(t),n.d(t,{CollectionReference:function(){return ut},Db:function(){return It},DocumentReference:function(){return Ze},Query:function(){return it}});var r,o,i={};n.r(i),n.d(i,{LineString:function(){return V},MultiLineString:function(){return $},MultiPoint:function(){return Y},MultiPolygon:function(){return X},Point:function(){return we},Polygon:function(){return J}}),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.BooleanError="must be boolean",e.ArrayError="must be array",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined",e.CentersPhereError="centersPhere结构不合法"}(o||(o={}));var s,a,c="Object",u="GeoPoint",l="GeoLineString",h="GeoPolygon",d="GeoMultiPoint",f="GeoMultiLineString",p="GeoMultiPolygon",v="Date",y="ServerDate",g=["desc","asc"],m=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={})),(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte",function(e){e.WHERE="WHERE",e.DOC="DOC"}(a||(a={}));var b,_=(b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},b(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),E=[],w={},S=function(e){function t(t,n){if(n!==w)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return _(t,e),t.for=function(e){for(var n=0,r=E.length;n<r;n++)if(E[n].target===e)return E[n].instance;var o=new t(e,w);return E.push({target:e,instance:o}),o},t}(function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})}),I=S,O=I.for("UNSET_FIELD_NAME"),A=I.for("UPDATE_COMMAND"),T=I.for("QUERY_COMMAND"),P=I.for("LOGIC_COMMAND"),C=I.for("GEO_POINT"),R=I.for("SYMBOL_GEO_LINE_STRING"),N=I.for("SYMBOL_GEO_POLYGON"),k=I.for("SYMBOL_GEO_MULTI_POINT"),U=I.for("SYMBOL_GEO_MULTI_LINE_STRING"),D=I.for("SYMBOL_GEO_MULTI_POLYGON"),L=I.for("SERVER_DATE"),j=I.for("REGEXP"),x=I.for("OBJECTID"),M=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},q=function(e){return"object"===M(e)},F=function(e){return"number"===M(e)},B=function(e){return Array.isArray(e)},W=function(e){return"date"===M(e)},H=function(e){return"regexp"===M(e)},G=function(e){return e&&e._internalType instanceof S},V=function(){function e(e){if(!B(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach(function(e){if(!(e instanceof we))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))}),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map(function(e){return e.toJSON().coordinates})},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map(function(e){return e.toJSON().coordinates})}},e.validate=function(e){var t,n;if("LineString"!==e.type||!B(e.coordinates))return!1;try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!F(i[0])||!F(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],n=e.points[e.points.length-1];if(t.latitude===n.latitude&&t.longitude===n.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return R},enumerable:!1,configurable:!0}),e}(),K=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},J=function(){function e(e){if(!B(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach(function(e){if(!(e instanceof V))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"));if(!V.isClosed(e))throw new Error("LineString ".concat(e.points.map(function(e){return e.toReadableString()})," is not a closed cycle"))}),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})}},e.validate=function(e){var t,n,r,o;if("Polygon"!==e.type||!B(e.coordinates))return!1;try{for(var i=K(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var c=(r=void 0,K(a)),u=c.next();!u.done;u=c.next()){var l=u.value;if(!F(l[0])||!F(l[1]))return!1}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return N},enumerable:!1,configurable:!0}),e}(),Y=function(){function e(e){if(!B(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach(function(e){if(!(e instanceof we))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))}),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map(function(e){return e.toJSON().coordinates})},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map(function(e){return e.toJSON().coordinates})}},e.validate=function(e){var t,n;if("MultiPoint"!==e.type||!B(e.coordinates))return!1;try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!F(i[0])||!F(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return k},enumerable:!1,configurable:!0}),e}(),z=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},$=function(){function e(e){if(!B(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach(function(e){if(!(e instanceof V))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"))}),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})}},e.validate=function(e){var t,n,r,o;if("MultiLineString"!==e.type||!B(e.coordinates))return!1;try{for(var i=z(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var c=(r=void 0,z(a)),u=c.next();!u.done;u=c.next()){var l=u.value;if(!F(l[0])||!F(l[1]))return!1}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!1,configurable:!0}),e}(),Q=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},X=function(){function e(e){var t,n;if(!B(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=Q(e),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof J))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof i,"[]"))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map(function(e){return e.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})})},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map(function(e){return e.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})})}},e.validate=function(e){var t,n,r,o,i,s;if("MultiPolygon"!==e.type||!B(e.coordinates))return!1;try{for(var a=Q(e.coordinates),c=a.next();!c.done;c=a.next()){var u=c.value;try{for(var l=(r=void 0,Q(u)),h=l.next();!h.done;h=l.next()){var d=h.value;try{for(var f=(i=void 0,Q(d)),p=f.next();!p.done;p=f.next()){var v=p.value;if(!F(v[0])||!F(v[1]))return!1}}catch(e){i={error:e}}finally{try{p&&!p.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return D},enumerable:!1,configurable:!0}),e}(),Z=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},ee=function(){function e(){}return e.formatResDocumentData=function(t){return t.map(function(t){return e.formatField(t)})},e.formatField=function(t){var n=Object.keys(t),r={};return Array.isArray(t)&&(r=[]),n.forEach(function(n){var o,i=t[n];switch(e.whichType(i)){case u:o=new we(i.coordinates[0],i.coordinates[1]);break;case l:o=new V(i.coordinates.map(function(e){return new we(e[0],e[1])}));break;case h:o=new J(i.coordinates.map(function(e){return new V(e.map(function(e){var t=Z(e,2),n=t[0],r=t[1];return new we(n,r)}))}));break;case d:o=new Y(i.coordinates.map(function(e){return new we(e[0],e[1])}));break;case f:o=new $(i.coordinates.map(function(e){return new V(e.map(function(e){var t=Z(e,2),n=t[0],r=t[1];return new we(n,r)}))}));break;case p:o=new X(i.coordinates.map(function(e){return new J(e.map(function(e){return new V(e.map(function(e){var t=Z(e,2),n=t[0],r=t[1];return new we(n,r)}))}))}));break;case v:o=i;break;case c:case"Array":o=e.formatField(i);break;case y:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o}),r},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);return t===v?v:(t===c&&(e.$date?t=y:we.validate(e)?t=u:V.validate(e)?t=l:J.validate(e)?t=h:Y.validate(e)?t=d:$.validate(e)?t=f:X.validate(e)&&(t=p)),t)},e.generateDocId=function(){for(var e="",t=0;t<24;t++)e+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return e},e}(),te={code:"INVALID_PARAM",message:"Invalid request param"},ne="DATABASE_TRANSACTION_CONFLICT",re={code:"DATABASE_REQUEST_FAILED",message:"database request failed"},oe=n(2701),ie=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),se=function(){return se=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},se.apply(this,arguments)};function ae(e,t){if("function"!=typeof t)return e;e.then(function(e){return t(0,e)},function(e){return t(e)})}var ce={};function ue(e){if(!It.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return ce[t]||(ce[t]=new It.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:It.createRequest(e.config)}}})),ce[t]}var le=function(e){return void 0!==e.timeout?{timeout:e.timeout}:{}},he=function(e){if(!q(e))return e;for(var t in e)void 0===e[t]?delete e[t]:q(e[t])&&(e[t]=he(e[t]));return e},de=function(e){return e=he(e),oe.EJSON.stringify(e,{relaxed:!1})},fe=function(e){var t,n;if(e instanceof Date)return{$date:+e};if(e instanceof RegExp)return{$regex:e.source,$options:e.flags};if(e&&"object"==typeof e){if("ObjectId"===e._bsontype)return{$oid:e.toHexString()};if("BSONRegExp"===e._bsontype)return{$regex:e.pattern,$options:e.options};if(Array.isArray(e))return e.map(fe);var r={};try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(e)),i=o.next();!i.done;i=o.next()){var s=i.value;r[s]=fe(e[s])}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r}return e},pe=function(e){if(!e)return"{}";try{var t=oe.EJSON.parse(e);return JSON.stringify(fe(t))}catch(t){return e}},ve=function(e){function t(t){var n=e.call(this,t.message)||this;return n.code=t.code,n.message=t.message,n}return ie(t,e),t}(Error),ye=function(e){return new ve(e)};function ge(e,t){if(!1===e)return t;throw ye(se({},t))}var me,be=function(){return be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},_e=["limit","offset","projection","order","multiple","timeout","raw"],Ee=function(){function e(){}return e.isGeopoint=function(e,t){if("Number"!==ee.whichType(t))throw new Error("Geo Point must be number type");var n=Math.abs(t);if("latitude"===e&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+o.IntergerError);return!0},e.mustBeBoolean=function(e,t){if("boolean"!=typeof t)throw new Error(e+o.BooleanError);return!0},e.isProjection=function(e,t){if("object"!==M(t))throw ye(be(be({},te),{message:"".concat(e," projection must be an object")}));for(var n in t){var r=t[n];if("number"===M(r)){if(0!==r&&1!==r)throw ye(be(be({},te),{message:"if the value in projection is of number, it must be 0 or 1"}))}else if("object"!==M(r))throw ye(be(be({},te),{message:"invalid projection"}))}return!0},e.isOrder=function(e,t){if("object"!==M(t))throw ye(be(be({},te),{message:"".concat(e," order must be an object")}));for(var n in t){var r=t[n];if(1!==r&&-1!==r)throw ye(be(be({},te),{message:"order value must be 1 or -1"}))}return!0},e.isFieldOrder=function(e){if(-1===g.indexOf(e))throw new Error(o.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===m.indexOf(e))throw new Error(o.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(o.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(o.DocIDError);return!0},e.isValidOptions=function(t){if(void 0===t&&(t={}),"object"!==M(t))throw ye(be(be({},te),{message:"options must be an object"}));var n=Object.keys(t);for(var r in n)if(_e.indexOf(n[r])<0)throw ye(be(be({},te),{message:"".concat(n[r]," is invalid options key")}));var o=t,i=o.limit,s=o.offset,a=o.projection,c=o.order,u=t.multiple;return void 0!==i&&e.isInteger("limit",i),void 0!==s&&e.isInteger("offset",s),void 0!==a&&e.isProjection("projection",a),void 0!==c&&e.isOrder("order",c),void 0!==u&&e.mustBeBoolean("multiple",u),void 0!==t.timeout&&e.isInteger("timeout",t.timeout),!0},e.isValidAggregation=function(e){if(1!==Object.keys(e).length)throw ye(be(be({},te),{message:"aggregation stage must have one key"}));return!0},e.isCentersPhere=function(t){if(Array.isArray(t)&&2===t.length){if("object"===M(t[0])&&t[0]._internalType===C&&"number"==typeof t[1])return!0;if(Array.isArray(t[0])&&2===t[0].length){var n=t[0][0],r=t[0][1];if(e.isGeopoint("longitude",n),e.isGeopoint("latitude",r),"number"==typeof t[1])return!0}}throw new Error("".concat(o.CentersPhereError))},e}(),we=function(){function e(e,t){Ee.isGeopoint("longitude",e),Ee.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"[".concat(this.longitude,",").concat(this.latitude,"]")},e.validate=function(e){return"Point"===e.type&&B(e.coordinates)&&Ee.isGeopoint("longitude",e.coordinates[0])&&Ee.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return C},enumerable:!1,configurable:!0}),e}();!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(me||(me={}));var Se,Ie=function(){function e(e,t,n){this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||O}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function Oe(e){return e&&e instanceof Ie&&e._internalType===A}!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(Se||(Se={}));var Ae=function(){function e(e,t,n){if(this._internalType=P,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||O,this.fieldName!==O)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,o=t.length;r<o;r++)(Te(i=t[r])||Ne(i))&&(t[r]=i._setFieldName(this.fieldName))}else{var i;(Te(i=t)||Ne(i))&&(t=i._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var n=this.operands.map(function(n){return n instanceof e?n._setFieldName(t):n});return new e(this.operator,n,t)},e.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(Se.AND,r,this.fieldName)},e.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(Se.OR,r,this.fieldName)},e}();function Te(e){return e&&e instanceof Ae&&e._internalType===P}var Pe,Ce=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(Pe||(Pe={}));var Re=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.operator=t,o._internalType=T,o}return Ce(t,e),t.prototype.toJSON=function(){var e,t,n;switch(this.operator){case Pe.IN:case Pe.NIN:return(e={})["$"+this.operator]=this.operands,e;case Pe.NEQ:return(t={}).$ne=this.operands[0],t;default:return(n={})["$"+this.operator]=this.operands[0],n}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var n=new t(Pe.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(Pe.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(Pe.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(Pe.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(Pe.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(Pe.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(Pe.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(Pe.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof we))throw new TypeError('"geometry" must be of type Point. Received type '.concat(typeof e.geometry));if(void 0!==e.maxDistance&&!F(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof e.maxDistance));if(void 0!==e.minDistance&&!F(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '.concat(typeof e.minDistance));var n=new t(Pe.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof X||e.geometry instanceof J||Ee.isCentersPhere(e.centerSphere)))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof e.geometry));var n=new t(Pe.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof we||e.geometry instanceof V||e.geometry instanceof J||e.geometry instanceof Y||e.geometry instanceof $||e.geometry instanceof X))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '.concat(typeof e.geometry));var n=new t(Pe.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(Ae);function Ne(e){return e&&e instanceof Re&&e._internalType===T}function ke(e){return Ne(e)}var Ue={};for(var De in Pe)Ue[De]="$"+De;for(var De in Se)Ue[De]="$"+De;for(var De in me)Ue[De]="$"+De;function Le(e){return Ue[e]||"$"+e}Ue[Pe.NEQ]="$ne",Ue[me.REMOVE]="$unset",Ue[me.SHIFT]="$pop",Ue[me.UNSHIFT]="$push";var je=function(){return je=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},je.apply(this,arguments)},xe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},Me=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function qe(e){return Fe(e,[e])}function Fe(e,t){if(!G(e)){if(W(e))return e;if(H(e))return{$regularExpression:{pattern:e.source,options:e.flags}};if(B(e))return e.map(function(e){if(t.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return Fe(e,Me(Me([],xe(t),!1),[e],!1))});if(q(e)){var n=je({},e),r={};for(var o in n){if(t.indexOf(n[o])>-1)throw new Error("Cannot convert circular structure to JSON");void 0!==n[o]&&(r[o]=Fe(n[o],Me(Me([],xe(t),!1),[n[o]],!1)))}return r}return e}switch(e._internalType){case C:return e.toJSON();case L:case j:case x:return e.parse();default:return e.toJSON?e.toJSON():e}}var Be=function(){return Be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Be.apply(this,arguments)},We=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},He=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function Ge(e,t,n,r){var o=Be({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(void 0!==s){if(s&&q(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ge(s,t,He(He([],We(n),!1),[i],!1),He(He([],We(r),!1),[s],!1));o[i]=a;var c=!1;for(var u in a)/^\$/.test(u)?c=!0:(o["".concat(i,".").concat(u)]=a[u],delete o[i][u]);c||delete o[i]}}else delete o[i]}return o}function Ve(e){return Ge(e,Je,[],[e])}function Ke(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?B(e[r])?e[r].push(t[r]):q(e[r])?q(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is ".concat(M(t),", can only overwrite"),t,n),e[r]=t[r]):(console.warn("to-merge query is of type ".concat(M(e),", can only overwrite"),e,t,n),e[r]=t[r]):e[r]=t[r]}function Je(e){return G(e)||W(e)||H(e)}function Ye(e){return qe(e)}var ze=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.encodeEJSON=function(t,n){var r=new e;return de(n?t:r.encodeUpdate(t))},e.prototype.encodeUpdate=function(e){return Oe(e)?this.encodeUpdateCommand(e):"object"===M(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case me.PUSH:case me.PULL:case me.PULL_ALL:case me.POP:case me.SHIFT:case me.UNSHIFT:case me.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,o,i=Le(e.operator);return e.operator===me.REMOVE?((t={})[i]=((n={})[e.fieldName]="",n),t):((r={})[i]=((o={})[e.fieldName]=e.operands[0],o),r)},e.prototype.encodeArrayUpdateCommand=function(e){var t,n,r,o,i,s,a,c,u,l,h=Le(e.operator);switch(e.operator){case me.PUSH:var d=void 0;return d=B(e.operands)?{$each:e.operands.map(Ye)}:e.operands,(t={})[h]=((n={})[e.fieldName]=d,n),t;case me.UNSHIFT:return d={$each:e.operands.map(Ye),$position:0},(r={})[h]=((o={})[e.fieldName]=d,o),r;case me.POP:return(i={})[h]=((s={})[e.fieldName]=1,s),i;case me.SHIFT:return(a={})[h]=((c={})[e.fieldName]=-1,c),a;default:return(u={})[h]=((l={})[e.fieldName]=Ye(e.operands),l),u}},e.prototype.encodeUpdateObject=function(e){var t=Ve(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(Oe(r))t[n]=r._setFieldName(n),Ke(t,this.encodeUpdateCommand(t[n]),n);else{t[n]=r=Ye(r);var o=new Ie(me.SET,[r],n);Ke(t,this.encodeUpdateCommand(o),n)}}return t},e}(),$e=function(){return $e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},$e.apply(this,arguments)},Qe=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},Xe=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Ze=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){return ue(i._db).watch($e($e({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify({_id:i.id})}))},this._db=e,this._coll=t,this.id=r,this._transactionId=o,this.request=It.createRequest(this._db.config),this._apiOptions=n}return e.prototype.create=function(e,t){return ae(this._create(e),t)},e.prototype._create=function(e){return Qe(this,void 0,void 0,function(){var t,n,r;return Xe(this,function(o){switch(o.label){case 0:return!(t=Array.isArray(e))&&this.id&&(e._id=this.id),n={collectionName:this._coll,data:t?e.map(function(e){return de(qe(e))}):[de(qe(e))],transactionId:this._transactionId},[4,this.request.send("database.insertDocument",n,le(this._apiOptions))];case 1:return(r=o.sent()).code?[2,r]:this._transactionId?[2,{inserted:1,ok:1,id:r.data.insertedIds[0],requestId:r.requestId}]:t?[2,{ids:r.data&&r.data.insertedIds||[],requestId:r.requestId}]:[2,{id:r.data.insertedIds[0],requestId:r.requestId}]}})})},e.prototype.set=function(e,t){return ae(this._set(e),t)},e.prototype._set=function(e){return Qe(this,void 0,void 0,function(){var t,n,r,o;return Xe(this,function(i){switch(i.label){case 0:return this.id?e&&"object"==typeof e?e.hasOwnProperty("_id")?[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"不能更新_id的值"}))]:(t=!1,n=function(e){if("object"==typeof e)for(var r in e)e[r]instanceof Ie?t=!0:"object"==typeof e[r]&&n(e[r])},n(e),t?[2,ge(this._db.config.throwOnCode,$e($e({},re),{message:"update operator complicit"}))]:(r={collectionName:this._coll,queryType:a.DOC,data:de(qe(e)),transactionId:this._transactionId,multi:!1,merge:!1,upsert:!0},this.id&&(r.query=de({_id:this.id})),[4,this.request.send("database.modifyDocument",r,le(this._apiOptions))])):[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"参数必需是非空对象"}))]:[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"docId不能为空"}))];case 1:return(o=i.sent()).code?[2,o]:this._transactionId?[2,{updated:o.data.updated,upserted:[{_id:o.data.upsert_id}],requestId:o.requestId}]:[2,{updated:o.data.updated,upsertedId:o.data.upsert_id,requestId:o.requestId}]}})})},e.prototype.update=function(e,t){return ae(this._update(e),t)},e.prototype._update=function(e){return Qe(this,void 0,void 0,function(){var t,n,r;return Xe(this,function(o){switch(o.label){case 0:return e&&"object"==typeof e?e.hasOwnProperty("_id")?[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"不能更新_id的值"}))]:(t=de({_id:this.id}),n={collectionName:this._coll,transactionId:this._transactionId,data:ze.encodeEJSON(e,this._apiOptions.raw||!1),query:t,queryType:a.DOC,multi:!1,merge:!0,upsert:!1},[4,this.request.send("database.modifyDocument",n,le(this._apiOptions))]):[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"参数必需是非空对象"}))];case 1:return(r=o.sent()).code?[2,r]:[2,{updated:r.data.updated,requestId:r.requestId}]}})})},e.prototype.delete=function(e){return this.remove(e)},e.prototype.remove=function(e){return ae(this._remove(),e)},e.prototype._remove=function(){return Qe(this,void 0,void 0,function(){var e,t,n;return Xe(this,function(r){switch(r.label){case 0:return e=de({_id:this.id}),t={collectionName:this._coll,transactionId:this._transactionId,query:e,queryType:a.DOC,multi:!1},[4,this.request.send("database.removeDocument",t,le(this._apiOptions))];case 1:return(n=r.sent()).code?[2,n]:[2,{deleted:n.data.deleted,requestId:n.requestId}]}})})},e.prototype.get=function(e){return ae(this._get(),e)},e.prototype._get=function(){return Qe(this,void 0,void 0,function(){var e,t,n,r,o,i;return Xe(this,function(s){switch(s.label){case 0:return e=de({_id:this.id}),t=this._apiOptions.projection,n={collectionName:this._coll,query:e,transactionId:this._transactionId,queryType:a.DOC,multi:!1},t&&(n.projection=de(t)),[4,this.request.send("database.getDocument",n,le(this._apiOptions))];case 1:return(r=s.sent()).code?[2,r]:(o=r.data.list.map(function(e){return oe.EJSON.parse(e)}),i=ee.formatResDocumentData(o),this._transactionId?[2,{data:i[0]||null,requestId:r.requestId}]:[2,{data:i,requestId:r.requestId}])}})})},e.prototype.field=function(t){var n={};for(var r in t)"boolean"==typeof t[r]&&(n[r]=!0===t[r]?1:0),"number"==typeof t[r]&&(n[r]=t[r]>0?1:0),"object"==typeof t[r]&&(n[r]=t[r]);var o=$e({},this._apiOptions);return o.projection=n,new e(this._db,this._coll,o,this.id,this._transactionId)},e}(),et=function(){function e(){}return e.encode=function(e){return(new tt).encodeQuery(e)},e.encodeEJSON=function(e,t){var n=new tt;return de(t?e:n.encodeQuery(e))},e}(),tt=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n,r,o;return Je(e)?Te(e)?this.encodeLogicCommand(e):Ne(e)?this.encodeQueryCommand(e):H(e)?((n={})[t]=this.encodeRegExp(e),n):W(e)?((r={})[t]=Ye(e),r):((o={})[t]=this.encodeQueryObject(e),o):q(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regularExpression:{pattern:e.source,options:e.flags}}},e.prototype.encodeLogicCommand=function(e){var t,n,r,o,i,s,a,c=this;switch(e.operator){case Se.NOR:case Se.AND:case Se.OR:var u=Le(e.operator),l=e.operands.map(function(t){return c.encodeQuery(t,e.fieldName)});return(t={})[u]=l,t;case Se.NOT:u=Le(e.operator);var h=e.operands[0];return H(h)?((n={})[e.fieldName]=((r={})[u]=this.encodeRegExp(h),r),n):(l=this.encodeQuery(h)[e.fieldName],(o={})[e.fieldName]=((i={})[u]=l,i),o);default:if(u=Le(e.operator),1===e.operands.length){var d=this.encodeQuery(e.operands[0]);return(s={})[u]=d,s}return l=e.operands.map(this.encodeQuery.bind(this)),(a={})[u]=l,a}},e.prototype.encodeQueryCommand=function(e){return ke(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,o,i,s,a,c,u,l,h;if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var d=Le(e.operator);switch(e.operator){case Pe.EQ:case Pe.NEQ:case Pe.LT:case Pe.LTE:case Pe.GT:case Pe.GTE:case Pe.ELEM_MATCH:case Pe.EXISTS:case Pe.SIZE:case Pe.MOD:return(t={})[e.fieldName]=((n={})[d]=Ye(e.operands[0]),n),t;case Pe.IN:case Pe.NIN:case Pe.ALL:return(r={})[e.fieldName]=((o={})[d]=Ye(e.operands),o),r;case Pe.GEO_NEAR:var f=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:f.geometry.toJSON(),$maxDistance:f.maxDistance,$minDistance:f.minDistance}},i;case Pe.GEO_WITHIN:if((f=e.operands[0]).centerSphere){Ee.isCentersPhere(f.centerSphere);var p=f.centerSphere;return p[0]._internalType===C?((s={})[e.fieldName]={$geoWithin:{$centerSphere:[p[0].toJSON().coordinates,p[1]]}},s):((a={})[e.fieldName]={$geoWithin:{$centerSphere:f.centerSphere}},a)}return(c={})[e.fieldName]={$geoWithin:{$geometry:f.geometry.toJSON()}},c;case Pe.GEO_INTERSECTS:return f=e.operands[0],(u={})[e.fieldName]={$geoIntersects:{$geometry:f.geometry.toJSON()}},u;default:return(l={})[e.fieldName]=((h={})[d]=Ye(e.operands[0]),h),l}},e.prototype.encodeQueryObject=function(e){var t=Ve(e);for(var n in t){var r=t[n];if(Te(r)){t[n]=r._setFieldName(n);var o=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else ke(r)?(t[n]=r._setFieldName(n),o=this.encodeComparisonCommand(t[n]),this.mergeConditionAfterEncode(t,o,n)):Je(r)&&(t[n]=Ye(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?B(e[r])?e[r]=e[r].concat(t[r]):q(e[r])?q(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is ".concat(M(t),", can only overwrite"),t,n),e[r]=t[r]):(console.warn("to-merge query is of type ".concat(M(e),", can only overwrite"),e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),nt=function(){return nt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},nt.apply(this,arguments)},rt=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},ot=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},it=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){var t=ue(i._db),n=i._apiOptions,r=n.limit,o=n.order,s=o?Object.entries(o).reduce(function(e,t){var n=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}(t,2),r=n[0],o=n[1];return e[r]=-1===o?"desc":"asc",e},{}):void 0;return t.watch(nt(nt({},e),{envId:i._db.config.env,collectionName:i._coll,query:pe(i._fieldFilters),limit:r,orderBy:s}))},this._db=e,this._coll=t,this._fieldFilters=n,this._apiOptions=r||{},this._request=It.createRequest(this._db.config),this._transactionId=o}return e.prototype.get=function(e){return ae(this._get(),e)},e.prototype._get=function(){return rt(this,void 0,void 0,function(){var e,t,n,r,o,i,s,c,u;return ot(this,function(l){switch(l.label){case 0:return e=this._apiOptions.order,t={collectionName:this._coll,queryType:a.WHERE,transactionId:this._transactionId},this._fieldFilters&&(t.query=this._fieldFilters),e&&(t.order=de(e)),(n=this._apiOptions.offset)&&(t.offset=n),r=this._apiOptions.limit,t.limit=r?r<1e3?r:1e3:100,(o=this._apiOptions.projection)&&(t.projection=de(o)),[4,this._request.send("database.getDocument",t,le(this._apiOptions))];case 1:return(i=l.sent()).code?[2,i]:(s=i.data.list.map(function(e){return oe.EJSON.parse(e)}),c=ee.formatResDocumentData(s),u={data:c,requestId:i.requestId},i.total&&(u.total=i.total),i.limit&&(u.limit=i.limit),i.offset&&(u.offset=i.offset),[2,u])}})})},e.prototype.count=function(e){return ae(this._count(),e)},e.prototype._count=function(){return rt(this,void 0,void 0,function(){var e,t;return ot(this,function(n){switch(n.label){case 0:return e={collectionName:this._coll,queryType:a.WHERE},this._fieldFilters&&(e.query=this._fieldFilters),[4,this._request.send("database.calculateDocument",e,le(this._apiOptions))];case 1:return(t=n.sent()).code?[2,t]:[2,{requestId:t.requestId,total:t.data.total}]}})})},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(t),r=n.some(function(e){return void 0!==t[e]});if(n.length&&!r)throw Error(o.QueryParamValueError);return new e(this._db,this._coll,et.encodeEJSON(t,this._apiOptions.raw||!1),this._apiOptions,this._transactionId)},e.prototype.options=function(t){return Ee.isValidOptions(t),new e(this._db,this._coll,this._fieldFilters,t,this._transactionId)},e.prototype.orderBy=function(t,n){var r;Ee.isFieldPath(t),Ee.isFieldOrder(n);var o=((r={})[t]="desc"===n?-1:1,r),i=this._apiOptions.order||{},s=Object.assign({},this._apiOptions,{order:Object.assign({},i,o)});return new e(this._db,this._coll,this._fieldFilters,s,this._transactionId)},e.prototype.limit=function(t){Ee.isInteger("limit",t);var n=nt({},this._apiOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,n,this._transactionId)},e.prototype.skip=function(t){Ee.isInteger("offset",t);var n=nt({},this._apiOptions);return n.offset=t,new e(this._db,this._coll,this._fieldFilters,n,this._transactionId)},e.prototype.update=function(e,t){return ae(this._update(e),t)},e.prototype._update=function(e){return rt(this,void 0,void 0,function(){var t,n,r,o;return ot(this,function(i){switch(i.label){case 0:return e&&"object"==typeof e?e.hasOwnProperty("_id")?[2,ge(this._db.config.throwOnCode,nt(nt({},te),{message:"不能更新_id的值"}))]:(t=this._apiOptions.multiple,n=void 0===t||t,r={collectionName:this._coll,queryType:a.WHERE,multi:n,merge:!0,upsert:!1,data:ze.encodeEJSON(e,this._apiOptions.raw||!1)},this._transactionId&&(r.transactionId=this._transactionId),this._fieldFilters&&(r.query=this._fieldFilters),[4,this._request.send("database.modifyDocument",r,le(this._apiOptions))]):[2,ge(this._db.config.throwOnCode,nt(nt({},te),{message:"参数必需是非空对象"}))];case 1:return(o=i.sent()).code?[2,o]:[2,{requestId:o.requestId,updated:o.data.updated,upsertId:o.data.upsert_id}]}})})},e.prototype.field=function(t){var n={};for(var r in t)"boolean"==typeof t[r]&&(n[r]=!0===t[r]?1:0),"number"==typeof t[r]&&(n[r]=t[r]>0?1:0),"object"==typeof t[r]&&(n[r]=t[r]);var o=nt({},this._apiOptions);return o.projection=n,new e(this._db,this._coll,this._fieldFilters,o,this._transactionId)},e.prototype.remove=function(e){return ae(this._remove(),e)},e.prototype._remove=function(){return rt(this,void 0,void 0,function(){var e,t,n,r,o,i,s,c,u;return ot(this,function(l){switch(l.label){case 0:return e=this._apiOptions,t=e.offset,n=e.limit,r=e.projection,o=e.order,void 0===t&&void 0===n&&void 0===r&&void 0===o||console.warn("`offset`, `limit`, `projection`, `orderBy` are not supported in remove() operation"),i=this._apiOptions.multiple,s=void 0===i||i,c={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:s},this._transactionId&&(c.transactionId=this._transactionId),[4,this._request.send("database.removeDocument",c,le(this._apiOptions))];case 1:return(u=l.sent()).code?[2,u]:[2,{requestId:u.requestId,deleted:u.data.deleted}]}})})},e.prototype.updateAndReturn=function(e){return rt(this,void 0,void 0,function(){var t,n;return ot(this,function(r){switch(r.label){case 0:return e&&"object"==typeof e?e.hasOwnProperty("_id")?[2,ge(this._db.config.throwOnCode,nt(nt({},te),{message:"不能更新_id的值"}))]:(t={collectionName:this._coll,queryType:a.WHERE,data:ze.encodeEJSON(e,!1)},this._transactionId&&(t.transactionId=this._transactionId),this._fieldFilters&&(t.query=this._fieldFilters),[4,this._request.send("database.modifyAndReturnDoc",t,le(this._apiOptions))]):[2,ge(this._db.config.throwOnCode,nt(nt({},te),{message:"参数必需是非空对象"}))];case 1:return(n=r.sent()).code?[2,n]:[2,{requestId:n.requestId,updated:n.data.updated,doc:n.data.doc&&oe.EJSON.parse(n.data.doc)}]}})})},e}(),st=function(){function e(e,t,n){var r=this;this._stages=[],e&&t&&(this._db=e,this._request=It.createRequest(this._db.config),this._collectionName=t,n&&n.length>0&&n.forEach(function(e){Ee.isValidAggregation(e);var t=Object.keys(e)[0];r._pipe(t,e[t],!0)}))}return e.prototype.end=function(){return e=this,t=void 0,r=function(){var e;return function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,function(t){switch(t.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregateDocuments",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:e.data.list.map(oe.EJSON.parse)}]:[2,e]}})},new((n=void 0)||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())});var e,t,n,r},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map(function(e){var t,n=e.stageKey,r=e.stageValue;return(t={})[n]=JSON.parse(r),t})},e.prototype._pipe=function(e,t,n){void 0===n&&(n=!1);var r;return r="object"===M(t)?de(t):JSON.stringify(t),this._stages.push({stageKey:n?e:"$".concat(e),stageValue:r}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return e.query&&(e.query=et.encode(e.query)),e.distanceMultiplier&&"number"==typeof e.distanceMultiplier&&(e.distanceMultiplier=e.distanceMultiplier),e.near&&(e.near=new we(e.near.longitude,e.near.latitude).toJSON()),this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",et.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),at=st,ct=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ut=function(e){function t(t,n,r,o){var i=e.call(this,t,n,"",r,o)||this;return o&&(i._transactionId=o),i}return ct(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new Ze(this._db,this._coll,this._apiOptions,e,this._transactionId)},t.prototype.add=function(e,t){return ae(this._add(e),t)},t.prototype._add=function(e){return t=this,n=void 0,o=function(){var t,n,r;return function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,function(o){switch(o.label){case 0:return t=e,B(e)||(t=[e]),t=t.map(function(e){return de(qe(e))}),n={collectionName:this._coll,data:t},this._transactionId&&(n.transactionId=this._transactionId),[4,this._request.send("database.insertDocument",n,le(this._apiOptions))];case 1:return(r=o.sent()).code?[2,r]:B(e)?[2,{ids:r.data.insertedIds,requestId:r.requestId}]:this._transactionId?[2,{inserted:1,ok:1,id:r.data.insertedIds[0],requestId:r.requestId}]:[2,{id:r.data.insertedIds[0],requestId:r.requestId}]}})},new((r=void 0)||(r=Promise))(function(e,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(s,a)}c((o=o.apply(t,n||[])).next())});var t,n,r,o},t.prototype.aggregate=function(e){return void 0===e&&(e=[]),new at(this._db,this._coll,this._apiOptions.raw?e:[])},t.prototype.options=function(e){return Ee.isValidOptions(e),new t(this._db,this._coll,e,this._transactionId)},t}(it),lt={eq:function(e){return new Re(Pe.EQ,[e])},neq:function(e){return new Re(Pe.NEQ,[e])},lt:function(e){return new Re(Pe.LT,[e])},lte:function(e){return new Re(Pe.LTE,[e])},gt:function(e){return new Re(Pe.GT,[e])},gte:function(e){return new Re(Pe.GTE,[e])},in:function(e){return new Re(Pe.IN,e)},nin:function(e){return new Re(Pe.NIN,e)},all:function(e){return new Re(Pe.ALL,e)},elemMatch:function(e){return new Re(Pe.ELEM_MATCH,[e])},exists:function(e){return new Re(Pe.EXISTS,[e])},size:function(e){return new Re(Pe.SIZE,[e])},mod:function(){return new Re(Pe.MOD,1==arguments.length?[arguments[0]]:2==arguments.length?[[arguments[0],arguments[1]]]:arguments)},geoNear:function(e){return new Re(Pe.GEO_NEAR,[e])},geoWithin:function(e){return new Re(Pe.GEO_WITHIN,[e])},geoIntersects:function(e){return new Re(Pe.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ae(Se.AND,n)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ae(Se.NOR,n)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ae(Se.OR,n)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ae(Se.NOT,n)},set:function(e){return new Ie(me.SET,[e])},remove:function(){return new Ie(me.REMOVE,[])},inc:function(e){return new Ie(me.INC,[e])},mul:function(e){return new Ie(me.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(q(t[0])&&t[0].hasOwnProperty("each")){e={};var r=t[0];void 0!==r.each&&(e.$each=r.each),void 0!==r.position&&(e.$position=r.position),void 0!==r.sort&&(e.$sort=r.sort),void 0!==r.slice&&(e.$slice=r.slice)}else e=B(t[0])?t[0]:Array.from(t);return new Ie(me.PUSH,e)},pull:function(e){return new Ie(me.PULL,e)},pullAll:function(e){return new Ie(me.PULL_ALL,e)},pop:function(){return new Ie(me.POP,[])},shift:function(){return new Ie(me.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ie(me.UNSHIFT,n)},addToSet:function(e){return new Ie(me.ADD_TO_SET,e)},rename:function(e){return new Ie(me.RENAME,[e])},bit:function(e){return new Ie(me.BIT,[e])},max:function(e){return new Ie(me.MAX,[e])},min:function(e){return new Ie(me.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===M(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new at},abs:function(e){return new ht("abs",e)},add:function(e){return new ht("add",e)},ceil:function(e){return new ht("ceil",e)},divide:function(e){return new ht("divide",e)},exp:function(e){return new ht("exp",e)},floor:function(e){return new ht("floor",e)},ln:function(e){return new ht("ln",e)},log:function(e){return new ht("log",e)},log10:function(e){return new ht("log10",e)},mod:function(e){return new ht("mod",e)},multiply:function(e){return new ht("multiply",e)},pow:function(e){return new ht("pow",e)},sqrt:function(e){return new ht("sqrt",e)},subtract:function(e){return new ht("subtract",e)},trunc:function(e){return new ht("trunc",e)},arrayElemAt:function(e){return new ht("arrayElemAt",e)},arrayToObject:function(e){return new ht("arrayToObject",e)},concatArrays:function(e){return new ht("concatArrays",e)},filter:function(e){return new ht("filter",e)},in:function(e){return new ht("in",e)},indexOfArray:function(e){return new ht("indexOfArray",e)},isArray:function(e){return new ht("isArray",e)},map:function(e){return new ht("map",e)},range:function(e){return new ht("range",e)},reduce:function(e){return new ht("reduce",e)},reverseArray:function(e){return new ht("reverseArray",e)},size:function(e){return new ht("size",e)},slice:function(e){return new ht("slice",e)},zip:function(e){return new ht("zip",e)},and:function(e){return new ht("and",e)},not:function(e){return new ht("not",e)},or:function(e){return new ht("or",e)},cmp:function(e){return new ht("cmp",e)},eq:function(e){return new ht("eq",e)},gt:function(e){return new ht("gt",e)},gte:function(e){return new ht("gte",e)},lt:function(e){return new ht("lt",e)},lte:function(e){return new ht("lte",e)},neq:function(e){return new ht("ne",e)},cond:function(e){return new ht("cond",e)},ifNull:function(e){return new ht("ifNull",e)},switch:function(e){return new ht("switch",e)},dateFromParts:function(e){return new ht("dateFromParts",e)},dateFromString:function(e){return new ht("dateFromString",e)},dayOfMonth:function(e){return new ht("dayOfMonth",e)},dayOfWeek:function(e){return new ht("dayOfWeek",e)},dayOfYear:function(e){return new ht("dayOfYear",e)},isoDayOfWeek:function(e){return new ht("isoDayOfWeek",e)},isoWeek:function(e){return new ht("isoWeek",e)},isoWeekYear:function(e){return new ht("isoWeekYear",e)},millisecond:function(e){return new ht("millisecond",e)},minute:function(e){return new ht("minute",e)},month:function(e){return new ht("month",e)},second:function(e){return new ht("second",e)},hour:function(e){return new ht("hour",e)},week:function(e){return new ht("week",e)},year:function(e){return new ht("year",e)},literal:function(e){return new ht("literal",e)},mergeObjects:function(e){return new ht("mergeObjects",e)},objectToArray:function(e){return new ht("objectToArray",e)},allElementsTrue:function(e){return new ht("allElementsTrue",e)},anyElementTrue:function(e){return new ht("anyElementTrue",e)},setDifference:function(e){return new ht("setDifference",e)},setEquals:function(e){return new ht("setEquals",e)},setIntersection:function(e){return new ht("setIntersection",e)},setIsSubset:function(e){return new ht("setIsSubset",e)},setUnion:function(e){return new ht("setUnion",e)},concat:function(e){return new ht("concat",e)},dateToString:function(e){return new ht("dateToString",e)},indexOfBytes:function(e){return new ht("indexOfBytes",e)},indexOfCP:function(e){return new ht("indexOfCP",e)},split:function(e){return new ht("split",e)},strLenBytes:function(e){return new ht("strLenBytes",e)},strLenCP:function(e){return new ht("strLenCP",e)},strcasecmp:function(e){return new ht("strcasecmp",e)},substr:function(e){return new ht("substr",e)},substrBytes:function(e){return new ht("substrBytes",e)},substrCP:function(e){return new ht("substrCP",e)},toLower:function(e){return new ht("toLower",e)},toUpper:function(e){return new ht("toUpper",e)},meta:function(e){return new ht("meta",e)},addToSet:function(e){return new ht("addToSet",e)},avg:function(e){return new ht("avg",e)},first:function(e){return new ht("first",e)},last:function(e){return new ht("last",e)},max:function(e){return new ht("max",e)},min:function(e){return new ht("min",e)},push:function(e){return new ht("push",e)},stdDevPop:function(e){return new ht("stdDevPop",e)},stdDevSamp:function(e){return new ht("stdDevSamp",e)},sum:function(e){return new ht("sum",e)},let:function(e){return new ht("let",e)}},project:{slice:function(e){return new dt("slice",e)},elemMatch:function(e){return new dt("elemMatch",e)}}},ht=function(e,t){this["$"+e]=t},dt=function(e,t){this["$"+e]=t},ft=function(){function e(e){var t=(void 0===e?{}:e).offset,n=void 0===t?0:t;this.offset=n}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return L},enumerable:!1,configurable:!0}),e.prototype.parse=function(){return{$tcb_server_date:{offset:this.offset}}},e}();function pt(e){return new ft(e)}var vt=function(){function e(e){var t=e.regexp,n=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regularExpression={pattern:t||"",options:n||""}}return e.prototype.parse=function(){return{$regularExpression:{pattern:this.$regularExpression.pattern,options:this.$regularExpression.options}}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return j},enumerable:!1,configurable:!0}),e}();function yt(e){return new vt(e)}var gt=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},mt=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},bt=function(){function e(e){this._db=e,this._request=It.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return gt(this,void 0,void 0,function(){var e;return mt(this,function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}})})},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new ut(this._db,e,{},this._id)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return gt(this,void 0,void 0,function(){var e,t;return mt(this,function(n){switch(n.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=n.sent()).code)throw t;return this.commited=!0,[2,t]}})})},e.prototype.rollback=function(e){return gt(this,void 0,void 0,function(){var t,n;return mt(this,function(r){switch(r.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=e,[2,n]}})})},e}();function _t(){return gt(this,void 0,void 0,function(){var e;return mt(this,function(t){switch(t.label){case 0:return[4,(e=new bt(this)).init()];case 1:return t.sent(),[2,e]}})})}function Et(e,t){return void 0===t&&(t=3),gt(this,void 0,void 0,function(){var n,r,o,i,s=this;return mt(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new bt(this)).init()];case 1:return a.sent(),[4,e(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(e){return gt(s,void 0,void 0,function(){return mt(this,function(t){switch(t.label){case 0:if(n.aborted||n.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===n.aborted)throw n.abortReason;throw e}})})},t<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===ne?[4,Et.bind(this)(e,--t)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}})})}var wt=function(){function e(e){var t=(void 0===e?{}:e).id,n=void 0===t?"":t;this.id=n}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return x},enumerable:!1,configurable:!0}),e.prototype.parse=function(){return{$oid:this.id}},e}();function St(e){return new wt(e)}var It=function(){function e(e){this.config=e,this.Geo=i,this.serverDate=pt,this.command=lt,this.RegExp=yt,this.ObjectId=St,this.startTransaction=_t,this.runTransaction=Et,this.logicCommand=Ae,this.updateCommand=Ie,this.queryCommand=Re}return e.createRequest=function(t){var n=new e.reqClass(t),r=n.send;return n.send=function(e,n){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];return n&&(t.instance&&(n.instance=t.instance),t.database&&(n.database=t.database)),r.call.apply(r,function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([this,e,n],function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}(o),!1))},n},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new ut(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return e.createRequest(this.config).send("database.addCollection",n)},e}()},3388:function(e){e.exports={}},1012:function(e,t,n){"use strict";var r;if(n.r(t),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function j(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function x(e,t){return e&t}function M(e,t){return e|t}function q(e,t){return e^t}function F(e,t){return e&~t}function B(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function W(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function H(e){var t,n,r="";for(t=0;t+3<=e.length;t+=3)n=parseInt(e.substring(t,t+3),16),r+=i.charAt(n>>6)+i.charAt(63&n);for(t+1==e.length?(n=parseInt(e.substring(t,t+1),16),r+=i.charAt(n<<2)):t+2==e.length&&(n=parseInt(e.substring(t,t+2),16),r+=i.charAt(n>>2)+i.charAt((3&n)<<4));(3&r.length)>0;)r+="=";return r}function G(e){var t,n="",r=0,o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var s=i.indexOf(e.charAt(t));s<0||(0==r?(n+=j(s>>2),o=3&s,r=1):1==r?(n+=j(o<<2|s>>4),o=15&s,r=2):2==r?(n+=j(o),n+=j(s>>2),o=3&s,r=3):(n+=j(o<<2|s>>4),n+=j(15&s),r=0))}return 1==r&&(n+=j(o<<2)),n}var s,a,c={decode:function(e){var t;if(void 0===s){var n="0123456789ABCDEF";for(s={},t=0;t<16;++t)s[n.charAt(t)]=t;for(n=n.toLowerCase(),t=10;t<16;++t)s[n.charAt(t)]=t;for(t=0;t<8;++t)s[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],o=0,i=0;for(t=0;t<e.length;++t){var a=e.charAt(t);if("="==a)break;if(-1!=(a=s[a])){if(void 0===a)throw new Error("Illegal character at offset "+t);o|=a,++i>=2?(r[r.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return r}},u={decode:function(e){var t;if(void 0===a){for(a=Object.create(null),t=0;t<64;++t)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)a["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],r=0,o=0;for(t=0;t<e.length;++t){var i=e.charAt(t);if("="==i)break;if(-1!=(i=a[i])){if(void 0===i)throw new Error("Illegal character at offset "+t);r|=i,++o>=4?(n[n.length]=r>>16,n[n.length]=r>>8&255,n[n.length]=255&r,r=0,o=0):r<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=r>>10;break;case 3:n[n.length]=r>>16,n[n.length]=r>>8&255}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(e){var t=u.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return u.decode(e)}},l=1e13;class V{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var n,r,o=this.buf,i=o.length;for(n=0;n<i;++n)(r=o[n]*e+t)<l?t=0:r-=(t=0|r/l)*l,o[n]=r;t>0&&(o[n]=t)}sub(e){var t,n,r=this.buf,o=r.length;for(t=0;t<o;++t)(n=r[t]-e)<0?(n+=l,e=1):e=0,r[t]=n;for(;0===r[r.length-1];)r.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,n=t[t.length-1].toString(),r=t.length-2;r>=0;--r)n+=(l+t[r]).toString().substring(1);return n}valueOf(){for(var e=this.buf,t=0,n=e.length-1;n>=0;--n)t=t*l+e[n];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var h,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,f=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function K(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class J{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof J?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,n){for(var r="",o=e;o<t;++o)if(r+=this.hexByte(this.get(o)),!0!==n)switch(15&o){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r}isASCII(e,t){for(var n=e;n<t;++n){var r=this.get(n);if(r<32||r>176)return!1}return!0}parseStringISO(e,t){for(var n="",r=e;r<t;++r)n+=String.fromCharCode(this.get(r));return n}parseStringUTF(e,t){for(var n="",r=e;r<t;){var o=this.get(r++);n+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(r++)):String.fromCharCode((15&o)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return n}parseStringBMP(e,t){for(var n,r,o="",i=e;i<t;)n=this.get(i++),r=this.get(i++),o+=String.fromCharCode(n<<8|r);return o}parseTime(e,t,n){var r=this.parseStringISO(e,t),o=(n?d:f).exec(r);return o?(n&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),r=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(r+=":"+o[5],o[6]&&(r+=":"+o[6],o[7]&&(r+="."+o[7]))),o[8]&&(r+=" UTC","Z"!=o[8]&&(r+=o[8],o[9]&&(r+=":"+o[9]))),r):"Unrecognized time: "+r}parseInteger(e,t){for(var n,r=this.get(e),o=r>127,i=o?255:0,s="";r==i&&++e<t;)r=this.get(e);if(0===(n=t-e))return o?-1:0;if(n>4){for(s=r,n<<=3;!(128&(+s^i));)s=+s<<1,--n;s="("+n+" bit)\n"}o&&(r-=256);for(var a=new V(r),c=e+1;c<t;++c)a.mulAdd(256,this.get(c));return s+a.toString()}parseBitString(e,t,n){for(var r=this.get(e),o="("+((t-e-1<<3)-r)+" bit)\n",i="",s=e+1;s<t;++s){for(var a=this.get(s),c=s==t-1?r:0,u=7;u>=c;--u)i+=a>>u&1?"1":"0";if(i.length>n)return o+K(i,n)}return o+i}parseOctetString(e,t,n){if(this.isASCII(e,t))return K(this.parseStringISO(e,t),n);var r=t-e,o="("+r+" byte)\n";r>(n/=2)&&(t=e+n);for(var i=e;i<t;++i)o+=this.hexByte(this.get(i));return r>n&&(o+="…"),o}parseOID(e,t,n){for(var r="",o=new V,i=0,s=e;s<t;++s){var a=this.get(s);if(o.mulAdd(128,127&a),i+=7,!(128&a)){if(""===r)if((o=o.simplify())instanceof V)o.sub(80),r="2."+o.toString();else{var c=o<80?o<40?0:1:2;r=c+"."+(o-40*c)}else r+="."+o.toString();if(r.length>n)return K(r,n);o=new V,i=0}}return i>0&&(r+=".incomplete"),r}}class Y{constructor(e,t,n,r,o){if(!(r instanceof z))throw new Error("Invalid tag value.");this.stream=e,this.header=t,this.length=n,this.tag=r,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),n=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+n,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+n);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+n,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+n,e);case 6:return this.stream.parseOID(t,t+n,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return K(this.stream.parseStringUTF(t,t+n),e);case 18:case 19:case 20:case 21:case 22:case 26:return K(this.stream.parseStringISO(t,t+n),e);case 30:return K(this.stream.parseStringBMP(t,t+n),e);case 23:case 24:return this.stream.parseTime(t,t+n,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var n=0,r=this.sub.length;n<r;++n)t+=this.sub[n].toPrettyString(e)}return t}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(e){var t=e.get(),n=127&t;if(n==t)return n;if(n>6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(0===n)return null;t=0;for(var r=0;r<n;++r)t=256*t+e.get();return t}getHexStringValue(){var e=this.toHexString(),t=2*this.header,n=2*this.length;return e.substr(t,n)}static decode(e){var t;t=e instanceof J?e:new J(e,0);var n=new J(t),r=new z(t),o=Y.decodeLength(t),i=t.pos,s=i-n.pos,a=null,c=function(){var e=[];if(null!==o){for(var n=i+o;t.pos<n;)e[e.length]=Y.decode(t);if(t.pos!=n)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var r=Y.decode(t);if(r.tag.isEOC())break;e[e.length]=r}o=i-t.pos}catch(e){throw new Error("Exception while decoding undefined length content: "+e)}return e};if(r.tagConstructed)a=c();else if(r.isUniversal()&&(3==r.tagNumber||4==r.tagNumber))try{if(3==r.tagNumber&&0!=t.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=c();for(var u=0;u<a.length;++u)if(a[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(e){a=null}if(null===a){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+i);t.pos=i+Math.abs(o)}return new Y(n,s,o,r,a)}}class z{constructor(e){var t=e.get();if(this.tagClass=t>>6,this.tagConstructed=!!(32&t),this.tagNumber=31&t,31==this.tagNumber){var n=new V;do{t=e.get(),n.mulAdd(128,127&t)}while(128&t);this.tagNumber=n.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/p[p.length-1];class ${constructor(e,t,n){null!=e&&("number"==typeof e?this.fromNumber(e,t,n):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}toString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var n,r=(1<<t)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(n=this[s]>>a)>0&&(o=!0,i=j(n));s>=0;)a<t?(n=(this[s]&(1<<a)-1)<<t-a,n|=this[--s]>>(a+=this.DB-t)):(n=this[s]>>(a-=t)&r,a<=0&&(a+=this.DB,--s)),n>0&&(o=!0),o&&(i+=j(n));return o?i:"0"}negate(){var e=Q();return $.ZERO.subTo(this,e),e}abs(){return this.s<0?this.negate():this}compareTo(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+oe(this[this.t-1]^this.s&this.DM)}mod(e){var t=Q();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo($.ZERO)>0&&e.subTo(t,t),t}modPowInt(e,t){var n;return n=e<256||t.isEven()?new g(t):new m(t),this.exp(e,n)}clone(){var e=Q();return this.copyTo(e),e}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var e=this.t,t=[];t[0]=this.s;var n,r=this.DB-e*this.DB%8,o=0;if(e-- >0)for(r<this.DB&&(n=this[e]>>r)!=(this.s&this.DM)>>r&&(t[o++]=n|this.s<<this.DB-r);e>=0;)r<8?(n=(this[e]&(1<<r)-1)<<8-r,n|=this[--e]>>(r+=this.DB-8)):(n=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),128&n&&(n|=-256),0==o&&(128&this.s)!=(128&n)&&++o,(o>0||n!=this.s)&&(t[o++]=n);return t}equals(e){return 0==this.compareTo(e)}min(e){return this.compareTo(e)<0?this:e}max(e){return this.compareTo(e)>0?this:e}and(e){var t=Q();return this.bitwiseTo(e,x,t),t}or(e){var t=Q();return this.bitwiseTo(e,M,t),t}xor(e){var t=Q();return this.bitwiseTo(e,q,t),t}andNot(e){var t=Q();return this.bitwiseTo(e,F,t),t}not(){for(var e=Q(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}shiftLeft(e){var t=Q();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}shiftRight(e){var t=Q();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}getLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+B(this[e]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var e=0,t=this.s&this.DM,n=0;n<this.t;++n)e+=W(this[n]^t);return e}testBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)}setBit(e){return this.changeBit(e,M)}clearBit(e){return this.changeBit(e,F)}flipBit(e){return this.changeBit(e,q)}add(e){var t=Q();return this.addTo(e,t),t}subtract(e){var t=Q();return this.subTo(e,t),t}multiply(e){var t=Q();return this.multiplyTo(e,t),t}divide(e){var t=Q();return this.divRemTo(e,t,null),t}remainder(e){var t=Q();return this.divRemTo(e,null,t),t}divideAndRemainder(e){var t=Q(),n=Q();return this.divRemTo(e,t,n),[t,n]}modPow(e,t){var n,r,o=e.bitLength(),i=re(1);if(o<=0)return i;n=o<18?1:o<48?3:o<144?4:o<768?5:6,r=o<8?new g(t):t.isEven()?new b(t):new m(t);var s=[],a=3,c=n-1,u=(1<<n)-1;if(s[1]=r.convert(this),n>1){var l=Q();for(r.sqrTo(s[1],l);a<=u;)s[a]=Q(),r.mulTo(l,s[a-2],s[a]),a+=2}var h,d,f=e.t-1,p=!0,v=Q();for(o=oe(e[f])-1;f>=0;){for(o>=c?h=e[f]>>o-c&u:(h=(e[f]&(1<<o+1)-1)<<c-o,f>0&&(h|=e[f-1]>>this.DB+o-c)),a=n;!(1&h);)h>>=1,--a;if((o-=a)<0&&(o+=this.DB,--f),p)s[h].copyTo(i),p=!1;else{for(;a>1;)r.sqrTo(i,v),r.sqrTo(v,i),a-=2;a>0?r.sqrTo(i,v):(d=i,i=v,v=d),r.mulTo(v,s[h],i)}for(;f>=0&&!(e[f]&1<<o);)r.sqrTo(i,v),d=i,i=v,v=d,--o<0&&(o=this.DB-1,--f)}return r.revert(i)}modInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return $.ZERO;for(var n=e.clone(),r=this.clone(),o=re(1),i=re(0),s=re(0),a=re(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),t?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(e,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;r.isEven();)r.rShiftTo(1,r),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);n.compareTo(r)>=0?(n.subTo(r,n),t&&o.subTo(s,o),i.subTo(a,i)):(r.subTo(n,r),t&&s.subTo(o,s),a.subTo(i,a))}return 0!=r.compareTo($.ONE)?$.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a}pow(e){return this.exp(e,new y)}gcd(e){var t=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(t.compareTo(n)<0){var r=t;t=n,n=r}var o=t.getLowestSetBit(),i=n.getLowestSetBit();if(i<0)return t;for(o<i&&(i=o),i>0&&(t.rShiftTo(i,t),n.rShiftTo(i,n));t.signum()>0;)(o=t.getLowestSetBit())>0&&t.rShiftTo(o,t),(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),t.compareTo(n)>=0?(t.subTo(n,t),t.rShiftTo(1,t)):(n.subTo(t,n),n.rShiftTo(1,n));return i>0&&n.lShiftTo(i,n),n}isProbablePrime(e){var t,n=this.abs();if(1==n.t&&n[0]<=p[p.length-1]){for(t=0;t<p.length;++t)if(n[0]==p[t])return!0;return!1}if(n.isEven())return!1;for(t=1;t<p.length;){for(var r=p[t],o=t+1;o<p.length&&r<v;)r*=p[o++];for(r=n.modInt(r);t<o;)if(r%p[t++]==0)return!1}return n.millerRabin(e)}copyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}fromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}fromString(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var r=e.length,o=!1,i=0;--r>=0;){var s=8==n?255&+e[r]:ne(e,r);s<0?"-"==e.charAt(r)&&(o=!0):(o=!1,0==i?this[this.t++]=s:i+n>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,(i+=n)>=this.DB&&(i-=this.DB))}8==n&&128&+e[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&$.ZERO.subTo(this,this)}clamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}dlShiftTo(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s}drShiftTo(e,t){for(var n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s}lShiftTo(e,t){for(var n=e%this.DB,r=this.DB-n,o=(1<<r)-1,i=Math.floor(e/this.DB),s=this.s<<n&this.DM,a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>r|s,s=(this[a]&o)<<n;for(a=i-1;a>=0;--a)t[a]=0;t[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}rShiftTo(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var r=e%this.DB,o=this.DB-r,i=(1<<r)-1;t[0]=this[n]>>r;for(var s=n+1;s<this.t;++s)t[s-n-1]|=(this[s]&i)<<o,t[s-n]=this[s]>>r;r>0&&(t[this.t-n-1]|=(this.s&i)<<o),t.t=this.t-n,t.clamp()}}subTo(e,t){for(var n=0,r=0,o=Math.min(e.t,this.t);n<o;)r+=this[n]-e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r-=e[n],t[n++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t[n++]=this.DV+r:r>0&&(t[n++]=r),t.t=n,t.clamp()}multiplyTo(e,t){var n=this.abs(),r=e.abs(),o=n.t;for(t.t=o+r.t;--o>=0;)t[o]=0;for(o=0;o<r.t;++o)t[o+n.t]=n.am(0,r[o],t,o,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&$.ZERO.subTo(t,t)}squareTo(e){for(var t=this.abs(),n=e.t=2*t.t;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){var r=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,r,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()}divRemTo(e,t,n){var r=e.abs();if(!(r.t<=0)){var o=this.abs();if(o.t<r.t)return null!=t&&t.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=Q());var i=Q(),s=this.s,a=e.s,c=this.DB-oe(r[r.t-1]);c>0?(r.lShiftTo(c,i),o.lShiftTo(c,n)):(r.copyTo(i),o.copyTo(n));var u=i.t,l=i[u-1];if(0!=l){var h=l*(1<<this.F1)+(u>1?i[u-2]>>this.F2:0),d=this.FV/h,f=(1<<this.F1)/h,p=1<<this.F2,v=n.t,y=v-u,g=null==t?Q():t;for(i.dlShiftTo(y,g),n.compareTo(g)>=0&&(n[n.t++]=1,n.subTo(g,n)),$.ONE.dlShiftTo(u,g),g.subTo(i,i);i.t<u;)i[i.t++]=0;for(;--y>=0;){var m=n[--v]==l?this.DM:Math.floor(n[v]*d+(n[v-1]+p)*f);if((n[v]+=i.am(0,m,n,y,0,u))<m)for(i.dlShiftTo(y,g),n.subTo(g,n);n[v]<--m;)n.subTo(g,n)}null!=t&&(n.drShiftTo(u,t),s!=a&&$.ZERO.subTo(t,t)),n.t=u,n.clamp(),c>0&&n.rShiftTo(c,n),s<0&&$.ZERO.subTo(n,n)}}}invDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(e,t){if(e>4294967295||e<1)return $.ONE;var n=Q(),r=Q(),o=t.convert(this),i=oe(e)-1;for(o.copyTo(n);--i>=0;)if(t.sqrTo(n,r),(e&1<<i)>0)t.mulTo(r,o,n);else{var s=n;n=r,r=s}return t.revert(n)}chunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}toRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),n=Math.pow(e,t),r=re(n),o=Q(),i=Q(),s="";for(this.divRemTo(r,o,i);o.signum()>0;)s=(n+i.intValue()).toString(e).substr(1)+s,o.divRemTo(r,o,i);return i.intValue().toString(e)+s}fromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),r=Math.pow(t,n),o=!1,i=0,s=0,a=0;a<e.length;++a){var c=ne(e,a);c<0?"-"==e.charAt(a)&&0==this.signum()&&(o=!0):(s=t*s+c,++i>=n&&(this.dMultiply(r),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(s,0)),o&&$.ZERO.subTo(this,this)}fromNumber(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo($.ONE.shiftLeft(e-1),M,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo($.ONE.shiftLeft(e-1),this);else{var r=[],o=7&e;r.length=1+(e>>3),t.nextBytes(r),o>0?r[0]&=(1<<o)-1:r[0]=0,this.fromString(r,256)}}bitwiseTo(e,t,n){var r,o,i=Math.min(e.t,this.t);for(r=0;r<i;++r)n[r]=t(this[r],e[r]);if(e.t<this.t){for(o=e.s&this.DM,r=i;r<this.t;++r)n[r]=t(this[r],o);n.t=this.t}else{for(o=this.s&this.DM,r=i;r<e.t;++r)n[r]=t(o,e[r]);n.t=e.t}n.s=t(this.s,e.s),n.clamp()}changeBit(e,t){var n=$.ONE.shiftLeft(e);return this.bitwiseTo(n,t,n),n}addTo(e,t){for(var n=0,r=0,o=Math.min(e.t,this.t);n<o;)r+=this[n]+e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r+=e[n],t[n++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t[n++]=r:r<-1&&(t[n++]=this.DV+r),t.t=n,t.clamp()}dMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}multiplyLowerTo(e,t,n){var r=Math.min(this.t+e.t,t);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(var o=n.t-this.t;r<o;++r)n[r+this.t]=this.am(0,e[r],n,r,0,this.t);for(o=Math.min(e.t,t);r<o;++r)this.am(0,e[r],n,r,0,t-r);n.clamp()}multiplyUpperTo(e,t,n){--t;var r=n.t=this.t+e.t-t;for(n.s=0;--r>=0;)n[r]=0;for(r=Math.max(t-this.t,0);r<e.t;++r)n[this.t+r-t]=this.am(t-r,e[r],n,0,0,this.t+r-t);n.clamp(),n.drShiftTo(1,n)}modInt(e){if(e<=0)return 0;var t=this.DV%e,n=this.s<0?e-1:0;if(this.t>0)if(0==t)n=this[0]%e;else for(var r=this.t-1;r>=0;--r)n=(t*n+this[r])%e;return n}millerRabin(e){var t=this.subtract($.ONE),n=t.getLowestSetBit();if(n<=0)return!1;var r=t.shiftRight(n);(e=e+1>>1)>p.length&&(e=p.length);for(var o=Q(),i=0;i<e;++i){o.fromInt(p[Math.floor(Math.random()*p.length)]);var s=o.modPow(r,this);if(0!=s.compareTo($.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<n&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo($.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0}square(){var e=Q();return this.squareTo(e),e}gcda(e,t){var n=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(n.compareTo(r)<0){var o=n;n=r,r=o}var i=n.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)t(n);else{i<s&&(s=i),s>0&&(n.rShiftTo(s,n),r.rShiftTo(s,r));var a=()=>{(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),n.compareTo(r)>=0?(n.subTo(r,n),n.rShiftTo(1,n)):(r.subTo(n,r),r.rShiftTo(1,r)),n.signum()>0?setTimeout(a,0):(s>0&&r.lShiftTo(s,r),setTimeout(function(){t(r)},0))};setTimeout(a,10)}}fromNumberAsync(e,t,n,r){if("number"==typeof t)if(e<2)this.fromInt(1);else{this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo($.ONE.shiftLeft(e-1),M,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo($.ONE.shiftLeft(e-1),o),o.isProbablePrime(t)?setTimeout(function(){r()},0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&e;s.length=1+(e>>3),t.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var y=function(){function e(){}return e.prototype.convert=function(e){return e},e.prototype.revert=function(e){return e},e.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n)},e.prototype.sqrTo=function(e,t){e.squareTo(t)},e}(),g=function(){function e(e){this.m=e}return e.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},e.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),m=function(){function e(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}return e.prototype.convert=function(e){var t=Q();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo($.ZERO)>0&&this.m.subTo(t,t),t},e.prototype.revert=function(e){var t=Q();return e.copyTo(t),this.reduce(t),t},e.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var n=32767&e[t],r=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,r,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),b=function(){function e(e){this.m=e,this.r2=Q(),this.q3=Q(),$.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e)}return e.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=Q();return e.copyTo(t),this.reduce(t),t},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}();function Q(){return new $(null)}function X(e,t){return new $(e,t)}function Z(e,t,n,r,o,i){for(;--i>=0;){var s=t*this[e++]+n[r]+o;o=Math.floor(s/67108864),n[r++]=67108863&s}return o}function ee(e,t,n,r,o,i){for(var s=32767&t,a=t>>15;--i>=0;){var c=32767&this[e],u=this[e++]>>15,l=a*c+u*s;o=((c=s*c+((32767&l)<<15)+n[r]+(1073741823&o))>>>30)+(l>>>15)+a*u+(o>>>30),n[r++]=1073741823&c}return o}function te(e,t,n,r,o,i){for(var s=16383&t,a=t>>14;--i>=0;){var c=16383&this[e],u=this[e++]>>14,l=a*c+u*s;o=((c=s*c+((16383&l)<<14)+n[r]+o)>>28)+(l>>14)+a*u,n[r++]=268435455&c}return o}void 0!==o&&"Microsoft Internet Explorer"==(null==o?void 0:o.appName)?($.prototype.am=ee,h=30):"Netscape"!=(null==o?void 0:o.appName)?($.prototype.am=Z,h=26):($.prototype.am=te,h=28),$.prototype.DB=h,$.prototype.DM=(1<<h)-1,$.prototype.DV=1<<h,$.prototype.FV=Math.pow(2,52),$.prototype.F1=52-h,$.prototype.F2=2*h-52;var _,E,w=[];for(_="0".charCodeAt(0),E=0;E<=9;++E)w[_++]=E;for(_="a".charCodeAt(0),E=10;E<36;++E)w[_++]=E;for(_="A".charCodeAt(0),E=10;E<36;++E)w[_++]=E;function ne(e,t){var n=w[e.charCodeAt(t)];return null==n?-1:n}function re(e){var t=Q();return t.fromInt(e),t}function oe(e){var t,n=1;return 0!=(t=e>>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}$.ZERO=re(0),$.ONE=re(1);class ie{constructor(){this.i=0,this.j=0,this.S=[]}init(e){var t,n,r;for(t=0;t<256;++t)this.S[t]=t;for(n=0,t=0;t<256;++t)n=n+this.S[t]+e[t%e.length]&255,r=this.S[t],this.S[t]=this.S[n],this.S[n]=r;this.i=0,this.j=0}next(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}var S,I,O=null;if(null==O){O=[],I=0;var A,T,P=void 0;if("undefined"!=typeof window&&null!==(A=window)&&void 0!==A&&A.crypto&&null!==(T=window)&&void 0!==T&&T.crypto.getRandomValues){var C,R=new Uint32Array(256);for(null===(C=window)||void 0===C||C.crypto.getRandomValues(R),P=0;P<R.length;++P)O[I++]=255&R[P]}var N,k,U,D=function(e){var t,n,r;if(this.count=this.count||0,this.count>=256||I>=256){if("undefined"!=typeof window)if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(r=window)||void 0===r||r.removeEventListener("mousemove",D,!1);else if(null!==(n=window)&&void 0!==n&&n.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",D)}}else try{var i=e.x+e.y;O[I++]=255&i,this.count+=1}catch(e){}};if("undefined"!=typeof window)if(null!==(N=window)&&void 0!==N&&N.addEventListener)null===(U=window)||void 0===U||U.addEventListener("mousemove",D,!1);else if(null!==(k=window)&&void 0!==k&&k.attachEvent){var L;null===(L=window)||void 0===L||L.attachEvent("onmousemove",D)}}function se(){if(null==S){for(S=new ie;I<256;){var e=Math.floor(65536*Math.random());O[I++]=255&e}for(S.init(O),I=0;I<O.length;++I)O[I]=0;I=0}return S.next()}class ae{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=se()}}function ce(e,t){if(t<e.length+11)return console.error("Message too long for RSA"),null;for(var n=[],r=e.length-1;r>=0&&t>0;){var o=e.charCodeAt(r--);o<128?n[--t]=o:o>127&&o<2048?(n[--t]=63&o|128,n[--t]=o>>6|192):(n[--t]=63&o|128,n[--t]=o>>6&63|128,n[--t]=o>>12|224)}n[--t]=0;for(var i=new ae,s=[];t>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);n[--t]=s[0]}return n[--t]=2,n[--t]=0,new $(n)}class ue{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(e){return e.modPowInt(this.e,this.n)}doPrivate(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),n=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(n)<0;)t=t.add(this.p);return t.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)}setPublic(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")}encrypt(e){var t=ce(e,this.n.bitLength()+7>>3);if(null==t)return null;var n=this.doPublic(t);if(null==n)return null;var r=n.toString(16);return 1&r.length?"0"+r:r}encryptLong(e){var t=this,n=(this.n.bitLength()+7>>3)-11;try{var r="";return e.length>n?(e.match(/.{1,117}/g).forEach(function(e){var n=t.encrypt(e);r+=n}),H(r)):H(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,n=this.n.bitLength()+7>>3;e=G(e);try{if(e.length>n){var r="";return e.match(/.{1,256}/g).forEach(function(e){var n=t.decrypt(e);r+=n}),r}return this.decrypt(e)}catch(e){return!1}}setPrivate(e,t,n){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16),this.d=X(n,16)):console.error("Invalid RSA private key")}setPrivateEx(e,t,n,r,o,i,s,a){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16),this.d=X(n,16),this.p=X(r,16),this.q=X(o,16),this.dmp1=X(i,16),this.dmq1=X(s,16),this.coeff=X(a,16)):console.error("Invalid RSA private key")}generate(e,t){var n=new ae,r=e>>1;this.e=parseInt(t,16);for(var o=new $(t,16);;){for(;this.p=new $(e-r,1,n),0!=this.p.subtract($.ONE).gcd(o).compareTo($.ONE)||!this.p.isProbablePrime(10););for(;this.q=new $(r,1,n),0!=this.q.subtract($.ONE).gcd(o).compareTo($.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q,this.q=i}var s=this.p.subtract($.ONE),a=this.q.subtract($.ONE),c=s.multiply(a);if(0==c.gcd(o).compareTo($.ONE)){this.n=this.p.multiply(this.q),this.d=o.modInverse(c),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(e){var t=X(e,16),n=this.doPrivate(t);return null==n?null:le(n,this.n.bitLength()+7>>3)}generateAsync(e,t,n){var r=new ae,o=e>>1;this.e=parseInt(t,16);var i=new $(t,16),s=this,a=()=>{var t=()=>{if(s.p.compareTo(s.q)<=0){var e=s.p;s.p=s.q,s.q=e}var t=s.p.subtract($.ONE),r=s.q.subtract($.ONE),o=t.multiply(r);0==o.gcd(i).compareTo($.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(t),s.dmq1=s.d.mod(r),s.coeff=s.q.modInverse(s.p),setTimeout(function(){n()},0)):setTimeout(a,0)},c=()=>{s.q=Q(),s.q.fromNumberAsync(o,1,r,function(){s.q.subtract($.ONE).gcda(i,function(e){0==e.compareTo($.ONE)&&s.q.isProbablePrime(10)?setTimeout(t,0):setTimeout(c,0)})})},u=()=>{s.p=Q(),s.p.fromNumberAsync(e-o,1,r,function(){s.p.subtract($.ONE).gcda(i,function(e){0==e.compareTo($.ONE)&&s.p.isProbablePrime(10)?setTimeout(c,0):setTimeout(u,0)})})};setTimeout(u,0)};setTimeout(a,0)}}function le(e,t){for(var n=e.toByteArray(),r=0;r<n.length&&0==n[r];)++r;if(n.length-r!=t-1||2!=n[r])return null;for(++r;0!=n[r];)if(++r>=n.length)return null;for(var o="";++r<n.length;){var i=255&n[r];i<128?o+=String.fromCharCode(i):i>191&&i<224?(o+=String.fromCharCode((31&i)<<6|63&n[r+1]),++r):(o+=String.fromCharCode((15&i)<<12|(63&n[r+1])<<6|63&n[r+2]),r+=2)}return o}class he extends ue{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),e&&("string"==typeof e?this.parseKey(e):(this.hasPrivateKeyProperty(e)||this.hasPublicKeyProperty(e))&&this.parsePropertiesFrom(e))}parseKey(e){try{var t=0,n=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?c.decode(e):u.unarmor(e),o=Y.decode(r);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){t=o.sub[1].getHexStringValue(),this.n=X(t,16),n=o.sub[2].getHexStringValue(),this.e=parseInt(n,16);var i=o.sub[3].getHexStringValue();this.d=X(i,16);var s=o.sub[4].getHexStringValue();this.p=X(s,16);var a=o.sub[5].getHexStringValue();this.q=X(a,16);var l=o.sub[6].getHexStringValue();this.dmp1=X(l,16);var h=o.sub[7].getHexStringValue();this.dmq1=X(h,16);var d=o.sub[8].getHexStringValue();this.coeff=X(d,16)}else{if(2!==o.sub.length)return!1;var f=o.sub[1].sub[0];t=f.sub[0].getHexStringValue(),this.n=X(t,16),n=f.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(e){return!1}}hasPublicKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")}hasPrivateKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")}parsePropertiesFrom(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)}}(r=function(e){e=e||{},this.default_key_size=parseInt(e.default_key_size,10)||1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}).prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new he(e)},r.prototype.setPrivateKey=function(e){this.setKey(e)},r.prototype.setPublicKey=function(e){this.setKey(e)},r.prototype.decrypt=function(e){try{return this.getKey().decrypt(G(e))}catch(e){return!1}},r.prototype.encrypt=function(e){try{return H(this.getKey().encrypt(e))}catch(e){return!1}},r.prototype.encryptLong=function(e){try{for(var t=this.getKey().encryptLong(e)||"",n=this.getKey().decryptLong(t)||"",r=0,o=/null$/g;o.test(n)&&(r++,t=this.getKey().encryptLong(e)||"",n=this.getKey().decryptLong(t)||"",!(r>10)););return t}catch(e){return!1}},r.prototype.getKey=function(e){if(!this.key){if(this.key=new he,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},r.version="3.1.4"}t.default=r},8182:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,c=s(n(4274)),u=n(3616);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var n=0,o=(0,u.isArray)(e)?e:[e];n<o.length;n++){var i=o[n],s=i.isMatch,a=i.genAdapter,c=i.runtime;if(s())return{adapter:r({isMatch:s},a(t)),runtime:c}}},t.useDefaultAdapter=function(){return{adapter:r({},c.genAdapter()),runtime:a.WEB}}},4274:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var c=n(2764),u=n(3616),l=n(2946);function h(e){try{return JSON.parse(e)}catch(t){return e}}var d=function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e,n=t.data,r=t.file,o=t.fileContent,s=t.name,a=t.method,c=t.headers,u=void 0===c?{}:c,l=null!=r?r:o,h={post:"post",put:"put"}[null==a?void 0:a.toLowerCase()]||"put",d=new FormData;return"post"===h?(Object.keys(n).forEach(function(e){d.append(e,n[e])}),d.append("key",s),d.append("file",l instanceof Blob?l:new Blob([l])),this.request(i(i({},e),{data:d,method:h}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:u,body:l}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,function(){var t,n,r,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(t){t({statusCode:200,tempFilePath:e.url})})]}})})},t.prototype.fetch=function(e){var t;return s(this,void 0,void 0,function(){var n,r,o,c,u,l,d,f,p,v,y,g,m,b,_,E=this;return a(this,function(w){switch(w.label){case 0:return n=new AbortController,r=e.url,o=e.enableAbort,c=void 0!==o&&o,u=e.stream,l=void 0!==u&&u,d=e.signal,f=e.timeout,p=e.shouldThrowOnError,v=void 0===p||p,y=null!=f?f:this.timeout,d&&(d.aborted&&n.abort(),d.addEventListener("abort",function(){return n.abort()})),g=null,c&&y&&(g=setTimeout(function(){console.warn(E.timeoutMsg),n.abort(new Error(E.timeoutMsg))},y)),[4,fetch(r,i(i({},e),{signal:n.signal})).then(function(e){return s(E,void 0,void 0,function(){var t,n,r;return a(this,function(o){switch(o.label){case 0:return clearTimeout(g),v?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,e.json()];case 2:t=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(g),Promise.reject(e)})];case 1:return m=w.sent(),l?(b=m.body,[3,5]):[3,2];case 2:return(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?(_=h,[4,m.text()]):[3,4];case 3:return b=_.apply(void 0,[w.sent()]),[3,5];case 4:b=m.text(),w.label=5;case 5:return[2,{data:b,statusCode:m.status,header:m.headers,response:m}]}})})},t.prototype.request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i=e.url,s=e.headers,a=void 0===s?{}:s,c=e.data,h=e.responseType,d=e.withCredentials,f=e.body,p=e.onUploadProgress,v=(0,u.formatUrl)((0,l.getProtocol)(),i,"get"===r?c:{}),y=new XMLHttpRequest;y.open(r,v),h&&(y.responseType=h);var g,m,b=e.signal;b&&(b.aborted?y.abort():b.addEventListener("abort",function(){return y.abort()},{once:!0})),Object.keys(a).forEach(function(e){y.setRequestHeader(e,a[e])}),p&&y.upload.addEventListener("progress",p),y.onreadystatechange=function(){var e={};if(4===y.readyState){var t=y.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach(function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o}),e.header=n,e.statusCode=y.status;try{e.data="blob"===h?y.response:JSON.parse(y.responseText)}catch(t){e.data="blob"===h?y.response:y.responseText}clearTimeout(g),o(e)}},t&&n.timeout&&(g=setTimeout(function(){console.warn(n.timeoutMsg),y.abort()},n.timeout)),m=(0,u.isFormData)(c)?c:"application/x-www-form-urlencoded"===a["content-type"]?(0,u.toQueryString)(c):f||(c?JSON.stringify(c):void 0),d&&(y.withCredentials=!0),y.send(m)})},t}(c.AbstractSDKRequest);t.WebRequest=d,t.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage:localStorage}}},2946:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var n="@cloudbase/js-sdk";t.setSdkName=function(e){n=e},t.getSdkName=function(){return n};var r="https:";t.setProtocol=function(e){r=e},t.getProtocol=function(){return r},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},6205:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},794:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(n(2946),t),o(n(6205),t),t.OATUH_LOGINTYPE="constants"},7718:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=n(3616),s=n(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,n=e.className,r=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),h=s.findIndex(function(e){return c.test(e)});if(-1!==h){var d=s.filter(function(e,t){return t>h});d.unshift(s[h].replace(l,"".concat(n,".").concat(r)).replace(u,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,a=e.customInfo,h=void 0===a?{}:a,d=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=h.className||e.constructor.name,v=h.methodName||t,y=a.value,g=function(){var e="",t=(new Error).stack.split("\n"),n=t.findIndex(function(e){return c.test(e)});if(-1!==n){var r=u.exec(t[n+1]||"");e=r?r[0]:""}return e}();a.value="sync"===n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=l({err:new Error,className:f,methodName:v,sourceLink:g});try{return y.apply(this,e)}catch(e){var r=e,o=e.message,s=e.error,a=e.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(n?(n.code=u.code,n.msg=u.msg):(e.code=u.code,e.message=u.msg),r=n||e,c.content=p.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(c.subtitle=a,n?(n.code=s,n.msg=a):(e.code=s,e.message=a),r=n||e,c.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(c),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,function(){var t,n,r,s,a,c,u,h;return o(this,function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,c=n.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(h=JSON.parse(s),u.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(n.code=h.code,n.message=h.msg),r=t||n,u.content=p.map(function(e){return{type:"info",body:e}}))),a&&c&&(u.subtitle=c,t?(t.code=a,t.msg=c):(n.code=a,n.message=c),r=t||n,u.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(u),r;case 4:return[2]}})})}}}}},141:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(7718),t)},6197:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=n(2764),c=n(3616),u=n(794),l=function(e){function t(t){var n=e.call(this)||this;return n.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),h=function(){function e(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return i(this,void 0,void 0,function(){var r;return s(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var r=this.storage.getItem(e);return r&&r.indexOf(t)>=0?JSON.parse(r).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return i(this,void 0,void 0,function(){var r;return s(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(r=o.sent())&&r.indexOf(t)>=0?[2,JSON.parse(r).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}();t.CloudbaseCache=h},9689:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=n(3616),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var c=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return o(t,e),t}(a);t.IErrorEvent=c;var u=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,c))return console.error(e.error),this;var n=(0,s.isString)(e)?new a(e,t||{}):e,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,u=this.listeners[r]?i([],this.listeners[r],!0):[];o<u.length;o++)u[o].call(this,n)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=u;var l=new u;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},3616:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.errorToResult=t.promoteGatewayError=t.maybeThrow=t.resolveThrow=t.createCloudbaseError=t.CloudbaseError=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var a=n(794);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var r=16*Math.random();return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:7&r|8).toString(16)})},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";return Object.keys(n).forEach(function(e){""===o?!r&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(n[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(n){t.push("".concat(n,"=").concat(encodeURIComponent(e[n])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||decodeURIComponent(window.location.search),r=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('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}var n=new Promise(function(t,n){e=function(e,r){return e?n(e):t(r)}});return e.promise=n,e},t.execCallback=function(e,t,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(t,n);if(t)throw t;return n},t.printWarn=function(e,t){console.warn("[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){var n=new Error(JSON.stringify({code:e,msg:"[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t)}));throw n.code=e,n};var c=function(e){function t(t){var n=e.call(this,t.msg||t.message||"")||this;return n.code=t.code||"",n.requestId=t.requestId||"",Object.defineProperty(n,"message",{value:t.msg||t.message||"",enumerable:!0,writable:!0,configurable:!0}),n}return o(t,e),t}(Error);t.CloudbaseError=c;var u=function(e){return new c(e)};function l(e,t){return(t||u)(e)}function h(e){return!e||"boolean"!=typeof e.throw||e.throw}t.createCloudbaseError=l,t.resolveThrow=h,t.maybeThrow=function(e,t){if(h(e))throw l(i(i({},t),{msg:t.message}),null==e?void 0:e.errorFactory);return i({code:t.code,message:t.message},t.requestId?{requestId:t.requestId}:{})},t.promoteGatewayError=function(e){if(e&&"object"==typeof e&&e.data&&"object"==typeof e.data){var t=e.data,n=t.code,r=t.message;if(!e.code&&n||!e.message&&r)return i(i(i({},e),!e.code&&n?{code:n}:{}),!e.message&&r?{message:r}:{})}return e},t.errorToResult=function(e){if(e instanceof Error&&"string"==typeof e.message)try{var t=JSON.parse(e.message);if(t&&"string"==typeof t.code)return{code:t.code,message:t.msg||t.message||"",requestId:t.requestId}}catch(e){}return e&&"string"==typeof e.code?{code:e.code,message:e.message||"",requestId:e.requestId}:{code:"UNKNOWN_ERROR",message:String((null==e?void 0:e.message)||e||"")}},t.printGroupLog=function(e){var t,n=e.title,r=e.subtitle,o=void 0===r?"":r,i=e.content,s=void 0===i?[]:i,a=e.printTrace,c=void 0!==a&&a,u=e.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var l=0,h=s;l<h.length;l++){var d=h[l],f=d.type,p=d.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}c&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var n=e.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(t[r]?Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]:t[r]=o)}),t},t.parseCaptcha=function(e){var n={},r=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){e=r[1];var o=r[2];o&&(n=(0,t.parseQueryString)(o))}var i=n.token,a=s(n,["token"]);return/^data:/.test(e)&&!i?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:i?{state:a.state,token:i,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},9515:function(e,t,n){var r=n(8761)(n(7772),"DataView");e.exports=r},9612:function(e,t,n){var r=n(2118),o=n(6909),i=n(8138),s=n(4174),a=n(7942);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,e.exports=c},235:function(e,t,n){var r=n(3945),o=n(1846),i=n(8028),s=n(6018),a=n(4769);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,e.exports=c},326:function(e,t,n){var r=n(8761)(n(7772),"Map");e.exports=r},6738:function(e,t,n){var r=n(2411),o=n(6417),i=n(6928),s=n(9493),a=n(4150);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,e.exports=c},2760:function(e,t,n){var r=n(8761)(n(7772),"Promise");e.exports=r},2143:function(e,t,n){var r=n(8761)(n(7772),"Set");e.exports=r},6571:function(e,t,n){var r=n(235),o=n(5243),i=n(2858),s=n(4417),a=n(8605),c=n(1418);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=o,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=a,u.prototype.set=c,e.exports=u},857:function(e,t,n){var r=n(7772).Symbol;e.exports=r},9162:function(e,t,n){var r=n(7772).Uint8Array;e.exports=r},3215:function(e,t,n){var r=n(8761)(n(7772),"WeakMap");e.exports=r},2517:function(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},7552:function(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[o++]=s)}return i}},1634:function(e,t,n){var r=n(6473),o=n(9631),i=n(6152),s=n(3226),a=n(9045),c=n(7598),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),l=!n&&o(e),h=!n&&!l&&s(e),d=!n&&!l&&!h&&c(e),f=n||l||h||d,p=f?r(e.length,String):[],v=p.length;for(var y in e)!t&&!u.call(e,y)||f&&("length"==y||h&&("offset"==y||"parent"==y)||d&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||a(y,v))||p.push(y);return p}},343:function(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}},5067:function(e){e.exports=function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}},91:function(e,t,n){var r=n(3940),o=n(1225),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&o(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},2218:function(e,t,n){var r=n(1225);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},7993:function(e,t,n){var r=n(752),o=n(249);e.exports=function(e,t){return e&&r(t,o(t),e)}},5906:function(e,t,n){var r=n(752),o=n(8582);e.exports=function(e,t){return e&&r(t,o(t),e)}},3940:function(e,t,n){var r=n(3043);e.exports=function(e,t,n){"__proto__"==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},8874:function(e,t,n){var r=n(6571),o=n(2517),i=n(91),s=n(7993),a=n(5906),c=n(2175),u=n(1522),l=n(7680),h=n(9987),d=n(3483),f=n(6939),p=n(940),v=n(9917),y=n(8222),g=n(8725),m=n(6152),b=n(3226),_=n(4714),E=n(9259),w=n(3679),S=n(249),I=n(8582),O="[object Arguments]",A="[object Function]",T="[object Object]",P={};P[O]=P["[object Array]"]=P["[object ArrayBuffer]"]=P["[object DataView]"]=P["[object Boolean]"]=P["[object Date]"]=P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Map]"]=P["[object Number]"]=P[T]=P["[object RegExp]"]=P["[object Set]"]=P["[object String]"]=P["[object Symbol]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P["[object Error]"]=P[A]=P["[object WeakMap]"]=!1,e.exports=function e(t,n,C,R,N,k){var U,D=1&n,L=2&n,j=4&n;if(C&&(U=N?C(t,R,N,k):C(t)),void 0!==U)return U;if(!E(t))return t;var x=m(t);if(x){if(U=v(t),!D)return u(t,U)}else{var M=p(t),q=M==A||"[object GeneratorFunction]"==M;if(b(t))return c(t,D);if(M==T||M==O||q&&!N){if(U=L||q?{}:g(t),!D)return L?h(t,a(U,t)):l(t,s(U,t))}else{if(!P[M])return N?t:{};U=y(t,M,D)}}k||(k=new r);var F=k.get(t);if(F)return F;k.set(t,U),w(t)?t.forEach(function(r){U.add(e(r,n,C,r,t,k))}):_(t)&&t.forEach(function(r,o){U.set(o,e(r,n,C,o,t,k))});var B=x?void 0:(j?L?f:d:L?I:S)(t);return o(B||t,function(r,o){B&&(r=t[o=r]),i(U,o,e(r,n,C,o,t,k))}),U}},9413:function(e,t,n){var r=n(9259),o=Object.create,i=function(){function e(){}return function(t){if(!r(t))return{};if(o)return o(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();e.exports=i},3324:function(e,t,n){var r=n(7297),o=n(3812);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[o(t[n++])];return n&&n==i?e:void 0}},1897:function(e,t,n){var r=n(5067),o=n(6152);e.exports=function(e,t,n){var i=t(e);return o(e)?i:r(i,n(e))}},3366:function(e,t,n){var r=n(857),o=n(2107),i=n(7157),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},5183:function(e,t,n){var r=n(3366),o=n(5125);e.exports=function(e){return o(e)&&"[object Arguments]"==r(e)}},4511:function(e,t,n){var r=n(940),o=n(5125);e.exports=function(e){return o(e)&&"[object Map]"==r(e)}},6840:function(e,t,n){var r=n(1049),o=n(7394),i=n(9259),s=n(7035),a=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,h=u.hasOwnProperty,d=RegExp("^"+l.call(h).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(r(e)?d:a).test(s(e))}},8436:function(e,t,n){var r=n(940),o=n(5125);e.exports=function(e){return o(e)&&"[object Set]"==r(e)}},5522:function(e,t,n){var r=n(3366),o=n(1158),i=n(5125),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,e.exports=function(e){return i(e)&&o(e.length)&&!!s[r(e)]}},6411:function(e,t,n){var r=n(6001),o=n(4248),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return o(e);var t=[];for(var n in Object(e))i.call(e,n)&&"constructor"!=n&&t.push(n);return t}},8390:function(e,t,n){var r=n(9259),o=n(6001),i=n(2966),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=o(e),n=[];for(var a in e)("constructor"!=a||!t&&s.call(e,a))&&n.push(a);return n}},2857:function(e,t,n){var r=n(91),o=n(7297),i=n(9045),s=n(9259),a=n(3812);e.exports=function(e,t,n,c){if(!s(e))return e;for(var u=-1,l=(t=o(t,e)).length,h=l-1,d=e;null!=d&&++u<l;){var f=a(t[u]),p=n;if("__proto__"===f||"constructor"===f||"prototype"===f)return e;if(u!=h){var v=d[f];void 0===(p=c?c(v,f,d):void 0)&&(p=s(v)?v:i(t[u+1])?[]:{})}r(d,f,p),d=d[f]}return e}},9872:function(e){e.exports=function(e,t,n){var r=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=e[r+t];return i}},6473:function(e){e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},1054:function(e,t,n){var r=n(857),o=n(343),i=n(6152),s=n(4795),a=r?r.prototype:void 0,c=a?a.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(i(t))return o(t,e)+"";if(s(t))return c?c.call(t):"";var n=t+"";return"0"==n&&1/t==-1/0?"-0":n}},7826:function(e){e.exports=function(e){return function(t){return e(t)}}},9078:function(e,t,n){var r=n(7297),o=n(6974),i=n(2721),s=n(3812),a=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=-1,c=(t=r(t,e)).length;if(!c)return!0;for(;++n<c;){var u=s(t[n]);if("__proto__"===u&&!a.call(e,"__proto__"))return!1;if(("constructor"===u||"prototype"===u)&&n<c-1)return!1}var l=i(e,t);return null==l||delete l[s(o(t))]}},7297:function(e,t,n){var r=n(6152),o=n(1401),i=n(4452),s=n(6188);e.exports=function(e,t){return r(e)?e:o(e,t)?[e]:i(s(e))}},9882:function(e,t,n){var r=n(9162);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},2175:function(e,t,n){e=n.nmd(e);var r=n(7772),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=a?a(n):new e.constructor(n);return e.copy(r),r}},4727:function(e,t,n){var r=n(9882);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}},6058:function(e){var t=/\w*$/;e.exports=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}},169:function(e,t,n){var r=n(857),o=r?r.prototype:void 0,i=o?o.valueOf:void 0;e.exports=function(e){return i?Object(i.call(e)):{}}},6190:function(e,t,n){var r=n(9882);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},1522:function(e){e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},752:function(e,t,n){var r=n(91),o=n(3940);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var a=-1,c=t.length;++a<c;){var u=t[a],l=i?i(n[u],e[u],u,n,e):void 0;void 0===l&&(l=e[u]),s?o(n,u,l):r(n,u,l)}return n}},7680:function(e,t,n){var r=n(752),o=n(633);e.exports=function(e,t){return r(e,o(e),t)}},9987:function(e,t,n){var r=n(752),o=n(2680);e.exports=function(e,t){return r(e,o(e),t)}},4019:function(e,t,n){var r=n(7772)["__core-js_shared__"];e.exports=r},3043:function(e,t,n){var r=n(8761),o=function(){try{var e=r(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=o},1242:function(e,t,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},3483:function(e,t,n){var r=n(1897),o=n(633),i=n(249);e.exports=function(e){return r(e,i,o)}},6939:function(e,t,n){var r=n(1897),o=n(2680),i=n(8582);e.exports=function(e){return r(e,i,o)}},7937:function(e,t,n){var r=n(8304);e.exports=function(e,t){var n=e.__data__;return r(t)?n["string"==typeof t?"string":"hash"]:n.map}},8761:function(e,t,n){var r=n(6840),o=n(8109);e.exports=function(e,t){var n=o(e,t);return r(n)?n:void 0}},7353:function(e,t,n){var r=n(241)(Object.getPrototypeOf,Object);e.exports=r},2107:function(e,t,n){var r=n(857),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},633:function(e,t,n){var r=n(7552),o=n(981),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:o;e.exports=a},2680:function(e,t,n){var r=n(5067),o=n(7353),i=n(633),s=n(981),a=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)r(t,i(e)),e=o(e);return t}:s;e.exports=a},940:function(e,t,n){var r=n(9515),o=n(326),i=n(2760),s=n(2143),a=n(3215),c=n(3366),u=n(7035),l="[object Map]",h="[object Promise]",d="[object Set]",f="[object WeakMap]",p="[object DataView]",v=u(r),y=u(o),g=u(i),m=u(s),b=u(a),_=c;(r&&_(new r(new ArrayBuffer(1)))!=p||o&&_(new o)!=l||i&&_(i.resolve())!=h||s&&_(new s)!=d||a&&_(new a)!=f)&&(_=function(e){var t=c(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):"";if(r)switch(r){case v:return p;case y:return l;case g:return h;case m:return d;case b:return f}return t}),e.exports=_},8109:function(e){e.exports=function(e,t){return null==e?void 0:e[t]}},2118:function(e,t,n){var r=n(9191);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},6909:function(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},8138:function(e,t,n){var r=n(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return o.call(t,e)?t[e]:void 0}},4174:function(e,t,n){var r=n(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:o.call(t,e)}},7942:function(e,t,n){var r=n(9191);e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?"__lodash_hash_undefined__":t,this}},9917:function(e){var t=Object.prototype.hasOwnProperty;e.exports=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r}},8222:function(e,t,n){var r=n(9882),o=n(4727),i=n(6058),s=n(169),a=n(6190);e.exports=function(e,t,n){var c=e.constructor;switch(t){case"[object ArrayBuffer]":return r(e);case"[object Boolean]":case"[object Date]":return new c(+e);case"[object DataView]":return o(e,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return a(e,n);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(e);case"[object RegExp]":return i(e);case"[object Symbol]":return s(e)}}},8725:function(e,t,n){var r=n(9413),o=n(7353),i=n(6001);e.exports=function(e){return"function"!=typeof e.constructor||i(e)?{}:r(o(e))}},9045:function(e){var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n}},1401:function(e,t,n){var r=n(6152),o=n(4795),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!o(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},8304:function(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},7394:function(e,t,n){var r,o=n(4019),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!i&&i in e}},6001:function(e){var t=Object.prototype;e.exports=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}},3945:function(e){e.exports=function(){this.__data__=[],this.size=0}},1846:function(e,t,n){var r=n(2218),o=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():o.call(t,n,1),--this.size,0))}},8028:function(e,t,n){var r=n(2218);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},6018:function(e,t,n){var r=n(2218);e.exports=function(e){return r(this.__data__,e)>-1}},4769:function(e,t,n){var r=n(2218);e.exports=function(e,t){var n=this.__data__,o=r(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this}},2411:function(e,t,n){var r=n(9612),o=n(235),i=n(326);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||o),string:new r}}},6417:function(e,t,n){var r=n(7937);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},6928:function(e,t,n){var r=n(7937);e.exports=function(e){return r(this,e).get(e)}},9493:function(e,t,n){var r=n(7937);e.exports=function(e){return r(this,e).has(e)}},4150:function(e,t,n){var r=n(7937);e.exports=function(e,t){var n=r(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this}},7777:function(e,t,n){var r=n(733);e.exports=function(e){var t=r(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}},9191:function(e,t,n){var r=n(8761)(Object,"create");e.exports=r},4248:function(e,t,n){var r=n(241)(Object.keys,Object);e.exports=r},2966:function(e){e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},4146:function(e,t,n){e=n.nmd(e);var r=n(1242),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o&&r.process,a=function(){try{return i&&i.require&&i.require("util").types||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=a},7157:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},241:function(e){e.exports=function(e,t){return function(n){return e(t(n))}}},2721:function(e,t,n){var r=n(3324),o=n(9872);e.exports=function(e,t){return t.length<2?e:r(e,o(t,0,-1))}},7772:function(e,t,n){var r=n(1242),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},5243:function(e,t,n){var r=n(235);e.exports=function(){this.__data__=new r,this.size=0}},2858:function(e){e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},4417:function(e){e.exports=function(e){return this.__data__.get(e)}},8605:function(e){e.exports=function(e){return this.__data__.has(e)}},1418:function(e,t,n){var r=n(235),o=n(326),i=n(6738);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!o||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},4452:function(e,t,n){var r=n(7777),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=r(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(o,function(e,n,r,o){t.push(r?o.replace(i,"$1"):n||e)}),t});e.exports=s},3812:function(e,t,n){var r=n(4795);e.exports=function(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}},7035:function(e){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},9850:function(e,t,n){var r=n(8874);e.exports=function(e){return r(e,5)}},1225:function(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},9631:function(e,t,n){var r=n(5183),o=n(5125),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,c=r(function(){return arguments}())?r:function(e){return o(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=c},6152:function(e){var t=Array.isArray;e.exports=t},7878:function(e,t,n){var r=n(1049),o=n(1158);e.exports=function(e){return null!=e&&o(e.length)&&!r(e)}},3226:function(e,t,n){e=n.nmd(e);var r=n(7772),o=n(6330),i=t&&!t.nodeType&&t,s=i&&e&&!e.nodeType&&e,a=s&&s.exports===i?r.Buffer:void 0,c=(a?a.isBuffer:void 0)||o;e.exports=c},1049:function(e,t,n){var r=n(3366),o=n(9259);e.exports=function(e){if(!o(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1158:function(e){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},4714:function(e,t,n){var r=n(4511),o=n(7826),i=n(4146),s=i&&i.isMap,a=s?o(s):r;e.exports=a},9259:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5125:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},3679:function(e,t,n){var r=n(8436),o=n(7826),i=n(4146),s=i&&i.isSet,a=s?o(s):r;e.exports=a},4795:function(e,t,n){var r=n(3366),o=n(5125);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},7598:function(e,t,n){var r=n(5522),o=n(7826),i=n(4146),s=i&&i.isTypedArray,a=s?o(s):r;e.exports=a},249:function(e,t,n){var r=n(1634),o=n(6411),i=n(7878);e.exports=function(e){return i(e)?r(e):o(e)}},8582:function(e,t,n){var r=n(1634),o=n(8390),i=n(7878);e.exports=function(e){return i(e)?r(e,!0):o(e)}},6974:function(e){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},733:function(e,t,n){var r=n(6738);function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(o.Cache||r),n}o.Cache=r,e.exports=o},6765:function(e,t,n){var r=n(2857);e.exports=function(e,t,n){return null==e?e:r(e,t,n)}},981:function(e){e.exports=function(){return[]}},6330:function(e){e.exports=function(){return!1}},6188:function(e,t,n){var r=n(1054);e.exports=function(e){return null==e?"":r(e)}},7195:function(e,t,n){var r=n(9078);e.exports=function(e,t){return null==e||r(e,t)}},2764:function(e){"use strict";e.exports=require("@cloudbase/adapter-interface")},7917:function(e){"use strict";e.exports=require("@cloudbase/adapter-wx_mp")},8630:function(e){"use strict";e.exports=require("@cloudbase/wx-cloud-client-sdk")},766:function(e){"use strict";e.exports=require("@mattiasbuelens/web-streams-adapter")},2701:function(e){"use strict";e.exports=require("bson")},3107:function(e){"use strict";e.exports=require("jwt-decode")},6282:function(e){"use strict";e.exports=require("text-encoding-shim")},8775:function(e){"use strict";e.exports=require("web-streams-polyfill")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={id:e,loaded:!1,exports:{}};return n[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}t=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&r&&n;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach(function(e){s[e]=function(){return n[e]}});return s.default=function(){return n},o.d(i,s),i},o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e};var i=o(8795);module.exports=i}();
2
+ !function(){var e,t,n={2772:function(e){"use strict";var t,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(s,{Channel:()=>I,LongPoll:()=>A,Presence:()=>T,Push:()=>w,Serializer:()=>P,Socket:()=>C,Timer:()=>S}),e.exports=(t=s,((e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||void 0===s||n(e,s,{get:()=>t[s],enumerable:!(a=r(t,s))||a.enumerable});return e})(n({},"__esModule",{value:!0}),t));var a=e=>"function"==typeof e?e:function(){return e},c="undefined"!=typeof self?self:null,u="undefined"!=typeof window?window:null,l=c||u||globalThis,h="closed",d="errored",f="joined",p="joining",v="leaving",y="phx_close",g="phx_error",m="phx_reply",b="phx_leave",_="websocket",E="base64url.bearer.phx.",w=class{constructor(e,t,n,r){this.channel=e,this.event=t,this.payload=n||function(){return{}},this.receivedResp=null,this.timeout=r,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:e,response:t,_ref:n}){this.recHooks.filter(t=>t.status===e).forEach(e=>e.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},S=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},I=class{constructor(e,t,n){this.state=h,this.topic=e,this.params=a(t||{}),this.socket=n,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new w(this,"phx_join",this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new S(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=f,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=d,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=h,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=d,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new w(this,b,a({}),this.timeout).send(),this.state=d,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(m,(e,t)=>{this.trigger(this.replyEventName(t),e)})}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=h,this.bindings=[]}onClose(e){this.on(y,e)}onError(e){return this.on(g,t=>e(t))}on(e,t){let n=this.bindingRef++;return this.bindings.push({event:e,ref:n,callback:t}),n}off(e,t){this.bindings=this.bindings.filter(n=>!(n.event===e&&(void 0===t||t===n.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,n=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let r=new w(this,e,function(){return t},n);return this.canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=v;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(y,"leave")},n=new w(this,b,a({}),e);return n.receive("ok",()=>t()).receive("timeout",()=>t()),n.send(),this.canPush()||n.trigger("ok",{}),n}onMessage(e,t,n){return t}filterBindings(e,t,n){return!0}isMember(e,t,n,r){return!(this.topic!==e||r&&r!==this.joinRef()&&(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:n,joinRef:r}),1))}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=p,this.joinPush.resend(e))}trigger(e,t,n,r){let o=this.onMessage(e,t,n,r);if(t&&!o)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(r=>r.event===e&&this.filterBindings(r,t,n));for(let e=0;e<i.length;e++)i[e].callback(o,n,r||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===h}isErrored(){return this.state===d}isJoined(){return this.state===f}isJoining(){return this.state===p}isLeaving(){return this.state===v}},O=class{static request(e,t,n,r,o,i,s){if(l.XDomainRequest){let n=new l.XDomainRequest;return this.xdomainRequest(n,e,t,r,o,i,s)}if(l.XMLHttpRequest){let a=new l.XMLHttpRequest;return this.xhrRequest(a,e,t,n,r,o,i,s)}if(l.fetch&&l.AbortController)return this.fetchRequest(e,t,n,r,o,i,s);throw new Error("No suitable XMLHttpRequest implementation found")}static fetchRequest(e,t,n,r,o,i,s){let a={method:e,headers:n,body:r},c=null;return o&&(c=new AbortController,setTimeout(()=>c.abort(),o),a.signal=c.signal),l.fetch(t,a).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>s&&s(e)).catch(e=>{"AbortError"===e.name&&i?i():s&&s(null)}),c}static xdomainRequest(e,t,n,r,o,i,s){return e.timeout=o,e.open(t,n),e.onload=()=>{let t=this.parseJSON(e.responseText);s&&s(t)},i&&(e.ontimeout=i),e.onprogress=()=>{},e.send(r),e}static xhrRequest(e,t,n,r,o,i,s,a){e.open(t,n,!0),e.timeout=i;for(let[t,n]of Object.entries(r))e.setRequestHeader(t,n);return e.onerror=()=>a&&a(null),e.onreadystatechange=()=>{if(4===e.readyState&&a){let t=this.parseJSON(e.responseText);a(t)}},s&&(e.ontimeout=s),e.send(o),e}static parseJSON(e){if(!e||""===e)return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let n=[];for(var r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let o=t?`${t}[${r}]`:r,i=e[r];"object"==typeof i?n.push(this.serialize(i,o)):n.push(encodeURIComponent(o)+"="+encodeURIComponent(i))}return n.join("&")}static appendParams(e,t){if(0===Object.keys(t).length)return e;let n=e.match(/\?/)?"&":"?";return`${e}${n}${this.serialize(t)}`}},A=class{constructor(e,t){t&&2===t.length&&t[1].startsWith(E)&&(this.authToken=atob(t[1].slice(21))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=0,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+_),"$1/longpoll")}endpointURL(){return O.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,n){this.close(e,t,n),this.readyState=0}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return 1===this.readyState||0===this.readyState}poll(){const e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:n,messages:r}=e;if(410===t&&null!==this.token)return this.onerror(410),void this.closeAndRetry(3410,"session_gone",!1);this.token=n}else t=0;switch(t){case 200:r.forEach(e=>{setTimeout(()=>this.onmessage({data:e}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=1,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${t}`)}})}send(e){"string"!=typeof e&&(e=(e=>{let t="",n=new Uint8Array(e),r=n.byteLength;for(let e=0;e<r;e++)t+=String.fromCharCode(n[e]);return btoa(t)})(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e,t=0){this.awaitingBatchAck=!0;const n=t+100,r=e.slice(t,n);this.ajax("POST",{"Content-Type":"application/x-ndjson"},r.join("\n"),()=>this.onerror("timeout"),t=>{t&&200===t.status?n<e.length?this.batchSend(e,n):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1:(this.awaitingBatchAck=!1,this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1))})}close(e,t,n){for(let e of this.reqs)e.abort();this.readyState=3;let r=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:n});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,"undefined"!=typeof CloseEvent?this.onclose(new CloseEvent("close",r)):this.onclose(r)}ajax(e,t,n,r,o){let i;i=O.request(e,this.endpointURL(),t,n,this.timeout,()=>{this.reqs.delete(i),r()},e=>{this.reqs.delete(i),this.isActive()&&o(e)}),this.reqs.add(i)}},T=class e{constructor(t,n={}){let r=n.events||{state:"presence_state",diff:"presence_diff"};this.state=Object.create(null),this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(r.state,t=>{let{onJoin:n,onLeave:r,onSync:o}=this.caller;this.joinRef=this.channel.joinRef(),this.state=e.syncState(this.state,t,n,r),this.pendingDiffs.forEach(t=>{this.state=e.syncDiff(this.state,t,n,r)}),this.pendingDiffs=[],o()}),this.channel.on(r.diff,t=>{let{onJoin:n,onLeave:r,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(t):(this.state=e.syncDiff(this.state,t,n,r),o())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(t){return e.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,t,n,r){let o=this.toNullProtoObj(this.clone(e));t=this.toNullProtoObj(t);let i=Object.create(null),s=Object.create(null);return this.map(o,(e,n)=>{t[e]||(s[e]=n)}),this.map(t,(e,t)=>{let n=o[e];if(n){let r=t.metas.map(e=>e.phx_ref),o=n.metas.map(e=>e.phx_ref),a=t.metas.filter(e=>o.indexOf(e.phx_ref)<0),c=n.metas.filter(e=>r.indexOf(e.phx_ref)<0);a.length>0&&(i[e]=t,i[e].metas=a),c.length>0&&(s[e]=this.clone(n),s[e].metas=c)}else i[e]=t}),this.syncDiff(o,{joins:i,leaves:s},n,r)}static syncDiff(e,t,n,r){e=this.toNullProtoObj(e);let{joins:o,leaves:i}=this.clone(t);return n||(n=function(){}),r||(r=function(){}),this.map(o,(t,r)=>{let o=e[t];if(e[t]=this.clone(r),o){let n=e[t].metas.map(e=>e.phx_ref),r=o.metas.filter(e=>n.indexOf(e.phx_ref)<0);e[t].metas.unshift(...r)}n(t,o,r)}),this.map(i,(t,n)=>{let o=e[t];if(!o)return;let i=n.metas.map(e=>e.phx_ref);o.metas=o.metas.filter(e=>i.indexOf(e.phx_ref)<0),r(t,o,n),0===o.metas.length&&delete e[t]}),e}static list(e,t){return t||(t=function(e,t){return t}),this.map(e,(e,n)=>t(e,n))}static map(e,t){return Object.getOwnPropertyNames(e).map(n=>t(n,e[n]))}static toNullProtoObj(e){if(null===Object.getPrototypeOf(e))return e;let t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(n=>{t[n]=e[n]}),t}static clone(e){return JSON.parse(JSON.stringify(e))}},P={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[n,r,o,i,s]=JSON.parse(e);return t({join_ref:n,ref:r,topic:o,event:i,payload:s})}},binaryEncode(e){let{join_ref:t,ref:n,event:r,topic:o,payload:i}=e,s=new TextEncoder,a=s.encode(t),c=s.encode(n),u=s.encode(o),l=s.encode(r);this.assertFieldSize(a.byteLength,"join_ref"),this.assertFieldSize(c.byteLength,"ref"),this.assertFieldSize(u.byteLength,"topic"),this.assertFieldSize(l.byteLength,"event");let h=this.META_LENGTH+a.byteLength+c.byteLength+u.byteLength+l.byteLength,d=new ArrayBuffer(this.HEADER_LENGTH+h),f=new Uint8Array(d),p=new DataView(d),v=0;p.setUint8(v++,this.KINDS.push),p.setUint8(v++,a.byteLength),p.setUint8(v++,c.byteLength),p.setUint8(v++,u.byteLength),p.setUint8(v++,l.byteLength),f.set(a,v),v+=a.byteLength,f.set(c,v),v+=c.byteLength,f.set(u,v),v+=u.byteLength,f.set(l,v),v+=l.byteLength;var y=new Uint8Array(d.byteLength+i.byteLength);return y.set(f,0),y.set(new Uint8Array(i),d.byteLength),y.buffer},assertFieldSize(e,t){if(e>255)throw new Error(`unable to convert ${t} to binary: must be less than or equal to 255 bytes, but is ${e} bytes`)},binaryDecode(e){let t=new DataView(e),n=t.getUint8(0),r=new TextDecoder;switch(n){case this.KINDS.push:return this.decodePush(e,t,r);case this.KINDS.reply:return this.decodeReply(e,t,r);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,r)}},decodePush(e,t,n){let r=t.getUint8(1),o=t.getUint8(2),i=t.getUint8(3),s=this.HEADER_LENGTH+this.META_LENGTH-1,a=n.decode(e.slice(s,s+r));s+=r;let c=n.decode(e.slice(s,s+o));s+=o;let u=n.decode(e.slice(s,s+i));return s+=i,{join_ref:a,ref:null,topic:c,event:u,payload:e.slice(s,e.byteLength)}},decodeReply(e,t,n){let r=t.getUint8(1),o=t.getUint8(2),i=t.getUint8(3),s=t.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,c=n.decode(e.slice(a,a+r));a+=r;let u=n.decode(e.slice(a,a+o));a+=o;let l=n.decode(e.slice(a,a+i));a+=i;let h=n.decode(e.slice(a,a+s));a+=s;let d=e.slice(a,e.byteLength);return{join_ref:c,ref:u,topic:l,event:m,payload:{status:h,response:d}}},decodeBroadcast(e,t,n){let r=t.getUint8(1),o=t.getUint8(2),i=this.HEADER_LENGTH+2,s=n.decode(e.slice(i,i+r));i+=r;let a=n.decode(e.slice(i,i+o));return i+=o,{join_ref:null,ref:null,topic:s,event:a,payload:e.slice(i,e.byteLength)}}},C=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=t.timeout||1e4,this.transport=t.transport||l.WebSocket||A,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let n=null;try{n=l&&l.sessionStorage}catch{}this.sessionStore=t.sessionStorage||n,this.establishedConnections=0,this.defaultEncoder=P.encode.bind(P),this.defaultDecoder=P.decode.bind(P),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==A?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let r=null;u&&u.addEventListener&&(u.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),r=this.connectClock)}),u.addEventListener("pageshow",e=>{r===this.connectClock&&(r=null,this.connect())}),u.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?this.pageHidden=!0:(this.pageHidden=!1,this.isConnected()||this.closeWasClean||this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=t.autoSendHeartbeat??!0,this.heartbeatCallback=t.heartbeatCallback??(()=>{}),this.rejoinAfterMs=e=>t.rejoinAfterMs?t.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>t.reconnectAfterMs?t.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(e,t,n)=>{console.log(`${e}: ${t}`,n)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=a(t.params||{}),this.endPoint=`${e}/${_}`,this.vsn=t.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new S(()=>{if(this.pageHidden)return this.log("Not reconnecting as page is hidden!"),void this.teardown();this.teardown(async()=>{t.beforeReconnect&&await t.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=t.authToken&&a(t.authToken)}getLongPollTransport(){return A}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=O.appendParams(O.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return"/"!==e.charAt(0)?e:"/"===e.charAt(1)?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,n){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,n)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=a(e)),this.conn&&!this.disconnecting||(this.longPollFallbackMs&&this.transport!==A?this.connectWithFallback(A,this.longPollFallbackMs):this.transportConnect())}log(e,t,n){this.logger&&this.logger(e,t,n)}hasLogger(){return null!==this.logger}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),n=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let r=this.onMessage(o=>{o.ref===t&&(this.off([r]),e(Date.now()-n))});return!0}transportName(e){return e===A?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix",`${E}${btoa(this.authToken()).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let n,r=!1,o=!0,i=this.transportName(e),s=t=>{this.log("transport",`falling back to ${i}...`,t),this.off([void 0,n]),o=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${i}`))return s("memorized");this.fallbackTimer=setTimeout(s,t),n=this.onError(e=>{this.log("transport","error",e),o&&!r&&(clearTimeout(this.fallbackTimer),s(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(r=!0,!o){let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t}`,"true"),this.log("transport",`established ${t} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(s,t),this.ping(e=>{this.log("transport","connected to primary after",e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),1e3,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,n){if(!this.conn)return e&&e();const r=this.conn;this.waitForBufferDone(r,()=>{t?r.close(t,n||""):r.close(),this.waitForSocketClosed(r,()=>{this.conn===r&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t,n=1){5!==n&&e.bufferedAmount?setTimeout(()=>{this.waitForBufferDone(e,t,n+1)},150*n):t()}waitForSocketClosed(e,t,n=1){5!==n&&3!==e.readyState?setTimeout(()=>{this.waitForSocketClosed(e,t,n+1)},150*n):t()}onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(e),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport","error",e);let t=this.transport,n=this.establishedConnections;this.triggerStateCallbacks("error",e,t,n),(t===this.transport||n>0)&&this.triggerChanError(e)}triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(g,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case 0:return"connecting";case 1:return"open";case 2:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([t])=>-1===e.indexOf(t))}channel(e,t={}){let n=new I(e,t,this);return this.channels.push(n),n}push(e){if(this.hasLogger()){let{topic:t,event:n,payload:r,ref:o,join_ref:i}=e;this.log("push",`${t} ${n} (${i}, ${o})`,r)}this.isConnected()?this.encode(e,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(e,e=>this.conn.send(e)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(this.isConnected())if(this.pendingHeartbeatRef)this.heartbeatTimeout();else{this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}else try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:n,payload:r,ref:o,join_ref:i}=e;if(o&&o===this.pendingHeartbeatRef){const e=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback("ok"===r.status?"ok":"error",e)}catch(e){this.log("error","error in heartbeat callback",e)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${r.status||""} ${t} ${n} ${o&&"("+o+")"||""}`.trim(),r);for(let e=0;e<this.channels.length;e++){const s=this.channels[e];s.isMember(t,n,r,i)&&s.trigger(n,r,o,i)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(e,...t){try{this.stateChangeCallbacks[e].forEach(([n,r])=>{try{r(...t)}catch(t){this.log("error",`error in ${e} callback`,t)}})}catch(t){this.log("error",`error triggering ${e} callbacks`,t)}}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}}},7756:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AI=void 0;var u=n(9737),l=s(n(5305)),h=n(1689),d=n(2877),f=l.MODELS,p=function(){function e(e,t,n,o){var i=this;this.req=e,this.baseUrl=t,this.modelRequest=function(e){var t=e.url,n=e.data,o=e.headers,s=e.stream,u=e.timeout;return a(i,void 0,void 0,function(){var e,i,a,l,h,d,f;return c(this,function(c){switch(c.label){case 0:return e={"Content-Type":"application/json"},s&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:r(r((h={},h[null===(d=this.i18n)||void 0===d?void 0:d.LANG_HEADER_KEY]=null===(f=this.i18n)||void 0===f?void 0:f.lang,h),e),o),body:JSON.stringify(n),url:this.resolveUrl(t),stream:s,timeout:u})];case 1:return i=c.sent(),a=i.data,l=i.header,[2,this.handleResponseData(a,l)]}})})},this.botRequest=function(e){var t=e.method,n=e.url,o=e.data,s=void 0===o?{}:o,u=e.headers,l=e.stream,h=e.timeout;return a(i,void 0,void 0,function(){var e,o,i,a,d,f,p,v,y;return c(this,function(c){switch(c.label){case 0:return e=this.resolveUrl(n),"get"!==t?[3,2]:(o=this.handleResponseData,[4,this.req.fetch({url:"".concat(e,"?").concat((g=s,Object.entries(g).map(function(e){var t=e[0],n=e[1];return"".concat(t,"=").concat(n)}).join("&"))),method:t,headers:u,stream:l,timeout:h})]);case 1:return[2,o.apply(this,[c.sent().data])];case 2:return i={"Content-Type":"application/json"},l&&Object.assign(i,{Accept:"text/event-stream"}),[4,this.req.fetch({url:e,body:JSON.stringify(s),headers:r(r((p={},p[null===(v=this.i18n)||void 0===v?void 0:v.LANG_HEADER_KEY]=null===(y=this.i18n)||void 0===y?void 0:y.lang,p),i),u),stream:l,method:t,timeout:h})];case 3:return a=c.sent(),d=a.data,f=a.header,[2,this.handleResponseData(d,f)]}var g})})},this._getBaseUrl=o,this.bot=new u.Bot(this.botRequest,this.aiBotBaseUrl),this.i18n=n,d.langEvent.bus.on(d.langEvent.LANG_CHANGE_EVENT,function(e){var t;i.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||i.i18n})}return Object.defineProperty(e.prototype,"aiBaseUrl",{get:function(){return"".concat(this._getBaseUrl?this._getBaseUrl():this.baseUrl,"/ai")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aiBotBaseUrl",{get:function(){return"".concat(this._getBaseUrl?this._getBaseUrl():this.baseUrl,"/aibot")},enumerable:!1,configurable:!0}),e.prototype.handleResponseData=function(e,t){var n,r;return a(this,void 0,void 0,function(){var o,i,s,a,u,l=this;return c(this,function(c){switch(c.label){case 0:return o=function(e){var t,n,r;return null!==(r=null===(n=null===(t=l.i18n)||void 0===t?void 0:t.t)||void 0===n?void 0:n.call(t,e))&&void 0!==r?r:e},i="".concat(o("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),s=function(e){if("object"==typeof e&&e&&"code"in e&&"NORMAL"!==e.code)throw new Error("".concat(o("AI+ 请求出错,错误码"),":").concat(e.code,",").concat(o("错误信息"),":").concat(e.message,"\n").concat(i,"\n").concat(JSON.stringify(e,null,2)))},"object"==typeof e&&e&&"function"!=typeof e.getReader?"then"in e?[4,e]:[3,2]:[3,4];case 1:return a=c.sent(),[3,3];case 2:a=e,c.label=3;case 3:return s(u=a),[2,e];case 4:if("function"!=typeof(null==e?void 0:e.getReader)){if("object"==typeof(u=e)&&u&&"code"in u&&"NORMAL"!==u.code)throw new Error("".concat(o("AI+ 请求出错,错误码"),":").concat(u.code,",").concat(o("错误信息"),":").concat(u.message,"\n").concat(i,"\n").concat(JSON.stringify(u,null,2)));return[2,e]}return(null===(r=null===(n=null==t?void 0:t.get)||void 0===n?void 0:n.call(t,"content-type"))||void 0===r?void 0:r.includes("application/json"))?[4,(0,h.readableStream2JsonObject)(e)]:[3,6];case 5:u=c.sent(),s(u),c.label=6;case 6:return[2,e]}})})},e.prototype.createModel=function(e,t){var n,r=f[e];if(r)n=new r(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==t?void 0:t.defaultModelSubUrl)?t.defaultModelSubUrl:"/chat/completions";n=new l.DefaultSimpleModel(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new l.ReactModel(n)},e.prototype.registerModel=function(e,t){null==f[e]?f[e]=t:console.warn("AI model ".concat(e," already exists!"))},e.prototype.createImageModel=function(e){return new l.DefaultImageModel(this.modelRequest,this.aiBaseUrl,e)},e.prototype.registerFunctionTool=function(e){l.toolMap.has(e.name)&&console.warn("AI function tool ".concat(e.name," already exists and will be overwritten!")),l.toolMap.set(e.name,e.fn)},e.prototype.resolveUrl=function(e){if(!this._getBaseUrl)return e;var t=this._getBaseUrl();return t!==this.baseUrl&&e.startsWith(this.baseUrl)?e.replace(this.baseUrl,t):e},e}();t.AI=p},9737:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.Bot=void 0;var a=n(1689),c=function(){function e(e,t){this.baseUrl=t;var n=arguments[2];this.req="string"==typeof n?function(t){var o=t.headers,i=void 0===o?{}:o,a=s(t,["headers"]);return e(r(r({},a),{headers:r(r({},i),{Authorization:"Bearer ".concat(n)})}))}:e}return e.prototype.list=function(e,t){return this.req({method:"get",url:this.join("bots"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.create=function(e,t){var n=e.botInfo;return this.req({method:"post",url:this.join("bots"),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.get=function(e,t){var n=e.botId;return this.req({method:"get",url:this.join("bots/".concat(n)),timeout:null==t?void 0:t.timeout})},e.prototype.update=function(e,t){var n=e.botId,r=e.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(n)),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.delete=function(e,t){var n=e.botId;return this.req({method:"delete",url:this.join("bots/".concat(n)),timeout:null==t?void 0:t.timeout})},e.prototype.getChatRecords=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/records")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendFeedback=function(e,t){var n=e.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(n.botId,"/feedback")),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.getFeedback=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/feedback")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.uploadFiles=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/files")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.createConversation=function(e,t){var n=e.botId,r=s(e,["botId"]);return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.req({method:"post",url:this.join("bots/".concat(n,"/conversation")),data:r,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getConversation=function(e,t){var n=e.pageSize,a=void 0===n?10:n,c=e.pageNumber,u=void 0===c?1:c,l=e.botId,h=s(e,["pageSize","pageNumber","botId"]);return o(this,void 0,void 0,function(){var e,n;return i(this,function(o){if(u<1)throw new Error("pageNumber must be greater than 0");return e=a*(u-1),n=a,[2,this.req({method:"get",url:this.join("bots/".concat(l,"/conversation")),data:r(r({},h),{offset:e,limit:n}),timeout:null==t?void 0:t.timeout})]})})},e.prototype.deleteConversation=function(e,t){var n=e.botId,r=e.conversationId,a=s(e,["botId","conversationId"]);return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.req({method:"delete",url:this.join("bots/".concat(n,"/conversation/").concat(r)),data:a,timeout:null==t?void 0:t.timeout})]})})},e.prototype.speechToText=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/speech-to-text")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.textToSpeech=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getTextToSpeechResult=function(e,t){return o(this,void 0,void 0,function(){return i(this,function(n){return[2,this.req({method:"get",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]})})},e.prototype.getRecommendQuestions=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/recommend-questions")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.generateBot=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.getPreview=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.generateImage=function(e,t){return this.req({method:"post",url:this.join("generate-image"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendMessage=function(e,t){return o(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/send-message")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new u(n)]}})})},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}();t.Bot=c;var u=function(){function e(e){var t=(0,a.toPolyfillReadable)(e);this._eventSourceStream=t.pipeThrough(new a.TextDecoderStream).pipeThrough((0,a.createEventSourceParserTransformStream)())}return Object.defineProperty(e.prototype,"teeedStream",{get:function(){var e=this._eventSourceStream.tee(),t=e[0],n=e[1];return this._eventSourceStream=n,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eventSourceStream",{get:function(){return(0,a.createAsyncIterable)(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataStream",{get:function(){return(0,a.createAsyncIterable)(this.eventSourceStream.pipeThrough(new a.TransformStream({transform:function(e,t){try{var n=JSON.parse(e.data);t.enqueue(n)}catch(n){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",n,e):t.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textStream",{get:function(){return(0,a.createAsyncIterable)(this.dataStream.pipeThrough(new a.TransformStream({transform:function(e,t){var n;t.enqueue(null!==(n=null==e?void 0:e.content)&&void 0!==n?n:"")}})))},enumerable:!1,configurable:!0}),e}()},713:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.InvalidParamsError=void 0;var o=function(e){function t(t,n){var r=e.call(this,t)||this;return r.name="InvalidParamsError",r.code="INVALID_PARAMS",r.field=n,r}return r(t,e),t.prototype.toJSON=function(){return{code:this.code,message:this.message,field:this.field}},t}(Error);t.InvalidParamsError=o},9964:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0;var r=n(6298);Object.defineProperty(t,"createParser",{enumerable:!0,get:function(){return r.createParser}})},6298:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0,t.createParser=function(e){var t,r,o,i,s,a,c;return u(),{feed:function(e){r=r?r+e:e,t&&function(e){return n.every(function(t,n){return e.charCodeAt(n)===t})}(r)&&(r=r.slice(n.length)),t=!1;for(var s=r.length,a=0,c=!1;a<s;){c&&("\n"===r[a]&&(a+=1),c=!1);for(var u=-1,h=i,d=void 0,f=o;u<0&&f<s;f++)":"===(d=r[f])&&h<0?h=f-a:"\r"===d?(c=!0,u=f-a):"\n"===d&&(u=f-a);if(u<0){o=s-a,i=h;break}o=0,i=-1,l(r,a,h,u),a+=u+1}a===s?r="":a>0&&(r=r.slice(a))},reset:u};function u(){t=!0,r="",o=0,i=-1,s=void 0,a=void 0,c=""}function l(t,n,r,o){if(0===o)return c.length>0&&(e({type:"event",id:s,event:a||void 0,data:c.slice(0,-1)}),c="",s=void 0),void(a=void 0);var i,u=r<0,l=t.slice(n,n+(u?o:r)),h=n+(i=u?o:" "===t[n+r+1]?r+2:r+1),d=o-i,f=t.slice(h,h+d).toString();if("data"===l)c+=f?"".concat(f,"\n"):"\n";else if("event"===l)a=f;else if("id"!==l||f.includes("\0")){if("retry"===l){var p=parseInt(f,10);Number.isNaN(p)||e({type:"reconnect-interval",value:p})}}else s=f}};var n=[239,187,191]},5337:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},c=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},u=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},l=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.registerAi=t.models=t.createAI=t.createAi=t.Bot=t.AI=void 0;var h=n(7756);Object.defineProperty(t,"AI",{enumerable:!0,get:function(){return h.AI}});var d=n(9737);Object.defineProperty(t,"Bot",{enumerable:!0,get:function(){return d.Bot}});var f=s(n(5305)),p=s(n(1689));t.utils=p,f.MODELS;var v=l(f,["MODELS"]);function y(e){var t=e.env,n=e.baseUrl,o=e.getBaseUrl,i=e.req,s=e.getAccessToken,a=e.handleReqInstance,d=e.i18n;return new h.AI(function(){if(null==a){if(null==s)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return function(e){var t=e.getAccessToken,n=e.req;return{download:n.download,post:n.post,upload:n.upload,fetch:function(e){return c(void 0,void 0,void 0,function(){var o,i,s,a,c;return u(this,function(u){switch(u.label){case 0:if("function"!=typeof n.fetch)throw new Error("req.fetch is not a function");return o=e.token,i=e.headers,s=void 0===i?{}:i,a=l(e,["token","headers"]),null==o?[3,1]:(c=o,[3,3]);case 1:return[4,t()];case 2:c=u.sent().accessToken,u.label=3;case 3:return[2,n.fetch(r({headers:r({Authorization:"Bearer ".concat(c)},s)},a))]}})})}}}({req:i,getAccessToken:s})}return a({req:i})}(),function(){if(null!=o)return o();if(null!=n)return n;if(null==t)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(t,".api.tcloudbasegateway.com/v1")}(),d,o)}t.models=v,t.createAI=y;var g=y;t.createAi=g;var m={name:"ai",entity:{ai:function(e){var t=this,n=this.request;if(null==n.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");var r=function(){var e=t.getEndPointWithKey("GATEWAY"),n=e.BASE_URL,r=e.PROTOCOL;return"".concat(r).concat(n)};return(null==e?void 0:e.baseUrl)?y({req:n,baseUrl:e.baseUrl,handleReqInstance:function(e){return e.req},i18n:this.config.i18n}):y({req:n,baseUrl:r(),getBaseUrl:r,handleReqInstance:function(e){return e.req},i18n:this.config.i18n})}}};function b(e){try{e.registerComponent(m)}catch(e){console.warn(e)}}t.registerAi=b,a(n(4669),t),a(n(713),t);try{window.registerAi=b}catch(e){}},5476:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ArkSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,s=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:s,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="ark/api/v3/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.ArkSimpleModel=c},7265:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DSSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,s=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:s,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),r(r({},e),n?{finish_reason:"tool_calls",delta:t}:{delta:t})}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.DSSimpleModel=c},2102:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepSeekSimpleModel=void 0;var s=n(1689),a=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="deepseek/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},e),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,a,c,u;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),a=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(a),u=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(u)]}})})},e}();t.DeepSeekSimpleModel=a},8017:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSimpleModel=void 0;var s=n(1689),a=function(){function e(e,t,n){void 0===n&&(n=""),this.req=e,this.baseUrl=t,this.subUrl=n}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},e),{stream:!1}),stream:!1})];case 1:return t=n.sent(),[2,r(r({},t),{rawResponse:t})]}})})},e.prototype.doStream=function(e){return o(this,void 0,Promise,function(){var t,n,o,a,c;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:r(r({},e),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,s.toPolyfillReadable)(n),a=(0,s.intoStandardStream)(o),c=a.pipeThrough(new s.TransformStream({transform:function(e,n){var o=e.choices.map(function(e){var n=e.delta;return null==t&&(t=(0,s.isToolCallAssistantMessage)(n)),t?r(r({},e),{finish_reason:"tool_calls",delta:n}):e}),i=r(r({},e),{choices:o});n.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(c)]}})})},e}();t.DefaultSimpleModel=a},7239:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanSimpleModel=void 0;var s=n(1689),a=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=(0,a.titleCaseToSnakeCase)(n.Response),[2,r(r({},o),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=(0,a.titleCaseToSnakeCase)(e),i=o.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),c=r(r({},o),{choices:i});t.enqueue(r(r({},c),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.HunYuanSimpleModel=c},8586:function(e,t){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.titleCaseToSnakeCase=t.processInput=void 0,t.processInput=function(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tool_choice,s=e.tools,a=e.top_p;return n(n({},e),{messages:(t.forEach(function(e){"tool_calls"in e&&e.tool_calls.filter(function(e){return"function"!==e.type}).forEach(function(t){return console.warn("`type` in tool_call is not 'function'",t,e)})}),t),model:r,tools:function(){if(s)return s.forEach(function(e){"function"!==e.type&&console.warn("`type` in tool is not 'function'",e)}),s}(),top_p:a,tool_choice:i,temperature:o})},t.titleCaseToSnakeCase=function e(t){return"object"!=typeof t||null==t?t:Array.isArray(t)?t.map(function(t){return e(t)}):Object.entries(t).reduce(function(t,n){var r,o=n[0],i=n[1];return t["_"===(r=o.replace(/[A-Z]/g,function(e){return"_".concat(e.toLowerCase())})).charAt(0)?r.slice(1):r]="object"==typeof i?e(i):i,t},{})}},9301:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanBetaSimpleModel=void 0;var s=n(1689),a=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.HunYuanBetaSimpleModel=c},5720:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanExpSimpleModel=void 0;var s=n(1689),a=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-exp/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!1}),stream:!1})];case 1:return t=n.sent(),[2,r(r({},t),{rawResponse:t})]}})})},e.prototype.doStream=function(e){return o(this,void 0,Promise,function(){var t,n,o,c,u;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,s.toPolyfillReadable)(n),c=(0,s.intoStandardStream)(o),u=c.pipeThrough(new s.TransformStream({transform:function(e,n){var o=e.choices.map(function(e){var n=e.delta;return null==t&&(t=(0,s.isToolCallAssistantMessage)(n)),t?r(r({},e),{finish_reason:"tool_calls",delta:n}):e}),i=r(r({},e),{choices:o});n.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(u)]}})})},e}();t.HunYuanExpSimpleModel=c},1586:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanOpenSimpleModel=void 0;var s=n(1689),a=n(8586),c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-open/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.HunYuanOpenSimpleModel=c},3925:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.MoonshotSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,s=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:s,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="moonshot/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.MoonshotSimpleModel=c},4532:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.YiSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,s=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:s,temperature:o})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="01-ai/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l;return i(this,function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),c=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(c),l=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o,i,a,c,u,l;if((null===(a=null===(i=null===(o=null==e?void 0:e.choices)||void 0===o?void 0:o[0])||void 0===i?void 0:i.delta)||void 0===a?void 0:a.content)||(null===(l=null===(u=null===(c=null==e?void 0:e.choices)||void 0===c?void 0:c[0])||void 0===u?void 0:u.delta)||void 0===l?void 0:l.tool_calls)){var h=e.choices.map(function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==n&&(n=(0,s.isToolCallAssistantMessage)(t)),r(r({},e),n?{finish_reason:"tool_calls",delta:t}:{delta:t})}),d=r(r({},e),{choices:h});t.enqueue(r(r({},d),{rawResponse:e}))}}})),[2,(0,s.createAsyncIterable)(l)]}})})},e}();t.YiSimpleModel=c},7173:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ZhiPuSimpleModel=void 0;var s=n(1689);function a(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tool_choice,s=e.tools,a=e.top_p;return r(r({},e),{messages:t,model:n,temperature:o,tool_choice:(i&&"auto"!==i&&console.warn("`tool_choice` is not 'auto'"),i),tools:s,top_p:a})}var c=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return n=a(e),[4,this.req({url:this.url,data:r(r({},n),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),[2,r(r({},o),{rawResponse:o})]}})})},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,function(){var n,o,c,u,l,h;return i(this,function(i){switch(i.label){case 0:return n=a(e),o=null,[4,this.req({url:this.url,data:r(r({},n),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return c=i.sent(),u=(0,s.toPolyfillReadable)(c),l=(0,s.intoStandardStream)(u),h=l.pipeThrough(new s.TransformStream({transform:function(e,t){var n=e.choices.map(function(e){var t=e.delta;return null==o&&(o=(0,s.isToolCallAssistantMessage)(t)),o?r(r({},e),{finish_reason:"tool_calls",delta:t}):e}),i=r(r({},e),{choices:n});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(h)]}})})},e}();t.ZhiPuSimpleModel=c},8328:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultImageModel=void 0;var i=n(713),s=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.provider=n,this.defaultGenerateImageSubUrl="images/ar/generations",this.generateImageSubUrlConfig={"hunyuan-image":[[/^hunyuan-image(-v[12](\..*)?)?$/,"images/generations"]],cloudbase:[[/^hy-image-v3\.5-preview$/,"wand/hunyuan-image/v35-generation"]]},this.generateImage=this.generateImageImpl.bind(this)}return e.prototype.generateImageImpl=function(e){return r(this,void 0,Promise,function(){var t;return o(this,function(n){switch(n.label){case 0:return this.validateInput(e),t=this.resolveSubUrl(e),[4,this.req({url:this.getGenerateUrl(t),data:e,stream:!1})];case 1:return[2,n.sent()]}})})},e.prototype.validateInput=function(e){""!==this.provider&&"hunyuan-image"!==this.provider||this.assertHunyuanInput(e)},e.prototype.assertHunyuanInput=function(e){if(e&&"HY-Image-v3.0-I2I-ToB-v1.0.1"===e.model){var t=e.image_urls,n=e.images;if(t&&t.length>1)throw new i.InvalidParamsError("当模型为 HY-Image-v3.0-I2I-ToB-v1.0.1 时,image_urls 最多只能有 1 个元素","image_urls");if(n&&n.length>1)throw new i.InvalidParamsError("当模型为 HY-Image-v3.0-I2I-ToB-v1.0.1 时,images 最多只能有 1 个元素","images")}},e.prototype.resolveSubUrl=function(e){var t=e&&"string"==typeof e.model?e.model:void 0,n=t?this.getGenerateImageSubUrl(this.provider,t):void 0;if(n)return n;if("cloudbase"===this.provider)throw new i.InvalidParamsError("cloudbase provider 不支持的模型:".concat(null!=t?t:"(未指定)"),"model");return this.defaultGenerateImageSubUrl},e.prototype.getGenerateUrl=function(e){return"".concat(this.baseUrl,"/").concat(this.provider,"/").concat(e)},e.prototype.getGenerateImageSubUrl=function(e,t){var n=this.generateImageSubUrlConfig[e];if(n)for(var r=0,o=n;r<o.length;r++){var i=o[r],s=i[0],a=i[1];if(s.test(t))return a}},e}();t.DefaultImageModel=s},5305:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toolMap=t.ReactModel=t.DefaultImageModel=t.DefaultSimpleModel=t.HunYuanOpenSimpleModel=t.HunYuanExpSimpleModel=t.MoonshotSimpleModel=t.YiSimpleModel=t.DSSimpleModel=t.ArkSimpleModel=t.HunYuanSimpleModel=t.HunYuanBetaSimpleModel=t.ZhiPuSimpleModel=t.MODELS=void 0;var r=n(7173);Object.defineProperty(t,"ZhiPuSimpleModel",{enumerable:!0,get:function(){return r.ZhiPuSimpleModel}});var o=n(9301);Object.defineProperty(t,"HunYuanBetaSimpleModel",{enumerable:!0,get:function(){return o.HunYuanBetaSimpleModel}});var i=n(7239);Object.defineProperty(t,"HunYuanSimpleModel",{enumerable:!0,get:function(){return i.HunYuanSimpleModel}});var s=n(5476);Object.defineProperty(t,"ArkSimpleModel",{enumerable:!0,get:function(){return s.ArkSimpleModel}});var a=n(7265);Object.defineProperty(t,"DSSimpleModel",{enumerable:!0,get:function(){return a.DSSimpleModel}});var c=n(4532);Object.defineProperty(t,"YiSimpleModel",{enumerable:!0,get:function(){return c.YiSimpleModel}});var u=n(3925);Object.defineProperty(t,"MoonshotSimpleModel",{enumerable:!0,get:function(){return u.MoonshotSimpleModel}});var l=n(5720);Object.defineProperty(t,"HunYuanExpSimpleModel",{enumerable:!0,get:function(){return l.HunYuanExpSimpleModel}});var h=n(1586);Object.defineProperty(t,"HunYuanOpenSimpleModel",{enumerable:!0,get:function(){return h.HunYuanOpenSimpleModel}});var d=n(2102),f=n(8017);Object.defineProperty(t,"DefaultSimpleModel",{enumerable:!0,get:function(){return f.DefaultSimpleModel}});var p=n(8328);Object.defineProperty(t,"DefaultImageModel",{enumerable:!0,get:function(){return p.DefaultImageModel}}),t.MODELS={hunyuan:i.HunYuanSimpleModel,"hunyuan-beta":o.HunYuanBetaSimpleModel,ark:s.ArkSimpleModel,dashscope:a.DSSimpleModel,"01-ai":c.YiSimpleModel,moonshot:u.MoonshotSimpleModel,zhipu:r.ZhiPuSimpleModel,"hunyuan-exp":l.HunYuanExpSimpleModel,"hunyuan-open":h.HunYuanOpenSimpleModel,deepseek:d.DeepSeekSimpleModel};var v=n(1443);Object.defineProperty(t,"ReactModel",{enumerable:!0,get:function(){return v.ReactModel}}),Object.defineProperty(t,"toolMap",{enumerable:!0,get:function(){return v.toolMap}})},1443:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},a=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise(function(r,o){!function(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}(r,o,(t=e[n](t)).done,t.value)})}}},c=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.toolMap=t.ReactModel=void 0;var u=n(1689);function l(e){var t,n=e.onStepFinish,o=e.abortSignal,i=e.maxSteps,a=e.topP,c=e.toolChoice,l=s(e,["onStepFinish","abortSignal","maxSteps","topP","toolChoice"]);if(null!=i&&i<1)throw new Error("`maxSteps` muse be greater than 0.");return[{onStepFinish:n,abortSignal:o,maxSteps:i},r(r({},l),{tools:null===(t=l.tools)||void 0===t?void 0:t.map(function(e){return"fn"in e?(0,u.functionToolToModelTool)(e):e}),top_p:null!=a?a:l.top_p,tool_choice:null!=c?c:l.tool_choice})]}var h=function(){function e(e){this.model=e}return e.prototype.generateText=function(e,t){var n,r;return o(this,void 0,Promise,function(){var o,s,a,u,h,g,m,b,_,E,w,S,I,O,A,T,P,C,R,N,k,U=this;return i(this,function(i){switch(i.label){case 0:return o=[],s={completion_tokens:0,prompt_tokens:0,total_tokens:0},a=l(e),u=a[0],h=u.onStepFinish,g=u.maxSteps,m=void 0===g?10:g,b=a[1],[4,(_=function(){return U.model.doGenerate(b,t)})()];case 1:E=i.sent(),w=1,E.rawResponse&&o.push(E.rawResponse),S=null,i.label=2;case 2:if(!(w<m&&null!=(S=d(E))))return[3,9];I=v(E.usage),y(s,I),i.label=3;case 3:return i.trys.push([3,7,,8]),[4,p(S)];case 4:return O=i.sent(),A=E.choices[0],[4,null==h?void 0:h({finishReason:A.finish_reason,messages:b.messages.slice(),text:A.message.content,toolCall:S,toolResult:O,stepUsage:I,totalUsage:Object.assign({},s)})];case 5:return i.sent(),f(b.messages,A.message,O),[4,_()];case 6:return(E=i.sent()).rawResponse&&o.push(E.rawResponse),w+=1,[3,8];case 7:return T=i.sent(),[2,{text:"",messages:b.messages,usage:s,error:T,rawResponses:o}];case 8:return[3,2];case 9:return P=null===(n=null==E?void 0:E.choices)||void 0===n?void 0:n[0],C=null==P?void 0:P.message,R=null!==(r=null==C?void 0:C.content)&&void 0!==r?r:"",N=C?c(c([],b.messages,!0),[C],!1):b.messages,k=v(E.usage),y(s,k),[4,null==h?void 0:h({finishReason:P.finish_reason,messages:N.slice(),text:R,toolCall:d(E),toolResult:null,stepUsage:k,totalUsage:Object.assign({},s)})];case 10:return i.sent(),[2,{text:R,messages:N,usage:s,rawResponses:o}]}})})},e.prototype.streamText=function(e,t){var n;return o(this,void 0,Promise,function(){var r,s,h,d,v,g,m,b,_,E,w,S,I,O,A,T,P,C,R,N,k,U,D,L,j,x,M,q,F,B,W,H,G,V,K,J,Y=this;return i(this,function(z){switch(z.label){case 0:return r={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=l(e),h=s[0],d=h.onStepFinish,v=h.maxSteps,g=void 0===v?10:v,m=s[1],[4,(b=function(){return Y.model.doStream(m,t)})()];case 1:_=z.sent(),E=1,w=null,S=function(){var e=_.tee(),t=e[0],n=e[1];return _=(0,u.createAsyncIterable)(t),function(e){var t,n,r,s,c,l,h,d,f,p;return o(this,void 0,Promise,function(){var o,v,y,g,m,b,_,E,w,S,I,O,A;return i(this,function(i){switch(i.label){case 0:o={completion_tokens:0,prompt_tokens:0,total_tokens:0},v=(0,u.createAsyncIterable)(e),g={role:"assistant",content:"",tool_calls:[y={id:"",function:{name:"",arguments:""},type:""}]},i.label=1;case 1:i.trys.push([1,6,7,12]),m=!0,b=a(v),i.label=2;case 2:return[4,b.next()];case 3:if(_=i.sent(),t=_.done)return[3,5];s=_.value,m=!1;try{if(!(w=null==(E=s)?void 0:E.choices[0]))return[2,null];if(S=w.finish_reason,I=w.delta,"tool_calls"!==S)return[2,null];if(!I)return[3,4];if(I.content&&(g.content+=I.content),!("tool_calls"in I))return[3,4];(null==(O=null===(c=null==I?void 0:I.tool_calls)||void 0===c?void 0:c[0])?void 0:O.id)&&(y.id=O.id),(null==O?void 0:O.type)&&(y.type=O.type),(null===(l=null==O?void 0:O.function)||void 0===l?void 0:l.name)&&(y.function.name=O.function.name),(null===(h=null==O?void 0:O.function)||void 0===h?void 0:h.arguments)&&(y.function.arguments+=O.function.arguments),(null===(d=null==E?void 0:E.usage)||void 0===d?void 0:d.completion_tokens)&&(o.completion_tokens=E.usage.completion_tokens),(null===(f=null==E?void 0:E.usage)||void 0===f?void 0:f.prompt_tokens)&&(o.prompt_tokens=E.usage.prompt_tokens),(null===(p=null==E?void 0:E.usage)||void 0===p?void 0:p.total_tokens)&&(o.total_tokens=E.usage.total_tokens)}finally{m=!0}i.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return A=i.sent(),n={error:A},[3,12];case 7:return i.trys.push([7,,10,11]),m||t||!(r=b.return)?[3,9]:[4,r.call(b)];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,{message:g,usage:o}]}})})}(n)},z.label=2;case 2:return(I=E<g)?[4,S()]:[3,4];case 3:I=null!=(w=z.sent()),z.label=4;case 4:if(!I)return[3,11];O=w.message,A=w.usage,y(r,A),T=null===(n=O.tool_calls)||void 0===n?void 0:n[0],z.label=5;case 5:return z.trys.push([5,9,,10]),[4,p(T)];case 6:return P=z.sent(),[4,null==d?void 0:d({finishReason:"tool_calls",messages:m.messages.slice(),text:O.content,toolCall:T,toolResult:P,stepUsage:A,totalUsage:Object.assign({},r)})];case 7:return z.sent(),f(m.messages,O,P),[4,b()];case 8:return _=z.sent(),[3,10];case 9:return C=z.sent(),R=_.tee(),N=R[0],k=R[1],[2,{messages:Promise.resolve(m.messages),dataStream:(0,u.createAsyncIterable)(N),textStream:(0,u.createAsyncIterable)(k.pipeThrough(new u.TransformStream({transform:function(e,t){var n,r,o,i=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:Promise.resolve(r),error:C}];case 10:return[3,2];case 11:return[4,S()];case 12:return(w=z.sent())?(U=w.message,D=w.usage,y(r,D),L=c(c([],m.messages,!0),[U],!1),d({messages:L.slice(),finishReason:"tool_call",stepUsage:D,text:U.content,toolCall:U.tool_calls[0],totalUsage:Object.assign({},r)}),j=_.tee(),x=j[0],M=j[1],[2,{messages:Promise.resolve(c(c([],m.messages,!0),[U],!1)),dataStream:(0,u.createAsyncIterable)(x),textStream:(0,u.createAsyncIterable)(M.pipeThrough(new u.TransformStream({transform:function(e,t){var n,r,o,i=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:Promise.resolve(r)}]):(q=(0,u.createPromise)(),F=(0,u.createPromise)(),B={role:"assistant",content:""},W="",H={completion_tokens:0,prompt_tokens:0,total_tokens:0},G=_.pipeThrough(new u.TransformStream({transform:function(e,t){var n,r,o,i,s,a,c,u,l=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof l&&(B.content+=l);var h=null===(s=null===(i=null==e?void 0:e.choices)||void 0===i?void 0:i[0])||void 0===s?void 0:s.finish_reason;h&&(W=h),(null===(a=null==e?void 0:e.usage)||void 0===a?void 0:a.completion_tokens)&&(H.completion_tokens=e.usage.completion_tokens),(null===(c=null==e?void 0:e.usage)||void 0===c?void 0:c.prompt_tokens)&&(H.prompt_tokens=e.usage.prompt_tokens),(null===(u=null==e?void 0:e.usage)||void 0===u?void 0:u.total_tokens)&&(H.total_tokens=e.usage.total_tokens),t.enqueue(e)},flush:function(){q.res(c(c([],m.messages,!0),[B],!1)),y(r,H),F.res(Object.assign({},r)),null==d||d({messages:c(c([],m.messages,!0),[B],!1),finishReason:W,text:B.content,stepUsage:H,totalUsage:Object.assign({},r)})}})),V=G.tee(),K=V[0],J=V[1],[2,{messages:q.promise,dataStream:(0,u.createAsyncIterable)(K),textStream:(0,u.createAsyncIterable)(J.pipeThrough(new u.TransformStream({transform:function(e,t){var n,r,o,i=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:F.promise}])}})})},e}();function d(e){var t,n=null===(t=null==e?void 0:e.choices)||void 0===t?void 0:t[0];if(!n)return null;var r=n.finish_reason,o=n.message;return"tool_calls"!==r?null:o&&(0,u.isToolCallAssistantMessage)(o)?o.tool_calls[0]:null}function f(e,t,n){e.push(t,{role:"tool",tool_call_id:t.tool_calls[0].id,content:JSON.stringify(n)})}function p(e){return t.toolMap.get(e.function.name)(JSON.parse(e.function.arguments))}function v(e){var t,n,r;return{completion_tokens:null!==(t=null==e?void 0:e.completion_tokens)&&void 0!==t?t:0,prompt_tokens:null!==(n=null==e?void 0:e.prompt_tokens)&&void 0!==n?n:0,total_tokens:null!==(r=null==e?void 0:e.total_tokens)&&void 0!==r?r:0}}function y(e,t){e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens}t.ReactModel=h,t.toolMap=new Map},4669:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleChatModel=void 0;t.SimpleChatModel=function(){}},1689:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},i=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise(function(r,o){!function(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}(r,o,(t=e[n](t)).done,t.value)})}}};Object.defineProperty(t,"__esModule",{value:!0}),t.functionToolToModelTool=t.isToolCallAssistantMessage=t.createPromise=t.readableStream2JsonObject=t.intoTextStream=t.intoStandardStream=t.createAsyncIterable=t.TextDecoderStream=t.toPolyfillReadable=t.createEventSourceParserTransformStream=t.TransformStream=t.ReadableStream=void 0;var s=n(8775),a=n(766),c=n(9964),u=n(6282),l="function"==typeof globalThis.ReadableStream&&"function"==typeof globalThis.TransformStream&&"function"==typeof globalThis.ReadableStream.prototype.pipeThrough;t.ReadableStream=l?globalThis.ReadableStream:s.ReadableStream,t.TransformStream=l?globalThis.TransformStream:s.TransformStream,t.createEventSourceParserTransformStream=function(){var e;return new t.TransformStream({start:function(t){e=(0,c.createParser)(function(e){"event"===e.type&&t.enqueue(e)})},transform:function(t){e.feed(t)}})},t.toPolyfillReadable=l?function(e){return e}:(0,a.createReadableStreamWrapper)(t.ReadableStream);var h=function(){function e(e,n){void 0===e&&(e="utf-8"),void 0===n&&(n={});var r=this;this.transform=new t.TransformStream({transform:function(e,t){var n=r.handle.decode(new Uint8Array(e),{stream:!0});n&&t.enqueue(n)},flush:function(e){var t=r.handle.decode();t&&e.enqueue(t),e.terminate()}}),this.handle=new u.TextDecoder(e,n)}return Object.defineProperty(e.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),e}();function d(e){var t=e;return t[Symbol.asyncIterator]=function(){var t=e.getReader();return{next:function(){return r(this,void 0,Promise,function(){var e,n,r;return o(this,function(o){switch(o.label){case 0:return[4,t.read()];case 1:return e=o.sent(),n=e.done,r=e.value,[2,n?{done:!0,value:void 0}:{done:!1,value:r}]}})})}}},t}function f(e){return d((0,t.toPolyfillReadable)(e).pipeThrough(new h))}t.TextDecoderStream=h,t.createAsyncIterable=d,t.intoStandardStream=function(e){return d(e.pipeThrough(new h).pipeThrough((0,t.createEventSourceParserTransformStream)()).pipeThrough(new t.TransformStream({transform:function(e,t){try{var n=JSON.parse(e.data);t.enqueue(n)}catch(n){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",n,e):t.terminate()}}})))},t.intoTextStream=f,t.readableStream2JsonObject=function(e){var t,n,s,a;return r(this,void 0,void 0,function(){var r,c,u,l,h,d;return o(this,function(o){switch(o.label){case 0:r=f(e),c="",o.label=1;case 1:o.trys.push([1,6,7,12]),u=!0,l=i(r),o.label=2;case 2:return[4,l.next()];case 3:if(h=o.sent(),t=h.done)return[3,5];a=h.value,u=!1;try{c+=a}finally{u=!0}o.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return d=o.sent(),n={error:d},[3,12];case 7:return o.trys.push([7,,10,11]),u||t||!(s=l.return)?[3,9]:[4,s.call(l)];case 8:o.sent(),o.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,JSON.parse(c)]}})})},t.createPromise=function(){var e,t;return{promise:new Promise(function(n,r){e=n,t=r}),res:e,rej:t}},t.isToolCallAssistantMessage=function(e){var t;return"assistant"===e.role&&"tool_calls"in e&&null!=(null===(t=e.tool_calls)||void 0===t?void 0:t[0])},t.functionToolToModelTool=function(e){return{type:"function",function:{description:e.description,name:e.name,parameters:e.parameters}}}},5378:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateApis=t.generateCallApis=t.callApi=void 0;var s=n(794);function a(e,t){var n,a,c,u;return o(this,void 0,Promise,function(){var o,l,h,d,f,p,v,y,g,m,b,_,E,w,S,I,O,A,T,P,C,R,N;return i(this,function(i){switch(i.label){case 0:l=(o=e||{}).name,h=o.body,d=o.path,f=void 0===d?"":d,p=o.method,v=void 0===p?"POST":p,y=o.headers,g=void 0===y?{}:y,m=(e||{}).token,b={};try{b=JSON.parse(h)}catch(e){b=h||{}}if(!l)throw new Error(JSON.stringify({code:s.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return _="",w=(E=this).gatewayOrigin,S=E.getAccessToken,I=E.env,w?_="".concat(w,"/v1"):this.getEndPointWithKey?(O=this.getEndPointWithKey("GATEWAY"),A=O.BASE_URL,T=O.PROTOCOL,_="".concat(T).concat(A)):_="https://".concat(I,".api.tcloudbasegateway.com/v1"),P="".concat(_,"/apis/").concat(l),C=f.startsWith("/")?f:"/".concat(f),S?[4,S()]:[3,2];case 1:R=i.sent().accessToken,g.Authorization="Bearer ".concat(R),i.label=2;case 2:if(N=["GET","HEAD"].includes(null===(n=null==v?void 0:v.toUpperCase)||void 0===n?void 0:n.call(v)))try{C="".concat(C).concat(C.includes("?")?"&":"?").concat(Object.keys(b).map(function(e){return"".concat(e,"=").concat(b[e])}).join("&"))}catch(e){}return[4,this.request.fetch(r(r(r({url:"".concat(P).concat(C),method:v||"POST",headers:r({"Content-Type":"application/json; charset=utf-8"},g)},N?{}:{body:JSON.stringify(b)}),{token:(null===(a=null==m?void 0:m.trim)||void 0===a?void 0:a.call(m))||(null===(u=null===(c=g.Authorization)||void 0===c?void 0:c.replace)||void 0===u?void 0:u.call(c,/^Bearer /,""))||null}),t))];case 3:return[4,i.sent().data];case 4:return[2,i.sent()]}})})}t.callApi=a;var c=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function u(e){var t=this;return new Proxy({},{get:function(n,s){if("string"!=typeof s)throw new Error("[apis] method must be string");var u=s.toLocaleUpperCase();if(!c.includes(u))throw new Error("[apis] invalid method: ".concat(s));return function(n,s){return o(t,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,a.call(this,r({name:e,method:("REQUEST"===u?n.method:u)||"POST"},n),s)];case 1:return[2,t.sent()]}})})}}})}t.generateCallApis=u,t.generateApis=function(e){var t=this;return Object.keys(e||{}).forEach(function(n){void 0!==e[n]&&(t[n]=e[n])}),new Proxy({},{get:function(e,n){if("string"==typeof n)return u.call(t,n)}})}},1944:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.registerApis=t.generateApis=void 0;var i=n(5378);Object.defineProperty(t,"generateApis",{enumerable:!0,get:function(){return i.generateApis}});var s="apis",a={name:s,IIFE:!0,entity:function(){Object.defineProperty(this.prototype,s,{get:function(){return i.generateApis.call(this)},configurable:!0,enumerable:!0})}};function c(e){try{e.registerComponent(a)}catch(e){console.warn(e)}}t.registerApis=c;try{cloudbase.registerComponent(a)}catch(e){}o(n(2026),t);try{window.registerApis=c}catch(e){}},2026:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},7922:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.OAUTH2_LOGINTYPE_PREFIX=t.LOGINTYPE=t.getBaseEndPoint=t.setRegionLevelEndpoint=t.setGatewayEndPointWithEnv=t.getEndPointInfo=t.setEndPointInfo=t.DEFAULT_PROTOCOL=t.DATA_VERSION=t.getSdkName=t.setSdkName=t.getSdkVersion=t.setSdkVersion=void 0;var o=n(2877),i=o.constants.setSdkName,s=o.constants.setProtocol,a="",c="@cloudbase/js-sdk";t.setSdkVersion=function(e){a=e},t.getSdkVersion=function(){return a},t.setSdkName=function(e){c=e,i(e)},t.getSdkName=function(){return c},t.DATA_VERSION="2020-01-10";var u,l=[],h=["env","endPointKey","region"];function d(e){return l.find(function(t){return h.filter(function(t){return null!=e[t]}).every(function(n){return t[n]===e[n]})})}function f(e){var n,o;e.protocol&&!/:$/.test(e.protocol)&&(e.protocol="".concat(e.protocol,":"));var i=d(e);i?(null!=e.baseUrl&&(i.baseUrl=e.baseUrl),null!=e.protocol&&(i.protocol=e.protocol)):l.push(r(r({},e),{protocol:null!==(n=e.protocol)&&void 0!==n?n:t.DEFAULT_PROTOCOL})),"CLOUD_API"===e.endPointKey&&s(null!==(o=e.protocol)&&void 0!==o?o:t.DEFAULT_PROTOCOL)}function p(e,t,n){return d({env:e,endPointKey:t,region:n})}t.DEFAULT_PROTOCOL="https:",t.setEndPointInfo=f,t.getEndPointInfo=p,t.setGatewayEndPointWithEnv=function(e,t,n){var r="//".concat(e,".api.tcloudbasegateway.com/v1");n&&(r="//".concat(e,".api.intl.tcloudbasegateway.com/v1")),f({endPointKey:"GATEWAY",env:e,baseUrl:r,protocol:t})},t.setRegionLevelEndpoint=function(e,t,n){f({env:e,region:t,baseUrl:"//".concat(e,".").concat(t||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:n,endPointKey:"CLOUD_API"})},t.getBaseEndPoint=function(e,t){void 0===t&&(t="CLOUD_API");var n=p(e,t||"CLOUD_API"),r=n.protocol,o=n.baseUrl;return"".concat(r).concat(o).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]},(u=t.LOGINTYPE||(t.LOGINTYPE={})).NULL="NULL",u.ANONYMOUS="ANONYMOUS",u.WECHAT="WECHAT",u.WECHAT_PUBLIC="WECHAT-PUBLIC",u.WECHAT_OPEN="WECHAT-OPEN",u.CUSTOM="CUSTOM",u.EMAIL="EMAIL",u.USERNAME="USERNAME",u.PHONE="PHONE",t.OAUTH2_LOGINTYPE_PREFIX="OAUTH2"},6950:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.cloudbase=t.LANGS=t.getBaseEndPoint=void 0;var c=n(2877),u=n(4276),l=n(1985),h=n(6938),d=n(901),f=n(7922),p=n(3509),v=n(3809),y=n(7922);Object.defineProperty(t,"getBaseEndPoint",{enumerable:!0,get:function(){return y.getBaseEndPoint}});var g=n(3509);Object.defineProperty(t,"LANGS",{enumerable:!0,get:function(){return g.LANGS}});var m=c.adapters.useAdapters,b=c.adapters.useDefaultAdapter,_=c.constants.ERRORS,E=c.constants.COMMUNITY_SITE_URL,w=c.utils.printWarn,S=c.helpers.catchErrorsDecorator,I={persistence:"local"},O=6e5,A={},T=function(){function e(e){this.cloudbaseConfig=e||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.requestInstance=null,this.version=(0,f.getSdkVersion)()}return Object.defineProperty(e.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return l.Platform},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return(0,h.getCacheByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return(0,h.getLocalCache)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return this.requestInstance||(0,d.getRequestByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),e.prototype.init=function(t){var n,o,i,s,a;if(void 0===t&&(t={env:""}),t.endPointMode=t.endPointMode||"GATEWAY",l.Platform.adapter||this.useDefaultAdapter(),(t=this.dealNodeAdapterConfig(t)).throw=null===(o=null!==(n=t.throw)&&void 0!==n?n:t.throwOnCode)||void 0===o||o,delete t.throwOnCode,!t.env)throw new Error(JSON.stringify({code:_.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(t);var c=this.isNodeEnv()?void 0:15e3,u=t.timeout||c,y={env:t.env,region:t.region,accessKey:t.accessKey,context:t.context,auth:t.auth,timeout:u,timeoutMsg:u?"[".concat((0,f.getSdkName)(),"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(u/1e3,"s"):void 0};this.requestClient=new l.Platform.adapter.reqClass(y),this.cloudbaseConfig=r(r(r({},I),t),{timeout:u,i18n:(0,p.i18nProxy)(l.Platform,t)}),(0,v.registerThrowConfig)(this.cloudbaseConfig),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var g=this.cloudbaseConfig,m=g.env,b=g.persistence,E=g.debug,w=g.timeout,S=g.oauthClient,O=g.i18n;(0,h.initCache)({env:m,persistence:b,debug:E,platformInfo:this.platform}),(0,f.setRegionLevelEndpoint)(m,t.region||""),(0,f.setGatewayEndPointWithEnv)(m,f.DEFAULT_PROTOCOL,t.intl);var A=new e(this.cloudbaseConfig);return A.requestInstance=(0,d.initRequest)({env:m,region:t.region||"",timeout:w,oauthClient:S,_fromApp:A,i18n:O,endPointMode:t.endPointMode,auth:t.auth,context:t.context,accessKey:t.accessKey,throw:t.throw}),A.requestClient=this.requestClient,null===(i=null==this?void 0:this.fire)||void 0===i||i.call(this,"cloudbase_init",A),this.try2InitAuth(A),(null===(s=l.Platform.adapter)||void 0===s?void 0:s.nodeTool)&&(null===(a=l.Platform.adapter)||void 0===a||a.nodeTool(A,this.cloudbaseConfig)),A},e.prototype.updateConfig=function(e){var t=e.persistence,n=e.debug;this.cloudbaseConfig.persistence=t,this.cloudbaseConfig.debug=n,(0,h.initCache)({env:this.cloudbaseConfig.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.setThrowOnCode=function(e){this.cloudbaseConfig.throw=e},e.prototype.updateLang=function(e){var t;e&&e!==(null===(t=this.cloudbaseConfig.i18n)||void 0===t?void 0:t.lang)&&(this.cloudbaseConfig.i18n.lang=e)},e.prototype.registerExtension=function(e){A[e.name]=e},e.prototype.invokeExtension=function(e,t){return s(this,void 0,void 0,function(){var n;return a(this,function(r){switch(r.label){case 0:if(!(n=A[e]))throw new Error(JSON.stringify({code:_.INVALID_PARAMS,msg:"extension:".concat(e," must be registered before invoke")}));return[4,n.invoke(t,this)];case 1:return[2,r.sent()]}})})},e.prototype.useAdapters=function(e,t){var n=m(e,t)||{},r=n.adapter,o=n.runtime;r&&(l.Platform.adapter=r),o&&(l.Platform.runtime=o)},e.prototype.registerHook=function(t){(0,u.registerHook)(e,t)},e.prototype.registerComponent=function(t){(0,u.registerComponent)(e,t)},e.prototype.registerVersion=function(e){(0,f.setSdkVersion)(e),this.version=e},e.prototype.registerSdkName=function(e){(0,f.setSdkName)(e)},e.prototype.isInitialized=function(e){return void 0===e&&(e=this.cloudbaseConfig),"string"==typeof e.env&&["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some(function(t){return e.env.toLowerCase()===t.toLowerCase()})&&w(_.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(e.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==e?void 0:e.env)},e.prototype.registerEndPoint=function(e,t){(0,f.setEndPointInfo)({baseUrl:e,protocol:t,env:this.config.env,endPointKey:"CLOUD_API"})},e.prototype.registerEndPointWithKey=function(e){(0,f.setEndPointInfo)({env:this.config.env,endPointKey:e.key,baseUrl:e.url,protocol:e.protocol})},e.prototype.registerHost=function(e,t){void 0===t&&(t="http");var n=e.replace(/^(https?:)?\/\//,""),r="//".concat(n);(0,f.setEndPointInfo)({baseUrl:"".concat(r,"/web"),protocol:t,env:this.config.env,endPointKey:"CLOUD_API"}),(0,f.setEndPointInfo)({baseUrl:"".concat(r,"/v1"),protocol:t,env:this.config.env,endPointKey:"GATEWAY"})},e.prototype.getEndPointWithKey=function(e){var t=(0,f.getEndPointInfo)(this.config.env,e);return{BASE_URL:t.baseUrl,PROTOCOL:t.protocol}},e.prototype.parseCaptcha=function(e){return c.utils.parseCaptcha(e)},e.prototype.useDefaultAdapter=function(){var e=b.bind(this)(),t=e.adapter,n=e.runtime;l.Platform.adapter=t,l.Platform.runtime=n},e.prototype.isNodeEnv=function(){var e;return"undefined"!=typeof process&&!!(null===(e=l.Platform.adapter)||void 0===e?void 0:e.getSecretInfo)},e.prototype.formatTimeout=function(e){if(null==e)return e;switch(!0){case e>O:return w(_.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),O;case e<100:return w(_.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},e.prototype.try2InitAuth=function(e){try{e.auth()}catch(e){console.log("try2InitAuth error:",e)}},e.prototype.dealNodeAdapterConfig=function(e){var t,n,o,i,s;if(this.isNodeEnv()){var a=null===(t=l.Platform.adapter)||void 0===t?void 0:t.getSecretInfo(e);e.env&&"symbol"!=typeof e.env||(e.env=a.env),a.credentials&&(e.auth=r(r({},e.auth),{credentials:a.credentials}));var c=e,u=c.secretId||(null===(n=e.auth)||void 0===n?void 0:n.secretId),h=c.secretKey||(null===(o=e.auth)||void 0===o?void 0:o.secretKey);if(u&&h){var d=c.sessionToken||(null===(i=e.auth)||void 0===i?void 0:i.sessionToken)||"";e.auth=r(r({},e.auth),{secretId:u,secretKey:h,sessionToken:d,secretType:(null===(s=e.auth)||void 0===s?void 0:s.secretType)||(d?"SESSION_SECRET":"SECRET")})}}return e},o([S({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",e)],e.prototype,"init",null),o([S({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(E)]}),i("design:type",Function),i("design:paramtypes",[String,Object]),i("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}();t.cloudbase=new T;var P=(0,l.getWxDefaultAdapter)();P&&t.cloudbase.useAdapters(P),t.default=t.cloudbase},1985:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.getWxDefaultAdapter=t.Platform=void 0;var c=s(n(7917)),u=n(2764);t.Platform={},t.getWxDefaultAdapter=function(){return void 0===c.WxRequest?null:(c.default.genAdapter=function(e){return{root:{globalThis:{}},reqClass:c.WxRequest,wsClass:c.WxMpWebSocket,captchaOptions:{openURIWithCallback:function(t){var n=e.EventBus,o={},i=t;console.log("openURIWithCallback",t);var s=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(s){i=s[1],console.log("openURIWithCallback url",i);var u=s[2];u&&(o=(0,c.parseQueryString)(u))}console.log("openURIWithCallback queryObj",o);var l=o.token,h=a(o,["token"]);return/^data:/.test(i)&&!l?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(t)}):l?new Promise(function(e){console.log("wait for captcha..."),n.$emit("CAPTCHA_DATA_CHANGE",r(r({},h),{token:l,url:i})),n.$once("RESOLVE_CAPTCHA_DATA",function(t){e(t)})}):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:c.wxMpStorage,primaryStorage:u.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},c.default)}},6938:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.getLocalCache=t.getCacheByEnvId=t.initCache=void 0;var o=n(2877).cache.CloudbaseCache,i={},s={};t.initCache=function(e){var t=e.env,n=e.platformInfo,a={userInfoKey:"".concat("user_info","_").concat(t)};i[t]=i[t]||new o(r(r({},e),{keys:a,platformInfo:n})),s[t]=s[t]||new o(r(r({},e),{keys:a,platformInfo:n,persistence:"local"}))},t.getCacheByEnvId=function(e){return i[e]},t.getLocalCache=function(e){return s[e]}},4276:function(e,t,n){"use strict";var r=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.registerHook=t.registerComponent=void 0;var o=n(2877).constants.ERRORS,i={};function s(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var n=0,r=Object.keys(t);n<r.length;n++){var o=r[n];Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=s(e[o],t[o]))}return e}t.registerComponent=function(e,t){var n=t.name,a=t.namespace,c=t.entity,u=t.injectEvents,l=t.IIFE,h=void 0!==l&&l;if(i[n]||a&&e[a])throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(h){if(!c||"function"!=typeof c)throw new Error(JSON.stringify({code:o.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));c.call(e)}if(i[n]=t,a?e.prototype[a]=c:s(e.prototype,c),u){var d=u.bus,f=u.events;if(!d||!f||0===f.length)return;var p=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[n]?e.prototype.events[n].events=r(r([],e.prototype.events[n].events,!0),f,!0):e.prototype.events[n]={bus:d,events:f},e.prototype.fire=function(e,t){p(e,t);for(var n=0,r=Object.keys(this.events);n<r.length;n++){var o=r[n],i=this.events[o],s=i.bus;if(i.events.includes(e)){s.fire(e,t);break}}}}},t.registerHook=function(e,t){var n=t.entity,i=t.target;if(Object.prototype.hasOwnProperty.call(e,i))throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:".concat(i," is not exist")}));var s=e.prototype[i];if("function"!=typeof s)throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:".concat(i," is not a function which is the only type supports hook")}));e.prototype[i]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.call.apply(n,r([this],e,!1)),s.call.apply(s,r([this],e,!1))}}},3509:function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.i18nProxy=t.t=t.langMap=t.LANG_HEADER_KEY=t.LANGS=void 0;var o,i=n(2877);!function(e){e.ZH="zh-CN",e.EN="en-US"}(o=t.LANGS||(t.LANGS={})),t.LANG_HEADER_KEY="Accept-Language",t.langMap=((r={})[o.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code","错误信息":"error message","未实现":"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs","请求超时":"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},r),t.t=function(e,n){var r;return(null===(r=t.langMap[n])||void 0===r?void 0:r[e])||e},t.i18nProxy=function(e,n){var r,s,a=function(e){return"lang_".concat(e.clientId||e.env)}(n),c=(e.adapter||{}).localStorage,u=n.lang||(null===(r=null==c?void 0:c.getItem)||void 0===r?void 0:r.call(c,a))||o.ZH;return null===(s=null==c?void 0:c.setItem)||void 0===s||s.call(c,a,u),new Proxy({t:function(e){return(0,t.t)(e,u)},LANG_HEADER_KEY:t.LANG_HEADER_KEY,lang:u},{get:function(e,t){var n;return"lang"===t&&(null===(n=null==c?void 0:c.getItem)||void 0===n?void 0:n.call(c,a))||e[t]},set:function(e,n,r){var o;return"lang"===n&&r!==e[n]&&(e[n]=r,e.t=function(e){return(0,t.t)(e,r)},null===(o=null==c?void 0:c.setItem)||void 0===o||o.call(c,a,r),i.langEvent.bus.fire(i.langEvent.LANG_CHANGE_EVENT,{i18n:e})),e[n]=r,!0}})}},901:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestByEnvId=t.initRequest=t.CloudbaseRequest=void 0;var a=n(7922),c=n(2877),u=n(6938),l=n(1985),h=c.constants.ERRORS,d=c.utils.genSeqId,f=c.utils.isFormData,p=c.utils.formatUrl,v=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function y(e,t,n){var o=e[t];e[t]=function(t){var i={},s={};n.forEach(function(n){var r=n.call(e,t),o=r.data,a=r.headers;Object.assign(i,o),Object.assign(s,a)});var a=t.data;return a&&(f(a)?Object.keys(i).forEach(function(e){a.append(e,i[e])}):t.data=r(r({},a),i)),t.headers=r(r({},t.headers||{}),s),o.call(e,t)}}function g(){var e=d();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat((0,a.getSdkVersion)()),"x-seqid":e}}}var m=function(){function e(e){var t=this;this.config=e;var n={env:this.config.env,region:this.config.region,accessKey:this.config.accessKey,context:this.config.context,auth:this.config.auth,timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"]};this.reqClass=new l.Platform.adapter.reqClass(n),this.localCache=(0,u.getLocalCache)(this.config.env),"GATEWAY"!==this.config.endPointMode&&(y(this.reqClass,"post",[g]),y(this.reqClass,"upload",[g]),y(this.reqClass,"download",[g])),c.langEvent.bus.on(c.langEvent.LANG_CHANGE_EVENT,function(e){var n;t.config.i18n=(null===(n=e.data)||void 0===n?void 0:n.i18n)||t.config.i18n})}return Object.defineProperty(e.prototype,"throwWhenRequestFail",{get:function(){var e,t,n,r,o=null===(n=null===(t=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===t?void 0:t.config)||void 0===n?void 0:n.throw;return"boolean"==typeof o?o:!1!==(null===(r=this.config)||void 0===r?void 0:r.throw)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"errorFactory",{get:function(){var e,t,n,r=this.config;return null!==(e=null==r?void 0:r.errorFactory)&&void 0!==e?e:null===(n=null===(t=null==r?void 0:r._fromApp)||void 0===t?void 0:t.config)||void 0===n?void 0:n.errorFactory},enumerable:!1,configurable:!0}),e.prototype.getAccessToken=function(e){return void 0===e&&(e=null),o(this,void 0,void 0,function(){var t,n,r;return i(this,function(o){switch(o.label){case 0:if(null!=e)return[2,e];if(!(t=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return n=t.oauthInstance,r=n.oauth2client,[4,this.getOauthAccessTokenV2(r)];case 1:return[2,o.sent().accessToken]}})})},e.prototype.getDefaultHeaders=function(){var e,t,n;return(e={})[null===(t=this.config.i18n)||void 0===t?void 0:t.LANG_HEADER_KEY]=null===(n=this.config.i18n)||void 0===n?void 0:n.lang,e["X-SDK-Version"]="@cloudbase/js-sdk/".concat((0,a.getSdkVersion)()),e},Object.defineProperty(e.prototype,"requestDebug",{get:function(){var e,t,n;return!0===(null===(n=null===(t=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===t?void 0:t.config)||void 0===n?void 0:n.debug)},enumerable:!1,configurable:!0}),e.prototype.post=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return[4,this.reqClass.post(r(r({},e),{headers:r(r({},e.headers),this.getDefaultHeaders()),customReqOpts:t,debug:this.requestDebug}))];case 1:return[2,n.sent()]}})})},e.prototype.upload=function(e){var t;return o(this,void 0,Promise,function(){var n,o,s;return i(this,function(i){switch(i.label){case 0:return o=null!==(t=(n=e).file)&&void 0!==t?t:n.fileContent,delete(s=r(r({},n),{file:o,headers:r(r({},n.headers),this.getDefaultHeaders()),debug:this.requestDebug})).fileContent,[4,this.reqClass.upload(s)];case 1:return[2,i.sent()]}})})},e.prototype.download=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.reqClass.download(r(r({},e),{headers:r(r({},e.headers),this.getDefaultHeaders()),debug:this.requestDebug}))];case 1:return[2,t.sent()]}})})},e.prototype.getUploadByteLength=function(e){var t,n;return null===(n=(t=this.reqClass).getUploadByteLength)||void 0===n?void 0:n.call(t,e)},e.prototype.getBaseEndPoint=function(e){return void 0===e&&(e="CLOUD_API"),(0,a.getBaseEndPoint)(this.config.env,e)},e.prototype.getOauthAccessTokenV2=function(e){return o(this,void 0,Promise,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return[4,e.getAccessToken()];case 1:return t=r.sent(),[4,e.getCredentials()];case 2:return n=r.sent(),[2,{accessToken:t,accessTokenExpire:new Date(n.expires_at).getTime()}]}})})},e.prototype.request=function(e,t,n,s){var c,u;return o(this,void 0,Promise,function(){var o,l,h,d,f,y,g,m,b,_,E,w,S,I,O,A,T,P,C,R,N,k,U;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,4,,5]),o="x-tcb-trace_".concat(this.config.env),l="application/x-www-form-urlencoded",h=r({action:e,dataVersion:a.DATA_VERSION,env:this.config.env},t),-1!==v.indexOf(e))return[3,2];if(!(d=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return f=d.oauthInstance,y=f.oauth2client,g=h,[4,this.getOauthAccessTokenV2(y)];case 1:g.access_token=i.sent().accessToken,i.label=2;case 2:return"storage.uploadFile"===e?(m=new FormData,Object.keys(m).forEach(function(e){Object.prototype.hasOwnProperty.call(m,e)&&void 0!==m[e]&&m.append(e,h[e])}),l="multipart/form-data"):(l="application/json;charset=UTF-8",m={},Object.keys(h).forEach(function(e){void 0!==h[e]&&(m[e]=h[e])})),b={headers:r(r({"content-type":l},this.getDefaultHeaders()),null==n?void 0:n.headers)},(null==n?void 0:n.onUploadProgress)&&(b.onUploadProgress=n.onUploadProgress),this.config.region&&(b.headers["X-TCB-Region"]=this.config.region),(_=this.localCache.getStore(o))&&(b.headers["X-TCB-Trace"]=_),E=void 0!==(null==n?void 0:n.parse)?n.parse:t.parse,w=void 0!==(null==n?void 0:n.inQuery)?n.inQuery:t.inQuery,S=void 0!==(null==n?void 0:n.search)?n.search:t.search,I=r(r({},(null==n?void 0:n.defaultQuery)||{}),{env:this.config.env}),E&&(I.parse=!0),w&&(I=r(r({},w),I)),O=(null==n?void 0:n.endPointMode)||this.config.endPointMode||"CLOUD_API",A=(0,a.getEndPointInfo)(this.config.env,O),T=A.baseUrl,P=A.protocol,"GATEWAY"===O&&/^((database)\.)|(auth\.wsWebSign)/.test(e)&&(C=(0,a.getEndPointInfo)(this.config.env,"CLOUD_API"),T="".concat(C.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),R=void 0,R=n.pathname?p(P,"".concat(null===(c=(0,a.getBaseEndPoint)(this.config.env,O))||void 0===c?void 0:c.replace(/^https?:/,""),"/").concat(n.pathname),I):p(P,T,I),S&&(R+=S),[4,this.post(r({url:R,data:m},b),s)];case 3:if(N=i.sent(),(k=null===(u=N.header)||void 0===u?void 0:u["x-tcb-trace"])&&this.localCache.setStore(o,k),200!==Number(N.status)&&200!==Number(N.statusCode)||!N.data)throw new Error("network request error");return[2,N];case 4:U=i.sent();try{U.requestId=U.requestId||(null==n?void 0:n.headers["x-request-id"])||(null==n?void 0:n.headers["X-Request-Id"])||""}catch(e){}throw U;case 5:return[2]}})})},e.prototype.fetch=function(e){var t,n,c,u,l,h,d,f;return o(this,void 0,Promise,function(){var p,v,y,g,m,b,_,E,w=this;return i(this,function(S){switch(S.label){case 0:p=e.token,v=e.headers,y=void 0===v?{}:v,g=e.withCredentials,m=void 0===g||g,b=s(e,["token","headers","withCredentials"]),_=function(){return o(w,void 0,void 0,function(){var e,t,n,o;return i(this,function(i){switch(i.label){case 0:if(e={},!m)return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getAccessToken(p)];case 2:return(t=i.sent())&&(e.Authorization="Bearer ".concat(t)),[3,4];case 3:if(n=i.sent(),"undefined"==typeof process||null==process.versions||null==process.versions.node)throw n;return[3,4];case 4:return o=r({headers:r(r(r({"X-SDK-Version":"@cloudbase/js-sdk/".concat((0,a.getSdkVersion)())},e),this.getDefaultHeaders()),y),withCredentials:m},b),[2,this.reqClass.fetch(o)]}})})},S.label=1;case 1:return S.trys.push([1,3,,6]),[4,_()];case 2:return[2,S.sent()];case 3:E=S.sent();try{E.requestId=E.requestId||y["x-request-id"]||y["X-Request-Id"]||""}catch(e){}if("ACCESS_TOKEN_EXPIRED"!==(null==E?void 0:E.code))return[3,5];if("function"!=typeof(null===(u=null===(c=null===(n=null===(t=this.config)||void 0===t?void 0:t._fromApp)||void 0===n?void 0:n.oauthInstance)||void 0===c?void 0:c.authApi)||void 0===u?void 0:u.refreshTokenForce))throw E;return[4,null===(f=null===(d=null===(h=null===(l=this.config)||void 0===l?void 0:l._fromApp)||void 0===h?void 0:h.oauthInstance)||void 0===d?void 0:d.authApi)||void 0===f?void 0:f.refreshTokenForce()];case 4:return S.sent(),[2,_()];case 5:throw E;case 6:return[2]}})})},e.prototype.send=function(e,t,n,s){return void 0===t&&(t={}),void 0===n&&(n={}),o(this,void 0,Promise,function(){var o;return i(this,function(i){switch(i.label){case 0:return[4,this.request(e,t,r(r({},n),{onUploadProgress:t.onUploadProgress}),s)];case 1:if((o=i.sent()).data.code&&this.throwWhenRequestFail)throw c.utils.createCloudbaseError({code:o.data.code,msg:o.data.message||"",requestId:o.requestId},this.errorFactory);return[2,o.data]}})})},e.prototype.gateWay=function(e,t){var n,s;return o(this,void 0,void 0,function(){var o,u,l,d,f,p,v,y,g,m,b,_,E,w,S,I,O,A,T;return i(this,function(i){switch(i.label){case 0:if(o=e.url,u=e.name,l=e.data,d=e.path,f=void 0===d?"":d,p=e.method,v=e.header,y=void 0===v?{}:v,!(u&&f||o))throw c.utils.createCloudbaseError({code:h.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"},this.errorFactory);try{g=l?JSON.stringify(l):""}catch(e){throw c.utils.createCloudbaseError({code:h.INVALID_PARAMS,msg:"[gateWay] invalid data"},this.errorFactory)}if(m=c.utils.generateRequestId(),b=(0,a.getEndPointInfo)(this.config.env,"GATEWAY"),_=b.baseUrl,E=b.protocol,w="".concat(E).concat(_).concat(o||"/".concat(f,"/").concat(u)),S=["GET","HEAD"].includes(null===(n=null==p?void 0:p.toUpperCase)||void 0===n?void 0:n.call(p)))try{I={};try{I=JSON.parse(l)}catch(e){I=l||{}}w="".concat(w).concat(w.includes("?")?"&":"?").concat(Object.keys(I).map(function(e){return"".concat(e,"=").concat(I[e])}).join("&"))}catch(e){}return[4,this.fetch(r(r({method:p||"POST",headers:r({"Content-Type":"application/json; charset=utf-8","X-Request-Id":m},y)},S?{}:{body:g}),{url:w,customReqOpts:t,shouldThrowOnError:null!==(s=e.shouldThrowOnError)&&void 0!==s?s:this.throwWhenRequestFail}))];case 1:return O=i.sent(),A=[r({requestId:m},O)],T={},[4,O.data];case 2:return[2,r.apply(void 0,A.concat([(T.data=i.sent(),T)]))]}})})},e}();t.CloudbaseRequest=m;var b={};t.initRequest=function(e){var t=new m(r(r({},e),{throw:e.throw}));return b[e.env]=t,t},t.getRequestByEnvId=function(e){return b[e]}},3809:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setThrowOnCode=t.registerThrowConfig=void 0;var n=new Set;t.registerThrowConfig=function(e){e&&"object"==typeof e&&n.add(e)},t.setThrowOnCode=function(e){n.forEach(function(t){t.throw=e})}},3548:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.useAuthAdapter=void 0;var s=n(1019),a=function(){function e(e){var t,n;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(n=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===n?void 0:n.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.localStorage.getItem(e)]})})},e.prototype.removeItem=function(e){return o(this,void 0,void 0,function(){return i(this,function(t){return this.localStorage.removeItem(e),[2]})})},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){return this.localStorage.setItem(e,t),[2]})})},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),c=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,u=function(e,t){var n,r,o,i,s=null===(n=null==t?void 0:t.headers)||void 0===n?void 0:n["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(i=null==t?void 0:t.url,c.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}};t.useAuthAdapter=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var n=r({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(n.storage=new a({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(n.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var s={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:e.auth},c=new t.reqClass(s);n.baseRequest=function(e,t){var n,s,a,l,h;return o(this,void 0,void 0,function(){var o,d,f,p;return i(this,function(i){switch(i.label){case 0:if(o={},d=(null===(n=t.method)||void 0===n?void 0:n.toLocaleLowerCase())||"post","function"!=typeof(f=null===(a=null===(s=null==c?void 0:c[d])||void 0===s?void 0:s.bind)||void 0===a?void 0:a.call(s,c)))throw new Error("invalid 【".concat(d,"】 request method"));i.label=1;case 1:return i.trys.push([1,3,,4]),(null===(l=t.headers)||void 0===l?void 0:l["content-type"])&&!(null===(h=t.headers)||void 0===h?void 0:h["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,f(r({url:e},t))];case 2:return o=i.sent(),o=u(o,r(r({},t),{url:e})),[3,4];case 3:throw p=i.sent(),o=r(r({},null==p?void 0:p.data),p);case 4:if(null==o?void 0:o.error)throw o;return[2,o]}})})}}}catch(e){console.error("user adapter generate fail:",e)}return n}(e,e.adapter):function(e,t){var n=r({},e),c={};if((null==t?void 0:t.captchaOptions)&&(n.captchaOptions=t.captchaOptions),!s.adapterForWxMp.isMatch()||e.storage&&e.baseRequest)return n;try{var l=s.adapterForWxMp.genAdapter({}),h=l.localStorage,d=l.reqClass;if(h&&(c.storage=new a({localStorage:h,adapter:t})),d){var f=new d({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});c.request=function(e){return function(t,n){return o(this,void 0,void 0,function(){return i(this,function(o){return[2,new Promise(function(o,i){var s=Object.assign({},n);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:t,data:s.body,timeout:e._timeout,method:s.method||"GET",header:s.headers,success:function(e){(e=u(e,r(r({},n),{url:t}))).error&&i(e),o(e)},fail:function(e){i({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{a.abort()}catch(e){}}}})})]})})}}(f)}return n.captchaOptions&&(c.baseRequest=c.request,c.request=void 0),r(r({},n),c)}catch(e){console.error("adapter generate fail:",e)}return n}(e,e.adapter)}},9895:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},c=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},u=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},l=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=t.AuthError=t.AuthErrorCode=t.AuthErrorCategory=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=t.Auth=t.generateAuthInstance=t.LoginState=t.User=void 0;var h=n(6722),d=n(3548),f=n(1019),p=n(5266),v=n(916);Object.defineProperty(t,"WeixinAuthProvider",{enumerable:!0,get:function(){return v.WeixinAuthProvider}}),Object.defineProperty(t,"CustomAuthProvider",{enumerable:!0,get:function(){return v.CustomAuthProvider}}),Object.defineProperty(t,"AnonymousAuthProvider",{enumerable:!0,get:function(){return v.AnonymousAuthProvider}});var y=n(2877),g=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},m=["avatar_url","avatarUrl"];function b(e){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(e).length:e.length}function _(e,t){if(e)for(var n=0,r=m;n<r.length;n++){var o=r[n],i=e[o];if(null!=i&&""!==i){var s=b(String(i));if(s>204800)throw new h.AuthError({error:"invalid_argument",error_code:h.AuthErrorCode.INVALID_ARGUMENT,error_description:"auth.".concat(t,'(params): "').concat(o,'" 超过 200KB 限制(当前 ').concat(s," 字节),请传入图片 URL 而非文件内容")},{method:t})}}}var E=t.User=function(){function e(e){var t=e.cache,n=e.oauthInstance;this.cache=t,this.oauthInstance=n,this.setUserInfo()}var t,n,r;return e.prototype.checkLocalInfo=function(){return c(this,void 0,void 0,function(){return u(this,function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]})})},e.prototype.checkLocalInfoAsync=function(){return c(this,void 0,void 0,function(){var e,t,n,r;return u(this,function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),n=this,[4,this.getLocalUserInfoAsync("email")];case 3:return n.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),r=this,[4,this.getLocalUserInfoAsync("username")];case 4:return r.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}})})},e.prototype.update=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return _(e,"update"),[4,this.oauthInstance.authApi.setUserProfile(i({},e))];case 1:return t=n.sent(),this.setLocalUserInfo(t),[2]}})})},e.prototype.updateUserBasicInfo=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return _(e,"updateUserBasicInfo"),[4,this.oauthInstance.authApi.updateUserBasicInfo(i({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}})})},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=n.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}})})},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,n=this.cache.getStore(t);return e?n[e]:n||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,n.sent()[e]]}})})},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,n=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach(function(t){e[t]=n[t]})},s([(0,f.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(t=void 0!==h.authModels&&h.authModels.UserProfile)?t:Object]),a("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"update",null),s([(0,f.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String,String]),a("design:returntype",void 0)],e.prototype,"updatePassword",null),s([(0,f.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],e.prototype,"updateUsername",null),s([(0,f.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(r="undefined"!=typeof Promise&&Promise)?r:Object)],e.prototype,"refresh",null),e}();(0,v.applyUserV1Compat)(E);var w=function(){function e(e){var t=e.envId,n=e.cache,r=e.oauthInstance;t||(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=n,this.oauthInstance=r,this.user=new E({cache:this.cache,oauthInstance:r})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return c(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}})})},e}();t.LoginState=w;var S=function(e){function t(t){var n=e.call(this)||this;return n.listeners=new Map,n.hasListenerSetUp=!1,n.config=t,n.oauthInstance=t.oauthInstance,n.cache=t.cache,n.init(),n.setAccessKey(),n}var n,r,d,v,m,b,E,S,I,O,A,T,P,C,R,N,k,U,D,L,j;return o(t,e),t.prototype.signInAnonymously=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,s;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return a.sent(),[4,this.createLoginState()];case 2:return t=a.sent(),[4,this.getSession()];case 3:return n=a.sent().data,r=(void 0===n?{}:n).session,[2,i(i({},t),{data:{user:r.user,session:r},error:null})];case 4:return o=a.sent(),(s=new h.AuthError(o,{method:"signInAnonymously"})).category===h.AuthErrorCategory.PROVIDER_NOT_ENABLED?(console.error(s.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(s.category,"]: ").concat(s.message)),s.loginMethodHint&&console.warn(s.loginMethodHint)),[2,{data:{user:null,session:null},error:s}];case 5:return[2]}})})},t.prototype.signUp=function(e){return c(this,void 0,Promise,function(){var t,n,r=this;return u(this,function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?(e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[4,this.oauthInstance.authApi.signUp(e)]):[3,2];case 1:return o.sent(),[2,this.createLoginState()];case 2:return o.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"signUp"),[4,this.getVerification(e.email?{email:e.email,usage:h.VerificationUsage.EMAIL}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=o.sent(),[2,{data:{verifyOtp:function(n){var o=n.token,s=n.messageId,a=void 0===s?t.verification_id:s;return c(r,void 0,Promise,function(){var n,r,s,c,l;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.verify({verification_id:a||t.verification_id,verification_code:String(o)})];case 1:return n=u.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:n.verification_token})]:[3,3];case 2:return u.sent(),[3,6];case 3:return delete(r=JSON.parse(JSON.stringify(e))).email,delete r.phone,[4,this.oauthInstance.authApi.signUp(i(i(i({},r),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:n.verification_token,verification_code:o}))];case 4:return u.sent(),[4,this.createLoginState()];case 5:u.sent(),u.label=6;case 6:return[4,this.getSession()];case 7:return s=u.sent().data,[2,{data:{user:(c=(void 0===s?{}:s).session).user,session:c},error:null}];case 8:return l=u.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(l,{method:"signUp"})}];case 9:return[2]}})})}},error:null}];case 4:return n=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(n,{method:"signUp"})}];case 5:return[2]}})})},t.prototype.signOut=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return n=o.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return o.sent(),this.setAccessKey(),[2,i(i({},n),{data:{},error:null})];case 3:return r=o.sent(),[2,{data:{},error:new h.AuthError(r,{method:"signOut"})}];case 4:return[2]}})})},t.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var n=Math.random().toString(36);return this.listeners.has(n)||this.listeners.set(n,new Set),this.listeners.get(n).add(e),{data:{subscription:{id:n,callback:e,unsubscribe:function(){var r=t.listeners.get(n);r&&(r.delete(e),0===r.size&&t.listeners.delete(n))}}}}},t.prototype.signInWithPassword=function(e){var t,n;return c(this,void 0,Promise,function(){var r,o,s,a,c,l,d,f;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"signInWithPassword"),this.validateParams(e,{password:{required:!0,message:"Password is required"}},"signInWithPassword"),r="username"in e?e.username:void 0,o="email"in e?e.email:void 0,s="phone"in e?e.phone:void 0,a=null!==(n=null===(t=e.options)||void 0===t?void 0:t.is_encrypt)&&void 0!==n?n:e.is_encrypt,[4,this.signIn(i({username:r||o||this.formatPhone(s),password:e.password},a?{isEncrypt:!0,version:"v2"}:{}))];case 1:return u.sent(),[4,this.getSession()];case 2:return c=u.sent().data,[2,{data:{user:(l=(void 0===c?{}:c).session).user,session:l},error:null}];case 3:return d=u.sent(),(f=new h.AuthError(d,{method:"signInWithPassword"})).category===h.AuthErrorCategory.PROVIDER_NOT_ENABLED?console.error(f.helpMessage):f.category===h.AuthErrorCategory.INVALID_CREDENTIALS||f.category===h.AuthErrorCategory.USER_NOT_FOUND?console.warn(f.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(f.category,"]: ").concat(f.message)),f.loginMethodHint&&console.info(f.loginMethodHint),[2,{data:{user:null,session:null},error:f}];case 4:return[2]}})})},t.prototype.signInWithIdToken=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}},"signInWithIdToken"),[4,this.signInWithProvider({provider_id:e.provider,provider_id_token:e.token})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(n=(void 0===t?{}:t).session).user,session:n},error:null}];case 3:return r=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"signInWithIdToken"})}];case 4:return[2]}})})},t.prototype.signInWithOtp=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,s,a=this;return u(this,function(l){switch(l.label){case 0:if(t=e.options,n="email"in e?e.email:void 0,r="phone"in e?e.phone:void 0,!(null==t?void 0:t.emailRedirectTo)&&(void 0===(null==t?void 0:t.shouldCreateUser)||(null==t?void 0:t.shouldCreateUser)))return[2,this.signUp(n?{email:n}:{phone:r})];l.label=1;case 1:return l.trys.push([1,3,,4]),this.validateAtLeastOne(e,[["email"],["phone"]],"signInWithOtp"),[4,this.getVerification(i(i({email_redirect_to:null==t?void 0:t.emailRedirectTo},n?{email:n,usage:h.VerificationUsage.EMAIL}:{phone_number:this.formatPhone(r)}),{target:(null==t?void 0:t.emailRedirectTo)&&(null==t?void 0:t.shouldCreateUser)?"ANY":"USER"}))];case 2:return o=l.sent(),[2,{data:{user:null,session:null,verifyOtp:function(e){var t=e.token,i=e.messageId,s=void 0===i?o.verification_id:i;return c(a,void 0,Promise,function(){return u(this,function(e){return[2,this.verifyOtp(n?{email:n,token:String(t),messageId:s||""}:{phone:r,token:String(t),messageId:s||""})]})})}},error:null}];case 3:return s=l.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"signInWithOtp"})}];case 4:return[2]}})})},t.prototype.verifyOAuth=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,s,a,c,l,d;return u(this,function(u){switch(u.label){case 0:t={},u.label=1;case 1:return u.trys.push([1,7,,8]),n=(null==e?void 0:e.code)||y.utils.getQuery("code"),r=(null==e?void 0:e.state)||y.utils.getQuery("state"),n?r?(o=(0,p.getBrowserSession)(r),t.type=null==o?void 0:o.type,(s=(null==e?void 0:e.provider)||(null==o?void 0:o.provider)||y.utils.getQuery("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:n})]:[2,{data:i(i({},t),{user:null,session:null,redirectUrl:null}),error:this.missingRequiredParam("verifyOAuth","provider")}]):[2,{data:{user:null,session:null,redirectUrl:null},error:this.missingRequiredParam("verifyOAuth","state")}]:[2,{data:{user:null,session:null,redirectUrl:null},error:this.missingRequiredParam("verifyOAuth","code")}];case 2:return a=u.sent().provider_token,c=void 0,o.type!==h.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return c=u.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(c=u.sent()).data=i(i({},t),c.data),u.label=6;case 6:return(l=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),l.delete("state"),c.data.redirectUrl=(0,p.addUrlSearch)(void 0===(null==o?void 0:o.search)?"?".concat(l.toString()):null==o?void 0:o.search,(null==o?void 0:o.hash)||location.hash),(0,p.removeBrowserSession)(r),[2,c];case 7:return d=u.sent(),[2,{data:i(i({},t),{user:null,session:null,redirectUrl:null}),error:new h.AuthError(d,{method:"verifyOAuth"})}];case 8:return[2]}})})},t.prototype.signInWithOAuth=function(e){var t,n,r,o,i;return c(this,void 0,Promise,function(){var s,a,c,l,d,f,v,y,m;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}},"signInWithOAuth"),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),c=a.origin+a.pathname,l=(null===(n=e.options)||void 0===n?void 0:n.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:c,state:l})];case 1:return d=u.sent().uri,f=decodeURIComponent(d),v=f,(null===(r=e.options)||void 0===r?void 0:r.queryParams)&&(y=new URL(f),Object.entries(e.options.queryParams).forEach(function(e){var t=e[0],n=e[1];y.searchParams.set(t,n)}),v=y.toString()),(0,p.saveToBrowserSession)(l,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(o=e.options)||void 0===o?void 0:o.type)||h.OAUTH_TYPE.SIGN_IN}),g()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(v),[2,{data:{url:v,provider:e.provider},error:null}];case 2:return m=u.sent(),[2,{data:{url:null,provider:null},error:new h.AuthError(m,{method:"signInWithOAuth"})}];case 3:return[2]}})})},t.prototype.getClaims=function(){return c(this,void 0,Promise,function(){var e,t;return u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=n.sent().accessToken,[2,{data:(0,h.weAppJwtDecodeAll)(e),error:null}];case 2:return t=n.sent(),[2,{data:{claims:null,header:null,signature:null},error:new h.AuthError(t,{method:"getClaims"})}];case 3:return[2]}})})},t.prototype.resetPasswordForEmail=function(e,t){return c(this,void 0,Promise,function(){var n,r,o,s,a,l,d=this;return u(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}},"resetPasswordForEmail"),n=(t||{}).redirectTo,r=e.includes("@"),o=void 0,r?o={email:e,usage:h.VerificationUsage.RECOVERY}:(s=this.formatPhone(e),o={phone_number:s}),[4,this.getVerification(i(i({},o),{target:"USER"}))];case 1:return a=f.sent(),[2,{data:{updateUser:function(t){return c(d,void 0,Promise,function(){var o,i,s,c;return u(this,function(u){switch(u.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}},"resetPasswordForEmail"),u.label=1;case 1:return u.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:t.nonce})];case 2:return o=u.sent(),[4,this.oauthInstance.authApi.resetPassword({email:r?e:void 0,phone_number:r?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return u.sent(),null===(c=this.config.eventBus)||void 0===c||c.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:r?e:void 0,phone:r?void 0:e,password:t.password})];case 4:return i=u.sent(),n&&g()&&window.location.assign(n),[2,i];case 5:return s=u.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"resetPasswordForEmail"})}];case 6:return[2]}})})}},error:null}];case 2:return l=f.sent(),[2,{data:{updateUser:null},error:new h.AuthError(l,{method:"resetPasswordForEmail"})}];case 3:return[2]}})})},t.prototype.resetPasswordForOld=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(n=(void 0===t?{}:t).session).user,session:n},error:null}];case 3:return r=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"resetPasswordForOld"})}];case 4:return[2]}})})},t.prototype.verifyOtp=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,i,s,a;return u(this,function(c){switch(c.label){case 0:return c.trys.push([0,6,,7]),t=e.type,n=String(e.token),r="email"in e?e.email:void 0,o="phone"in e?e.phone:void 0,this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}},"verifyOtp"),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:n})]:[3,2];case 1:return c.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:n,username:r||this.formatPhone(o)||"",loginType:r?"email":"phone"})];case 3:c.sent(),c.label=4;case 4:return[4,this.getSession()];case 5:return i=c.sent().data,[2,{data:{user:(s=(void 0===i?{}:i).session).user,session:s},error:null}];case 6:return a=c.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(a,{method:"verifyOtp"})}];case 7:return[2]}})})},t.prototype.getSession=function(){return c(this,void 0,Promise,function(){var e,t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=o.sent())&&"accessKey"!==e.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return t=o.sent().data,n=(void 0===t?{}:t).user,[2,{data:{session:i(i({},e),{user:n}),user:n},error:null}];case 3:return r=o.sent(),[2,{data:{session:null,user:null},error:new h.AuthError(r,{method:"getSession"})}];case 4:return[2]}})})},t.prototype.refreshSession=function(e){return c(this,void 0,Promise,function(){var t,n,r,o,s;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=a.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return n=a.sent(),[4,this.getUser(!1)];case 3:return r=a.sent().data,[2,{data:{user:o=(void 0===r?{}:r).user,session:i(i({},n),{user:o})},error:null}];case 4:return s=a.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(s,{method:"refreshSession"})}];case 5:return[2]}})})},t.prototype.getUser=function(e){return void 0===e&&(e=!0),c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=o.sent())&&"accessKey"!==t.scope?(n=this.convertToUser,[4,this.getCurrentUser(e)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:n.apply(this,[o.sent()])},error:null}];case 3:return r=o.sent(),[2,{data:{user:null},error:new h.AuthError(r,{method:"getUser"})}];case 4:return[2]}})})},t.prototype.refreshUser=function(){return c(this,void 0,Promise,function(){var e,t,n;return u(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return r.sent(),[4,this.getSession()];case 2:return e=r.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return n=r.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(n,{method:"refreshUser"})}];case 4:return[2]}})})},t.prototype.updateUser=function(e){var t;return c(this,void 0,Promise,function(){var n,r,o,s,a,d,f,p,v,y,g,m,b,E=this;return u(this,function(w){switch(w.label){case 0:if(w.trys.push([0,8,,9]),_(e,"updateUser"),n=["password","new_password"].find(function(t){var n=e[t];return null!=n&&""!==n}))throw new h.AuthError({message:'updateUser 不支持更新密码,检测到传入了 "'.concat(n,'" 参数。如需修改密码请使用 resetPasswordForOld(旧密码修改)、resetPasswordForEmail(验证码重置)或 reauthenticate(重新认证后改密)')});if(!Object.keys(e).some(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}))throw this.missingRequiredParam("updateUser","(at least one field)");return r=e.email,o=e.phone,s=l(e,["email","phone"]),d=void 0!==o,f={},(a=void 0!==r)||d?(p=void 0,a?(p={email:e.email,usage:h.VerificationUsage.REAUTHENTICATION},v="email_change"):(y=this.formatPhone(e.phone),p={phone_number:y},v="phone_change"),[4,this.getVerification(i({},p))]):[3,4];case 1:return g=w.sent(),Object.keys(s).length>0?[4,this.updateUserBasicInfo(s)]:[3,3];case 2:w.sent(),w.label=3;case 3:return f={messageId:g.verification_id,verifyOtp:function(t){return c(E,void 0,Promise,function(){var n,r,o,i;return u(this,function(s){switch(s.label){case 0:return s.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:g.verification_id||""})]:[3,3];case 1:return(n=s.sent()).error?[2,n]:[4,this.updateUserBasicInfo({email:e.email})];case 2:return s.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:g.verification_id||""})]:[3,6];case 4:return(n=s.sent()).error?[2,n]:[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return s.sent(),[3,9];case 6:return[4,this.verifyOtp(a?{type:v,email:e.email,token:t.token,messageId:g.verification_id||""}:{type:v,phone:e.phone,token:t.token,messageId:g.verification_id||""})];case 7:return(n=s.sent()).error?[2,n]:[4,this.updateUserBasicInfo(e)];case 8:s.sent(),s.label=9;case 9:return[4,this.getUser(!1)];case 10:return r=s.sent().data.user,null===(i=this.config.eventBus)||void 0===i||i.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:r},error:null}];case 11:return o=s.sent(),[2,{data:{user:null},error:new h.AuthError(o,{method:"updateUser"})}];case 12:return[2]}})})}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:w.sent(),w.label=6;case 6:return[4,this.getUser(!1)];case 7:return m=w.sent().data.user,Object.keys(s).length>0&&(null===(t=this.config.eventBus)||void 0===t||t.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.USER_UPDATED})),[2,{data:i({user:m},f),error:null}];case 8:return b=w.sent(),[2,{data:{user:null},error:new h.AuthError(b,{method:"updateUser"})}];case 9:return[2]}})})},t.prototype.getUserIdentities=function(){var e;return c(this,void 0,Promise,function(){var t,n;return u(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=r.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter(function(e){return!!e.bind})},error:null}];case 2:return n=r.sent(),[2,{data:{identities:null},error:new h.AuthError(n,{method:"getUserIdentities"})}];case 3:return[2]}})})},t.prototype.linkIdentity=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}},"linkIdentity"),[4,this.signInWithOAuth({provider:e.provider,options:{type:h.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return n.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=n.sent(),[2,{data:{provider:null},error:new h.AuthError(t,{method:"linkIdentity"})}];case 3:return[2]}})})},t.prototype.unlinkIdentity=function(e){return c(this,void 0,Promise,function(){var t;return u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}},"unlinkIdentity"),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return n.sent(),[2,{data:{},error:null}];case 2:return t=n.sent(),[2,{data:{},error:new h.AuthError(t,{method:"unlinkIdentity"})}];case 3:return[2]}})})},t.prototype.reauthenticate=function(){return c(this,void 0,Promise,function(){var e,t,n,r,o=this;return u(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return e=s.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"reauthenticate"),t=e.email?{email:e.email,usage:h.VerificationUsage.REAUTHENTICATION}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return n=s.sent(),[2,{data:{updateUser:function(e){return c(o,void 0,Promise,function(){var r,o,s,a,c;return u(this,function(u){switch(u.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}},"reauthenticate"),u.label=1;case 1:return u.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:n.verification_id,verification_code:e.nonce})]:[3,5];case 2:return r=u.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:r.verification_token})];case 3:return o=u.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:o.sudo_token})];case 4:return u.sent(),[3,7];case 5:return[4,this.signInWithUsername(i(i({verificationInfo:n,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:u.sent(),u.label=7;case 7:return[4,this.getSession()];case 8:return s=u.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return c=u.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(c,{method:"reauthenticate"})}];case 10:return[2]}})})}},error:null}];case 3:return r=s.sent(),[2,{data:{updateUser:null},error:new h.AuthError(r,{method:"reauthenticate"})}];case 4:return[2]}})})},t.prototype.resend=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"resend"),t="signup"===e.type?"ANY":"USER",n={target:t},"email"in e&&(n.email=e.email,n.usage=h.VerificationUsage.EMAIL),"phone"in e&&(n.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(n)];case 1:return[2,{data:{messageId:o.sent().verification_id},error:null}];case 2:return r=o.sent(),[2,{data:{messageId:null},error:new h.AuthError(r,{method:"resend"})}];case 3:return[2]}})})},t.prototype.setSession=function(e){return c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}},"setSession"),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(n=(void 0===t?{}:t).session).user,session:n},error:null}];case 3:return r=o.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(r,{method:"setSession"})}];case 4:return[2]}})})},t.prototype.exchangeCodeForSession=function(){return c(this,void 0,void 0,function(){return u(this,function(e){return[2]})})},t.prototype.deleteUser=function(e){return c(this,void 0,Promise,function(){var t,n;return u(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}},"deleteUser"),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=r.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return r.sent(),[2,{data:{},error:null}];case 3:return n=r.sent(),[2,{data:{},error:new h.AuthError(n,{method:"deleteUser"})}];case 4:return[2]}})})},t.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),c(this,void 0,Promise,function(){var t,n,r,o,i;return u(this,function(s){try{return t=e.config_version||"env",n=Object.keys(e.query||{}).map(function(t){return"".concat(t,"=").concat(e.query[t])}).join("&"),f.adapterForWxMp.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(n?"?".concat(n):"")}):(r=e.redirect_uri||window.location.href,o=new URL(r),i="".concat(o.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(r)).concat(n?"&".concat(n):""),window.location.href=i),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new h.AuthError(e,{method:"toDefaultLoginPage"})}]}return[2]})})},t.prototype.signInWithCustomTicket=function(e){return c(this,void 0,Promise,function(){var t,n,r,o;return u(this,function(s){switch(s.label){case 0:e&&this.setCustomSignFunc(e),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return t=s.sent(),[4,this.getSession()];case 4:return n=s.sent().data,r=(void 0===n?{}:n).session,[2,i(i({},t),{data:{user:r.user,session:r},error:null})];case 5:return o=s.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(o,{method:"signInWithCustomTicket"})}];case 6:return[2]}})})},t.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,n=void 0===t||t;return c(this,void 0,Promise,function(){var e,t,r,o,s,a,l=this;return u(this,function(d){switch(d.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return c(l,void 0,void 0,function(){var r,o;return u(this,function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},n)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:r.provider_token},n)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}})})},d.label=1;case 1:return d.trys.push([1,5,,6]),[4,new Promise(function(e,n){wx.login({success:function(r){return c(l,void 0,void 0,function(){var o;return u(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(r.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),n(o),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})})];case 2:return d.sent(),[4,this.createLoginState()];case 3:return r=d.sent(),[4,this.getSession()];case 4:return o=d.sent().data,s=(void 0===o?{}:o).session,[2,i(i({},r),{data:{user:s.user,session:s},error:null})];case 5:return a=d.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(a,{method:"signInWithOpenId"})}];case 6:return[2]}})})},t.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,n=void 0===t?"":t,r=e.useWxCloud,o=void 0!==r&&r;return c(this,void 0,Promise,function(){var e,t,r,s,a,c,l,d,p;return u(this,function(u){switch(u.label){case 0:return f.adapterForWxMp.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone",code:n,appid:e.appId},provider_id:e.appId},[4,wx.login()]):[2,{data:{user:null,session:null},error:new h.AuthError({message:"wx api undefined"})}];case 1:r=u.sent().code,t.provider_code=r,u.label=2;case 2:return u.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(t,o)];case 3:if((s=u.sent()).error_code)throw s;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:s.provider_token},o)];case 4:if(null==(a=u.sent())?void 0:a.error_code)throw a;return[3,6];case 5:return c=u.sent(),[2,{data:{user:null,session:null},error:new h.AuthError(c,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return l=u.sent(),[4,this.getSession()];case 8:return d=u.sent().data,p=(void 0===d?{}:d).session,[2,i(i({},l),{data:{user:p.user,session:p},error:null})]}})})},t.prototype.bindPhoneNumber=function(e){return c(this,void 0,void 0,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.editContact(e)]})})},t.prototype.unbindProvider=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]})})},t.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},t.prototype.verify=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.verify(e)]})})},t.prototype.getVerification=function(e,t){return c(this,void 0,Promise,function(){return u(this,function(n){return e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[2,this.oauthInstance.authApi.getVerification(e,t)]})})},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(e){return void 0===e&&(e=!0),c(this,void 0,Promise,function(){var t,n,r;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),e?[4,this.getLoginState()]:[3,3];case 1:return(t=o.sent())?[4,t.user.refresh()]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return o.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(n=o.sent())?(r=n.user.getLocalUserInfo(),[4,n.user.checkLocalInfoAsync()]):[3,8];case 7:return o.sent(),[2,i(i({},n.user),r)];case 8:return[2,null]}})})},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return c(this,void 0,Promise,function(){var e,n,r=this;return u(this,function(o){switch(o.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,n=function(n){return c(r,void 0,void 0,function(){var r,o;return u(this,function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:n,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:r.provider_token},t)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}})})},[4,new Promise(function(e,t){wx.login({success:function(o){return c(r,void 0,void 0,function(){var r;return u(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,n(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),t(r),[3,3];case 3:return[2]}})})},fail:function(e){var n=new Error(null==e?void 0:e.errMsg);n.code=null==e?void 0:e.errno,t(n)}})})];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}})})},t.prototype.bindOpenId=function(){return c(this,void 0,Promise,function(){var e,t,n=this;return u(this,function(r){switch(r.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return c(n,void 0,void 0,function(){var n;return u(this,function(r){switch(r.label){case 0:n=void 0,r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(n=r.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:n.provider_token})];case 3:return r.sent(),[3,5];case 4:throw r.sent();case 5:return[2]}})})},[4,new Promise(function(e,r){wx.login({success:function(o){return c(n,void 0,void 0,function(){var n;return u(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),r(n),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 1:return r.sent(),[2]}})})},t.prototype.signInWithUnionId=function(){return c(this,void 0,Promise,function(){var e=this;return u(this,function(t){switch(t.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise(function(t,n){var r=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return c(e,void 0,void 0,function(){var e,i,s,a,c;return u(this,function(u){switch(u.label){case 0:e=null==r?void 0:r.appId,u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==r?void 0:r.appId}})];case 2:return i=u.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(n(i),[2]);case 3:return(null==(a=u.sent())?void 0:a.error_code)?(n(a),[2]):(t(!0),[3,5]);case 4:return c=u.sent(),n(c),[3,5];case 5:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})})];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}})})},t.prototype.signInWithSms=function(e){var t=e.verificationInfo,n=void 0===t?{verification_id:"",is_user:!1}:t,r=e.verificationCode,o=void 0===r?"":r,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,l=void 0===a?void 0:a;return c(this,void 0,Promise,function(){return u(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:l,username:s,loginType:"sms"})]}catch(e){throw e}return[2]})})},t.prototype.signInWithEmail=function(e){var t=e.verificationInfo,n=void 0===t?{verification_id:"",is_user:!1}:t,r=e.verificationCode,o=void 0===r?"":r,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,l=void 0===a?"":a;return c(this,void 0,Promise,function(){return u(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:s,username:l,loginType:"email"})]}catch(e){throw e}return[2]})})},t.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},t.prototype.signIn=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.setPassword=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.setPassword(e)]})})},t.prototype.isUsernameRegistered=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}})})},t.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new w({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},t.prototype.getLoginState=function(){return c(this,void 0,Promise,function(){var e;return u(this,function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new w({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}})})},t.prototype.getUserInfo=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.getCurrentUser()]})})},t.prototype.getWedaUserInfo=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]})})},t.prototype.updateUserBasicInfo=function(e){return c(this,void 0,void 0,function(){var t;return u(this,function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return(t=n.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]})})},t.prototype.queryUser=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]})})},t.prototype.getAccessToken=function(){return c(this,void 0,Promise,function(){return u(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}})})},t.prototype.grantProviderToken=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]})})},t.prototype.patchProviderToken=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]})})},t.prototype.signInWithProvider=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),c(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},t.prototype.grantToken=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}})})},t.prototype.genProviderRedirectUri=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]})})},t.prototype.resetPassword=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]})})},t.prototype.deviceAuthorize=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]})})},t.prototype.sudo=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.sudo(e)]})})},t.prototype.deleteMe=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]})})},t.prototype.getProviders=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.getProviders()]})})},t.prototype.loginScope=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.loginScope()]})})},t.prototype.loginGroups=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.loginGroups()]})})},t.prototype.onLoginStateChanged=function(e){var t;return c(this,void 0,void 0,function(){var n,r=this;return u(this,function(o){switch(o.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(h.EVENTS.LOGIN_STATE_CHANGED,function(t){return c(r,void 0,void 0,function(){var n,r,o;return u(this,function(s){switch(s.label){case 0:return(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.eventType)===h.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return r=s.sent(),[3,3];case 2:r={},s.label=3;case 3:return n=r,e.call(this,i(i({},t),n)),[2]}})})}),[4,this.getLoginState()];case 1:return n=o.sent(),e.call(this,n),[2]}})})},t.prototype.refreshTokenForce=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]})})},t.prototype.getCredentials=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.getCredentials()]})})},t.prototype.setCredentials=function(e){return c(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}})})},t.prototype.getProviderSubType=function(){return c(this,void 0,Promise,function(){return u(this,function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]})})},t.prototype.createCaptchaData=function(e){return c(this,void 0,void 0,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]})})},t.prototype.verifyCaptchaData=function(e){return c(this,void 0,void 0,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]})})},t.prototype.getMiniProgramQrCode=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]})})},t.prototype.getMiniProgramQrCodeStatus=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]})})},t.prototype.modifyPassword=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]})})},t.prototype.modifyPasswordWithoutLogin=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]})})},t.prototype.getUserBehaviorLog=function(e){return c(this,void 0,Promise,function(){return u(this,function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]})})},t.prototype.signInWithUsername=function(e){var t=e.verificationInfo,n=void 0===t?{verification_id:"",is_user:!1}:t,r=e.verificationCode,o=void 0===r?"":r,s=e.username,a=void 0===s?"":s,l=e.bindInfo,h=void 0===l?void 0:l,d=e.loginType,f=void 0===d?"":d;return c(this,void 0,Promise,function(){var e,t,r,s,c,l,d;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:n.verification_id,verification_code:o})];case 1:if(null==(e=u.sent())?void 0:e.error_code)throw e;return t=e.verification_token,r=this.formatPhone(a),s={phone_number:r},"email"===f&&(s={email:r=a}),n.is_user?[4,this.oauthInstance.authApi.signIn({username:r,verification_token:t})]:[3,5];case 2:if(null==(c=u.sent())?void 0:c.error_code)throw c;return h?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==h?void 0:h.providerToken})]:[3,4];case 3:if(null==(l=u.sent())?void 0:l.error_code)throw l;u.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(i(i({},s),{verification_token:t,provider_token:null==h?void 0:h.providerId}))];case 6:if(null==(d=u.sent())?void 0:d.error_code)throw d;u.label=7;case 7:return[2,this.createLoginState()];case 8:throw u.sent();case 9:return[2]}})})},t.prototype.createLoginState=function(e,t){return c(this,void 0,Promise,function(){var n;return u(this,function(r){switch(r.label){case 0:return[4,(n=new w({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return r.sent(),(null==t?void 0:t.userInfo)?(n.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(n.user.refresh(e),[3,5]):[3,3];case 3:return[4,n.user.refresh(e)];case 4:r.sent(),r.label=5;case 5:return[2,n]}})})},t.prototype.setAccessKey=function(){var e,t;return c(this,void 0,void 0,function(){var n,r;return u(this,function(o){if(n="",r="",this.config.accessKey?(n=this.config.accessKey,r="accessKey"):(null===(e=this.config.auth)||void 0===e?void 0:e.secretId)&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretKey)&&(n="",r=h.DEFAULT_NODE_ACCESS_SCOPE),!r)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:n,token_type:"Bearer",scope:r,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]})})},t.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},t.prototype.notifyListeners=function(e,t,n){this.listeners.forEach(function(r){r.forEach(function(r){try{r(e,t,n)}catch(e){console.error("Error in auth state change callback:",e)}})})},t.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(h.EVENTS.AUTH_STATE_CHANGED,function(e){return c(t,void 0,void 0,function(){var t,n,r,o,i,s,a;return u(this,function(c){switch(c.label){case 0:return t=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.event,n=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.info,t!==h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN||n?[3,2]:[4,this.getUser(!0)];case 1:r=c.sent().data,(o=(void 0===r?{}:r).user)&&(n={user:o}),c.label=2;case 2:return[4,this.getSession()];case 3:return i=c.sent().data.session,this.notifyListeners(t,i,n),[2]}})})})},t.prototype.convertToUser=function(e){var t,n,r,o,i,s;if(!e)return null;var a=(null==e?void 0:e.email)||"",c=(null==e?void 0:e.phone_number)||"",u=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:u,aud:"authenticated",role:null===(n=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===n?void 0:n.call(t,function(e){return"string"==typeof e?e:e.id}),email:a||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:c,phone_confirmed_at:c?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(r=e.loginType)||void 0===r?void 0:r.toLowerCase())||"cloudbase",providers:[(null===(o=e.loginType)||void 0===o?void 0:o.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:null!==(i=e.hasPassword)&&void 0!==i?i:"SET"===e.password,open_id:null==e?void 0:e.open_id},identities:(null===(s=null==e?void 0:e.providers)||void 0===s?void 0:s.map(function(t){return{id:t.id||"",identity_id:t.id||"",user_id:u,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}}))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},t.prototype.missingRequiredParam=function(e,t){return new h.AuthError({error:"missing_required_param",error_code:4e3,error_description:"auth.".concat(e,"(params): missing required param '").concat(t,"'")},{method:e})},t.prototype.validateParams=function(e,t,n){for(var r=0,o=Object.entries(t);r<o.length;r++){var i=o[r],s=i[0];if(i[1].required&&(void 0===(null==e?void 0:e[s])||null===(null==e?void 0:e[s])||""===(null==e?void 0:e[s])))throw this.missingRequiredParam(n,s)}},t.prototype.validateAtLeastOne=function(e,t,n){if(!t.some(function(t){return t.some(function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])})}))throw this.missingRequiredParam(n,t.map(function(e){return e.join("|")}).join("|"))},t.prototype.init=function(){var e;return c(this,void 0,Promise,function(){return u(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&!this.oauthInstance.oauth2client.initSessionEmitted&&(null===(e=this.config.eventBus)||void 0===e||e.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}})})},s([(0,f.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(n=void 0!==h.authModels&&h.authModels.BindPhoneRequest)?n:Object]),a("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),s([(0,f.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(r=void 0!==h.authModels&&h.authModels.UnbindProviderRequest)?r:Object]),a("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],t.prototype,"unbindProvider",null),s([(0,f.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(v=void 0!==h.authModels&&h.authModels.BindEmailRequest)?v:Object]),a("design:returntype",void 0)],t.prototype,"bindEmail",null),s([(0,f.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(m=void 0!==h.authModels&&h.authModels.VerifyRequest)?m:Object]),a("design:returntype","function"==typeof(b="undefined"!=typeof Promise&&Promise)?b:Object)],t.prototype,"verify",null),s([(0,f.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(E=void 0!==h.authModels&&h.authModels.GetVerificationRequest)?E:Object,Object]),a("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],t.prototype,"getVerification",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(I="undefined"!=typeof Promise&&Promise)?I:Object)],t.prototype,"getCurrentUser",null),s([(0,f.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],t.prototype,"signInAnonymouslyInWx",null),s([(0,f.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],t.prototype,"bindOpenId",null),s([(0,f.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],t.prototype,"signInWithUnionId",null),s([(0,f.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],t.prototype,"signInWithSms",null),s([(0,f.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],t.prototype,"signInWithEmail",null),s([(0,f.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype","function"==typeof(R="undefined"!=typeof Promise&&Promise)?R:Object)],t.prototype,"isUsernameRegistered",null),s([(0,f.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],t.prototype,"getLoginState",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(k="undefined"!=typeof Promise&&Promise)?k:Object)],t.prototype,"getUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],t.prototype,"getWedaUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(D=void 0!==h.authModels&&h.authModels.BindWithProviderRequest)?D:Object]),a("design:returntype","function"==typeof(L="undefined"!=typeof Promise&&Promise)?L:Object)],t.prototype,"bindWithProvider",null),s([(0,f.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(j="undefined"!=typeof Promise&&Promise)?j:Object)],t.prototype,"getProviderSubType",null),t}(v.AuthV1Compat);function I(e,t){var n,r,o,s,a=this,l=e.region,p=void 0===l?"ap-shanghai":l,v=e.i18n,y=e.accessKey,g=e.useWxCloud,m=(null==t?void 0:t.platform)||f.useDefaultAdapter.bind(t)(),b=m.runtime,_=m.adapter,E=t||{},w=E.env,I=E.clientId,O=E.debug,A=E.cache,T=E.app,P=E.getApiOrigin,C=(t||{}).apiOrigin;C||(C="https://".concat(w,".").concat(p,".tcb-api.tencentcloudapi.com"));var R,N={env:w,clientId:I,i18n:v,accessKey:y,useWxCloud:g,eventBus:new f.CloudbaseEventEmitter},k=new h.CloudbaseOAuth((0,d.useAuthAdapter)(i(i({},N),{apiOrigin:C,getApiOrigin:P,apiPath:(null==e?void 0:e.apiPath)||h.AUTH_API_PREFIX,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:_,onCredentialsError:(R=N.eventBus,function(e){R.fire(h.EVENTS.LOGIN_STATE_CHANGED,i(i({},e),{eventType:h.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:i({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:O,auth:null===(r=null===(n=t.app)||void 0===n?void 0:n.config)||void 0===r?void 0:r.auth}))),U=new S(i(i({},N),{region:p,persistence:e.persistence,debug:O,cache:A||new f.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(w)},platformInfo:m}),runtime:b||"web",_fromApp:T,oauthInstance:k,auth:null===(s=null===(o=t.app)||void 0===o?void 0:o.config)||void 0===s?void 0:s.auth}));return k.initializeSession(function(e,t){return c(a,void 0,void 0,function(){return u(this,function(n){return e?(e.type===h.OAUTH_TYPE.SIGN_IN?t?N.eventBus.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:i(i({},e),{error:t})}):e.user&&U.createLoginState({},{userInfo:e.user}):e.type===h.OAUTH_TYPE.BIND_IDENTITY&&N.eventBus.fire(h.EVENTS.AUTH_STATE_CHANGED,{event:h.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:i(i({},e),{error:t})}),[2]):[2]})})}),{authInstance:U,oauthInstance:k}}t.Auth=S,t.generateAuthInstance=I;var O="auth";function A(e,t){for(var n=[],r=0;r<=e.length;r++)n[r]=[r];for(var o=0;o<=t.length;o++)n[0][o]=o;for(r=1;r<=e.length;r++)for(o=1;o<=t.length;o++){var i=e[r-1].toLowerCase()===t[o-1].toLowerCase()?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+i)}return n[e.length][t.length]}var T={name:"auth",namespace:O,entity:function(e){var t=function(e){var t,n=this;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:h.AUTH_API_PREFIX};var r=this.platform.adapter,o=e.persistence||r.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var s=I(i(i({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,getApiOrigin:function(){return n.request.getBaseEndPoint(n.config.endPointMode||"CLOUD_API")},platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),a=s.authInstance,c=s.oauthInstance;return this.oauthInstance=c,this.authInstance=a,this.authInstance},n=t.call(this,e);Object.assign(t,n),Object.setPrototypeOf(t,Object.getPrototypeOf(n));var r="undefined"!=typeof Proxy?new Proxy(t,{get:function(e,t,n){var r=Reflect.get(e,t,n);if(void 0!==r||"string"!=typeof t)return r;var o=function(e,t){for(var n=null,r=1/0,o=0,i=t;o<i.length;o++){var s=i[o];if(!s.startsWith("_")&&"constructor"!==s){var a=A(e,s);a<r&&(r=a,n=s)}}return n}(t,Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)).filter(function(t){return"function"==typeof e[t]}));return o&&console.warn("[CloudBase Auth] auth.".concat(t," is not a function. Did you mean: auth.").concat(o,"() ?")),r}}):t;return this[O]=r,r}};try{cloudbase.registerComponent(T)}catch(e){}var P=n(6722);Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return P.AuthErrorCategory}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return P.AuthErrorCode}}),Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return P.AuthError}}),t.registerAuth=function(e){try{e.registerComponent(T)}catch(e){console.warn(e)}}},1019:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.adapterForWxMp=t.CloudbaseCache=t.CloudbaseEventEmitter=t.catchErrorsDecorator=t.COMMUNITY_SITE_URL=t.ERRORS=t.throwError=t.printWarn=void 0;var o=n(3616);Object.defineProperty(t,"printWarn",{enumerable:!0,get:function(){return o.printWarn}}),Object.defineProperty(t,"throwError",{enumerable:!0,get:function(){return o.throwError}});var i=n(794);Object.defineProperty(t,"ERRORS",{enumerable:!0,get:function(){return i.ERRORS}}),Object.defineProperty(t,"COMMUNITY_SITE_URL",{enumerable:!0,get:function(){return i.COMMUNITY_SITE_URL}});var s=n(141);Object.defineProperty(t,"catchErrorsDecorator",{enumerable:!0,get:function(){return s.catchErrorsDecorator}});var a=n(9689);Object.defineProperty(t,"CloudbaseEventEmitter",{enumerable:!0,get:function(){return a.CloudbaseEventEmitter}});var c=n(6197);Object.defineProperty(t,"CloudbaseCache",{enumerable:!0,get:function(){return c.CloudbaseCache}});var u=n(7917);Object.defineProperty(t,"adapterForWxMp",{enumerable:!0,get:function(){return r(u).default}});var l=n(8182);Object.defineProperty(t,"useDefaultAdapter",{enumerable:!0,get:function(){return l.useDefaultAdapter}})},5266:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlParams=t.addUrlSearch=t.removeBrowserSession=t.getBrowserSession=t.saveToBrowserSession=void 0,t.saveToBrowserSession=function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}},t.getBrowserSession=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}},t.removeBrowserSession=function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}},t.addUrlSearch=function(e,t){if(void 0!==e){var n=new URL(window.location.href);return n.search=e,n.hash=t||n.hash,window.history.replaceState({},"",n.href),n.href}},t.removeUrlParams=function(e){if("undefined"!=typeof window)try{var t=new URL(window.location.href);e.forEach(function(e){t.searchParams.delete(e)}),window.history.replaceState({},"",t.href)}catch(e){console.error("Failed to remove URL params:",e)}}},916:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.applyUserV1Compat=t.AuthV1Compat=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=void 0;var s=n(6722),a=n(1019),c=function(){function e(e){}return e.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},e.prototype.getRedirectResult=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")})})},e.prototype.getLinkRedirectResult=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")})})},e}();t.WeixinAuthProvider=c;var u=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.authInstance.signInWithCustomTicket(function(){return Promise.resolve(e)})];case 1:return t.sent(),[2]}})})},e}();t.CustomAuthProvider=u;var l=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return e.sent(),[2]}})})},e}();t.AnonymousAuthProvider=l;var h=function(){function e(){}return e.prototype.weixinAuthProvider=function(e){return new c({authInstance:this,appid:e.appid,scope:e.scope})},e.prototype.customAuthProvider=function(){return new u({authInstance:this})},e.prototype.anonymousAuthProvider=function(){return new l({authInstance:this})},e.prototype.signUpWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:e,password:t})];case 1:return[2,n.sent()]}})})},e.prototype.signInWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return n.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPasswordResetEmail=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.signInWithUsernameAndPassword=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return n.sent(),[2,this.createLoginState()]}})})},e.prototype.sendPhoneCode=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),t=this.formatPhone(e),[4,this.getVerification({phone_number:t})];case 1:return n.sent(),[2,!0]}})})},e.prototype.signUpWithPhoneCode=function(e,t,n){return o(this,void 0,Promise,function(){var o;return i(this,function(i){switch(i.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),o=this.formatPhone(e),[4,this.signUp(r({phone_number:o,verification_code:t},n?{password:n}:{}))];case 1:return i.sent(),[2,this.createLoginState()]}})})},e.prototype.signInWithPhoneCodeOrPassword=function(e){return o(this,void 0,Promise,function(){var t,n,r,o;return i(this,function(i){switch(i.label){case 0:return t=e.phoneNumber,n=e.phoneCode,r=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),o=this.formatPhone(t),r?[4,this.signIn({username:o,password:r})]:[3,2];case 1:return i.sent(),[3,5];case 2:return n?[4,this.signIn({username:o,verification_token:n})]:[3,4];case 3:return i.sent(),[3,5];case 4:(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),i.label=5;case 5:return[2,this.createLoginState()]}})})},e.prototype.forceResetPwdByPhoneCode=function(e){return o(this,void 0,Promise,function(){var t,n,r,o;return i(this,function(i){switch(i.label){case 0:return t=e.phoneNumber,n=e.phoneCode,r=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof n&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof r&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),o=this.formatPhone(t),[4,this.resetPassword({phone_number:o,new_password:r,verification_token:n})];case 1:return i.sent(),[4,this.signIn({username:o,password:r})];case 2:return i.sent(),[2,this.createLoginState()]}})})},e.prototype.shouldRefreshAccessToken=function(e){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},e.prototype.onLoginStateExpired=function(e){var t=this;this.onLoginStateChanged(function(n){(null==n?void 0:n.eventType)===s.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR&&e.call(t)})},e.prototype.onAccessTokenRefreshed=function(e){var t=this;this.onAuthStateChange(function(n){n===s.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED&&e.call(t)})},e.prototype.onAnonymousConverted=function(e){var t=this;this.onAuthStateChange(function(n){n===s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&e.call(t)})},e.prototype.onLoginTypeChanged=function(e){var t=this;this.onAuthStateChange(function(n){n!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&n!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT||e.call(t)})},e}();t.AuthV1Compat=h,t.applyUserV1Compat=function(e){e.prototype.linkWithTicket=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")})})},e.prototype.linkWithRedirect=function(e){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},e.prototype.updateEmail=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:e})];case 1:return t.sent(),[2]}})})},e.prototype.linkWithPhoneNumber=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")})})},e.prototype.updatePhoneNumber=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")})})},e.prototype.unlink=function(e){return o(this,void 0,Promise,function(){return i(this,function(e){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")})})}}},3198:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerDatabase=t.gateWayFunc=void 0;var c=n(4954),u=n(2701),l=n(2877);function h(e,t,n,r){(function(e){var t,n,r;return!0===(null===(r=null===(n=null===(t=null==e?void 0:e.config)||void 0===t?void 0:t._fromApp)||void 0===n?void 0:n.config)||void 0===r?void 0:r.debug)})(e)&&function(e,t){var n=e.data;console.error("[cloudbase] NETWORK_ERROR",{status:t,requestId:e.requestId,body:"string"==typeof n?n.slice(0,1024):""})}(t,n),t.code=l.constants.ERRORS.NETWORK_ERROR,t.message=function(e,t){return"HTTP ".concat(e,". Expected ").concat(t,". Set debug: true to see the response.")}(n,r)}t.gateWayFunc={filterRes:function(e,t){e=l.utils.promoteGatewayError(e);var n=Number(e.statusCode);return n>=400&&!e.code&&h(null!=t?t:this,e,n,"HTTP 2xx"),delete e.header,delete e.statusCode,e},normalizeTransactionResponse:function(e,n){var r=null==(e=l.utils.promoteGatewayError(e))?void 0:e.data;r&&"object"==typeof r&&"string"==typeof r.request_id&&r.request_id&&(e.requestId=r.request_id);var o=Number(e.statusCode),i="start"===n?"HTTP 201 with transactionId":"HTTP 204 with an empty body";if(o>=400)return e.code||h(this,e,o,i),delete e.header,delete e.statusCode,e;if("start"===n){var s=null==r?void 0:r.transactionId;if(201===o&&"string"==typeof s&&s){var a=t.gateWayFunc.flattenResData(e);return delete a.header,delete a.statusCode,a}return e.code||h(this,e,o,i),delete e.header,delete e.statusCode,e}return 204!==o||""!==r&&null!=r?(e.code||h(this,e,o,i),delete e.header,delete e.statusCode,e):(delete e.data,delete e.header,delete e.statusCode,e)},flattenResData:function(e){if("object"==typeof e.data&&null!==e.data){var t=i(i({},e),e.data);return delete t.data,t}return e},safeParseEJSON:function(e){if("string"!=typeof e)return e;try{return u.EJSON.parse(e)}catch(t){return e}},parseEJSONParam:function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}},parseEJSONValue:function(e){if("string"!=typeof e)return e;try{return u.EJSON.parse(e)}catch(n){return t.gateWayFunc.parseEJSONParam(e)}},normalizeOrderParam:function(e){if(null!=e&&""!==e){for(var n=t.gateWayFunc.parseEJSONValue(e),r=function(e){var t=e&&"object"==typeof e?Number(e):e;if("number"==typeof t&&!isNaN(t))return t<0?"desc":"asc";if("string"==typeof t){var n=t.toLowerCase();if("desc"===n||"-1"===n)return"desc";if("asc"===n||"1"===n)return"asc"}},o=[],i=0,s=Array.isArray(n)?n:[n];i<s.length;i++){var a=s[i];if(a&&"object"==typeof a)if(void 0!==a.field)(l=r(a.direction))&&o.push({field:a.field,direction:l});else for(var c=0,u=Object.entries(a);c<u.length;c++){var l,h=u[c],d=h[0];(l=r(h[1]))&&o.push({field:d,direction:l})}}return o.length?o:void 0}},extractDocId:function(e){if(e&&"object"==typeof e&&!Array.isArray(e)&&1===Object.keys(e).length&&"_id"in e){var t=e._id;if("string"==typeof t||"number"==typeof t)return String(t);if(t&&"object"==typeof t){if("string"==typeof t.$oid)return t.$oid;var n=t.$eq;if("string"==typeof n||"number"==typeof n)return String(n);if(n&&"object"==typeof n&&"string"==typeof n.$oid)return n.$oid}}},toLegacyRegExp:function(e){if(!e||"object"!=typeof e)return e;if(e.$regularExpression&&"object"==typeof e.$regularExpression){var n=e.$regularExpression;return{$regex:n.pattern,$options:n.options}}if(Array.isArray(e))return e.map(function(e){return t.gateWayFunc.toLegacyRegExp(e)});var r={};for(var o in e)r[o]=t.gateWayFunc.toLegacyRegExp(e[o]);return r},parseWriteParam:function(e){return t.gateWayFunc.toLegacyRegExp(t.gateWayFunc.parseEJSONParam(e))},buildQueryParams:function(e){return Object.entries(e).filter(function(e){e[0];var t=e[1];return null!=t&&""!==t}).map(function(e){var t=e[0],n=e[1],r="object"==typeof n?JSON.stringify(n):String(n);return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(r))}).join("&")},getUrlPrefix:function(e){var t=(null==e?void 0:e.instance)||"(default)",n=(null==e?void 0:e.database)||"(default)";return"/database/instances/".concat(t,"/databases/").concat(n)},"database.queryDocument":function(e,n){var r,o,c,l;return s(this,void 0,Promise,function(){var s,h,d,f,p,v,y;return a(this,function(a){switch(a.label){case 0:return s=t.gateWayFunc.parseEJSONParam(e.query),h=t.gateWayFunc.parseEJSONValue(e.projection),d=t.gateWayFunc.extractDocId(s),f=void 0!==d,p=t.gateWayFunc.buildQueryParams(i({projection:h,transactionId:e.transactionId},f?{}:{offset:null!==(r=e.offset)&&void 0!==r?r:0,limit:null!==(o=e.limit)&&void 0!==o?o:100,order:t.gateWayFunc.normalizeOrderParam(e.order),query:s?u.EJSON.stringify(s,{relaxed:!1}):void 0})),v="".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(p),f&&(v="".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/").concat(d,"?").concat(p)),[4,this.gateWay({url:v,method:"GET"},n)];case 1:return(y=a.sent()).data=t.gateWayFunc.safeParseEJSON(JSON.stringify(y.data)),!f||y.code||(null===(c=y.data)||void 0===c?void 0:c.code)?(y.code||(null===(l=y.data)||void 0===l?void 0:l.code)?y=i(i({},y),{data:i(i({},y.data),{list:[]})}):Array.isArray(y.data)?y=i(i({},y),{data:{list:y.data}}):y.data&&!Array.isArray(y.data.list)&&(y=i(i({},y),{data:i(i({},y.data),{list:[]})})),[2,t.gateWayFunc.filterRes(y,this)]):[2,i(i({},y),{data:{list:[y.data]}})]}})})},"database.addDocument":function(e,n){var r,o,c;return s(this,void 0,Promise,function(){var s,u;return a(this,function(a){switch(a.label){case 0:return s=(Array.isArray(e.data)?e.data:[e.data]).map(function(e){return t.gateWayFunc.parseWriteParam(e)}),[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"POST",data:i({data:s},e.transactionId&&{transactionId:e.transactionId})},n)];case 1:return u=a.sent(),Array.isArray(e.data)?u=i(i({},u),{data:i({ids:(null===(r=u.data)||void 0===r?void 0:r.insertedIds)||[]},u.data)}):(null===(c=null===(o=u.data)||void 0===o?void 0:o.insertedIds)||void 0===c?void 0:c[0])&&(u=i(i({},u),{data:i({_id:u.data.insertedIds[0]},u.data)})),[2,t.gateWayFunc.filterRes(u,this)]}})})},"database.updateDocument":function(e,n){var r;return s(this,void 0,Promise,function(){var o;return a(this,function(s){switch(s.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"PATCH",data:i({query:t.gateWayFunc.parseEJSONParam(e.query),data:t.gateWayFunc.parseEJSONParam(e.data),multi:!!e.multi,upsert:!!e.upsert,replaceMode:null!==(r=e.replaceMode)&&void 0!==r?r:!1===e.merge},e.transactionId&&{transactionId:e.transactionId})},n)];case 1:return o=s.sent(),[2,t.gateWayFunc.filterRes(o,this)]}})})},"database.deleteDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/remove"),method:"POST",data:i({query:t.gateWayFunc.parseEJSONParam(e.query),multi:!!e.multi},e.transactionId&&{transactionId:e.transactionId})},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.filterRes(r,this)]}})})},"database.countDocument":function(e,n){return s(this,void 0,Promise,function(){var r,o,i;return a(this,function(s){switch(s.label){case 0:return r=t.gateWayFunc.parseEJSONParam(e.query),o=t.gateWayFunc.buildQueryParams({count:!0,query:r?u.EJSON.stringify(r,{relaxed:!1}):void 0}),[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(o),method:"GET"},n)];case 1:return i=s.sent(),[2,t.gateWayFunc.filterRes(i,this)]}})})},"database.addCollection":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections"),method:"POST",data:{collectionName:e.collectionName}},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.filterRes(r,this)]}})})},"database.aggregate":function(e,n){var r;return s(this,void 0,Promise,function(){var o,i;return a(this,function(s){switch(s.label){case 0:return o=e.stages.map(function(e){var t,n;try{var r="string"==typeof e.stageValue?JSON.parse(e.stageValue):e.stageValue;return(t={})[e.stageKey]=u.EJSON.serialize(r),t}catch(t){return(n={})[e.stageKey]=e.stageValue,n}}),[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/aggregations"),method:"POST",data:{pipeline:o}},n)];case 1:return i=s.sent(),Array.isArray(null===(r=i.data)||void 0===r?void 0:r.list)&&(i.data.list=JSON.stringify(i.data.list.map(function(e){return JSON.stringify(e)}))),[2,t.gateWayFunc.filterRes(i,this)]}})})},"database.startTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/transactions"),method:"POST",shouldThrowOnError:!1},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.normalizeTransactionResponse.call(this,r,"start")]}})})},"database.commitTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/commit"),method:"POST",shouldThrowOnError:!1},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.normalizeTransactionResponse.call(this,r,"commit")]}})})},"database.abortTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/rollback"),method:"POST",shouldThrowOnError:!1},n)];case 1:return r=o.sent(),[2,t.gateWayFunc.normalizeTransactionResponse.call(this,r,"rollback")]}})})},"database.getInTransaction":function(e,n){var r;return s(this,void 0,void 0,function(){var o;return a(this,function(s){switch(s.label){case 0:return[4,t.gateWayFunc["database.queryDocument"].call(this,e,n)];case 1:return"object"==typeof(o=s.sent()).data&&null!==o.data?(null===(r=o.data)||void 0===r?void 0:r.code)?[2,t.gateWayFunc.flattenResData(o)]:[2,i(i({},o),{data:JSON.stringify(o.data)})]:[2,o]}})})},"database.updateDocInTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,t.gateWayFunc["database.updateDocument"].call(this,e,n)];case 1:return r=o.sent(),[2,t.gateWayFunc.flattenResData(r)]}})})},"database.deleteDocInTransaction":function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,t.gateWayFunc["database.deleteDocument"].call(this,e,n)];case 1:return r=o.sent(),[2,t.gateWayFunc.flattenResData(r)]}})})},"database.insertDocInTransaction":function(e,n){var r;return s(this,void 0,Promise,function(){var o,s;return a(this,function(a){switch(a.label){case 0:return[4,t.gateWayFunc["database.addDocument"].call(this,e,n)];case 1:return"object"==typeof(o=a.sent()).data&&null!==o.data?(s=!!(null===(r=o.data)||void 0===r?void 0:r._id),o=i(i(i({},o),{inserted:s?1:0,ok:s?1:0}),o.data)):o=i({inserted:0,ok:0},o),delete o.data,[2,o]}})})},"database.runCommands":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(e),"/commands"),method:"POST",data:i({commands:u.EJSON.serialize(Array.isArray(e.commands)?e.commands.map(function(e){return t.gateWayFunc.parseEJSONParam(e)}):e.commands)},e.transactionId&&{transactionId:e.transactionId})},n)];case 1:"object"==typeof(r=o.sent()).data&&null!==r.data&&(delete(r=i(i({},r),r.data)).data,delete r.request_id);try{r=u.EJSON.deserialize(r)}catch(e){}return[2,t.gateWayFunc.filterRes(r,this)]}})})},"database.getDocument":function(e,n){var r;return s(this,void 0,Promise,function(){var o,s;return a(this,function(a){switch(a.label){case 0:return(o=i({},e)).query=t.gateWayFunc.parseEJSONParam(o.query),o.projection=t.gateWayFunc.parseEJSONValue(o.projection),[4,t.gateWayFunc["database.queryDocument"].call(this,o,n)];case 1:return s=a.sent(),Array.isArray(null===(r=s.data)||void 0===r?void 0:r.list)&&(s.data.list=s.data.list.map(function(e){return u.EJSON.stringify(e,{relaxed:!1})})),[2,s]}})})},"database.insertDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){return(r=i({},e)).data=Array.isArray(r.data)?r.data.map(function(e){return t.gateWayFunc.parseWriteParam(e)}):t.gateWayFunc.parseWriteParam(r.data),[2,t.gateWayFunc["database.addDocument"].call(this,r,n)]})})},"database.modifyDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){return(r=i({},e)).query=t.gateWayFunc.parseEJSONParam(r.query),r.data=t.gateWayFunc.parseEJSONParam(r.data),[2,t.gateWayFunc["database.updateDocument"].call(this,r,n)]})})},"database.modifyAndReturnDoc":function(e,n){var r,o;return s(this,void 0,Promise,function(){var s,c,l;return a(this,function(a){switch(a.label){case 0:return(s=i({},e)).query=t.gateWayFunc.parseEJSONParam(s.query),s.data=t.gateWayFunc.parseEJSONParam(s.data),(c=t.gateWayFunc.extractDocId(s.query))?[4,this.gateWay({url:"".concat(t.gateWayFunc.getUrlPrefix(s),"/collections/").concat(s.collectionName,"/documents/").concat(c),method:"PATCH",data:i({data:s.data,replaceMode:null!==(r=s.replaceMode)&&void 0!==r&&r,upsert:!!s.upsert,returnDoc:!0},s.transactionId&&{transactionId:s.transactionId})},n)]:[2,t.gateWayFunc["database.updateDocument"].call(this,s,n)];case 1:return l=a.sent(),void 0!==(null===(o=l.data)||void 0===o?void 0:o.doc)&&"string"!=typeof l.data.doc&&(l.data.doc=u.EJSON.stringify(l.data.doc,{relaxed:!1})),[2,t.gateWayFunc.filterRes(l,this)]}})})},"database.removeDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){return(r=i({},e)).query=t.gateWayFunc.parseEJSONParam(r.query),void 0!==r.query&&null!==r.query&&""!==r.query||(r.query={_id:{$exists:!0}}),[2,t.gateWayFunc["database.deleteDocument"].call(this,r,n)]})})},"database.calculateDocument":function(e,n){return s(this,void 0,Promise,function(){var r;return a(this,function(o){return(r=i({},e)).query=t.gateWayFunc.parseEJSONParam(r.query),[2,t.gateWayFunc["database.countDocument"].call(this,r,n)]})})},"database.aggregateDocuments":function(e,n){var r;return s(this,void 0,Promise,function(){var o,s;return a(this,function(a){switch(a.label){case 0:return o=i({},e),Array.isArray(o.stages)&&(o.stages=o.stages.map(function(e){return i(i({},e),{stageValue:t.gateWayFunc.parseEJSONParam(e.stageValue)})})),[4,t.gateWayFunc["database.aggregate"].call(this,o,n)];case 1:if(s=a.sent(),"string"==typeof(null===(r=s.data)||void 0===r?void 0:r.list))try{s.data.list=JSON.parse(s.data.list)}catch(e){}return[2,s]}})})}};var d={name:"database",entity:{database:function(e){var n;if(void 0!==e&&"Object"!==Object.prototype.toString.call(e).slice(8,-1))throw l.utils.createCloudbaseError({code:"INVALID_PARAM",msg:"dbConfig must be an object"},null===(n=this.config)||void 0===n?void 0:n.errorFactory);var r=this.platform,u=r.adapter,h=r.runtime,d=function(e){function n(t){return e.call(this,t)||this}return o(n,e),n.prototype.send=function(n,r,o){var i,c,u,h;return s(this,void 0,void 0,function(){var s,d,f;return a(this,function(a){switch(a.label){case 0:return s=null,d=o&&"number"==typeof o.timeout?{timeout:o.timeout}:void 0,"GATEWAY"===this.config.endPointMode&&t.gateWayFunc[n]?[4,t.gateWayFunc[n].call(this,r,d)]:[3,2];case 1:return s=a.sent(),[3,4];case 2:return[4,e.prototype.send.call(this,n,r,void 0,d)];case 3:s=a.sent(),a.label=4;case 4:if(f=l.utils.resolveThrow(null!==(u=null===(c=null===(i=this.config)||void 0===i?void 0:i._fromApp)||void 0===c?void 0:c.config)&&void 0!==u?u:this.config),s&&s.code&&f)throw l.utils.createCloudbaseError({code:s.code,msg:s.message||s.data&&s.data.message||"",requestId:s.requestId},null===(h=this.config)||void 0===h?void 0:h.errorFactory);return[2,s]}})})},n}(this.request.constructor);return c.Db.reqClass=d,c.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},c.Db.runtime=h,this.wsClientClass&&(c.Db.wsClass=u.wsClass,c.Db.wsClientClass=this.wsClientClass),c.Db.ws||(c.Db.ws=null),new(function(e){function t(t){return e.call(this,t)||this}return o(t,e),t.prototype.runCommands=function(e){return s(this,void 0,Promise,function(){return a(this,function(t){return[2,c.Db.createRequest(this.config).send("database.runCommands",e)]})})},t}(c.Db))(i(i(i({},this.config),{_fromApp:this}),e))}}};try{cloudbase.registerComponent(d)}catch(e){}function f(e){try{e.registerComponent(d)}catch(e){console.warn(e)}}t.registerDatabase=f;try{window.registerDatabase=f}catch(e){}},8795:function(e,t,n){"use strict";var r=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(n(6950)),o=n(9895),i=n(1060),s=n(3456),a=n(7209),c=n(7397),u=n(3645),l=n(5337),h=n(9253),d=n(9126),f=n(1944),p=n(3198);r.default.registerVersion("3.11.0");try{(0,o.registerAuth)(r.default),(0,i.registerFunctions)(r.default),(0,s.registerStorage)(r.default),(0,p.registerDatabase)(r.default),(0,a.registerRealtime)(r.default),(0,c.registerRealtimeJs)(r.default),(0,u.registerModel)(r.default),(0,l.registerAi)(r.default),(0,h.registerCloudrun)(r.default),(0,d.registerMySQL)(r.default),(0,f.registerApis)(r.default)}catch(e){}try{window.cloudbase=r.default}catch(e){}t.default=r.default,e.exports=r.default},9253:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerCloudrun=t.requestContainer=void 0;var s=n(2877).constants.ERRORS,a="cloudrun",c=function(){function e(){}return e.prototype.callContainer=function(e,t){return o(this,void 0,void 0,function(){var n,o,c;return i(this,function(i){switch(i.label){case 0:if(n=e.name,o=e.data,!n)throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(a,".callContainer] invalid name")}));try{c=o?JSON.stringify(o):""}catch(e){throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(a,".callContainer] invalid data")}))}return[4,u.call(this,r(r({},e),{data:c}),t)];case 1:return[2,i.sent()]}})})},e}();function u(e,t){var n;return o(this,void 0,void 0,function(){var o,s,a,c,u,l,h,d,f,p,v,y,g,m,b;return i(this,function(i){switch(i.label){case 0:if(o=e.name,s=e.data,a=e.path,c=void 0===a?"":a,u=e.method,l=e.header,h=void 0===l?{}:l,d=this.getEndPointWithKey("GATEWAY"),f=d.BASE_URL,p=d.PROTOCOL,v="".concat(p).concat(f,"/cloudrun/").concat(o),y=c.startsWith("/")?c:"/".concat(c),g=["GET","HEAD"].includes(null===(n=null==u?void 0:u.toUpperCase)||void 0===n?void 0:n.call(u)))try{m={};try{m=JSON.parse(s)}catch(e){m=s||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(m).map(function(e){return"".concat(e,"=").concat(m[e])}).join("&"))}catch(e){}return[4,this.request.fetch(r(r({method:u||"POST",headers:Object.assign({},{"Content-Type":"application/json; charset=utf-8"},h)},g?{}:{body:s}),{url:"".concat(v).concat(y),customReqOpts:t}))];case 1:return b=i.sent(),"node-sdk"===(null==t?void 0:t.from)?[2,b]:[4,b.data];case 2:return[2,i.sent()]}})})}t.requestContainer=u;var l=new c,h={name:a,entity:{callContainer:l.callContainer}};try{cloudbase.registerComponent(h)}catch(e){}function d(e){try{e.registerComponent(h)}catch(e){console.warn(e)}}t.registerCloudrun=d;try{window.registerCloudrun=d}catch(e){}},1060:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerFunctions=void 0;var c=n(3388),u=n(2877),l=n(9253),h=u.constants.getSdkName,d=u.constants.ERRORS,f=u.constants.COMMUNITY_SITE_URL,p=u.utils.execCallback,v=u.utils.maybeThrow,y=u.helpers.catchErrorsDecorator,g="functions";function m(e){return e.length<=1024?e:"".concat(e.slice(0,1024),"…")}function b(e,t){return{code:(null==e?void 0:e.code)||d.NETWORK_ERROR,message:(null==e?void 0:e.message)||(null==e?void 0:e.msg)||"",requestId:t}}function _(e,t){if(e&&"object"==typeof e&&!Array.isArray(e))return b(e,t);if("string"==typeof e){try{var n=JSON.parse(e);if(n&&"object"==typeof n&&!Array.isArray(n))return b(n,t)}catch(e){}return{code:d.NETWORK_ERROR,message:m(e),requestId:t}}return{code:d.NETWORK_ERROR,message:m(null==e?"":String(e)),requestId:t}}var E=new(function(){function e(){}var t,n,m;return e.invokeCloudrun=function(e,t,n){return s(this,void 0,void 0,function(){var o,i,s,c,h,d,f;return a(this,function(a){switch(a.label){case 0:return o=t.name,i=t.path,s=void 0===i?"":i,c=t.method,h=t.header,d=void 0===h?{}:h,f=u.utils.generateRequestId(),[4,l.requestContainer.call(e,{name:o,data:n,path:s,method:c,header:r(r({},d),{"X-Request-Id":f})})];case 1:return[2,{result:a.sent(),requestId:f}]}})})},e.invokeGateway=function(e,t,n,o){return s(this,void 0,void 0,function(){var i,s,c,u,l;return a(this,function(a){switch(a.label){case 0:i=e.request,s=e.config,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,i.gateWay(r(r({},t),{path:"functions",shouldThrowOnError:!1}),o)];case 2:return c=a.sent(),[3,4];case 3:return u=a.sent(),function(e){if(!e)return!1;if(e instanceof SyntaxError||"SyntaxError"===e.name)return!0;var t=String(e.message||"");return/not valid JSON|Unexpected token|JSON\.parse|Failed to execute 'json'/i.test(t)}(l=u)?[2,v(s,_(l.message,l.requestId))]:[2,p(n,l)];case 4:return Number(null==c?void 0:c.statusCode)>=400?[2,v(s,_(null==c?void 0:c.data,null==c?void 0:c.requestId))]:[2,p(n,null,{requestId:null==c?void 0:c.requestId,result:null==c?void 0:c.data})]}})})},e.invokeCloudApi=function(e,t,n,r,o){var i,c,u;return s(this,void 0,void 0,function(){var s,l,f,v,y,m,b;return a(this,function(a){switch(a.label){case 0:return s=t.name,l=t.data,f=t.query,v=t.parse,y=t.search,[4,e.request.send("functions.invokeFunction",{inQuery:f,parse:v,search:y,function_name:s,request_data:n},{endPointMode:"CLOUD_API",defaultQuery:(null===(i=null==l?void 0:l.params)||void 0===i?void 0:i.action)?{action:null===(c=null==l?void 0:l.params)||void 0===c?void 0:c.action}:{}},o)];case 1:if(m=a.sent(),void 0===(b=null===(u=m.data)||void 0===u?void 0:u.response_data))return[2,p(r,null,m)];if(v)return[2,p(r,null,{result:b,requestId:m.requestId})];try{return b=JSON.parse(b),[2,p(r,null,{result:b,requestId:m.requestId})]}catch(e){return[2,p(r,new Error("[".concat(h(),"][").concat(d.INVALID_PARAMS,"][").concat(g,".callFunction] response data must be json")))]}return[2]}})})},e.prototype.callFunction=function(t,n,r){return s(this,void 0,void 0,function(){var o,i,s,c,u,l;return a(this,function(a){switch(a.label){case 0:if(o=t.name,i=t.data,s=t.type,c=this.config,!o)return[2,v(c,{code:d.INVALID_PARAMS,message:"[".concat(g,".callFunction] invalid function name")})];try{u=i?JSON.stringify(i):""}catch(e){return[2,v(c,{code:d.INVALID_PARAMS,message:"[".concat(g,".callFunction] invalid data")})]}if("cloudrun"===s)return[2,e.invokeCloudrun(this,t,u)];a.label=1;case 1:return a.trys.push([1,5,,6]),function(e,t){return"GATEWAY"===e.endPointMode&&!function(e){return"lcap-common-service"===e||"lcap-datasource-test"===e||e.startsWith("lcap-data")||e.startsWith("lowcode-datasource")||"cloudbase_module"===e}(t)&&!function(e){return"lowcode-wx-datasource"===e}(t)}(c,o)?[4,e.invokeGateway(this,t,n,r)]:[3,3];case 2:return[2,a.sent()];case 3:return[4,e.invokeCloudApi(this,t,u,n,r)];case 4:return[2,a.sent()];case 5:return l=a.sent(),p(n,l),[3,6];case 6:return[2]}})})},o([y({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(t=void 0!==c.ICallFunctionOptions&&c.ICallFunctionOptions)?t:Object,"function"==typeof(n="undefined"!=typeof Function&&Function)?n:Object,"function"==typeof(m=void 0!==c.ICustomReqOpts&&c.ICustomReqOpts)?m:Object]),i("design:returntype",Promise)],e.prototype,"callFunction",null),e}()),w={name:g,entity:{callFunction:E.callFunction}};try{cloudbase.registerComponent(w)}catch(e){}t.registerFunctions=function(e){try{e.registerComponent(w)}catch(e){console.warn(e)}}},3645:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerModel=t.lazyGetEntity=void 0;var c=n(8630),u=n(2877).events.CloudbaseEventEmitter,l="models",h=new WeakMap;function d(e){return new Proxy({},{get:function(t,n){var o=e.getEndPointWithKey("GATEWAY"),i=o.BASE_URL,u=o.PROTOCOL,l=r(r({},e),{BASE_URL:i,PROTOCOL:u}),d=h.get(l);return d||(d=function(e){var t=this,n=e.callFunction.bind(e),o=e.request.fetch.bind(e.request),i=e.getEndPointWithKey("GATEWAY"),u=i.BASE_URL,l=i.PROTOCOL,h="".concat(l).concat(u,"/model"),d="".concat(l).concat(u,"/sql"),f=(0,c.generateHTTPClient)(n,function(e){return s(t,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:return[4,o(r(r({},e),{headers:r({"Content-Type":"application/json"},e.headers)}))];case 1:return[4,t.sent().data];case 2:return[2,t.sent()]}})})},h,{sqlBaseUrl:d});return f}(e),h.set(l,d)),d[n]}})}t.lazyGetEntity=d;var f="cloudbase_init",p=new u;p.on(f,function(e){var t=e.data;Object.assign(t,{models:d(t)})});var v={name:l,namespace:l,entity:new Proxy({},{get:function(e,t){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(t,"."))}}),injectEvents:{bus:p,events:[f]}};try{cloudbase.registerComponent(v)}catch(e){}function y(e){try{e.registerComponent(v)}catch(e){console.warn(e)}}t.registerModel=y;try{window.registerModel=y}catch(e){}i(n(8630),t)},9126:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerMySQL=void 0;var c=n(8630);function u(e){if(!e)return{get:function(){return null},forEach:function(){}};if("function"==typeof e.get)return e;var t={};return Object.keys(e).forEach(function(n){t[n.toLowerCase()]=e[n]}),{get:function(e){var n;return null!==(n=t[e.toLowerCase()])&&void 0!==n?n:null},forEach:function(e){Object.entries(t).forEach(function(t){var n=t[0],r=t[1];return e(r,n)})}}}function l(e,t,n){var o=this,i=e.request.fetch.bind(e.request),l=t||{},h=l.instance,d=void 0===h?n?void 0:"default":h,f=l.database,p=void 0===f?n?void 0:e.config.env:f,v=e.getEndPointWithKey("GATEWAY"),y=v.BASE_URL,g=v.PROTOCOL,m="".concat(g).concat(y),b=function(t,n){return s(o,void 0,void 0,function(){var o,s,c,l,h,f,v,y,g,b;return a(this,function(a){switch(a.label){case 0:return o={},n.headers instanceof Headers?n.headers.forEach(function(e,t){o[t]=e}):n.headers&&Object.assign(o,n.headers),[["X-Db-Instance",d],["Accept-Profile",p],["Content-Profile",p]].forEach(function(e){var t=e[0],n=e[1];o[t]||o[t.toLocaleLowerCase()]||!n||(o[t]=n)}),s=t.toString(),c=e.getEndPointWithKey("GATEWAY"),l=c.BASE_URL,h=c.PROTOCOL,(f="".concat(h).concat(l))!==m&&s.startsWith(m)&&(s=s.replace(m,f)),[4,i(r(r({url:s},n),{headers:r({"Content-Type":"application/json"},o),shouldThrowOnError:!1}))];case 1:v=a.sent(),y={},a.label=2;case 2:return a.trys.push([2,4,,5]),[4,v.data];case 3:return y=a.sent(),[3,5];case 4:if(g=a.sent(),!(null===(b=null==g?void 0:g.message)||void 0===b?void 0:b.includes("Unexpected end of JSON input")))throw g;return[3,5];case 5:return[2,{ok:(null==v?void 0:v.statusCode)>=200&&(null==v?void 0:v.statusCode)<300,status:(null==v?void 0:v.statusCode)||200,statusText:(null==v?void 0:v.statusMessage)||"OK",json:function(){return Promise.resolve(y||{})},text:function(){return Promise.resolve("string"==typeof y?y:JSON.stringify(y||{}))},headers:u(null==v?void 0:v.header)}]}})})},_="".concat(g).concat(y,"/rdb/rest");return n?(0,c.generatePGClient)(e,{pgBaseUrl:_,fetch:b}):(0,c.generateMySQLClient)(e,{mysqlBaseUrl:_,fetch:b})}var h={name:"mysql",entity:{mysql:function(e){return l(this,e,!1)(e)}}},d={name:"rdb",entity:{rdb:function(e){return l(this,e,!0)(e)}}};try{cloudbase.registerComponent(h),cloudbase.registerComponent(d)}catch(e){}function f(e){try{e.registerComponent(h),e.registerComponent(d)}catch(e){console.warn(e)}}t.registerMySQL=f;try{window.registerMySQL=f}catch(e){}i(n(8630),t)},5413:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Auth=void 0;var c=n(4949),u=n(5257),l=n(2962),h=n(2631),d=a(n(9639)),f=n(8308);function p(e,t){var r;return o(this,void 0,void 0,function(){var s,a=this;return i(this,function(c){s=function(){return o(a,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,1,,6]),[2,n(5814)];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,Promise.resolve().then(n.t.bind(n,5814,23))];case 3:return[2,e.sent()];case 4:return e.sent(),[2];case 5:return[3,6];case 6:return[2]}})})};try{if(((null===(r=null==t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).IS_MP_BUILD)return[2];if(e)return[2,s()]}catch(t){if(e)return[2,s()]}return[2]})})}var v=function(){function e(e){var t=e.request,n=e.credentialsClient;if(!n){var o={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};n=new u.OAuth2Client(o)}if(!t){var i=n.request.bind(n),s=new l.Captcha(r({env:e.env,clientId:e.clientId,request:i,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=s.request.bind(s)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:n,storage:e.storage||u.defaultStorage,adapter:e.adapter}}return e.parseParamsToSearch=function(e){return Object.keys(e).forEach(function(t){e[t]||delete e[t]}),new d.default(e).toString()},e.prototype.getParamsByVersion=function(e,t){var n,r=(0,h.deepClone)(e),o=(null===(n={v2:c.ApiUrlsV2}[null==r?void 0:r.version])||void 0===n?void 0:n[t])||c.ApiUrls[t];return r&&delete r.version,{params:r,url:o}},e.prototype.signIn=function(e){return o(this,void 0,Promise,function(){var t,n,o,s;return i(this,function(i){switch(i.label){case 0:return t=e.version||"v1",(n=this.getParamsByVersion(e,"AUTH_SIGN_IN_URL")).params.query&&delete n.params.query,[4,this.getEncryptParams(n.params)];case 1:return o=i.sent(),[4,this.config.request(n.url,{method:"POST",body:o})];case 2:return s=i.sent(),[4,this.config.credentialsClient.setCredentials(r(r({},s),{version:t}))];case 3:return i.sent(),[2,Promise.resolve(s)]}})})},e.prototype.signInAnonymously=function(e,t){return void 0===e&&(e={}),void 0===t&&(t=!1),o(this,void 0,Promise,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:e,useWxCloud:t})];case 1:return n=r.sent(),[4,this.config.credentialsClient.setCredentials(n)];case 2:return r.sent(),[2,Promise.resolve(n)]}})})},e.prototype.signUp=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_SIGN_UP_URL,{method:"POST",body:e})];case 1:return t=n.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return n.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signOut=function(e){return o(this,void 0,Promise,function(){var t,n,r,o;return i(this,function(i){switch(i.label){case 0:if(t={},!e)return[3,6];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.config.request(c.ApiUrls.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})];case 2:return t=i.sent(),[3,4];case 3:return(n=i.sent()).error!==c.ErrorType.UNAUTHENTICATED&&console.log("sign_out_error",n),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return i.sent(),[2,t];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return r=i.sent(),[4,this.config.request(c.ApiUrls.AUTH_REVOKE_URL,{method:"POST",body:{token:r}})];case 8:return o=i.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return i.sent(),[2,Promise.resolve(o)]}})})},e.prototype.revokeAllDevices=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}})})},e.prototype.revokeDevice=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.config.request(c.ApiUrls.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}})})},e.prototype.getVerification=function(e,t){return o(this,void 0,Promise,function(){var n,r;return i(this,function(o){switch(o.label){case 0:return n=!1,"CUR_USER"!==e.target?[3,1]:(n=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:o.sent()&&(n=!0),o.label=3;case 3:return(r=(0,h.deepClone)(e)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(r.phone_number)&&(r.phone_number="+86 ".concat(r.phone_number)),[2,this.config.request(c.ApiUrls.VERIFICATION_URL,{method:"POST",body:r,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:n})]}})})},e.prototype.verify=function(e){return o(this,void 0,Promise,function(){var t,n;return i(this,function(o){switch(o.label){case 0:return t=this.getParamsByVersion(e,"VERIFY_URL"),[4,this.config.request(t.url,{method:"POST",body:t.params})];case 1:return n=o.sent(),"v2"!==(null==e?void 0:e.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(r(r({},n),{version:"v2"}))];case 2:o.sent(),o.label=3;case 3:return[2,n]}})})},e.prototype.genProviderRedirectUri=function(t){return o(this,void 0,Promise,function(){var n,r,o,a,u;return i(this,function(i){return n=t.provider_redirect_uri,r=t.other_params,o=void 0===r?{}:r,a=s(t,["provider_redirect_uri","other_params"]),n&&!a.redirect_uri&&(a.redirect_uri=n),u="".concat(c.ApiUrls.PROVIDER_URI_URL,"?").concat(e.parseParamsToSearch(a)),Object.keys(o).forEach(function(e){var t=o[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(u+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))}),[2,this.config.request(u,{method:"GET"})]})})},e.prototype.grantProviderToken=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,function(){return i(this,function(n){return[2,this.config.request(c.ApiUrls.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:t})]})})},e.prototype.patchProviderToken=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})]})})},e.prototype.signInWithProvider=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return n=this.getParamsByVersion(e,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(n.url,{method:"POST",body:n.params,useWxCloud:t})];case 1:return o=i.sent(),[4,this.config.credentialsClient.setCredentials(r(r({},o),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return i.sent(),[2,Promise.resolve(o)]}})})},e.prototype.toBindIdentity=function(e){var t,n;return o(this,void 0,void 0,function(){var r,o,s,a;return i(this,function(i){switch(i.label){case 0:return(o=e.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:o=i.sent(),i.label=2;case 2:r=o,i.label=3;case 3:return i.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:e.provider_token},r)];case 4:return i.sent(),s={data:{type:c.OAUTH_TYPE.BIND_IDENTITY,provider:e.provider},error:null},[3,6];case 5:return a=i.sent(),s={data:{type:c.OAUTH_TYPE.BIND_IDENTITY},error:new f.AuthError(a)},[3,6];case 6:return e.fireEvent&&(null===(n=null===(t=this.config.eventBus)||void 0===t?void 0:t.fire)||void 0===n||n.call(t,c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:s})),[2,s]}})})},e.prototype.getInitialSession=function(){return o(this,void 0,Promise,function(){var e,t,n,o,s,a,u,l,h,d,p,v,y,g,m;return i(this,function(i){switch(i.label){case 0:e={},i.label=1;case 1:if(i.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(t=new URLSearchParams(null===location||void 0===location?void 0:location.search),n=t.get("code"),o=t.get("state"),!n||!o)return[2,{data:null,error:null}];s=null;try{s=JSON.parse(sessionStorage.getItem(o)||"null")}catch(e){}return e={type:null==s?void 0:s.type},a=t.get("error"),u=t.get("error_description"),a||u?[2,{data:e,error:new f.AuthError({message:u||a||"Unknown error from OAuth provider"})}]:(l=(null==s?void 0:s.provider)||t.get("provider"))?(h=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:l,provider_redirect_uri:h,provider_code:n})]):[2,{data:e,error:new f.AuthError({message:"Provider is required for OAuth verification"})}];case 2:return d=i.sent().provider_token,p=void 0,v=null,y=void 0,s.type!==c.OAUTH_TYPE.BIND_IDENTITY?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return p=i.sent(),[4,this.toBindIdentity({provider:l,provider_token:d,credentials:p})];case 4:return y=i.sent(),[3,11];case 5:return s.type!==c.OAUTH_TYPE.SIGN_IN?[3,11]:(y=this.getParamsByVersion({provider:l},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(y.url,{method:"POST",body:{provider_token:d}})]);case 6:p=i.sent(),i.label=7;case 7:return i.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:p})];case 8:return v=i.sent(),[3,10];case 9:return g=i.sent(),console.error("get user info error",g),[3,10];case 10:y={data:r(r({},e),{session:p,user:v}),error:null},i.label=11;case 11:t.delete("code"),t.delete("state"),t.delete("provider"),this.restoreUrlState(void 0===(null==s?void 0:s.search)?"?".concat(t.toString()):s.search,(null==s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(o)}catch(e){}return[2,y];case 12:return m=i.sent(),[2,{data:e,error:new f.AuthError(m)}];case 13:return[2]}})})},e.prototype.signInCustom=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e})];case 1:return t=n.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return n.sent(),[2,Promise.resolve(t)]}})})},e.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.config.request(c.ApiUrls.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:e})];case 1:return t=n.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return n.sent(),[2,Promise.resolve(t)]}})})},e.prototype.bindWithProvider=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){return[2,this.config.request(c.ApiUrls.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?function(){return t}:void 0})]})})},e.prototype.getUserProfile=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.getUserInfo(e)]})})},e.prototype.getUserInfo=function(e){var t,n,r;return void 0===e&&(e={}),o(this,void 0,Promise,function(){var o,s,a,c,u;return i(this,function(i){switch(i.label){case 0:return o=this.getParamsByVersion(e,"USER_ME_URL"),(null===(t=o.params)||void 0===t?void 0:t.query)&&(s=new d.default(o.params.query),o.url+="?".concat(s.toString())),[4,this.config.request(o.url,{method:"GET",withCredentials:!0,getCredentials:e.credentials?function(){return e.credentials}:void 0})];case 1:if((a=i.sent()).sub&&(a.uid=a.sub),null===(n=a.providers)||void 0===n?void 0:n.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(c=null===(r=wx.getAccountInfoSync().miniProgram)||void 0===r?void 0:r.appId,(null==(u=a.providers.find(function(e){return e.id===c}))?void 0:u.provider_user_id)&&(a.open_id=u.provider_user_id))}catch(e){}return[2,a]}})})},e.prototype.getWedaUserInfo=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.config.request(c.ApiUrls.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,e.sent()]}})})},e.prototype.deleteMe=function(t){return o(this,void 0,Promise,function(){var n,r;return i(this,function(o){return n=this.getParamsByVersion(t,"USER_ME_URL"),r="".concat(n.url,"?").concat(e.parseParamsToSearch(n.params)),[2,this.config.request(r,{method:"DELETE",withCredentials:!0})]})})},e.prototype.hasLoginState=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}})})},e.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},e.prototype.getLoginState=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getCredentialsAsync()]})})},e.prototype.transByProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.grantToken=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){return t=this.getParamsByVersion(e,"AUTH_TOKEN_URL"),[2,this.config.request(t.url,{method:"POST",body:t.params})]})})},e.prototype.getProviders=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrls.PROVIDER_LIST,{method:"GET",withCredentials:!0})]})})},e.prototype.unbindProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})]})})},e.prototype.checkPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.editContact=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.setPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})]})})},e.prototype.updatePasswordByOld=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.sudo({password:e.old_password})];case 1:return t=n.sent(),[2,this.setPassword({sudo_token:t.sudo_token,new_password:e.new_password})]}})})},e.prototype.sudo=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.SUDO_URL),{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.sendVerificationCodeToCurrentUser=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return e.target="CUR_USER",[2,this.config.request(c.ApiUrls.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})]})})},e.prototype.changeBoundProvider=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request("".concat(c.ApiUrls.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})]})})},e.prototype.setUserProfile=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})]})})},e.prototype.updateUserBasicInfo=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.queryUserProfile=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){return t=new d.default(e),[2,this.config.request("".concat(c.ApiUrls.USER_QUERY_URL,"?").concat(t.toString()),{method:"GET",withCredentials:!0})]})})},e.prototype.setCustomSignFunc=function(e){this.getCustomSignTicketFn=e},e.prototype.signInWithCustomTicket=function(){return o(this,void 0,Promise,function(){var e,t;return i(this,function(n){switch(n.label){case 0:return(e=this.getCustomSignTicketFn)?[4,e()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return t=n.sent(),[2,this.signInCustom({provider_id:"custom",ticket:t})]}})})},e.prototype.resetPassword=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.AUTH_RESET_PASSWORD,{method:"POST",body:e})]})})},e.prototype.authorize=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.authorizeDevice=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})]})})},e.prototype.deviceAuthorize=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.AUTH_GET_DEVICE_CODE,{method:"POST",body:e})]})})},e.prototype.authorizeInfo=function(t){return o(this,void 0,Promise,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n="".concat(c.ApiUrls.AUTHORIZE_INFO_URL,"?").concat(e.parseParamsToSearch(t)),r=!0,o=!1,[4,this.hasLoginState()];case 1:return i.sent()&&(o=!0,r=!1),[2,this.config.request(n,{method:"GET",withBasicAuth:r,withCredentials:o})]}})})},e.prototype.checkUsername=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})]})})},e.prototype.checkIfUserExist=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){return t=new d.default(e),[2,this.config.request("".concat(c.ApiUrls.CHECK_IF_USER_EXIST,"?").concat(t.toString()),{method:"GET"})]})})},e.prototype.loginScope=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getScope()]})})},e.prototype.loginGroups=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.credentialsClient.getGroups()]})})},e.prototype.refreshTokenForce=function(e){return o(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return t=n.sent(),[4,this.config.credentialsClient.refreshToken(r(r({},t),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return[2,n.sent()]}})})},e.prototype.getCredentials=function(){return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.credentialsClient.getCredentials()]})})},e.prototype.getPublicKey=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrlsV2.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]})})},e.prototype.getEncryptParams=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,a;return i(this,function(i){switch(i.label){case 0:return t=e.isEncrypt,delete e.isEncrypt,n=(0,h.deepClone)(e),[4,p(t,this.config.adapter)];case 1:if(!(r=i.sent()))return[2,e];o="",s="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(a=i.sent(),o=a.public_key,s=a.public_key_thumbprint,!o||!s)throw a;return[3,5];case 4:throw i.sent();case 5:return[2,{params:r.getEncryptInfo({publicKey:o,payload:n}),public_key_thumbprint:s}]}})})},e.prototype.getProviderSubType=function(){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrls.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]})})},e.prototype.verifyCaptchaData=function(e){var t=e.token,n=e.key;return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrls.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:n},withCredentials:!1})]})})},e.prototype.createCaptchaData=function(e){var t=e.state,n=e.redirect_uri,r=void 0===n?void 0:n;return o(this,void 0,void 0,function(){return i(this,function(e){return[2,this.config.request(c.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:r},withCredentials:!1})]})})},e.prototype.getMiniProgramCode=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})]})})},e.prototype.getMiniProgramQrCodeStatus=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.config.request(c.ApiUrls.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})]})})},e.prototype.getUserBehaviorLog=function(e){return o(this,void 0,Promise,function(){var t,n;return i(this,function(r){return t={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},n="".concat(c.ApiUrls.GET_USER_BEHAVIOR_LOG,"?").concat(t[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):""),[2,this.config.request(n,{method:"GET",withCredentials:!0})]})})},e.prototype.modifyPassword=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,a;return i(this,function(i){switch(i.label){case 0:return t="",n="",[4,p(!0,this.config.adapter)];case 1:if(!(r=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,n=o.public_key_thumbprint,!t||!n)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?r.getEncryptInfo({publicKey:t,payload:e.password}):"",a=r.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(c.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:n}})]}})})},e.prototype.modifyPasswordWithoutLogin=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,a;return i(this,function(i){switch(i.label){case 0:return t="",n="",[4,p(!0,this.config.adapter)];case 1:if(!(r=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,n=o.public_key_thumbprint,!t||!n)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?r.getEncryptInfo({publicKey:t,payload:e.password}):"",a=r.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(c.ApiUrlsV2.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:s,new_password:a,public_key_thumbprint:n}})]}})})},e.prototype.restoreUrlState=function(e,t){if(void 0!==e)try{var n=new URL(window.location.href);n.search=e,n.hash=t||"",window.history.replaceState(null,"",n.toString()),window.location.replace(n.toString())}catch(e){}},e}();t.Auth=v},8308:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.isAuthError=t.AuthError=t.AuthErrorCategory=void 0;var i,s=n(4949);!function(e){e.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS",e.USER_NOT_FOUND="USER_NOT_FOUND",e.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",e.SERVICE_ERROR="SERVICE_ERROR",e.INVALID_PARAMS="INVALID_PARAMS",e.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",e.RATE_LIMITED="RATE_LIMITED",e.CAPTCHA_REQUIRED="CAPTCHA_REQUIRED",e.CAPTCHA_INVALID="CAPTCHA_INVALID",e.MFA_REQUIRED="MFA_REQUIRED",e.PRECONDITION_FAILED="PRECONDITION_FAILED",e.VERIFICATION_FAILED="VERIFICATION_FAILED",e.UNKNOWN="UNKNOWN"}(i=t.AuthErrorCategory||(t.AuthErrorCategory={}));var a="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",c="https://docs.cloudbase.net/api-reference/webv3/initialization";function u(e,t){var n=(null==t?void 0:t.method)||"signIn",r={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」",getVerification:"「短信验证码登录」或「邮箱验证码登录」",verify:"「短信验证码登录」或「邮箱验证码登录」",verifyOtp:"「短信验证码登录」或「邮箱验证码登录」",resetPasswordForEmail:"「邮箱验证码登录」",reauthenticate:"「短信验证码登录」或「邮箱验证码登录」"}[n]||"对应的登录方式";switch(e){case i.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(n,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(r,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(a,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(c);case i.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(n,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case i.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(a,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case i.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(a);case i.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。\n 常见服务端错误:smtp 未配置、短信服务未配置、wedaapis 未设置等。";case i.INVALID_PARAMS:if((null==t?void 0:t.errorCode)===s.AuthErrorCode.MISSING_REQUIRED_PARAM||(null==t?void 0:t.code)===s.ErrorType.MISSING_REQUIRED_PARAM){var o=["verifyOtp","signInWithOtp","signUp"].includes(n)?"\n 若在校验验证码阶段缺参:\n - 独立调用 auth.verifyOtp() 时 messageId 为必填,请补上 params.messageId。\n - 推荐改用发码接口返回的回调(SDK 会自动携带 messageId):\n const { data } = await auth.signInWithOtp({ phone })\n await data.verifyOtp({ token })\n // 或 auth.signUp({ phone }) 返回的 data.verifyOtp\n":"";return"[CloudBase Auth] 缺少必填参数\n\n"+" 调用 auth.".concat(n,"() 时缺少必填参数。\n")+" 这是客户端入参问题,不是控制台通道配置问题。\n\n 修复方式:\n"+" 1. 查看 error.message 中的参数路径,补上缺失字段。\n".concat(o,"\n 参考 API 文档确认各参数的格式和约束:").concat(c)}return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求:\n - 不能同时输入手机号和邮箱\n - 手机号格式需正确(如 +86 开头)\n - 必须提供手机号或邮箱\n\n"+" 参考 API 文档确认各参数的格式和约束:".concat(c);case i.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(n,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(a);case i.RATE_LIMITED:return"[CloudBase Auth] 发送频率受限\n\n 验证码发送过于频繁,已触发频率限制。\n\n 限制规则:\n - 手机号:每分钟最多 1 条,每天有上限\n - 邮箱:每分钟有上限,每天有上限(默认 50 条)\n\n 建议:\n 1. 检查 error.retryAfter 获取建议等待时间\n 2. 在 UI 中显示倒计时,防止用户重复点击\n 3. 如业务需要更高频率,请联系技术支持调整限额";case i.CAPTCHA_REQUIRED:return"[CloudBase Auth] 需要滑块验证码\n\n 当前操作触发了风控策略,需要完成滑块验证。\n\n 处理方式:\n 1. 调用滑块验证码 SDK 展示验证组件\n 2. 用户完成验证后,将 captcha_token 附带到请求中重新发送\n 3. 可通过 getVerification 的 options.withCaptcha 参数自动携带验证码";case i.CAPTCHA_INVALID:return"[CloudBase Auth] 滑块验证码校验失败\n\n 提交的验证码 token 校验未通过(可能已过期或 client_id 不匹配)。\n\n 处理方式:\n 1. 刷新滑块验证码,让用户重新验证\n 2. 确认 captcha 组件初始化的 client_id 与认证配置一致";case i.MFA_REQUIRED:return"[CloudBase Auth] 需要 MFA 验证\n\n 当前操作要求用户绑定手机号进行多因素认证 (MFA)。\n\n 处理方式:\n 1. 引导用户进入手机号绑定流程\n 2. 绑定完成后重新执行原操作\n 3. error 中可能包含 MFA 详情信息";case i.PRECONDITION_FAILED:return"[CloudBase Auth] 前置条件不满足\n\n 当前操作的前置条件不满足,常见原因:\n - 该手机号/邮箱已被其他账号绑定\n - 目标用户不存在或已存在(与 target 参数冲突)\n - 当前邮箱/手机号未注册用户\n\n 请根据 error.message 中的具体描述处理。";case i.VERIFICATION_FAILED:return'[CloudBase Auth] 验证码校验失败\n\n 验证码验证未通过,常见原因:\n - 验证码已过期(通常有效期为几分钟)\n - 验证码输入不正确\n - verification_id 无效或已被使用\n - 验证码不属于当前项目(project id does not match)\n\n 处理方式:\n 1. 提示用户"验证码已过期或不正确,请重新获取"\n 2. 调用 getVerification() 重新发送验证码\n 3. 确保 verification_id 与最新发送的验证码对应\n\n 注意:每次重新发送验证码后,之前的 verification_id 即失效。';default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(a,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(c)}}function l(e){return e&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[e]||""}var h=function(e){function t(t,n){var r=this,o=d(t);return(r=e.call(this,o?t.message:t.error_description||t.message)||this).__isAuthError=!0,r.name="AuthError",o?(r.status=t.status,r.code=t.code,r.errorCode=t.errorCode,r.requestId=t.requestId,r.category=t.category,r.retryAfter=t.retryAfter,r.helpMessage=u(r.category,{method:null==n?void 0:n.method,errorCode:r.errorCode,code:r.code}),r.loginMethodHint=l(null==n?void 0:n.method),r):(r.status=t.error,r.code=String(t.error||t.error_code||"unknown").toLowerCase(),r.errorCode="number"==typeof t.error_code?t.error_code:"string"==typeof t.error_code&&parseInt(t.error_code,10)||void 0,r.requestId=t.requestId,r.category=function(e,t,n){if(!e&&!t&&!n)return i.UNKNOWN;try{var r=(e||"").toLowerCase(),o="string"==typeof n?parseInt(n,10):n;return o===s.AuthErrorCode.MISSING_REQUIRED_PARAM||t===s.ErrorType.MISSING_REQUIRED_PARAM?i.INVALID_PARAMS:o===s.AuthErrorCode.CAPTCHA_REQUIRED||t===s.ErrorType.CAPTCHA_REQUIRED?i.CAPTCHA_REQUIRED:o===s.AuthErrorCode.CAPTCHA_INVALID||t===s.ErrorType.CAPTCHA_INVALID?i.CAPTCHA_INVALID:o===s.AuthErrorCode.MFA_PHONE_REQUIRED||t===s.ErrorType.MFA_PHONE_REQUIRED?i.MFA_REQUIRED:o===s.AuthErrorCode.LOGIN_TYPE_DISABLED||t===s.ErrorType.LOGIN_TYPE_DISABLED?i.PROVIDER_NOT_ENABLED:o===s.AuthErrorCode.RESOURCE_EXHAUSTED||t===s.ErrorType.RESOURCE_EXHAUSTED?i.RATE_LIMITED:o===s.AuthErrorCode.INTERNAL||o===s.AuthErrorCode.UNAVAILABLE||o===s.AuthErrorCode.UNIMPLEMENTED||o===s.AuthErrorCode.ABORTED?i.SERVICE_ERROR:o===s.AuthErrorCode.NOT_FOUND?i.USER_NOT_FOUND:o===s.AuthErrorCode.UNAUTHENTICATED?i.INVALID_CREDENTIALS:o===s.AuthErrorCode.INVALID_ARGUMENT&&(r.includes("验证码")||r.includes("verification")||r.includes("verification_code")||r.includes("verification_id")||r.includes("does not match")||r.includes("token expired")||r.includes("token error")||r.includes("过期"))?i.VERIFICATION_FAILED:t===s.ErrorType.PROVIDER_NOT_ENABLED||t===s.ErrorType.LOGIN_METHOD_DISABLED||r.includes("身份源")||r.includes("开启")||r.includes("identity provider")||r.includes("provider not enabled")||r.includes("login method")||r.includes("登录方式")||r.includes("not enabled")||r.includes("未开启")||r.includes("未启用")||r.includes("请联系开发者")||r.includes("anonymous login is not enabled")||r.includes("匿名登录未开启")?i.PROVIDER_NOT_ENABLED:t===s.ErrorType.FAILED_PRECONDITION||o===s.AuthErrorCode.FAILED_PRECONDITION&&!r.includes("请联系开发者")?r.includes("不存在")||r.includes("not found")||r.includes("未注册")?i.USER_NOT_FOUND:i.PRECONDITION_FAILED:t===s.ErrorType.INVALID_PASSWORD||t===s.ErrorType.INVALID_GRANT||t===s.ErrorType.INVALID_VERIFICATION_CODE||t===s.ErrorType.INVALID_USERNAME_OR_PASSWORD||t===s.ErrorType.INVALID_CREDENTIALS||t===s.ErrorType.WRONG_PASSWORD||t===s.ErrorType.UNAUTHENTICATED||t===s.ErrorType.INVALID_TWO_FACTOR||t===s.ErrorType.INVALID_TWO_FACTOR_RECOVERY||t===s.ErrorType.PASSWORD_NOT_SET||r.includes("密码不正确")||r.includes("password")||r.includes("invalid_password")||r.includes("凭据")||r.includes("credentials")||r.includes("验证码")||r.includes("verification")||r.includes("invalid_verification_code")||r.includes("invalid_username_or_password")||r.includes("username or password")||r.includes("用户名或密码")||r.includes("wrong password")||r.includes("incorrect password")?i.INVALID_CREDENTIALS:t===s.ErrorType.NOT_FOUND||t===s.ErrorType.USER_NOT_FOUND||r.includes("用户不存在")||r.includes("not found")||r.includes("user not found")||r.includes("no such user")||r.includes("user does not exist")?i.USER_NOT_FOUND:t===s.ErrorType.USER_BLOCKED||t===s.ErrorType.USER_PENDING||t===s.ErrorType.UNDER_REVIEW||t===s.ErrorType.INVALID_STATUS||r.includes("被封禁")||r.includes("blocked")||r.includes("pending")||r.includes("审核")||r.includes("review")||r.includes("locked")||r.includes("已锁定")?i.USER_STATUS_ABNORMAL:t===s.ErrorType.SERVER_ERROR||t===s.ErrorType.UNAVAILABLE||t===s.ErrorType.TEMPORARILY_UNAVAILABLE||t===s.ErrorType.INTERNAL||t===s.ErrorType.UNREACHABLE||t===s.ErrorType.DEADLINE_EXCEEDED||t===s.ErrorType.DATA_LOSS||t===s.ErrorType.ABORTED||r.includes("network")||r.includes("timeout")||r.includes("timed out")||r.includes("超时")||r.includes("smtp is not set")||r.includes("sms sender does not config")?i.SERVICE_ERROR:t===s.ErrorType.INVALID_ARGUMENT||t===s.ErrorType.INVALID_REQUEST||t===s.ErrorType.INVALID_SCOPE||t===s.ErrorType.INVALID_REQUEST_URI||t===s.ErrorType.INVALID_REQUEST_OBJECT||o===s.AuthErrorCode.INVALID_ARGUMENT?i.INVALID_PARAMS:t===s.ErrorType.PERMISSION_DENIED||t===s.ErrorType.ACCESS_DENIED||t===s.ErrorType.UNAUTHORIZED_CLIENT?i.PROVIDER_NOT_ENABLED:i.UNKNOWN}catch(e){return t}}(r.message,r.status,r.errorCode),r.helpMessage=u(r.category,{method:null==n?void 0:n.method,errorCode:r.errorCode,code:r.code}),r.loginMethodHint=l(null==n?void 0:n.method),r.category===i.RATE_LIMITED&&(r.retryAfter=t.retry_after||t.retryAfter||void 0),r)}return o(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,code:this.code,errorCode:this.errorCode,status:this.status,requestId:this.requestId,category:this.category,retryAfter:this.retryAfter}},t}(Error);function d(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}t.AuthError=h,t.isAuthError=d},4949:function(e,t){"use strict";var n,r,o,i,s,a;Object.defineProperty(t,"__esModule",{value:!0}),t.VerificationUsage=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.EVENTS=t.AUTH_STATE_CHANGED_TYPE=t.LOGIN_STATE_CHANGED_TYPE=t.AuthErrorCode=t.ErrorType=t.VerificationUsages=t.ApiUrlsV2=t.ApiUrls=t.AUTH_API_PREFIX=void 0,t.AUTH_API_PREFIX="/auth",(a=t.ApiUrls||(t.ApiUrls={})).AUTH_SIGN_UP_URL="/v1/signup",a.AUTH_TOKEN_URL="/v1/token",a.AUTH_REVOKE_URL="/v1/revoke",a.WEDA_USER_URL="/v1/plugin/weda/userinfo",a.AUTH_RESET_PASSWORD="/v1/reset",a.AUTH_GET_DEVICE_CODE="/v1/device/code",a.CHECK_USERNAME="/v1/checkUsername",a.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",a.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",a.AUTH_SIGN_IN_URL="/v1/signin",a.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",a.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",a.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",a.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",a.PROVIDER_TOKEN_URL="/v1/provider/token",a.PROVIDER_URI_URL="/v1/provider/uri",a.USER_ME_URL="/v1/user/me",a.AUTH_SIGNOUT_URL="/v1/user/signout",a.USER_QUERY_URL="/v1/user/query",a.USER_PRIFILE_URL="/v1/user/profile",a.USER_BASIC_EDIT_URL="/v1/user/basic/edit",a.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",a.PROVIDER_LIST="/v1/user/provider",a.PROVIDER_BIND_URL="/v1/user/provider/bind",a.PROVIDER_UNBIND_URL="/v1/user/provider",a.CHECK_PWD_URL="/v1/user/sudo",a.SUDO_URL="/v1/user/sudo",a.BIND_CONTACT_URL="/v1/user/contact",a.AUTH_SET_PASSWORD="/v1/user/password",a.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",a.AUTHORIZE_URL="/v1/user/authorize",a.AUTHORIZE_INFO_URL="/v1/user/authorize/info",a.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",a.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",a.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",a.VERIFICATION_URL="/v1/verification",a.VERIFY_URL="/v1/verification/verify",a.CAPTCHA_DATA_URL="/v1/captcha/data",a.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",a.GET_CAPTCHA_URL="/v1/captcha/init",a.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",a.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status",(s=t.ApiUrlsV2||(t.ApiUrlsV2={})).AUTH_SIGN_IN_URL="/v2/signin/username",s.AUTH_TOKEN_URL="/v2/token",s.USER_ME_URL="/v2/user/me",s.VERIFY_URL="/v2/signin/verificationcode",s.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",s.AUTH_PUBLIC_KEY="/v2/signin/publichkey",s.AUTH_RESET_PASSWORD="/v2/signin/password/update",(i=t.VerificationUsages||(t.VerificationUsages={})).REGISTER="REGISTER",i.SIGN_IN="SIGN_IN",i.PASSWORD_RESET="PASSWORD_RESET",i.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",i.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE",(o=t.ErrorType||(t.ErrorType={})).UNREACHABLE="unreachable",o.LOCAL="local",o.CANCELLED="cancelled",o.UNKNOWN="unknown",o.UNAUTHENTICATED="unauthenticated",o.RESOURCE_EXHAUSTED="resource_exhausted",o.FAILED_PRECONDITION="failed_precondition",o.INVALID_ARGUMENT="invalid_argument",o.DEADLINE_EXCEEDED="deadline_exceeded",o.NOT_FOUND="not_found",o.ALREADY_EXISTS="already_exists",o.PERMISSION_DENIED="permission_denied",o.ABORTED="aborted",o.OUT_OF_RANGE="out_of_range",o.UNIMPLEMENTED="unimplemented",o.INTERNAL="internal",o.UNAVAILABLE="unavailable",o.DATA_LOSS="data_loss",o.INVALID_PASSWORD="invalid_password",o.PASSWORD_NOT_SET="password_not_set",o.INVALID_STATUS="invalid_status",o.USER_PENDING="user_pending",o.USER_BLOCKED="user_blocked",o.INVALID_VERIFICATION_CODE="invalid_verification_code",o.TWO_FACTOR_REQUIRED="two_factor_required",o.INVALID_TWO_FACTOR="invalid_two_factor",o.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",o.UNDER_REVIEW="under_review",o.INVALID_REQUEST="invalid_request",o.UNAUTHORIZED_CLIENT="unauthorized_client",o.ACCESS_DENIED="access_denied",o.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",o.INVALID_SCOPE="invalid_scope",o.INVALID_GRANT="invalid_grant",o.SERVER_ERROR="server_error",o.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",o.INTERACTION_REQUIRED="interaction_required",o.LOGIN_REQUIRED="login_required",o.ACCOUNT_SELECTION_REQUIRED="account_selection_required",o.CONSENT_REQUIRED="consent_required",o.INVALID_REQUEST_URI="invalid_request_uri",o.INVALID_REQUEST_OBJECT="invalid_request_object",o.REQUEST_NOT_SUPPORTED="request_not_supported",o.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",o.REGISTRATION_NOT_SUPPORTED="registration_not_supported",o.CAPTCHA_REQUIRED="captcha_required",o.CAPTCHA_INVALID="captcha_invalid",o.PROVIDER_NOT_ENABLED="provider_not_enabled",o.LOGIN_METHOD_DISABLED="login_method_disabled",o.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",o.INVALID_CREDENTIALS="invalid_credentials",o.WRONG_PASSWORD="wrong_password",o.USER_NOT_FOUND="user_not_found",o.MFA_PHONE_REQUIRED="mfa_phone_required",o.LOGIN_TYPE_DISABLED="login_type_disabled",o.PROVIDER_ERROR="provider_error",o.MISSING_REQUIRED_PARAM="missing_required_param",(r=t.AuthErrorCode||(t.AuthErrorCode={}))[r.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",r[r.NOT_FOUND=5]="NOT_FOUND",r[r.PERMISSION_DENIED=7]="PERMISSION_DENIED",r[r.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",r[r.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",r[r.ABORTED=10]="ABORTED",r[r.UNIMPLEMENTED=12]="UNIMPLEMENTED",r[r.INTERNAL=13]="INTERNAL",r[r.UNAVAILABLE=14]="UNAVAILABLE",r[r.UNAUTHENTICATED=16]="UNAUTHENTICATED",r[r.MISSING_REQUIRED_PARAM=4e3]="MISSING_REQUIRED_PARAM",r[r.CAPTCHA_REQUIRED=4001]="CAPTCHA_REQUIRED",r[r.CAPTCHA_INVALID=4002]="CAPTCHA_INVALID",r[r.PROVIDER_ERROR=4019]="PROVIDER_ERROR",r[r.UNAUTHORIZED_CLIENT=4022]="UNAUTHORIZED_CLIENT",r[r.MFA_PHONE_REQUIRED=4042]="MFA_PHONE_REQUIRED",r[r.LOGIN_TYPE_DISABLED=4045]="LOGIN_TYPE_DISABLED",t.LOGIN_STATE_CHANGED_TYPE={SIGN_OUT:"sign_out",SIGN_IN:"sign_in",CREDENTIALS_ERROR:"credentials_error"},t.AUTH_STATE_CHANGED_TYPE={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},t.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},t.OAUTH_TYPE={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},t.DEFAULT_NODE_ACCESS_SCOPE="node-sdk-scope",(n=t.VerificationUsage||(t.VerificationUsage={})).EMAIL="email",n.RECOVERY="recovery",n.REAUTHENTICATION="reauthentication"},3538:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2084:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.openURIWithCallback=void 0;var s=n(9689),a=n(3616),c=function(e,t){var n;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];clearTimeout(n),n=setTimeout(function(){return e.apply(null,r)},t)}},u=new s.CloudbaseEventEmitter,l="resolveCaptchaData",h="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",d="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",f="background:#6c757d;cursor:not-allowed";t.openURIWithCallback=function(e,t){return o(void 0,void 0,Promise,function(){var n,s,p,v;return i(this,function(y){return n=(0,a.parseCaptcha)(e),s=n.captchaData,p=n.state,v=n.token,function(e){var t=e.oauthInstance,n=e.captchaState,s="captcha-image",a=function(){return o(void 0,void 0,void 0,function(){var e,o;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t.createCaptchaData({state:n.state})];case 1:return e=i.sent(),n=r(r({},n),{captchaData:e.data,token:e.token}),document.getElementById(s).src=e.data,[3,3];case 2:return o=i.sent(),console.error("刷新图形验证码失败",o),[3,3];case 3:return[2]}})})},p=function(e,t,n){var r=document.createElement(e);return t&&(r.style.cssText=t),n&&(r.textContent=n),r},v=p("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),y=p("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");y.appendChild(p("p","margin-bottom:15px","请输入你看到的字符:"));var g=p("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),m=p("img","width:100%;height:auto;border:1px solid #eee");m.id=s,m.src=n.captchaData,g.appendChild(m);var b=p("button",h,"刷新");b.onclick=c(function(){return o(void 0,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:b.textContent="加载中...",b.disabled=!0,b.style.cssText="".concat(h,";").concat(f),e.label=1;case 1:return e.trys.push([1,,3,4]),[4,a()];case 2:return e.sent(),[3,4];case 3:return b.textContent="刷新",b.disabled=!1,b.style.cssText=h,[7];case 4:return[2]}})})},500),g.appendChild(b),y.appendChild(g);var _=p("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");_.type="text",_.placeholder="输入字符",_.maxLength=4,y.appendChild(_);var E=p("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");y.appendChild(E);var w=function(e){E.textContent=e,E.style.display="block"},S=p("button",d,"确定");S.onclick=c(function(){return o(void 0,void 0,void 0,function(){var e,r,o,s;return i(this,function(i){switch(i.label){case 0:if(!(e=_.value.trim()))return w("请输入字符"),[2];E.style.display="none",S.textContent="验证中...",S.disabled=!0,S.style.cssText="".concat(d,";").concat(f),i.label=1;case 1:return i.trys.push([1,3,5,6]),[4,t.verifyCaptchaData({token:n.token,key:e})];case 2:return r=i.sent(),u.fire(l,r),console.log("图形验证码校验成功"),document.body.removeChild(v),document.body.removeChild(y),[3,6];case 3:return o=i.sent(),console.error("图形验证码校验失败",o),s=o.error_description||"图形验证码校验失败",w(s),_.value="",_.focus(),[4,a()];case 4:return i.sent(),[3,6];case 5:return S.textContent="确定",S.disabled=!1,S.style.cssText=d,[7];case 6:return[2]}})})},500),y.appendChild(S),document.body.appendChild(v),document.body.appendChild(y)}({oauthInstance:t,captchaState:{captchaData:s,state:p,token:v}}),[2,new Promise(function(e){console.log("等待图形验证码校验结果..."),u.on(l,function(t){e(null==t?void 0:t.data)})})]})})}},2962:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Captcha=void 0;var i=n(4949),s=n(5257),a=n(7425),c=n(2084),u=function(){function e(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=s.defaultStorage),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}return e.prototype.isMatch=function(){var e,t,n;return(null===(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.adapter)||void 0===t?void 0:t.isMatch)||void 0===n?void 0:n.call(t))||(0,a.isMp)()},e.prototype.request=function(e,t){return r(this,void 0,Promise,function(){var n,r,s,a;return o(this,function(o){switch(o.label){case 0:return t||(t={}),t.method||(t.method="GET"),n="".concat(t.method,":").concat(e),r=e,t.withCaptcha?[4,this.appendCaptchaTokenToURL(e,n,!1)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return o.trys.push([2,4,,7]),[4,this.config.request(r,t)];case 3:return s=o.sent(),[3,7];case 4:return(a=o.sent()).error!==i.ErrorType.CAPTCHA_REQUIRED&&a.error!==i.ErrorType.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(e,n,a.error===i.ErrorType.CAPTCHA_INVALID)];case 5:return e=o.sent(),[2,this.config.request(e,t)];case 6:return[2,Promise.reject(a)];case 7:return[2,s]}})})},e.prototype.getDefaultOpenURIWithCallback=function(){var e=this;return function(t){return(0,c.openURIWithCallback)(t,e.config.oauthInstance)}},e.prototype.getCaptchaToken=function(e,t){return r(this,void 0,Promise,function(){var n,r,s,a;return o(this,function(o){switch(o.label){case 0:return e?[3,2]:[4,this.findCaptchaToken()];case 1:if(n=o.sent())return[2,n];o.label=2;case 2:return[4,this.config.request(i.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1})];case 3:return r=o.sent(),s="".concat(r.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(r.token)),[4,this.config.openURIWithCallback(s)];case 4:return a=o.sent(),this.saveCaptchaToken(a),[2,a.captcha_token]}})})},e.prototype.appendCaptchaTokenToURL=function(e,t,n){return r(this,void 0,Promise,function(){var r;return o(this,function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(n,t)];case 1:return r=o.sent(),e.indexOf("?")>0?e+="&captcha_token=".concat(r):e+="?captcha_token=".concat(r),[2,e]}})})},e.prototype.saveCaptchaToken=function(e){return r(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10)),t=JSON.stringify(e),[4,this.config.storage.setItem(this.tokenSectionName,t)];case 1:return n.sent(),[2]}})})},e.prototype.findCaptchaToken=function(){return r(this,void 0,Promise,function(){var e,t;return o(this,function(n){switch(n.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),t.expires_at<new Date?[2,null]:[2,t.captcha_token];case 3:return n.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),[2,null];case 5:return[2,null]}})})},e}();t.Captcha=u},6722:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseOAuth=t.VerificationUsage=t.ErrorType=t.AuthErrorCode=t.AUTH_STATE_CHANGED_TYPE=t.EVENTS=t.LOGIN_STATE_CHANGED_TYPE=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.AUTH_API_PREFIX=t.weAppJwtDecodeAll=t.authModels=t.isAuthError=t.AuthErrorCategory=t.AuthError=t.Auth=void 0;var a=n(5257),c=n(5413),u=n(4949),l=n(5413);Object.defineProperty(t,"Auth",{enumerable:!0,get:function(){return l.Auth}});var h=n(8308);Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return h.AuthError}}),Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return h.AuthErrorCategory}}),Object.defineProperty(t,"isAuthError",{enumerable:!0,get:function(){return h.isAuthError}}),t.authModels=s(n(3538));var d=n(2344);Object.defineProperty(t,"weAppJwtDecodeAll",{enumerable:!0,get:function(){return d.weAppJwtDecodeAll}});var f=n(4949);Object.defineProperty(t,"AUTH_API_PREFIX",{enumerable:!0,get:function(){return f.AUTH_API_PREFIX}}),Object.defineProperty(t,"OAUTH_TYPE",{enumerable:!0,get:function(){return f.OAUTH_TYPE}}),Object.defineProperty(t,"DEFAULT_NODE_ACCESS_SCOPE",{enumerable:!0,get:function(){return f.DEFAULT_NODE_ACCESS_SCOPE}}),Object.defineProperty(t,"LOGIN_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.LOGIN_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"EVENTS",{enumerable:!0,get:function(){return f.EVENTS}}),Object.defineProperty(t,"AUTH_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.AUTH_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"AuthErrorCode",{enumerable:!0,get:function(){return f.AuthErrorCode}}),Object.defineProperty(t,"ErrorType",{enumerable:!0,get:function(){return f.ErrorType}}),Object.defineProperty(t,"VerificationUsage",{enumerable:!0,get:function(){return f.VerificationUsage}});var p=function(){function e(e){var t=e.apiOrigin,n=e.getApiOrigin,o=e.apiPath,i=void 0===o?u.AUTH_API_PREFIX:o,s=e.clientId,l=e.env,h=e.storage,d=e.request,f=e.baseRequest,p=e.anonymousSignInFunc,v=e.wxCloud,y=e.adapter,g=e.onCredentialsError,m=e.headers,b=e.i18n,_=e.useWxCloud,E=e.eventBus,w=e.detectSessionInUrl,S=e.debug;if(this.detectSessionInUrl=null!=w&&w,this.oauth2client=new a.OAuth2Client({apiOrigin:t,getApiOrigin:n,apiPath:i,clientId:s,env:l,storage:h,baseRequest:f||d,anonymousSignInFunc:p,wxCloud:v,onCredentialsError:g,headers:m||{},i18n:b,useWxCloud:_,eventBus:E,debug:S}),this.authApi=new c.Auth(r(r({credentialsClient:this.oauth2client},e),{request:d?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:y})),w)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var I=new URL(window.location.href),O=I.searchParams.get("code"),A=I.searchParams.get("state"),T=JSON.parse(sessionStorage.getItem(A)||"null");O&&A&&(null==T?void 0:T.hash)&&(I.hash=T.hash,window.history.replaceState(null,"",I.toString()),window.location.replace(I.toString()))}catch(e){}}return e.prototype.initializeSession=function(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},e}();t.CloudbaseOAuth=p},6877:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Syntax=t.ErrorType=void 0;var r,o=n(4949);Object.defineProperty(t,"ErrorType",{enumerable:!0,get:function(){return o.ErrorType}}),(r=t.Syntax||(t.Syntax={})).CLIENT_ID="client_id",r.CLIENT_SECRET="client_secret",r.RESPONSE_TYPE="response_type",r.SCOPE="scope",r.STATE="state",r.REDIRECT_URI="redirect_uri",r.ERROR="error",r.ERROR_DESCRIPTION="error_description",r.ERROR_URI="error_uri",r.GRANT_TYPE="grant_type",r.CODE="code",r.ACCESS_TOKEN="access_token",r.TOKEN_TYPE="token_type",r.EXPIRES_IN="expires_in",r.USERNAME="username",r.PASSWORD="password",r.REFRESH_TOKEN="refresh_token"},5257:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Client=t.defaultStorage=t.generateRequestId=t.toResponseError=t.defaultRequest=void 0;var a=n(6877),c=n(4949),u=n(873),l=n(2631),h=n(8547),d=n(2344),f=n(7425),p=n(2877),v="x-request-id",y="x-device-id",g="device_id";function m(){return(0,u.uuidv4)()}t.defaultRequest=function(e,t){return o(this,void 0,Promise,function(){var n,r,o,s,c;return i(this,function(i){switch(i.label){case 0:n=null,r=null,i.label=1;case 1:return i.trys.push([1,4,,5]),(o=Object.assign({},t)).method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)),[4,fetch(e,o)];case 2:return[4,i.sent().json()];case 3:return(null==(s=i.sent())?void 0:s.error)?(r=s).error_uri=new URL(e).pathname:n=s,[3,5];case 4:return c=i.sent(),r={error:a.ErrorType.UNREACHABLE,error_description:c.message,error_uri:new URL(e).pathname},[3,5];case 5:if(r)throw r;return[2,n]}})})},t.toResponseError=function(e,t){var n,r=t||{};if(e instanceof Error)n={error:r.error||a.ErrorType.LOCAL,error_description:r.error_description||e.message,error_uri:r.error_uri,details:r.details||e.stack};else{var o=e||{};n={error:r.error||o.error||a.ErrorType.LOCAL,error_description:r.error_description||o.error_description,error_uri:r.error_uri||o.error_uri,details:r.details||o.details}}return n},t.generateRequestId=m;var b=function(){function e(e){this._env=(null==e?void 0:e.env)||""}return e.prototype.getItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,window.localStorage.getItem("".concat(e).concat(this._env))]})})},e.prototype.removeItem=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return window.localStorage.removeItem("".concat(e).concat(this._env)),[2]})})},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,function(){return i(this,function(n){return window.localStorage.setItem("".concat(e).concat(this._env),t),[2]})})},e.prototype.getItemSync=function(e){return window.localStorage.getItem("".concat(e).concat(this._env))},e.prototype.removeItemSync=function(e){window.localStorage.removeItem("".concat(e).concat(this._env))},e.prototype.setItemSync=function(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)},e}();t.defaultStorage=new b;var _=function(){function e(e){var t=this;this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new h.SinglePromise({clientId:this.clientId,getScope:function(){var e;return(null===(e=t.accessKeyCredentials)||void 0===e?void 0:e.access_token)?"".concat(t.clientId,"_").concat(t.accessKeyCredentials.access_token):t.clientId}}),this.credentials=e.credentials||null,this.onCredentialsChange=e.onCredentialsChange}return e.prototype.syncMemoryCredentials=function(e){this.credentials=e},e.prototype.getMemoryCredentials=function(){return this.credentials},e.prototype.getStorageCredentialsSync=function(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e},e.prototype.setCredentials=function(e,t){var n;return o(this,void 0,Promise,function(){var r,o;return i(this,function(i){switch(i.label){case 0:return r=!(!this.credentials||!this.credentials.access_token),(null==e?void 0:e.expires_in)?((null==e?void 0:e.expires_at)||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),this.storage?(o=JSON.stringify(e),[4,this.storage.setItem(this.tokenSectionName,o)]):[3,2]):[3,3];case 1:i.sent(),i.label=2;case 2:return this.credentials=e,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:i.sent(),i.label=5;case 5:this.credentials=null,i.label=6;case 6:return this.onCredentialsChange&&this.onCredentialsChange(e||null,{isInit:null!==(n=null==t?void 0:t.isInit)&&void 0!==n&&n,hadCredentials:r}),[2]}})})},e.prototype.setAccessKeyCredentials=function(e){this.accessKeyCredentials=e,e.scope===c.DEFAULT_NODE_ACCESS_SCOPE&&(this.credentials=e)},e.prototype.getCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return[2,this.singlePromise.run("getCredentials",function(){return o(e,void 0,void 0,function(){var e,t;return i(this,function(n){switch(n.label){case 0:return[4,this.getStorageCredentials()];case 1:return e=n.sent(),t=e.credentials,e.isAccessKeyCredentials?[2,t]:(this.credentials=t,[2,this.credentials])}})})})]})})},e.prototype.getStorageCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return[2,this.singlePromise.run("_getStorageCredentials",function(){return o(e,void 0,void 0,function(){var e,t,n;return i(this,function(r){switch(r.label){case 0:return e=null,t=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(n=r.sent()))return[3,6];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(e=JSON.parse(n))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),[3,5];case 3:return r.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),e=null,[3,5];case 5:return[3,7];case 6:e=this.accessKeyCredentials||null,t=!0,r.label=7;case 7:return[2,{credentials:e,isAccessKeyCredentials:t}]}})})})]})})},e}();t.OAuth2Client=function(){function e(n){var r,o=this;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,this._initSessionEmitted=!1,n.clientSecret||(n.clientSecret=""),!n.clientId&&n.env&&(n.clientId=n.env),this.apiOrigin=n.apiOrigin,this.getApiOriginFunc=n.getApiOrigin,this.apiPath=n.apiPath||c.AUTH_API_PREFIX,this.clientId=n.clientId,this.i18n=n.i18n,this.eventBus=n.eventBus,this.singlePromise=new h.SinglePromise({clientId:this.clientId}),this.retry=this.formatRetry(n.retry,e.defaultRetry),n.baseRequest?this.baseRequest=n.baseRequest:this.baseRequest=t.defaultRequest,this.tokenInURL=n.tokenInURL,this.headers=n.headers,this.storage=n.storage||t.defaultStorage,this.localCredentials=new _({tokenSectionName:"credentials_".concat(n.clientId),storage:this.storage,clientId:n.clientId,onCredentialsChange:this._handleCredentialsChange.bind(this)}),this.clientSecret=n.clientSecret,n.clientId&&(this.basicAuth="Basic ".concat((0,d.weBtoa)("".concat(n.clientId,":").concat(this.clientSecret)))),this.wxCloud=n.wxCloud;try{(0,f.isMp)()&&(this.useWxCloud=n.useWxCloud,void 0===this.wxCloud&&n.env&&(wx.cloud.init({env:n.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=n.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=n.anonymousSignInFunc,this.onCredentialsError=n.onCredentialsError,this.getInitialSession=n.getInitialSession,this.onInitialSessionObtained=n.onInitialSessionObtained,this.logDebugMessages=null!==(r=n.debug)&&void 0!==r&&r,p.langEvent.bus.on(p.langEvent.LANG_CHANGE_EVENT,function(e){var t;o.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||o.i18n}),this._initBroadcastChannel(),this._initVisibilityListener()}return e.prototype.setGetInitialSession=function(e){this.getInitialSession=e},e.prototype.setOnInitialSessionObtained=function(e){this.onInitialSessionObtained=e},e.prototype.initialize=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){switch(n.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,n.sent()];case 2:return void 0===e?[3,4]:(this.initializePromise=e,[4,this.initializePromise]);case 4:return this.initializePromise=o(t,void 0,void 0,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return[4,this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this._initialize()];case 1:return[2,e.sent()]}})})})];case 1:return[2,t.sent()]}})}),[4,this.initializePromise]}})})},e.prototype.setCredentials=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,function(){return o(t,void 0,void 0,function(){return i(this,function(t){return[2,this.localCredentials.setCredentials(e)]})})})]}})})},Object.defineProperty(e.prototype,"initSessionEmitted",{get:function(){return this._initSessionEmitted},enumerable:!1,configurable:!0}),e.prototype.destroy=function(){try{this.broadcastChannel&&"function"==typeof this.broadcastChannel.close&&this.broadcastChannel.close()}catch(e){this._debug("#destroy","close BroadcastChannel error",e)}finally{this.broadcastChannel=null}try{var e=this.visibilityEventHandler;this.visibilityEventHandler=void 0,e&&"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof window.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(e){this._debug("#destroy","remove visibility listener error",e)}},e.prototype.setAccessKeyCredentials=function(e){return this.localCredentials.setAccessKeyCredentials(e)},e.prototype.getAccessToken=function(){return o(this,void 0,Promise,function(){var e,t;return i(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[4,this.getCredentials()];case 2:return(null==(e=n.sent())?void 0:e.scope)===c.DEFAULT_NODE_ACCESS_SCOPE||(null==e?void 0:e.access_token)?[2,Promise.resolve(e.access_token)]:(t={error:a.ErrorType.UNAUTHENTICATED},[2,Promise.reject(t)])}})})},e.prototype.request=function(t,n){var s,c;return o(this,void 0,Promise,function(){var o,u,l,h,d,f,p,g,b,_;return i(this,function(i){switch(i.label){case 0:return n||(n={}),o=this.formatRetry(n.retry,this.retry),n.headers=r(r({},n.headers),((_={})[null===(s=this.i18n)||void 0===s?void 0:s.LANG_HEADER_KEY]=null===(c=this.i18n)||void 0===c?void 0:c.lang,_)),this.headers&&(n.headers=r(r({},this.headers),n.headers)),n.headers[v]||(n.headers[v]=m()),n.headers[y]?[3,2]:[4,this.getDeviceId()];case 1:u=i.sent(),n.headers[y]=u,i.label=2;case 2:return(null==n?void 0:n.withBasicAuth)&&this.basicAuth&&(n.headers.Authorization=this.basicAuth),(null==n?void 0:n.withCredentials)?n.getCredentials?[4,n.getCredentials()]:[3,4]:[3,7];case 3:return h=i.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:h=i.sent(),i.label=6;case 6:return(l=h)&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(l.access_token)):n.headers.Authorization="".concat(l.token_type," ").concat(l.access_token)),[3,8];case 7:this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(this.clientId)),i.label=8;case 8:t.startsWith("/")&&(d=this.getApiOriginFunc?this.getApiOriginFunc():this.apiOrigin,t="".concat(d).concat(this.apiPath).concat(t)),f=null,p=o+1,g=0,i.label=9;case 9:if(!(g<p))return[3,21];i.label=10;case 10:return i.trys.push([10,15,,18]),n.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(t,n)]:[3,12];case 11:return f=i.sent(),[3,14];case 12:return[4,this.baseRequest(t,n)];case 13:f=i.sent(),i.label=14;case 14:if(null==f?void 0:f.code)throw{error:f.code,error_description:f.message,error_uri:new URL(t).pathname};return[3,21];case 15:b=i.sent();try{b.requestId=b.requestId||n.headers[v]||""}catch(e){}return n.withCredentials&&b&&b.error===a.ErrorType.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return i.sent(),[2,Promise.reject(b)];case 17:return g!==o&&b&&"unreachable"===b.error?[3,18]:[2,Promise.reject(b)];case 18:return[4,this.sleep(e.retryInterval)];case 19:i.sent(),i.label=20;case 20:return g++,[3,9];case 21:return[2,f]}})})},e.prototype.wxCloudCallFunction=function(e,t){var n;return o(this,void 0,Promise,function(){var o,s,c,u,h;return i(this,function(i){switch(i.label){case 0:o=null,s=null,i.label=1;case 1:i.trys.push([1,7,,8]),c="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return c=i.sent(),[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:r({origin:"https://servicewechat.com","User-Agent":c},t.headers),body:t.body}})];case 6:return u=i.sent().result,(null===(n=null==u?void 0:u.body)||void 0===n?void 0:n.error_code)?(s=null==u?void 0:u.body).error_uri=(0,l.getPathName)(e):o=null==u?void 0:u.body,[3,8];case 7:return h=i.sent(),s={error:a.ErrorType.UNREACHABLE,error_description:h.message,error_uri:(0,l.getPathName)(e)},[3,8];case 8:if(s)throw s;return[2,o]}})})},e.prototype.getCredentials=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return[4,this.initializePromise];case 1:return t.sent(),[2,this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){return i(this,function(e){return[2,this._getCredentials()]})})})]}})})},e.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},e.prototype.getCredentialsAsync=function(){return this.getCredentials()},e.prototype.getScope=function(){var e;return o(this,void 0,Promise,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=r.sent())?[2,t.scope]:(n="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:n}),[2,this.unAuthenticatedError(n)])}})})},e.prototype.getGroups=function(){var e;return o(this,void 0,Promise,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=r.sent())?[2,t.groups]:(n="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:n}),[2,this.unAuthenticatedError(n)])}})})},e.prototype.refreshToken=function(e,t){return o(this,void 0,Promise,function(){var n=this;return i(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,function(){return o(n,void 0,void 0,function(){return i(this,function(n){return[2,this._refreshToken(e,t)]})})})]}})})},e.prototype._refreshToken=function(e,t){return o(this,void 0,Promise,function(){var n=this;return i(this,function(r){return[2,this.singlePromise.run("_refreshToken",function(){return o(n,void 0,void 0,function(){var n,r,o,s,u,l;return i(this,function(i){switch(i.label){case 0:if((null==e?void 0:e.scope)===c.DEFAULT_NODE_ACCESS_SCOPE)return[2,e];if(!e||!e.refresh_token)return o="no refresh token found in credentials",null===(s=this.onCredentialsError)||void 0===s||s.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];i.label=1;case 1:return i.trys.push([1,4,,7]),[4,this.refreshTokenFunc(e.refresh_token,e)];case 2:return n=i.sent(),[4,this.localCredentials.setCredentials(n)];case 3:return i.sent(),[2,n];case 4:if(r=i.sent(),null==t?void 0:t.throwError)throw r;return r.error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return i.sent(),o=r.error_description,null===(u=this.onCredentialsError)||void 0===u||u.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];case 6:return null===(l=this.onCredentialsError)||void 0===l||l.call(this,{msg:r.error_description}),[2,Promise.reject(r)];case 7:return[2]}})})})]})})},e.prototype.anonymousLogin=function(e){return o(this,void 0,void 0,function(){var t=this;return i(this,function(n){return[2,this.singlePromise.run("_anonymousLogin",function(){return o(t,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(e)]:[3,4];case 1:return t=r.sent(),(n=t)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:n=r.sent(),r.label=3;case 3:return e=n,[3,6];case 4:return[4,this.anonymousSignIn(e)];case 5:e=r.sent(),r.label=6;case 6:return[2,e]}})})})]})})},e.prototype.checkRetry=function(t){var n=null;if(("number"!=typeof t||t<e.minRetry||t>e.maxRetry)&&(n={error:a.ErrorType.UNREACHABLE,error_description:"wrong options param: retry"}),n)throw n;return t},e.prototype.formatRetry=function(e,t){return void 0===e?t:this.checkRetry(e)},e.prototype.sleep=function(e){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,new Promise(function(t){setTimeout(function(){t()},e)})]})})},e.prototype.anonymousSignIn=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){return[2,this.singlePromise.run("_anonymous",function(){return o(t,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:if(!e||"anonymous"!==e.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.request(c.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return t=r.sent(),[4,this.localCredentials.setCredentials(t)];case 3:return r.sent(),[2,t];case 4:return(n=r.sent()).error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}})})})]})})},e.prototype.defaultRefreshTokenFunc=function(e,t){var n;return o(this,void 0,Promise,function(){var o,s,a;return i(this,function(i){switch(i.label){case 0:return void 0===e||""===e?(o="refresh token not found",null===(n=this.onCredentialsError)||void 0===n||n.call(this,{msg:o}),[2,this.unAuthenticatedError(o)]):(s=c.ApiUrls.AUTH_TOKEN_URL,"v2"===(null==t?void 0:t.version)&&(s=c.ApiUrlsV2.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:e}})]);case 1:return a=i.sent(),[2,r(r({},a),{version:(null==t?void 0:t.version)||"v1"})]}})})},e.prototype.getDeviceId=function(){return o(this,void 0,Promise,function(){var e;return i(this,function(t){switch(t.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(g)];case 1:return"string"==typeof(e=t.sent())&&e.length>=16&&e.length<=48?[3,3]:(e=(0,u.uuidv4)(),[4,this.storage.setItem(g,e)]);case 2:t.sent(),t.label=3;case 3:return this.deviceID=e,[2,e]}})})},e.prototype.unAuthenticatedError=function(e){var t={error:a.ErrorType.UNAUTHENTICATED,error_description:e};return Promise.reject(t)},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logDebugMessages&&console.log.apply(console,s(["[OAuth2Client]"],e,!1))},e.prototype._initialize=function(){return o(this,void 0,Promise,function(){var e,t,n,r,o,s;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),i.label=1;case 1:return i.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return s=i.sent(),e=s.data,t=s.error,(null==e?void 0:e.session)?(this._debug("#_initialize()","session obtained from getInitialSession",e.session),this._initSessionEmitted=!0,[4,this.localCredentials.setCredentials(null==e?void 0:e.session,{isInit:!0})]):[3,4];case 3:i.sent(),i.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),i.label=5;case 5:return i.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(e,t)];case 6:return i.sent(),[3,8];case 7:return n=i.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",n),[3,8];case 8:return t?(this._debug("#_initialize()","error from getInitialSession",t),[2,{error:t}]):[2,{error:null}];case 9:return r=i.sent(),this._debug("#_initialize()","exception during getInitialSession",r),[2,{error:r instanceof Error?r:new Error(String(r))}];case 10:return[3,13];case 11:return o=i.sent(),this._debug("#_initialize()","unexpected error",o),[2,{error:o instanceof Error?o:new Error(String(o))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}})})},e.prototype._acquireLock=function(e,t){return o(this,void 0,Promise,function(){var n,r,a,c,u=this;return i(this,function(l){switch(l.label){case 0:this._debug("#_acquireLock","begin",e),l.label=1;case 1:if(l.trys.push([1,,10,11]),this.lockAcquired)return n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=o(u,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,n];case 1:return e.sent(),[4,t()];case 2:return[2,e.sent()]}})}),this.pendingInLock.push(o(u,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,r];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[2,r];this._debug("#_acquireLock","acquiring lock for client",this.clientId),l.label=2;case 2:return l.trys.push([2,,8,9]),this.lockAcquired=!0,a=t(),this.pendingInLock.push(o(u,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})),[4,a];case 3:l.sent(),l.label=4;case 4:return this.pendingInLock.length?(c=s([],this.pendingInLock,!0),[4,Promise.all(c)]):[3,6];case 5:return l.sent(),this.pendingInLock.splice(0,c.length),[3,4];case 6:return[4,a];case 7:return[2,l.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}})})},e.prototype._getCredentials=function(){var e,t,n;return o(this,void 0,Promise,function(){var r,o,s;return i(this,function(i){switch(i.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(r=i.sent())?void 0:r.scope)===c.DEFAULT_NODE_ACCESS_SCOPE)return[2,r];if(!r)return s="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];if(!function(e){var t=!0;return(null==e?void 0:e.expires_at)&&(null==e?void 0:e.access_token)&&(t=e.expires_at<new Date),t}(r))return[3,12];if(!r.refresh_token)return[3,9];i.label=2;case 2:return i.trys.push([2,4,,8]),[4,this._refreshToken(r)];case 3:return r=i.sent(),[3,8];case 4:return o=i.sent(),"anonymous"!==r.scope?[3,6]:[4,this.anonymousLogin(r)];case 5:return r=i.sent(),[3,7];case 6:return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:o.error_description}),[2,Promise.reject(o)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==r.scope?[3,11]:[4,this.anonymousLogin(r)];case 10:return r=i.sent(),[3,12];case 11:return s="no refresh token found in credentials",null===(n=this.onCredentialsError)||void 0===n||n.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];case 12:return[2,r]}})})},e.prototype._isUserCredentials=function(e){return!!(null==e?void 0:e.access_token)&&"accessKey"!==e.scope&&e.scope!==c.DEFAULT_NODE_ACCESS_SCOPE},e.prototype._fireCredentialsEvents=function(e,t,n){var r,o,i,s,a,u;this._isUserCredentials(e)?t?null===(i=this.eventBus)||void 0===i||i.fire(c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION}):n?null===(s=this.eventBus)||void 0===s||s.fire(c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED}):(null===(a=this.eventBus)||void 0===a||a.fire(c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),null===(u=this.eventBus)||void 0===u||u.fire(c.EVENTS.LOGIN_STATE_CHANGED,{eventType:c.LOGIN_STATE_CHANGED_TYPE.SIGN_IN})):n&&(null===(r=this.eventBus)||void 0===r||r.fire(c.EVENTS.AUTH_STATE_CHANGED,{event:c.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),null===(o=this.eventBus)||void 0===o||o.fire(c.EVENTS.LOGIN_STATE_CHANGED,{eventType:c.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}))},e.prototype._handleCredentialsChange=function(e,t){this._fireCredentialsEvents(e,t.isInit,t.hadCredentials),this._broadcastCredentials(e,t)},e.prototype._initBroadcastChannel=function(){var e=this;if(void 0===this.broadcastChannel)try{"undefined"!=typeof BroadcastChannel&&(this.broadcastChannelName="credentials_".concat(this.clientId),this.broadcastChannel=new BroadcastChannel(this.broadcastChannelName),this.broadcastChannel.addEventListener("message",function(t){e._handleBroadcastMessage(t.data)}),this._debug("#_initBroadcastChannel","channel created: ".concat(this.broadcastChannelName)))}catch(e){this.broadcastChannel=null,this._debug("#_initBroadcastChannel","BroadcastChannel not available, skip",e)}},e.prototype._broadcastCredentials=function(e,t){if(this.broadcastChannel)try{this.broadcastChannel.postMessage({type:"credentials_changed",credentials:e,context:t})}catch(e){this._debug("#_broadcastCredentials","postMessage error",e)}},e.prototype._handleBroadcastMessage=function(e){var t,n;try{if(!e||"credentials_changed"!==e.type)return;var o=e.context,i=e.credentials;if((null==i?void 0:i.expires_at)&&"string"==typeof i.expires_at&&(i=r(r({},i),{expires_at:new Date(i.expires_at)})),(null==i?void 0:i.access_token)===(null===(t=this.localCredentials.getMemoryCredentials())||void 0===t?void 0:t.access_token))return;var s=!!(null===(n=this.localCredentials.getMemoryCredentials())||void 0===n?void 0:n.access_token);this.localCredentials.syncMemoryCredentials(i),this._fireCredentialsEvents(i,o.isInit,s)}catch(e){this._debug("#_handleBroadcastMessage","error",e)}},e.prototype._initVisibilityListener=function(){var e=this;try{if("undefined"==typeof window||"undefined"==typeof document||"function"!=typeof window.addEventListener)return;this.visibilityEventHandler=function(){return o(e,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._onVisibilityChanged()];case 1:return t.sent(),[3,3];case 2:return e=t.sent(),this._debug("#visibilityChangedCallback","error",e),[3,3];case 3:return[2]}})})},window.addEventListener("visibilitychange",this.visibilityEventHandler)}catch(e){this._debug("#_initVisibilityListener",e)}},e.prototype._onVisibilityChanged=function(){return o(this,void 0,Promise,function(){var e=this;return i(this,function(t){return"visible"!==document.visibilityState||this._acquireLock(-1,function(){return o(e,void 0,void 0,function(){var e,t,n,r,o,s;return i(this,function(i){switch(i.label){case 0:if("visible"!==document.visibilityState)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),e=this.localCredentials.getMemoryCredentials(),[4,this.localCredentials.getCredentials()];case 2:return t=i.sent(),n=null==e?void 0:e.access_token,r=null==t?void 0:t.access_token,n===r?[2]:(o=!!n,this._fireCredentialsEvents(t,!1,o),[3,4]);case 3:return s=i.sent(),this._debug("#_onVisibilityChanged","reload credentials error",s),[3,4];case 4:return[2]}})})}),[2]})})},e.defaultRetry=2,e.minRetry=0,e.maxRetry=5,e.retryInterval=1e3,e}()},2344:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.weAppJwtDecodeAll=t.weappJwtDecode=t.base64_url_decode=t.weAtob=t.weBtoa=void 0;var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function o(e){var n=e.replace(/-/g,"+").replace(/_/g,"/");switch(n.length%4){case 0:break;case 2:n+="==";break;case 3:n+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent((0,t.weAtob)(e).replace(/(.)/g,function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)}))}(n)}catch(e){return(0,t.weAtob)(n)}}t.weBtoa=function(e){for(var t,r,o,i,s="",a=0,c=(e=String(e)).length%3;a<e.length;){if((r=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=n.charAt((t=r<<16|o<<8|i)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t)}return c?s.slice(0,c-3)+"===".substring(c):s},t.weAtob=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!r.test(e))throw new TypeError("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 o,i,s="",a=0;a<e.length;)t=n.indexOf(e.charAt(a++))<<18|n.indexOf(e.charAt(a++))<<12|(o=n.indexOf(e.charAt(a++)))<<6|(i=n.indexOf(e.charAt(a++))),s+=64===o?String.fromCharCode(t>>16&255):64===i?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return s},t.base64_url_decode=o,t.weappJwtDecode=function(e,t){if("string"!=typeof e)throw new Error("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(o(e.split(".")[n]))}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}},t.weAppJwtDecodeAll=function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{var t=e.split(".").map(function(e,t){return 2===t?e:JSON.parse(o(e))});return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}}},5814:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getEncryptInfo=void 0;var o=r(n(1012)),i=n(2631);t.getEncryptInfo=function(e){var t=void 0===e?{}:e,n=t.publicKey,r=void 0===n?"":n,s=t.payload,a=void 0===s?{}:s;if(!r)return"";try{var c=(0,i.deepClone)(a),u=new o.default;return u.setPublicKey(r),u.encryptLong("object"==typeof c?JSON.stringify(c):c)}catch(e){console.error("encrypt error:",e)}return""}},8547:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SinglePromise=void 0;var o=new Map,i=function(){function e(e){this.clientId=(null==e?void 0:e.clientId)||"",this.getScope=null==e?void 0:e.getScope,o=o||new Map}return e.prototype.run=function(e,t){return n(this,void 0,Promise,function(){var i,s,a=this;return r(this,function(c){return i=this.getScope?this.getScope():this.clientId,e="".concat(i,"_").concat(e),(s=o.get(e))||(s=new Promise(function(i,s){n(a,void 0,void 0,function(){var n,a,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return r.sent(),n=t(),a=i,[4,n];case 2:return a.apply(void 0,[r.sent()]),[3,5];case 3:return c=r.sent(),s(c),[3,5];case 4:return o.delete(e),[7];case 5:return[2]}})})}),o.set(e,s)),[2,s]})})},e.prototype.runIdlePromise=function(){return Promise.resolve()},e}();t.SinglePromise=i},2631:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getPathName=t.deepClone=void 0,t.deepClone=function(e){var n=function(n){for(var r in e)e.hasOwnProperty(r)&&(n[r]=(0,t.deepClone)(e[r]));return n},r=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return e.slice();switch(r){case"Object":return n(Object.create(Object.getPrototypeOf(e)));case"Array":return n([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},t.getPathName=function(e){var t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""}},7425:function(e,t){"use strict";function n(){if("undefined"==typeof globalThis)return!1;var e=globalThis.wx;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.isInMpWebView=t.isMp=void 0,t.isMp=n;var r=!1;function o(){r=r||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{n()||(r=r||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?o():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",o,!1))}catch(e){}t.isInMpWebView=function(){return r}},9639:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}return e.prototype.parse=function(e){var t=this;e.split("&").forEach(function(e){var n=e.split("=").map(decodeURIComponent),r=n[0],o=n[1];t.append(r,o)})},e.prototype.append=function(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]},e.prototype.get=function(e){return this.params[e]?this.params[e][0]:null},e.prototype.getAll=function(e){return this.params[e]||[]},e.prototype.delete=function(e){delete this.params[e]},e.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this.params,e)},e.prototype.set=function(e,t){this.params[e]=[t]},e.prototype.toString=function(){var e=[],t=function(t){Object.prototype.hasOwnProperty.call(n.params,t)&&n.params[t].forEach(function(n){e.push("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(n)))})},n=this;for(var r in this.params)t(r);return e.join("&")},e}();t.default=n},873:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=void 0,t.uuidv4=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}},317:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},c=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.REALTIME_CHANNEL_STATES=t.REALTIME_SUBSCRIBE_STATES=t.REALTIME_LISTEN_TYPES=t.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=t.postgresChangesFilter=t.RealtimePostgresFilterBuilder=void 0;var l,h,d,f=n(5633),p=u(n(4666)),v=s(n(8206)),y=n(8206),g=n(240),m=u(n(4663)),b=n(8352),_=n(8352);Object.defineProperty(t,"RealtimePostgresFilterBuilder",{enumerable:!0,get:function(){return _.RealtimePostgresFilterBuilder}}),Object.defineProperty(t,"postgresChangesFilter",{enumerable:!0,get:function(){return _.postgresChangesFilter}}),(d=t.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT||(t.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT={})).ALL="*",d.INSERT="INSERT",d.UPDATE="UPDATE",d.DELETE="DELETE",function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"}(l=t.REALTIME_LISTEN_TYPES||(t.REALTIME_LISTEN_TYPES={})),function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"}(h=t.REALTIME_SUBSCRIBE_STATES||(t.REALTIME_SUBSCRIBE_STATES={})),t.REALTIME_CHANNEL_STATES=f.CHANNEL_STATES;var E=function(){function e(e,t,n){void 0===t&&(t={config:{}});var o,i,s=this;if(this.topic=e,this.params=t,this.socket=n,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=r({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config),this.channelAdapter=new m.default(this.socket.socketAdapter,e,this.params),this.presence=new p.default(this),this._onClose(function(){s.socket._remove(s)}),this._updateFilterTransform(),this.private=this.params.config.private||!1,!this.private&&(null===(i=null===(o=this.params.config)||void 0===o?void 0:o.broadcast)||void 0===i?void 0:i.replay))throw new Error("tried to use replay on public channel '".concat(this.topic,"'. It must be a private channel."))}return Object.defineProperty(e.prototype,"state",{get:function(){return this.channelAdapter.state},set:function(e){this.channelAdapter.state=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"joinedOnce",{get:function(){return this.channelAdapter.joinedOnce},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timeout",{get:function(){return this.socket.timeout},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"broadcastEndpointURL",{get:function(){return(0,y.httpEndpointURL)(this.socket.socketAdapter.endPointURL())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"joinPush",{get:function(){return this.channelAdapter.joinPush},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rejoinTimer",{get:function(){return this.channelAdapter.rejoinTimer},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e,t){var n,o,i,s;if(void 0===t&&(t=this.timeout),this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){var a=this.params.config,c=a.broadcast,u=a.presence,h=a.private,d=a.postgres_changes_options,p=null!==(o=null===(n=this.bindings.postgres_changes)||void 0===n?void 0:n.map(function(e){return e.filter}))&&void 0!==o?o:[],v=!!this.bindings[l.PRESENCE]&&this.bindings[l.PRESENCE].length>0||!0===(null===(i=this.params.config.presence)||void 0===i?void 0:i.enabled),y=r({broadcast:c,presence:r(r({},u),{enabled:v}),postgres_changes:p,private:h},d?{postgres_changes_options:d}:{});this._subscribeCallback=e,this._subscribeTimeout=t,this._bindSubscribeLifecycle(),this.updateJoinPayload({config:y}),this._updateFilterMessage();var g=(null==d?void 0:d.wait)&&p.length>0?Math.max(t,(null!==(s=d.timeout)&&void 0!==s?s:f.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT)+f.POSTGRES_CHANGES_WAIT_ERROR_GRACE):t;this._subscribeJoinTimeout=g,this.channelAdapter.subscribe(g),this._bindJoinPushReceivers()}return this},e.prototype._warmupOn=function(e){var t=this,n=new m.default(e,this.topic,this.params);return n.updateJoinPayload(this.channelAdapter.joinPush.payload()),new Promise(function(e,r){var o,i;n.subscribe(null!==(i=null!==(o=t._subscribeJoinTimeout)&&void 0!==o?o:t._subscribeTimeout)&&void 0!==i?i:t.timeout).receive("ok",function(o){var i=o.postgres_changes;void 0===i||t._postgresBindingsAlign(i)?e({adapter:n,postgres_changes:i}):r(new Error("mismatch between server and client bindings for postgres changes"))}).receive("error",function(e){var t=Object.values(e).join(", ")||"error";r(new Error(t,{cause:e}))}).receive("timeout",function(){r(new Error("standby channel join timed out"))})})},e.prototype._adopt=function(e){var t=this,n=this.channelAdapter;n.detachLifecycleHooks(),n.teardown(),this.channelAdapter=e.adapter;for(var r=0,o=Object.keys(this.bindings);r<o.length;r++)for(var i=o[r],s=0,a=this.bindings[i];s<a.length;s++){var c=a[s];c.ref=this.channelAdapter.on(c.type,c.callback)}this._updateFilterMessage(),this._updateFilterTransform(),void 0!==e.postgres_changes&&this._applyPostgresBindingIds(e.postgres_changes),this._onClose(function(){t.socket._remove(t)}),this._bindSubscribeLifecycle(),this._bindJoinPushReceivers({skipImmediate:!0}),this.presence=new p.default(this)},e.prototype._bindSubscribeLifecycle=function(){if(this._subscribeCallback){var e=this._subscribeCallback;this._onError(function(t){e(h.CHANNEL_ERROR,(0,g.normalizeChannelError)(t))}),this._onClose(function(){return e(h.CLOSED)})}},e.prototype._bindJoinPushReceivers=function(e){var t,n=this,r=function(e){var t=e.postgres_changes;return a(n,void 0,void 0,function(){var e;return c(this,function(n){return this.socket._isManualToken()||this.socket.setAuth(),void 0===t?(null===(e=this._subscribeCallback)||void 0===e||e.call(this,h.SUBSCRIBED),[2]):(this._updatePostgresBindings(t,this._subscribeCallback),[2])})})},o=function(e){var t;n.state=f.CHANNEL_STATES.errored;var r=Object.values(e).join(", ")||"error";null===(t=n._subscribeCallback)||void 0===t||t.call(n,h.CHANNEL_ERROR,new Error(r,{cause:e}))},i=function(){var e;null===(e=n._subscribeCallback)||void 0===e||e.call(n,h.TIMED_OUT)},s=this.channelAdapter.joinPush;if((null==e?void 0:e.skipImmediate)&&"ok"===(null===(t=s.receivedResp)||void 0===t?void 0:t.status))return s.recHooks.push({status:"ok",callback:r}),s.recHooks.push({status:"error",callback:o}),void s.recHooks.push({status:"timeout",callback:i});this.channelAdapter.joinPush.receive("ok",r),this.channelAdapter.joinPush.receive("error",o),this.channelAdapter.joinPush.receive("timeout",i)},e.prototype._postgresBindingsAlign=function(t){for(var n,r=this.bindings.postgres_changes,o=null!==(n=null==r?void 0:r.length)&&void 0!==n?n:0,i=0;i<o;i++){var s=r[i].filter,a=s.event,c=s.schema,u=s.table,l=s.filter,h=t&&t[i];if(!(h&&h.event===a&&e.isFilterValueEqual(h.schema,c)&&e.isFilterValueEqual(h.table,u)&&e.isFilterValueEqual(h.filter,l)))return!1}return!0},e.prototype._applyPostgresBindingIds=function(e){for(var t,n=this.bindings.postgres_changes,o=null!==(t=null==n?void 0:n.length)&&void 0!==t?t:0,i=[],s=0;s<o;s++){var a=n[s],c=e&&e[s];i.push(r(r({},a),{id:null==c?void 0:c.id}))}this.bindings.postgres_changes=i},e.prototype._updatePostgresBindings=function(e,t){if(!this._postgresBindingsAlign(e))return this.unsubscribe(),this.state=f.CHANNEL_STATES.errored,void(null==t||t(h.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes")));this._applyPostgresBindingIds(e),this.state!=f.CHANNEL_STATES.errored&&t&&t(h.SUBSCRIBED)},e.prototype.presenceState=function(){return this.presence.state},e.prototype.track=function(e,t){return void 0===t&&(t={}),a(this,void 0,Promise,function(){return c(this,function(n){switch(n.label){case 0:return[4,this.send({type:"presence",event:"track",payload:e},t)];case 1:return[2,n.sent()]}})})},e.prototype.untrack=function(e){return void 0===e&&(e={}),a(this,void 0,Promise,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.send({type:"presence",event:"untrack"},e)];case 1:return[2,t.sent()]}})})},e.prototype.on=function(e,t,n){var r=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),o=e===l.PRESENCE||e===l.POSTGRES_CHANGES;if(r&&o)throw this.socket.log("channel","cannot add `".concat(e,"` callbacks for ").concat(this.topic," after `subscribe()`.")),new Error("cannot add `".concat(e,"` callbacks for ").concat(this.topic," after `subscribe()`."));return this._on(e,t,n)},e.prototype.httpSend=function(e,t,n){var r;return void 0===n&&(n={}),a(this,void 0,Promise,function(){var o,i,s,a,u,l,h;return c(this,function(c){switch(c.label){case 0:return null==t?[2,Promise.reject(new Error("Payload is required for httpSend()"))]:[4,this.socket.setAuth()];case 1:return c.sent(),o=t instanceof ArrayBuffer||ArrayBuffer.isView(t),i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":o?"application/octet-stream":"application/json"},this.socket.accessTokenValue&&(i.Authorization="Bearer ".concat(this.socket.accessTokenValue)),s=(0,y.joinBroadcastEventUrl)(this.broadcastEndpointURL,this.subTopic,e,this.private?{private:"true"}:void 0),a={method:"POST",headers:i,body:o?t:JSON.stringify(t)},[4,this._fetchWithTimeout(s,a,null!==(r=n.timeout)&&void 0!==r?r:this.timeout)];case 2:if(202===(u=c.sent()).status)return[2,{success:!0}];if(404===u.status)return[2,Promise.reject(new Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. See https://github.com/TencentCloudBase/cloudbase-js-sdk/blob/master/packages/realtime-js/migrations/httpsend-server-version.md"))];l=u.statusText,c.label=3;case 3:return c.trys.push([3,5,,6]),[4,u.json()];case 4:return h=c.sent(),l=h.error||h.message||l,[3,6];case 5:return c.sent(),[3,6];case 6:return[2,Promise.reject(new Error(l))]}})})},e.prototype.send=function(e,t){var n,r;return void 0===t&&(t={}),a(this,void 0,Promise,function(){var o,i,s,a,u,l,h,d=this;return c(this,function(c){switch(c.label){case 0:return this.channelAdapter.canPush()||"broadcast"!==e.type?[3,7]:(o="Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.",this.socket.hasLogger()?this.socket.log("channel",o):console.warn(o),i=e.event,s=e.payload,[4,this.socket.setAuth()]);case 1:c.sent(),a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},this.socket.accessTokenValue&&(a.Authorization="Bearer ".concat(this.socket.accessTokenValue)),u={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:s,private:this.private}]})},c.label=2;case 2:return c.trys.push([2,5,,6]),[4,this._fetchWithTimeout(this.broadcastEndpointURL,u,null!==(n=t.timeout)&&void 0!==n?n:this.timeout)];case 3:return l=c.sent(),[4,null===(r=l.body)||void 0===r?void 0:r.cancel()];case 4:return c.sent(),[2,l.ok?"ok":"error"];case 5:return(h=c.sent())instanceof Error&&"AbortError"===h.name?[2,"timed out"]:[2,"error"];case 6:return[3,8];case 7:return[2,new Promise(function(n){var r,o,i,s=d.channelAdapter.push(e.type,e,t.timeout||d.timeout);"broadcast"!==e.type||(null===(i=null===(o=null===(r=d.params)||void 0===r?void 0:r.config)||void 0===o?void 0:o.broadcast)||void 0===i?void 0:i.ack)||n("ok"),s.receive("ok",function(){return n("ok")}),s.receive("error",function(){return n("error")}),s.receive("timeout",function(){return n("timed out")})})];case 8:return[2]}})})},e.prototype.updateJoinPayload=function(e){this.channelAdapter.updateJoinPayload(e)},e.prototype.unsubscribe=function(e){return void 0===e&&(e=this.timeout),a(this,void 0,void 0,function(){var t=this;return c(this,function(n){return[2,new Promise(function(n){t.channelAdapter.unsubscribe(e).receive("ok",function(){return n("ok")}).receive("timeout",function(){return n("timed out")}).receive("error",function(){return n("error")})})]})})},e.prototype.teardown=function(){this.channelAdapter.teardown()},e.prototype._fetchWithTimeout=function(e,t,n){return a(this,void 0,void 0,function(){var o,i,s,a;return c(this,function(c){switch(c.label){case 0:if(o=function(){var e=new Error("The operation was aborted");return e.name="AbortError",e},"undefined"!=typeof AbortController)return[3,4];c.label=1;case 1:return c.trys.push([1,,3,4]),[4,Promise.race([this.socket.fetch(e,t),new Promise(function(e,t){i=setTimeout(function(){return t(o())},n)})])];case 2:return[2,c.sent()];case 3:return i&&clearTimeout(i),[7];case 4:s=new AbortController,a=setTimeout(function(){return s.abort()},n),c.label=5;case 5:return c.trys.push([5,,7,8]),[4,this.socket.fetch(e,r(r({},t),{signal:s.signal}))];case 6:return[2,c.sent()];case 7:return clearTimeout(a),[7];case 8:return[2]}})})},e.prototype._on=function(t,n,o){var i,s=t.toLocaleLowerCase(),a=null==n?void 0:n.filter;if((a instanceof b.RealtimePostgresFilterBuilder||"object"==typeof a&&null!==a&&"function"==typeof a.build)&&(n=r(r({},n),{filter:a.build()})),s===l.POSTGRES_CHANGES&&(null===(i=this.bindings[s])||void 0===i?void 0:i.find(function(t){return e.isSamePostgresFilter(t.filter,n)})))return this.socket.log("error","duplicate `postgres_changes` binding for ".concat(this.topic," ignored"),n),this;var c=this.channelAdapter.on(t,o),u={type:s,filter:n,callback:o,ref:c};return this.bindings[s]?this.bindings[s].push(u):this.bindings[s]=[u],this._updateFilterMessage(),this},e.prototype._onClose=function(e){this.channelAdapter.onClose(e)},e.prototype._onError=function(e){this.channelAdapter.onError(e)},e.prototype._updateFilterMessage=function(){var e=this;this.channelAdapter.updateFilterBindings(function(t,n,r){var o,i,s,a,c,u,l,h=t.event.toLocaleLowerCase();if(e._notThisChannelEvent(h,r))return!1;var d=null===(o=e.bindings[h])||void 0===o?void 0:o.find(function(e){return e.ref===t.ref});if(!d)return!0;if(["broadcast","presence","postgres_changes"].includes(h)){if("id"in d){var f=d.id,p=null===(i=d.filter)||void 0===i?void 0:i.event;return f&&(null===(s=n.ids)||void 0===s?void 0:s.includes(f))&&("*"===p||(null==p?void 0:p.toLocaleLowerCase())===(null===(a=n.data)||void 0===a?void 0:a.type.toLocaleLowerCase()))}return"*"===(p=null===(u=null===(c=null==d?void 0:d.filter)||void 0===c?void 0:c.event)||void 0===u?void 0:u.toLocaleLowerCase())||p===(null===(l=null==n?void 0:n.event)||void 0===l?void 0:l.toLocaleLowerCase())}return d.type.toLocaleLowerCase()===h})},e.prototype._notThisChannelEvent=function(e,t){var n=f.CHANNEL_EVENTS.close,r=f.CHANNEL_EVENTS.error,o=f.CHANNEL_EVENTS.leave,i=f.CHANNEL_EVENTS.join;return t&&[n,r,o,i].includes(e)&&t!==this.joinPush.ref},e.prototype._updateFilterTransform=function(){var e=this;this.channelAdapter.updatePayloadTransform(function(t,n,o){if("object"==typeof n&&"ids"in n){var i=n.data,s=i.schema,a=i.table,c=i.commit_timestamp,u=i.type,l=i.errors;return r(r({},{schema:s,table:a,commit_timestamp:c,eventType:u,new:{},old:{},errors:l}),e._getPayloadRecords(i))}return n})},e.prototype.copyBindings=function(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(var t in e.bindings)for(var n=0,r=e.bindings[t];n<r.length;n++){var o=r[n];this._on(o.type,o.filter,o.callback)}},e.isFilterValueEqual=function(e,t){return(null!=e?e:void 0)===(null!=t?t:void 0)},e.isSamePostgresFilter=function(t,n){var r,o,i,s,a=null!==(o=null===(r=null==t?void 0:t.select)||void 0===r?void 0:r.join())&&void 0!==o?o:void 0,c=null!==(s=null===(i=null==n?void 0:n.select)||void 0===i?void 0:i.join())&&void 0!==s?s:void 0;return(null==t?void 0:t.event)===(null==n?void 0:n.event)&&e.isFilterValueEqual(null==t?void 0:t.schema,null==n?void 0:n.schema)&&e.isFilterValueEqual(null==t?void 0:t.table,null==n?void 0:n.table)&&e.isFilterValueEqual(null==t?void 0:t.filter,null==n?void 0:n.filter)&&a===c},e.prototype._getPayloadRecords=function(e){var t={new:{},old:{}};return"INSERT"!==e.type&&"UPDATE"!==e.type||(t.new=v.convertChangeData(e.columns,e.record)),"UPDATE"!==e.type&&"DELETE"!==e.type||(t.old=v.convertChangeData(e.columns,e.old_record)),t},e}();t.default=E},539:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=s(n(1606)),c=n(5633),u=s(n(7135)),l=n(8206),h=s(n(317)),d=s(n(1563)),f=[1e3,2e3,5e3,1e4];var p=function(){function e(e,t){var n;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new u.default,this._manuallySetToken=!1,this._authPromise=null,this._authGeneration=0,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._endPoint="",this._socketOptions={},this._openingActive=!1,this._handlersAdapter=null,this._standbyAdapter=null,this._rotating=!1,this._cutoverStarted=!1,this._refreshTimer=null,this._rotateRetryTimer=null,this.connectionMaxAgeMs=0,this.connectionRefreshJitterMs=c.DEFAULT_CONNECTION_REFRESH_JITTER_MS,this._resolveFetch=function(e){return e?function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.apply(void 0,t)}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if("undefined"==typeof fetch)throw new Error("httpSend() requires a fetch implementation. Pass options.fetch, or use app.realtime() after registering a platform adapter that provides reqClass.");return fetch.apply(void 0,e)}},!(null===(n=null==t?void 0:t.params)||void 0===n?void 0:n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey;var r=this._initializeOptions(t);this._endPoint=e,this._socketOptions=r,this.socketAdapter=this._createSocketAdapter(),this.httpEndpoint=(0,l.httpEndpointURL)(e),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}return Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.socketAdapter.endPoint},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timeout",{get:function(){return this.socketAdapter.timeout},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){return this.socketAdapter.transport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatCallback",{get:function(){return this.socketAdapter.heartbeatCallback},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatIntervalMs",{get:function(){return this.socketAdapter.heartbeatIntervalMs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatTimer",{get:function(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingHeartbeatRef",{get:function(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reconnectTimer",{get:function(){return this.socketAdapter.reconnectTimer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vsn",{get:function(){return this.socketAdapter.vsn},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"encode",{get:function(){return this.socketAdapter.encode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"decode",{get:function(){return this.socketAdapter.decode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reconnectAfterMs",{get:function(){return this.socketAdapter.reconnectAfterMs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sendBuffer",{get:function(){return this.socketAdapter.sendBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stateChangeCallbacks",{get:function(){return this.socketAdapter.stateChangeCallbacks},enumerable:!1,configurable:!0}),e.prototype.connect=function(){var e=this;if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected()||this._openingActive)){if(this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._beforeTransportConnect)return this._openingActive=!0,void this._openActiveSocket().catch(function(t){e.log("error","failed to open socket",t)});this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(e){var t=e.message;throw new Error("WebSocket not available: ".concat(t))}this._handleNodeJsRaceCondition()}},e.prototype.endpointURL=function(){return this.socketAdapter.endPointURL()},e.prototype.disconnect=function(e,t){return o(this,void 0,void 0,function(){var n,r,o=this;return i(this,function(i){switch(i.label){case 0:return this._cancelPendingDisconnect(),this._cancelConnectionRefresh(),this._cancelRotateRetry(),this._rotating=!1,this._cutoverStarted=!1,n=this._standbyAdapter,this._standbyAdapter=null,this.isDisconnecting()?n?[4,n.disconnect(function(){},1e3,"connection refresh abort")]:[3,2]:[3,3];case 1:i.sent(),i.label=2;case 2:return[2,"ok"];case 3:return[4,this.socketAdapter.disconnect(function(){clearInterval(o._workerHeartbeatTimer),o._terminateWorker()},e,t)];case 4:return r=i.sent(),n?[4,n.disconnect(function(){},1e3,"connection refresh abort")]:[3,6];case 5:i.sent(),i.label=6;case 6:return[2,r]}})})},e.prototype.getChannels=function(){return this.channels},e.prototype.removeChannel=function(e){return o(this,void 0,Promise,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,e.unsubscribe()];case 1:return"ok"===(t=n.sent())&&e.teardown(),[2,t]}})})},e.prototype.removeAllChannels=function(){return o(this,void 0,Promise,function(){var e,t,n=this;return i(this,function(r){switch(r.label){case 0:return e=this.channels.map(function(e){return o(n,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,e.unsubscribe()];case 1:return t=n.sent(),e.teardown(),[2,t]}})})}),[4,Promise.all(e)];case 1:return t=r.sent(),[4,this.disconnect()];case 2:return r.sent(),[2,t]}})})},e.prototype.log=function(e,t,n){this.socketAdapter.log(e,t,n)},e.prototype.hasLogger=function(){return this.socketAdapter.hasLogger()},e.prototype.connectionState=function(){return this.socketAdapter.connectionState()||c.CONNECTION_STATE.closed},e.prototype.isConnected=function(){return this.socketAdapter.isConnected()},e.prototype.isConnecting=function(){return this.socketAdapter.isConnecting()},e.prototype.isDisconnecting=function(){return this.socketAdapter.isDisconnecting()},e.prototype.channel=function(e,t){void 0===t&&(t={config:{}});var n="realtime:".concat(e),r=this.getChannels().find(function(e){return e.topic===n});if(r)return r;var o=new h.default("realtime:".concat(e),t,this);return this._cancelPendingDisconnect(),this.channels.push(o),o},e.prototype.push=function(e){this.socketAdapter.push(e)},e.prototype.setAuth=function(e){return void 0===e&&(e=null),o(this,void 0,Promise,function(){var t,n;return i(this,function(r){switch(r.label){case 0:t=++this._authGeneration,n=this._performAuth(e,t),t===this._authGeneration&&(this._authPromise=n),r.label=1;case 1:return r.trys.push([1,,3,4]),[4,n];case 2:return r.sent(),[3,4];case 3:return this._authPromise===n&&(this._authPromise=null),[7];case 4:return[2]}})})},e.prototype._isManualToken=function(){return this._manuallySetToken},e.prototype.sendHeartbeat=function(){return o(this,void 0,void 0,function(){return i(this,function(e){return this.socketAdapter.sendHeartbeat(),[2]})})},e.prototype.onHeartbeat=function(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)},e.prototype._makeRef=function(){return this.socketAdapter.makeRef()},e.prototype._remove=function(e){this.channels=this.channels.filter(function(t){return t.topic!==e.topic}),0===this.channels.length&&(this.log("transport","no channels remaining, scheduling disconnect"),this._cancelConnectionRefresh(),this._cancelRotateRetry(),this._abortRotate(),this._schedulePendingDisconnect())},e.prototype._schedulePendingDisconnect=function(){var e=this;if(this._cancelPendingDisconnect(),0===this._disconnectOnEmptyChannelsAfterMs)return this.log("transport","disconnecting immediately - no channels"),void this.disconnect();this._pendingDisconnectTimer=setTimeout(function(){e._pendingDisconnectTimer=null,0===e.channels.length&&(e.log("transport","deferred disconnect fired - no channels, disconnecting"),e.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport","deferred disconnect scheduled in ".concat(this._disconnectOnEmptyChannelsAfterMs,"ms"))},e.prototype._cancelPendingDisconnect=function(){null!==this._pendingDisconnectTimer&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)},e.prototype._performAuth=function(e,t){return o(this,void 0,Promise,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return r=!1,e?(n=e,r=!0,[3,7]):[3,1];case 1:if(!this.accessToken)return[3,6];i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.accessToken()];case 3:return n=i.sent(),[3,5];case 4:return o=i.sent(),this.log("error","Error fetching access token from callback",o),n=this.accessTokenValue,[3,5];case 5:return[3,7];case 6:n=this.accessTokenValue,i.label=7;case 7:return t!==this._authGeneration||(this.accessToken?this._manuallySetToken=!1:r&&(this._manuallySetToken=!0),this.accessTokenValue!=n&&(this.accessTokenValue=n)),[2]}})})},e.prototype._waitForAuthIfNeeded=function(){return o(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return this._authPromise?[4,this._authPromise]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},e.prototype._setAuthSafely=function(e){var t=this;void 0===e&&(e="general"),this._isManualToken()||this.setAuth().catch(function(n){t.log("error","Error setting auth in ".concat(e),n)})},e.prototype._setupConnectionHandlers=function(){var e=this;if(this._handlersAdapter!==this.socketAdapter){this._handlersAdapter=this.socketAdapter;var t=this.socketAdapter;t.onOpen(function(){e.socketAdapter===t&&((e._authPromise||(e.accessToken&&!e.accessTokenValue?e.setAuth():Promise.resolve())).catch(function(t){e.log("error","error waiting for auth on connect",t)}),e.worker&&!e.workerRef&&e._startWorkerHeartbeat(),e._scheduleConnectionRefresh())}),t.onClose(function(){e.socketAdapter===t&&(e.worker&&e.workerRef&&e._terminateWorker(),e._rotating&&!e._cutoverStarted&&(e.log("transport","active socket closed during refresh, aborting standby"),e._abortRotate()),e._rotating||e._cancelConnectionRefresh())}),t.onMessage(function(n){e.socketAdapter===t&&n.ref&&n.ref===e._pendingWorkerHeartbeatRef&&(e._pendingWorkerHeartbeatRef=null)})}},e.prototype._handleNodeJsRaceCondition=function(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()},e.prototype._wrapHeartbeatCallback=function(e){var t=this;return function(n,r){"disconnected"!==n&&("sent"==n&&t._setAuthSafely(),e&&e(n,r))}},e.prototype._startWorkerHeartbeat=function(){var e=this;this.workerUrl?this.log("worker","starting worker for from ".concat(this.workerUrl)):this.log("worker","starting default worker");var t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=function(t){e.log("worker","worker error",t.message),e._terminateWorker(),e.disconnect()},this.workerRef.onmessage=function(t){"keepAlive"===t.data.event&&e.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})},e.prototype._terminateWorker=function(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)},e.prototype._workerObjectUrl=function(e){var t;if(e)t=e;else{var n=new Blob(['\n addEventListener("message", (e) => {\n if (e.data.event === "start") {\n setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);\n }\n });'],{type:"application/javascript"});t=URL.createObjectURL(n)}return t},e.prototype._initializeOptions=function(e){var t,n,o,i,s,u,l,h,d,p,v,y,g,m;this.worker=null!==(t=null==e?void 0:e.worker)&&void 0!==t&&t,this.accessToken=null!==(n=null==e?void 0:e.accessToken)&&void 0!==n?n:null,this.connectionMaxAgeMs=null!==(o=null==e?void 0:e.connectionMaxAgeMs)&&void 0!==o?o:0,this.connectionRefreshJitterMs=null!==(i=null==e?void 0:e.connectionRefreshJitterMs)&&void 0!==i?i:c.DEFAULT_CONNECTION_REFRESH_JITTER_MS,this._beforeTransportConnect=null==e?void 0:e.beforeTransportConnect;var b,_,E={};E.timeout=null!==(s=null==e?void 0:e.timeout)&&void 0!==s?s:c.DEFAULT_TIMEOUT,E.heartbeatIntervalMs=null!==(u=null==e?void 0:e.heartbeatIntervalMs)&&void 0!==u?u:25e3,this._disconnectOnEmptyChannelsAfterMs=null!==(l=null==e?void 0:e.disconnectOnEmptyChannelsAfterMs)&&void 0!==l?l:2*(null!==(h=null==e?void 0:e.heartbeatIntervalMs)&&void 0!==h?h:25e3),E.transport=null!==(d=null==e?void 0:e.transport)&&void 0!==d?d:a.default.getWebSocketConstructor(),E.params=null==e?void 0:e.params,E.logger=null==e?void 0:e.logger,E.heartbeatCallback=this._wrapHeartbeatCallback(null==e?void 0:e.heartbeatCallback),E.sessionStorage=null!==(p=null==e?void 0:e.sessionStorage)&&void 0!==p?p:function(){try{if("undefined"!=typeof globalThis&&globalThis.sessionStorage)return globalThis.sessionStorage}catch(e){}return e=new Map,{get length(){return e.size},clear:function(){e.clear()},getItem:function(t){return e.has(t)?e.get(t):null},key:function(t){var n;return null!==(n=Array.from(e.keys())[t])&&void 0!==n?n:null},removeItem:function(t){e.delete(t)},setItem:function(t,n){e.set(t,String(n))}};var e}(),E.reconnectAfterMs=null!==(v=null==e?void 0:e.reconnectAfterMs)&&void 0!==v?v:function(e){return f[e-1]||1e4};var w=null!==(y=null==e?void 0:e.vsn)&&void 0!==y?y:c.DEFAULT_VSN;switch(w){case c.VSN_1_0_0:b=function(e,t){return t(JSON.stringify(e))},_=function(e,t){return t(JSON.parse(e))};break;case c.VSN_2_0_0:b=this.serializer.encode.bind(this.serializer),_=this.serializer.decode.bind(this.serializer);break;default:throw new Error("Unsupported serializer version: ".concat(E.vsn))}if(E.vsn=w,E.encode=null!==(g=null==e?void 0:e.encode)&&void 0!==g?g:b,E.decode=null!==(m=null==e?void 0:e.decode)&&void 0!==m?m:_,E.beforeReconnect=this._reconnectAuth.bind(this),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,E.params=r(r({},E.params),{log_level:this.logLevel})),this.worker){if("undefined"!=typeof window&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl,E.autoSendHeartbeat=!this.worker}return E},e.prototype._reconnectAuth=function(){return o(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this._waitForAuthIfNeeded()];case 1:return e.sent(),this.isConnected()||this.connect(),[2]}})})},e.prototype._createSocketAdapter=function(){return new d.default(this._endPoint,this._socketOptions)},e.prototype._openActiveSocket=function(){return o(this,void 0,void 0,function(){var e,t;return i(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),this._beforeTransportConnect?[4,this._beforeTransportConnect()]:[3,2];case 1:n.sent(),n.label=2;case 2:return this.isConnecting()||this.isDisconnecting()||this.isConnected()?[2]:(this._setupConnectionHandlers(),this.socketAdapter.connect(),this._handleNodeJsRaceCondition(),[3,5]);case 3:throw e=n.sent(),t=e.message,new Error("WebSocket not available: ".concat(t));case 4:return this._openingActive=!1,[7];case 5:return[2]}})})},e.prototype._scheduleConnectionRefresh=function(){var e=this;if(this._cancelConnectionRefresh(),!(this.connectionMaxAgeMs<=0)){var t=this.connectionRefreshJitterMs>0?Math.floor(Math.random()*this.connectionRefreshJitterMs):0,n=this.connectionMaxAgeMs+t;this._refreshTimer=setTimeout(function(){e._refreshTimer=null,e._rotateConnection()},n),this.log("transport","connection refresh scheduled in ".concat(n,"ms"))}},e.prototype._cancelConnectionRefresh=function(){null!==this._refreshTimer&&(clearTimeout(this._refreshTimer),this._refreshTimer=null)},e.prototype._scheduleRotateRetry=function(){var e=this;this._cancelRotateRetry(),this._rotateRetryTimer=setTimeout(function(){e._rotateRetryTimer=null,e.isConnected()&&!e._rotating&&e._rotateConnection()},c.CONNECTION_REFRESH_RETRY_MS),this.log("transport","connection refresh retry scheduled in ".concat(c.CONNECTION_REFRESH_RETRY_MS,"ms"))},e.prototype._cancelRotateRetry=function(){null!==this._rotateRetryTimer&&(clearTimeout(this._rotateRetryTimer),this._rotateRetryTimer=null)},e.prototype._rotateConnection=function(){return o(this,void 0,void 0,function(){var e,t,n,r;return i(this,function(o){switch(o.label){case 0:if(this._rotating||!this.isConnected()||0===this.channels.length)return[2];this._rotating=!0,this._cutoverStarted=!1,this._cancelConnectionRefresh(),this.log("transport","starting connection refresh"),o.label=1;case 1:return o.trys.push([1,6,,8]),this._beforeTransportConnect?[4,this._beforeTransportConnect()]:[3,3];case 2:o.sent(),o.label=3;case 3:if(!this.isConnected()||0===this.channels.length)throw new Error("active connection lost before standby connect");return e=this._createSocketAdapter(),this._standbyAdapter=e,[4,this._connectAndWaitOpen(e)];case 4:return o.sent(),t=this.channels.filter(function(e){return e.joinedOnce&&!e.channelAdapter.isClosed()&&!e.channelAdapter.isLeaving()}),[4,Promise.all(t.map(function(t){return t._warmupOn(e)}))];case 5:return n=o.sent(),this._cutover(t,n,e),[3,8];case 6:return r=o.sent(),this.log("transport","connection refresh failed",r),[4,this._teardownStandby()];case 7:return o.sent(),this._rotating=!1,this._cutoverStarted=!1,this.isConnected()&&this.channels.length>0&&this._scheduleRotateRetry(),[3,8];case 8:return[2]}})})},e.prototype._cutover=function(e,t,n){this._cutoverStarted=!0;for(var r=this.socketAdapter,o=0;o<e.length;o++)e[o]._adopt(t[o]);this.socketAdapter=n,this._standbyAdapter=null,this._setupConnectionHandlers(),this.worker&&(this._terminateWorker(),this._startWorkerHeartbeat()),this._rotating=!1,this._scheduleConnectionRefresh(),r.disconnect(function(){},1e3,"connection refresh"),this.log("transport","connection refresh complete")},e.prototype._connectAndWaitOpen=function(e,t){return void 0===t&&(t=c.STANDBY_CONNECT_TIMEOUT_MS),o(this,void 0,Promise,function(){return i(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n,r){var o=setTimeout(function(){r(new Error("standby connect timed out"))},t);e.onOpen(function(){clearTimeout(o),n()}),e.onError(function(e){clearTimeout(o),r(e instanceof Error?e:new Error(String(e)))});try{e.connect()}catch(e){clearTimeout(o),r(e)}})];case 1:return n.sent(),[2]}})})},e.prototype._teardownStandby=function(){return o(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:if(e=this._standbyAdapter,this._standbyAdapter=null,!e)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.disconnect(function(){},1e3,"connection refresh abort")];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}})})},e.prototype._abortRotate=function(){return o(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return this._cancelRotateRetry(),[4,this._teardownStandby()];case 1:return e.sent(),this._rotating=!1,this._cutoverStarted=!1,[2]}})})},e}();t.default=p},8352:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postgresChangesFilter=t.RealtimePostgresFilterBuilder=void 0;var n=/[,()"\\]/,r=function(e){var t=null===e?"null":String(e);return function(e){return n.test(e)||e!==e.trim()}(t)?function(e){return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}(t):t},o=function(){function e(){this.filters=[]}return e.prototype.add=function(e,t,n,o){void 0===o&&(o=!1);var i=o?"not.":"";return this.filters.push("".concat(e,"=").concat(i).concat(function(e,t){if("in"===e){var n=Array.isArray(t)?t:[t];if(0===n.length)throw new Error("Realtime `in` filter requires at least one value.");var o=Array.from(new Set(n)).map(function(e){return r(e)}).join(",");return"in.(".concat(o,")")}return"is"===e?"is.".concat(function(e){return null===e?"null":String(e)}(t)):"".concat(e,".").concat(r(t))}(t,n))),this},e.prototype.eq=function(e,t){return this.add(e,"eq",t)},e.prototype.neq=function(e,t){return this.add(e,"neq",t)},e.prototype.gt=function(e,t){return this.add(e,"gt",t)},e.prototype.gte=function(e,t){return this.add(e,"gte",t)},e.prototype.lt=function(e,t){return this.add(e,"lt",t)},e.prototype.lte=function(e,t){return this.add(e,"lte",t)},e.prototype.in=function(e,t){return this.add(e,"in",t)},e.prototype.like=function(e,t){return this.add(e,"like",t)},e.prototype.ilike=function(e,t){return this.add(e,"ilike",t)},e.prototype.match=function(e,t){return this.add(e,"match",t)},e.prototype.imatch=function(e,t){return this.add(e,"imatch",t)},e.prototype.is=function(e,t){return this.add(e,"is",t)},e.prototype.isDistinct=function(e,t){return this.add(e,"isdistinct",t)},e.prototype.not=function(e,t,n){return this.add(e,t,n,!0)},e.prototype.build=function(){return this.filters.join(",")},e.prototype.toString=function(){return this.build()},e}();t.RealtimePostgresFilterBuilder=o,t.postgresChangesFilter=function(){return new o}},4666:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.REALTIME_PRESENCE_LISTEN_EVENTS=void 0;var o,i=r(n(1732));(o=t.REALTIME_PRESENCE_LISTEN_EVENTS||(t.REALTIME_PRESENCE_LISTEN_EVENTS={})).SYNC="sync",o.JOIN="join",o.LEAVE="leave";var s=function(){function e(e,t){this.channel=e,this.presenceAdapter=new i.default(this.channel.channelAdapter,t)}return Object.defineProperty(e.prototype,"state",{get:function(){return this.presenceAdapter.state},enumerable:!1,configurable:!0}),e}();t.default=s},9203:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerRealtimeJs=t.createRealtimeClient=t.bindRealtimeAuthEvents=t.buildRealtimeEndPoint=void 0;var s=i(n(539)),a=n(5633),c=n(4508),u=new Set(["TOKEN_REFRESHED","SIGNED_IN","INITIAL_SESSION"]),l=new WeakSet,h=new WeakMap;function d(e){var t=e.getEndPointWithKey("GATEWAY"),n=t.BASE_URL,r=t.PROTOCOL,o=/^https:?$/i.test(r)?"wss:":"ws:",i=String(n||"").replace(/\/+$/,"");return"".concat(o).concat(i,"/realtime")}function f(e){var t,n;return r(this,void 0,Promise,function(){var r;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,null===(n=null===(t=e.request)||void 0===t?void 0:t.getAccessToken)||void 0===n?void 0:n.call(t)];case 1:return(r=o.sent())?(l.delete(e),[2,r]):[3,3];case 2:return o.sent(),[3,3];case 3:return function(e){l.has(e)||(l.add(e),console.warn("[CloudBase Realtime] 当前没有登录态,无法使用 realtime 能力。\n请确认以下各项:\n 1 - 是否已调用 app.auth() 初始化认证\n 2 - 是否已完成登录(如 auth.signInAnonymously() / auth.signInWithPassword())\n 3 - 登录态是否已过期,需要重新登录"))}(e),[2,null]}})})}function p(e){return!!e&&"function"==typeof e.onAuthStateChange}t.buildRealtimeEndPoint=d;var v=new WeakSet,y=new WeakMap,g=new WeakSet;function m(e,t){var n;v.has(e)||(v.add(e),t.onAuthStateChange(function(t,r){var o,i=null!==(o=null==r?void 0:r.access_token)&&void 0!==o?o:void 0;if(u.has(t)&&i&&n!==i)return n=i,void e.setAuth(i).catch(function(t){e.log("error","Error setting auth from auth state change",t)});"SIGNED_OUT"===t&&(n=void 0,e.setAuth().catch(function(t){e.log("error","Error clearing auth from SIGNED_OUT",t)}))}))}function b(e){var t,n,i,u,l,h,v=this,b=d(e),_={apikey:(null===(t=e.config)||void 0===t?void 0:t.env)||"cloudbase"},E=function(e){return e&&(h.apiKey=e,_.apikey=e),e},w={params:_,vsn:a.VSN_1_0_0,accessToken:function(){return r(v,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return t=E,[4,f(e)];case 1:return[2,t.apply(void 0,[n.sent()])]}})})},connectionMaxAgeMs:a.CLOUDBASE_CONNECTION_MAX_AGE_MS,beforeTransportConnect:function(){return r(v,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return[4,h.setAuth()];case 1:return e.sent(),[2]}})})}},S=null===(i=null===(n=e.platform)||void 0===n?void 0:n.adapter)||void 0===i?void 0:i.wsClass;S&&(w.transport=S);var I=null===(l=null===(u=e.platform)||void 0===u?void 0:u.adapter)||void 0===l?void 0:l.reqClass;return I&&(w.fetch=(0,c.wrapReqClassFetch)(I)),h=new s.default(b,w),function(e,t){var n=function(e){try{if(p(e.auth))return e.auth;if(p(e.authInstance))return e.authInstance}catch(e){}return null}(e);if(n)m(t,n);else{var r=e.auth;if("function"==typeof r){var o=y.get(e);if(o||(o=new Set,y.set(e,o)),o.add(t),!g.has(e)){g.add(e);var i=function(t){var n=r.call(null!=this?this:e,t);return p(n)&&function(e,t){var n=y.get(e);if(n){for(var r=0,o=n;r<o.length;r++)m(o[r],t);n.clear(),y.delete(e)}}(e,n),n};try{Object.defineProperty(e,"auth",{configurable:!0,enumerable:!0,writable:!0,value:i})}catch(t){e.auth=i}}}}}(e,h),h}t.bindRealtimeAuthEvents=m,t.createRealtimeClient=b;var _={name:"realtime-js",entity:{realtime:function(){return function(e){var t=h.get(e);if(t)return t;var n=b(e);return h.set(e,n),n}(this)}}};try{cloudbase.registerComponent(_)}catch(e){}function E(e){try{e.registerComponent(_)}catch(e){console.warn(e)}}t.registerRealtimeJs=E;try{window.registerRealtimeJs=E}catch(e){}},7397:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.bindRealtimeAuthEvents=t.buildRealtimeEndPoint=t.createRealtimeClient=t.registerRealtimeJs=t.WebSocketLikeConstructor=t.WebSocketLike=t.WebSocketFactory=t.REALTIME_CHANNEL_STATES=t.REALTIME_SUBSCRIBE_STATES=t.REALTIME_PRESENCE_LISTEN_EVENTS=t.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=t.REALTIME_LISTEN_TYPES=t.RealtimeRemoveChannelResponse=t.RealtimePresenceState=t.RealtimePresenceLeavePayload=t.RealtimePresenceJoinPayload=t.RealtimeSystemPayload=t.RealtimePostgresDeletePayload=t.RealtimePostgresUpdatePayload=t.RealtimePostgresInsertPayload=t.RealtimePostgresChangesPayload=t.postgresChangesFilter=t.RealtimePostgresFilterBuilder=t.RealtimePostgresChangesFilterOperator=t.RealtimePostgresChangesFilter=t.RealtimeMessage=t.RealtimeClientOptions=t.RealtimeClient=t.RealtimeChannelSendResponse=t.RealtimeChannelOptions=t.RealtimeChannel=t.RealtimePresence=void 0;var s=i(n(539));t.RealtimeClient=s.default,Object.defineProperty(t,"RealtimeClientOptions",{enumerable:!0,get:function(){return s.RealtimeClientOptions}}),Object.defineProperty(t,"RealtimeMessage",{enumerable:!0,get:function(){return s.RealtimeMessage}}),Object.defineProperty(t,"RealtimeRemoveChannelResponse",{enumerable:!0,get:function(){return s.RealtimeRemoveChannelResponse}}),Object.defineProperty(t,"WebSocketLikeConstructor",{enumerable:!0,get:function(){return s.WebSocketLikeConstructor}});var a=i(n(317));t.RealtimeChannel=a.default,Object.defineProperty(t,"RealtimeChannelOptions",{enumerable:!0,get:function(){return a.RealtimeChannelOptions}}),Object.defineProperty(t,"RealtimeChannelSendResponse",{enumerable:!0,get:function(){return a.RealtimeChannelSendResponse}}),Object.defineProperty(t,"RealtimePostgresChangesFilter",{enumerable:!0,get:function(){return a.RealtimePostgresChangesFilter}}),Object.defineProperty(t,"RealtimePostgresChangesFilterOperator",{enumerable:!0,get:function(){return a.RealtimePostgresChangesFilterOperator}}),Object.defineProperty(t,"RealtimePostgresFilterBuilder",{enumerable:!0,get:function(){return a.RealtimePostgresFilterBuilder}}),Object.defineProperty(t,"postgresChangesFilter",{enumerable:!0,get:function(){return a.postgresChangesFilter}}),Object.defineProperty(t,"RealtimePostgresChangesPayload",{enumerable:!0,get:function(){return a.RealtimePostgresChangesPayload}}),Object.defineProperty(t,"RealtimePostgresInsertPayload",{enumerable:!0,get:function(){return a.RealtimePostgresInsertPayload}}),Object.defineProperty(t,"RealtimePostgresUpdatePayload",{enumerable:!0,get:function(){return a.RealtimePostgresUpdatePayload}}),Object.defineProperty(t,"RealtimePostgresDeletePayload",{enumerable:!0,get:function(){return a.RealtimePostgresDeletePayload}}),Object.defineProperty(t,"RealtimeSystemPayload",{enumerable:!0,get:function(){return a.RealtimeSystemPayload}}),Object.defineProperty(t,"REALTIME_LISTEN_TYPES",{enumerable:!0,get:function(){return a.REALTIME_LISTEN_TYPES}}),Object.defineProperty(t,"REALTIME_POSTGRES_CHANGES_LISTEN_EVENT",{enumerable:!0,get:function(){return a.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT}}),Object.defineProperty(t,"REALTIME_SUBSCRIBE_STATES",{enumerable:!0,get:function(){return a.REALTIME_SUBSCRIBE_STATES}}),Object.defineProperty(t,"REALTIME_CHANNEL_STATES",{enumerable:!0,get:function(){return a.REALTIME_CHANNEL_STATES}});var c=i(n(4666));t.RealtimePresence=c.default,Object.defineProperty(t,"RealtimePresenceState",{enumerable:!0,get:function(){return c.RealtimePresenceState}}),Object.defineProperty(t,"RealtimePresenceJoinPayload",{enumerable:!0,get:function(){return c.RealtimePresenceJoinPayload}}),Object.defineProperty(t,"RealtimePresenceLeavePayload",{enumerable:!0,get:function(){return c.RealtimePresenceLeavePayload}}),Object.defineProperty(t,"REALTIME_PRESENCE_LISTEN_EVENTS",{enumerable:!0,get:function(){return c.REALTIME_PRESENCE_LISTEN_EVENTS}});var u=i(n(1606));t.WebSocketFactory=u.default,Object.defineProperty(t,"WebSocketLike",{enumerable:!0,get:function(){return u.WebSocketLike}});var l=n(9203);Object.defineProperty(t,"registerRealtimeJs",{enumerable:!0,get:function(){return l.registerRealtimeJs}}),Object.defineProperty(t,"createRealtimeClient",{enumerable:!0,get:function(){return l.createRealtimeClient}}),Object.defineProperty(t,"buildRealtimeEndPoint",{enumerable:!0,get:function(){return l.buildRealtimeEndPoint}}),Object.defineProperty(t,"bindRealtimeAuthEvents",{enumerable:!0,get:function(){return l.bindRealtimeAuthEvents}})},5633:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CONNECTION_STATE=t.TRANSPORTS=t.CHANNEL_EVENTS=t.CHANNEL_STATES=t.SOCKET_STATES=t.MAX_PUSH_BUFFER_SIZE=t.WS_CLOSE_NORMAL=t.POSTGRES_CHANGES_WAIT_ERROR_GRACE=t.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT=t.STANDBY_CONNECT_TIMEOUT_MS=t.CONNECTION_REFRESH_RETRY_MS=t.DEFAULT_CONNECTION_REFRESH_JITTER_MS=t.CLOUDBASE_CONNECTION_MAX_AGE_MS=t.DEFAULT_TIMEOUT=t.VERSION=t.DEFAULT_VSN=t.VSN_2_0_0=t.VSN_1_0_0=t.DEFAULT_VERSION=void 0;var r=n(2986);t.DEFAULT_VERSION="realtime-js/".concat(r.version),t.VSN_1_0_0="1.0.0",t.VSN_2_0_0="2.0.0",t.DEFAULT_VSN=t.VSN_2_0_0,t.VERSION=r.version,t.DEFAULT_TIMEOUT=1e4,t.CLOUDBASE_CONNECTION_MAX_AGE_MS=27e4,t.DEFAULT_CONNECTION_REFRESH_JITTER_MS=2e4,t.CONNECTION_REFRESH_RETRY_MS=1e4,t.STANDBY_CONNECT_TIMEOUT_MS=1e4,t.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT=15e3,t.POSTGRES_CHANGES_WAIT_ERROR_GRACE=1e4,t.WS_CLOSE_NORMAL=1e3,t.MAX_PUSH_BUFFER_SIZE=100,t.SOCKET_STATES={connecting:0,open:1,closing:2,closed:3},t.CHANNEL_STATES={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},t.CHANNEL_EVENTS={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},t.TRANSPORTS={websocket:"websocket"},t.CONNECTION_STATE={connecting:"connecting",open:"open",closing:"closing",closed:"closed"}},240:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeChannelError=void 0,t.normalizeChannelError=function(e){if(e instanceof Error)return e;if("string"==typeof e)return new Error(e);if(e&&"object"==typeof e){var t=e;if("number"==typeof t.code){var n="string"==typeof t.reason&&t.reason?" (".concat(t.reason,")"):"";return new Error("socket closed: ".concat(t.code).concat(n),{cause:e})}return new Error("channel error: transport failure",{cause:e})}return new Error("channel error: connection lost")}},4508:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};function o(e){if(!e)return{};if("undefined"!=typeof Headers&&e instanceof Headers){var t={};return e.forEach(function(e,n){t[n]=e}),t}if(Array.isArray(e)){for(var n={},r=0,o=e;r<o.length;r++){var i=o[r],s=i[0],a=i[1];n[s]=String(a)}return n}for(var c={},u=0,l=Object.entries(e);u<l.length;u++){var h=l[u];s=h[0],null!=(a=h[1])&&(c[s]=String(a))}return c}function i(e){var t;return"string"==typeof e?e:"undefined"!=typeof URL&&e instanceof URL?e.toString():"undefined"!=typeof Request&&e instanceof Request?e.url:String(null!==(t=e.url)&&void 0!==t?t:e)}function s(e){return n(this,void 0,Promise,function(){var t;return r(this,function(n){switch(n.label){case 0:return[4,e];case 1:if(null==(t=n.sent())||""===t)return[2,{}];if("string"==typeof t)try{return[2,JSON.parse(t)]}catch(e){return[2,{message:t}]}return[2,t]}})})}function a(e){var t,o,i,a,c=this;if(e&&"object"==typeof e&&"number"==typeof e.status&&"function"==typeof e.json)return e;var u=null!=e?e:{},l=null!==(o=null!==(t=u.statusCode)&&void 0!==t?t:u.status)&&void 0!==o?o:0,h=u.data;return{ok:l>=200&&l<300,status:l,statusText:u.statusMessage||u.statusText||u.errMsg||"",headers:null!==(a=null!==(i=u.header)&&void 0!==i?i:u.headers)&&void 0!==a?a:{},json:function(){return n(c,void 0,void 0,function(){return r(this,function(e){return[2,s(h)]})})},text:function(){return n(c,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return[4,h];case 1:return"string"==typeof(e=t.sent())?[2,e]:null==e?[2,""]:[2,JSON.stringify(e)]}})})}}}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapReqClassFetch=void 0,t.wrapReqClassFetch=function(e,t){var s=this;void 0===t&&(t={});var c=new e(t);return function(e,t){return void 0===t&&(t={}),n(s,void 0,void 0,function(){var n;return r(this,function(r){switch(r.label){case 0:return[4,c.fetch({url:i(e),method:t.method||"GET",headers:o(t.headers),body:t.body,data:t.body,signal:null!==(n=t.signal)&&void 0!==n?n:void 0,shouldThrowOnError:!1})];case 1:return[2,a(r.sent())]}})})}}},7135:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=null!=e?e:[]}return e.prototype.encode=function(e,t){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&"string"==typeof e.payload.event)return t(this._binaryEncodeUserBroadcastPush(e));var n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))},e.prototype._binaryEncodeUserBroadcastPush=function(e){var t;return this._isArrayBuffer(null===(t=e.payload)||void 0===t?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)},e.prototype._encodeBinaryUserBroadcastPush=function(e){var t,n,r=null!==(n=null===(t=e.payload)||void 0===t?void 0:t.payload)&&void 0!==n?n:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,r)},e.prototype._encodeJsonUserBroadcastPush=function(e){var t,n,r=null!==(n=null===(t=e.payload)||void 0===t?void 0:t.payload)&&void 0!==n?n:{},o=(new TextEncoder).encode(JSON.stringify(r)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,o)},e.prototype._encodeUserBroadcastPush=function(e,t,n){var r,o,i=new TextEncoder,s=i.encode(e.topic),a=i.encode(null!==(r=e.ref)&&void 0!==r?r:""),c=i.encode(null!==(o=e.join_ref)&&void 0!==o?o:""),u=i.encode(e.payload.event),l=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},h=i.encode(0===Object.keys(l).length?"":JSON.stringify(l));if(c.length>255)throw new Error("joinRef length ".concat(c.length," exceeds maximum of 255"));if(a.length>255)throw new Error("ref length ".concat(a.length," exceeds maximum of 255"));if(s.length>255)throw new Error("topic length ".concat(s.length," exceeds maximum of 255"));if(u.length>255)throw new Error("userEvent length ".concat(u.length," exceeds maximum of 255"));if(h.length>255)throw new Error("metadata length ".concat(h.length," exceeds maximum of 255"));var d=this.USER_BROADCAST_PUSH_META_LENGTH+c.length+a.length+s.length+u.length+h.length,f=new ArrayBuffer(this.HEADER_LENGTH+d),p=new DataView(f),v=new Uint8Array(f),y=0;p.setUint8(y++,this.KINDS.userBroadcastPush),p.setUint8(y++,c.length),p.setUint8(y++,a.length),p.setUint8(y++,s.length),p.setUint8(y++,u.length),p.setUint8(y++,h.length),p.setUint8(y++,t),v.set(c,y),y+=c.length,v.set(a,y),y+=a.length,v.set(s,y),y+=s.length,v.set(u,y),y+=u.length,v.set(h,y),y+=h.length;var g=new Uint8Array(f.byteLength+n.byteLength);return g.set(new Uint8Array(f),0),g.set(new Uint8Array(n),f.byteLength),g.buffer},e.prototype.decode=function(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){var n=JSON.parse(e);return t({join_ref:n[0],ref:n[1],topic:n[2],event:n[3],payload:n[4]})}return t({})},e.prototype._binaryDecode=function(e){var t=new DataView(e),n=t.getUint8(0),r=new TextDecoder;if(n===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,t,r)},e.prototype._decodeUserBroadcast=function(e,t,n){var r=t.getUint8(1),o=t.getUint8(2),i=t.getUint8(3),s=t.getUint8(4),a=this.HEADER_LENGTH+4,c=n.decode(e.slice(a,a+r));a+=r;var u=n.decode(e.slice(a,a+o));a+=o;var l=n.decode(e.slice(a,a+i));a+=i;var h=e.slice(a,e.byteLength),d=s===this.JSON_ENCODING?JSON.parse(n.decode(h)):h,f={type:this.BROADCAST_EVENT,event:u,payload:d};return i>0&&(f.meta=JSON.parse(l)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:f}},e.prototype._isArrayBuffer=function(e){var t;return e instanceof ArrayBuffer||"ArrayBuffer"===(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)},e.prototype._pick=function(e,t){return e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(function(e){var n=e[0];return t.includes(n)})):{}},e}();t.default=n},8206:function(e,t){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.joinBroadcastEventUrl=t.httpEndpointURL=t.toTimestampString=t.toArray=t.toJson=t.toNumber=t.toBoolean=t.convertCell=t.convertColumn=t.convertChangeData=t.PostgresTypes=void 0,function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(n=t.PostgresTypes||(t.PostgresTypes={})),t.convertChangeData=function(e,n,r){var o;void 0===r&&(r={});var i=null!==(o=r.skipTypes)&&void 0!==o?o:[];return n?Object.keys(n).reduce(function(r,o){return r[o]=(0,t.convertColumn)(o,e,n,i),r},{}):{}},t.convertColumn=function(e,n,o,i){var s=n.find(function(t){return t.name===e}),a=null==s?void 0:s.type,c=o[e];return a&&!i.includes(a)?(0,t.convertCell)(a,c):r(c)},t.convertCell=function(e,o){if("_"===e.charAt(0)){var i=e.slice(1,e.length);return(0,t.toArray)(o,i)}switch(e){case n.bool:return(0,t.toBoolean)(o);case n.float4:case n.float8:case n.int2:case n.int4:case n.int8:case n.numeric:case n.oid:return(0,t.toNumber)(o);case n.json:case n.jsonb:return(0,t.toJson)(o);case n.timestamp:return(0,t.toTimestampString)(o);case n.abstime:case n.date:case n.daterange:case n.int4range:case n.int8range:case n.money:case n.reltime:case n.text:case n.time:case n.timestamptz:case n.timetz:case n.tsrange:case n.tstzrange:default:return r(o)}};var r=function(e){return e};function o(e){var t=e.indexOf("#"),n=-1===t?e:e.slice(0,t),r=-1===t?"":e.slice(t),o=n.indexOf("?");return{base:-1===o?n:n.slice(0,o),query:-1===o?"":n.slice(o),hash:r}}t.toBoolean=function(e){switch(e){case"t":return!0;case"f":return!1;default:return e}},t.toNumber=function(e){if("string"==typeof e){var t=parseFloat(e);if(!Number.isNaN(t))return t}return e},t.toJson=function(e){if("string"==typeof e)try{return JSON.parse(e)}catch(t){return e}return e},t.toArray=function(e,n){if("string"!=typeof e)return e;var r=e.length-1,o=e[r];if("{"===e[0]&&"}"===o){var i=void 0,s=e.slice(1,r);try{i=JSON.parse("["+s+"]")}catch(e){i=s?s.split(","):[]}return i.map(function(e){return(0,t.convertCell)(n,e)})}return e},t.toTimestampString=function(e){return"string"==typeof e?e.replace(" ","T"):e},t.httpEndpointURL=function(e){var t=o(e),n=t.base,r=t.query,i=t.hash,s=n.replace(/^ws/i,"http").replace(/\/+$/,"");return(s=(s=s.replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,"")).replace(/\/+$/,"")+"/api/broadcast")+r+i},t.joinBroadcastEventUrl=function(e,t,n,r){var i=o(e),s=i.base,a=i.query,c=i.hash,u="/".concat(encodeURIComponent(t),"/events/").concat(encodeURIComponent(n)),l=s.replace(/\/+$/,"")+u,h=[];if(a.startsWith("?")&&a.length>1&&h.push(a.slice(1)),r)for(var d=0,f=Object.entries(r);d<f.length;d++){var p=f[d],v=p[0],y=p[1];h.push("".concat(encodeURIComponent(v),"=").concat(encodeURIComponent(y)))}return l+(h.length?"?".concat(h.join("&")):"")+c}},2986:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="1.0.0-alpha.0"},1606:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketFactory=void 0;var r=function(){function e(){}return e.detectEnvironment=function(){var e;if("undefined"!=typeof WebSocket)return{type:"native",wsConstructor:WebSocket};var t=globalThis;if("undefined"!=typeof globalThis&&void 0!==t.WebSocket)return{type:"native",wsConstructor:t.WebSocket};var r=void 0!==n.g?n.g:void 0;if(r&&void 0!==r.WebSocket)return{type:"native",wsConstructor:r.WebSocket};if("undefined"!=typeof globalThis&&void 0!==t.WebSocketPair&&void 0===globalThis.WebSocket)return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if("undefined"!=typeof globalThis&&t.EdgeRuntime||"undefined"!=typeof navigator&&(null===(e=navigator.userAgent)||void 0===e?void 0:e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};var o=globalThis.process;if(o){var i=o.versions;if(i&&i.node)return{type:"unsupported",error:"Node.js detected but native WebSocket not found.",workaround:"Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}},e.getWebSocketConstructor=function(){var e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;var t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+="\n\nSuggested solution: ".concat(e.workaround)),new Error(t)},e.isWebSocketSupported=function(){try{return"native"===this.detectEnvironment().type}catch(e){return!1}},e}();t.WebSocketFactory=r,t.default=r},4663:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o=n(5633),i=function(){function e(e,t,n){var o={config:r({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config)};this.channel=e.getSocket().channel(t,o),this.socket=e}return Object.defineProperty(e.prototype,"state",{get:function(){return this.channel.state},set:function(e){this.channel.state=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"joinedOnce",{get:function(){return this.channel.joinedOnce},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"joinPush",{get:function(){return this.channel.joinPush},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rejoinTimer",{get:function(){return this.channel.rejoinTimer},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return this.channel.on(e,t)},e.prototype.off=function(e,t){this.channel.off(e,t)},e.prototype.subscribe=function(e){return this.channel.join(e)},e.prototype.unsubscribe=function(e){return this.channel.leave(e)},e.prototype.teardown=function(){this.channel.teardown()},e.prototype.detachLifecycleHooks=function(){this.channel.off(o.CHANNEL_EVENTS.close),this.channel.off(o.CHANNEL_EVENTS.error)},e.prototype.onClose=function(e){this.channel.onClose(e)},e.prototype.onError=function(e){return this.channel.onError(e)},e.prototype.push=function(e,t,n){var r;try{r=this.channel.push(e,t,n)}catch(t){throw new Error("tried to push '".concat(e,"' to '").concat(this.channel.topic,"' before joining. Use channel.subscribe() before pushing events"))}if(this.channel.pushBuffer.length>o.MAX_PUSH_BUFFER_SIZE){var i=this.channel.pushBuffer.shift();i.cancelTimeout(),this.socket.log("channel","discarded push due to buffer overflow: ".concat(i.event),i.payload())}return r},e.prototype.updateJoinPayload=function(e){var t=this.channel.joinPush.payload();this.channel.joinPush.payload=function(){return r(r({},t),e)}},e.prototype.canPush=function(){return this.socket.isConnected()&&this.state===o.CHANNEL_STATES.joined},e.prototype.isJoined=function(){return this.state===o.CHANNEL_STATES.joined},e.prototype.isJoining=function(){return this.state===o.CHANNEL_STATES.joining},e.prototype.isClosed=function(){return this.state===o.CHANNEL_STATES.closed},e.prototype.isLeaving=function(){return this.state===o.CHANNEL_STATES.leaving},e.prototype.updateFilterBindings=function(e){this.channel.filterBindings=e},e.prototype.updatePayloadTransform=function(e){this.channel.onMessage=e},e.prototype.getChannel=function(){return this.channel},e}();t.default=i},1732:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2772),o=function(){function e(t,n){var o=function(e){return(null==e?void 0:e.events)&&{events:e.events}}(n);this.presence=new r.Presence(t.getChannel(),o),this.presence.onJoin(function(n,r,o){var i=e.onJoinPayload(n,r,o);t.getChannel().trigger("presence",i)}),this.presence.onLeave(function(n,r,o){var i=e.onLeavePayload(n,r,o);t.getChannel().trigger("presence",i)}),this.presence.onSync(function(){t.getChannel().trigger("presence",{event:"sync"})})}return Object.defineProperty(e.prototype,"state",{get:function(){return e.transformState(this.presence.state)},enumerable:!1,configurable:!0}),e.transformState=function(e){return e=function(e){return JSON.parse(JSON.stringify(e))}(e),Object.getOwnPropertyNames(e).reduce(function(t,n){var r=e[n];return t[n]=i(r),t},{})},e.onJoinPayload=function(e,t,n){return{event:"join",key:e,currentPresences:s(t),newPresences:i(n)}},e.onLeavePayload=function(e,t,n){return{event:"leave",key:e,currentPresences:s(t),leftPresences:i(n)}},e}();function i(e){return e.metas.map(function(e){var t=Object.getOwnPropertyDescriptors(e),n=Object.defineProperties({},t);return n.presence_ref=n.phx_ref,delete n.phx_ref,delete n.phx_ref_prev,n})}function s(e){return(null==e?void 0:e.metas)?i(e):[]}t.default=o},1563:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2772),o=n(5633),i=function(){function e(e,t){this.socket=new r.Socket(e,t)}return Object.defineProperty(e.prototype,"timeout",{get:function(){return this.socket.timeout},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.socket.endPoint},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){return this.socket.transport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatIntervalMs",{get:function(){return this.socket.heartbeatIntervalMs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatCallback",{get:function(){return this.socket.heartbeatCallback},set:function(e){this.socket.heartbeatCallback=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heartbeatTimer",{get:function(){return this.socket.heartbeatTimer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingHeartbeatRef",{get:function(){return this.socket.pendingHeartbeatRef},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reconnectTimer",{get:function(){return this.socket.reconnectTimer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vsn",{get:function(){return this.socket.vsn},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"encode",{get:function(){return this.socket.encode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"decode",{get:function(){return this.socket.decode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"reconnectAfterMs",{get:function(){return this.socket.reconnectAfterMs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sendBuffer",{get:function(){return this.socket.sendBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stateChangeCallbacks",{get:function(){return this.socket.stateChangeCallbacks},enumerable:!1,configurable:!0}),e.prototype.connect=function(){this.socket.connect()},e.prototype.disconnect=function(e,t,n,r){var o=this;return void 0===r&&(r=1e4),new Promise(function(i){setTimeout(function(){return i("timeout")},r),o.socket.disconnect(function(){e(),i("ok")},t,n)})},e.prototype.push=function(e){this.socket.push(e)},e.prototype.log=function(e,t,n){this.socket.log(e,t,n)},e.prototype.hasLogger=function(){return this.socket.hasLogger()},e.prototype.makeRef=function(){return this.socket.makeRef()},e.prototype.onOpen=function(e){this.socket.onOpen(e)},e.prototype.onClose=function(e){this.socket.onClose(e)},e.prototype.onError=function(e){this.socket.onError(e)},e.prototype.onMessage=function(e){this.socket.onMessage(e)},e.prototype.isConnected=function(){return this.socket.isConnected()},e.prototype.isConnecting=function(){return this.socket.connectionState()==o.CONNECTION_STATE.connecting},e.prototype.isDisconnecting=function(){return this.socket.connectionState()==o.CONNECTION_STATE.closing},e.prototype.connectionState=function(){return this.socket.connectionState()},e.prototype.endPointURL=function(){return this.socket.endPointURL()},e.prototype.sendHeartbeat=function(){this.socket.sendHeartbeat()},e.prototype.getSocket=function(){return this.socket},e}();t.default=i},6511:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setRuntime=t.getRuntime=t.setWsClass=t.getWsClass=void 0;var n=null,r="web";t.getWsClass=function(){return n},t.setWsClass=function(e){n=e},t.getRuntime=function(){return r},t.setRuntime=function(e){r=e}},2917:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.ERR_CODE=t.CloudSDKError=t.isCancelledError=t.CancelledError=t.isTimeoutError=t.TimeoutError=t.isRealtimeErrorMessageError=t.RealtimeErrorMessageError=void 0;var o=function(e){function t(t){var n=e.call(this,"Watch Error ".concat(JSON.stringify(t.msgData)," (requestid: ").concat(t.requestId,")"))||this;return n.isRealtimeErrorMessageError=!0,n.payload=t,n}return r(t,e),t}(Error);t.RealtimeErrorMessageError=o,t.isRealtimeErrorMessageError=function(e){return null==e?void 0:e.isRealtimeErrorMessageError};var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="timeout",t.payload=null,t.generic=!0,t}return r(t,e),t}(Error);t.TimeoutError=i,t.isTimeoutError=function(e){return"timeout"===e.type};var s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="cancelled",t.payload=null,t.generic=!0,t}return r(t,e),t}(Error);t.CancelledError=s,t.isCancelledError=function(e){return"cancelled"===e.type};var a=function(e){function n(n){var r=e.call(this,n.errMsg)||this;return r.errCode="UNKNOWN_ERROR",Object.defineProperties(r,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(t.ERR_CODE[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e}}}),r.errCode=n.errCode||"UNKNOWN_ERROR",r.errMsg=n.errMsg,r}return r(n,e),Object.defineProperty(n.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),n}(Error);t.CloudSDKError=a,t.ERR_CODE={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"}},7209:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RealtimeWebSocketClient=t.registerRealtime=void 0;var r=n(2347);Object.defineProperty(t,"RealtimeWebSocketClient",{enumerable:!0,get:function(){return r.RealtimeWebSocketClient}});var o=n(6511),i={target:"database",entity:function(){var e=this.platform,t=e.adapter,n=e.runtime;(0,o.setWsClass)(t.wsClass),(0,o.setRuntime)(n)}},s={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=r.RealtimeWebSocketClient}};try{cloudbase.registerComponent(s),cloudbase.registerHook(i)}catch(e){}t.registerRealtime=function(e){try{e.registerComponent(s),e.registerHook(i)}catch(e){console.warn(e)}}},1601:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RealtimeListener=void 0;t.RealtimeListener=function(e){this.close=e.close,this.onChange=e.onChange,this.onError=e.onError,e.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return e.virtualClient}})}},3994:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInitEventMessage=t.genRequestId=void 0,t.genRequestId=function(e){return void 0===e&&(e=""),"".concat(e?"".concat(e,"_"):"").concat(+new Date,"_").concat(Math.random())},t.isInitEventMessage=function(e){return"INIT_EVENT"===e.msgType}},9770:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Snapshot=void 0;t.Snapshot=function(e){var t,n,r=e.id,o=e.docChanges,i=e.docs,s=e.msgType,a=e.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return t||(t=JSON.parse(JSON.stringify(o))),t},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})}},7589:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0,t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})}},4151:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VirtualWebSocketClient=void 0;var a,c=s(n(6765)),u=s(n(7195)),l=s(n(9850)),h=n(3994),d=n(1601),f=n(9770),p=n(2917),v=n(7589);!function(e){e.LOGGINGIN="LOGGINGIN",e.INITING="INITING",e.REBUILDING="REBUILDING",e.ACTIVE="ACTIVE",e.ERRORED="ERRORED",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.PAUSED="PAUSED",e.RESUMING="RESUMING"}(a||(a={}));var y=function(){function e(e){var t=this;this.watchStatus=a.INITING,this.wsLogin=function(e,n){return r(t,void 0,Promise,function(){var t;return o(this,function(r){switch(r.label){case 0:return this.watchStatus=a.LOGGINGIN,[4,this.login(e,n)];case 1:return t=r.sent(),this.envId||(this.envId=t.envId),[2,t]}})})},this.initWatch=function(e){return r(t,void 0,Promise,function(){var t,n=this;return o(this,function(i){switch(i.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise(function(t,i){r(n,void 0,void 0,function(){var n,r,s,c,u,l,d,p,v,y;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.watchStatus===a.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:return n=o.sent().envId,this.watchStatus===a.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=a.INITING,r={watchId:this.watchId,requestId:(0,h.genRequestId)(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:r,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(s=o.sent(),c=s.msgData,u=c.events,l=c.currEvent,this.sessionInfo={queryID:s.msgData.queryID,currentEventId:l-1,currentDocs:[]},u.length>0){for(d=0,p=u;d<p.length;d++)p[d].ID=l;this.handleServerEvents(s)}else this.sessionInfo.currentEventId=l,v=new f.Snapshot({id:l,docChanges:[],docs:[],type:"init"}),this.listener.onChange(v),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=a.ACTIVE,this.availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return y=o.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:t,reject:i}),[3,4];case 4:return[2]}})})}),t=!1,i.label=1;case 1:return i.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return i.sent(),t=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(t?"success":"fail")),[2]}})})},this.rebuildWatch=function(e){return r(t,void 0,Promise,function(){var t,n=this;return o(this,function(i){switch(i.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise(function(t,i){r(n,void 0,void 0,function(){var n,r,s,c;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.watchStatus===a.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:if(n=o.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===a.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=a.REBUILDING,r={watchId:this.watchId,requestId:(0,h.genRequestId)(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:r,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return s=o.sent(),this.handleServerEvents(s),this.watchStatus=a.ACTIVE,this.availableRetries.REBUILD_WATCH=2,t(),[3,4];case 3:return c=o.sent(),this.handleWatchEstablishmentError(c,{operationName:"REBUILD_WATCH",resolve:t,reject:i}),[3,4];case 4:return[2]}})})}),t=!1,i.label=1;case 1:return i.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return i.sent(),t=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(t?"success":"fail")),[2]}})})},this.handleWatchEstablishmentError=function(e,n){return r(t,void 0,void 0,function(){var t,i,s,c=this;return o(this,function(u){return t="INIT_WATCH"===n.operationName,i=function(){c.closeWithError(new p.CloudSDKError({errCode:t?p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),n.reject(e)},s=function(e){c.useRetryTicket(n.operationName)?t?(c.initWatchPromise=void 0,n.resolve(c.initWatch(e))):(c.rebuildWatchPromise=void 0,n.resolve(c.rebuildWatch(e))):i()},this.handleCommonError(e,{onSignError:function(){return s(!0)},onTimeoutError:function(){return s(!1)},onNotRetryableError:i,onCancelledError:n.reject,onUnknownError:function(){r(c,void 0,void 0,function(){var e,t=this;return o(this,function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),e=function(){return r(t,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),s(!0),[2]}})})},this.isWSConnected()?[3,2]:[4,e()];case 1:return i.sent(),[3,7];case 2:return[4,(0,v.sleep)(100)];case 3:return i.sent(),this.watchStatus!==a.PAUSED?[3,4]:(n.reject(new p.CancelledError("".concat(n.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];case 5:return i.sent(),[3,7];case 6:s(!1),i.label=7;case 7:return[3,9];case 8:return i.sent(),s(!0),[3,9];case 9:return[2]}})})}}),[2]})})},this.closeWatch=function(){return r(t,void 0,void 0,function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==a.ACTIVE)return this.watchStatus=a.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=a.CLOSING,t={watchId:this.watchId,requestId:(0,h.genRequestId)(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=a.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,e),[7];case 5:return[2]}})})},this.scheduleSendACK=function(){t.clearACKSchedule(),t.ackTimeoutId=setTimeout(function(){t.waitExpectedTimeoutId?t.scheduleSendACK():t.sendACK()},1e4)},this.clearACKSchedule=function(){t.ackTimeoutId&&clearTimeout(t.ackTimeoutId)},this.sendACK=function(){return r(t,void 0,Promise,function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==a.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:(0,h.genRequestId)(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:e})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(t=r.sent(),(0,p.isRealtimeErrorMessageError)(t))switch((n=t.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}})})},this.handleCommonError=function(e,t){if((0,p.isRealtimeErrorMessageError)(e))switch(e.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void t.onSignError(e);default:return void t.onNotRetryableError(e)}else{if((0,p.isTimeoutError)(e))return void t.onTimeoutError(e);if((0,p.isCancelledError)(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=e.envId,this.collectionName=e.collectionName,this.query=e.query,this.limit=e.limit,this.orderBy=e.orderBy,this.send=e.send,this.login=e.login,this.isWSConnected=e.isWSConnected,this.onceWSConnected=e.onceWSConnected,this.getWaitExpectedTimeoutLength=e.getWaitExpectedTimeoutLength,this.onWatchStart=e.onWatchStart,this.onWatchClose=e.onWatchClose,this.debug=e.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new d.RealtimeListener({close:function(){t.closeWatch()},onChange:e.onChange,onError:e.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return e.prototype.onMessage=function(e){var t=this;switch(this.watchStatus){case a.PAUSED:if("ERROR"!==e.msgType)return;break;case a.LOGGINGIN:case a.INITING:case a.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while ".concat(this.watchStatus));case a.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case a.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),e.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(e.msgData.currEvent," ignored"),e),this.handleServerEvents(e);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<e.msgData.currEvent&&(this.sessionInfo.expectEventId=e.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout(function(){t.rebuildWatch()},this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength ".concat(this.getWaitExpectedTimeoutLength())));break;case"ERROR":this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:"".concat(e.msgData.code," - ").concat(e.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(e.msgType,": "),e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){var t;this.watchStatus=a.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,(null===(t=this.sessionInfo)||void 0===t?void 0:t.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.pause=function(){this.watchStatus=a.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.resume=function(){return r(this,void 0,Promise,function(){var e;return o(this,function(t){switch(t.label){case 0:this.watchStatus=a.RESUMING,console.log("[realtime] client resuming with ".concat(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH"," (").concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return t.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),e),[3,4];case 4:return[2]}})})},e.prototype.useRetryTicket=function(e){return!!(this.availableRetries[e]&&this.availableRetries[e]>0)&&(this.availableRetries[e]-=1,console.log("[realtime] ".concat(e," use a retry ticket, now only ").concat(this.availableRetries[e]," retry left")),!0)},e.prototype.handleServerEvents=function(e){return r(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(e)];case 1:return n.sent(),this.postHandleServerEventsValidityCheck(e),[3,3];case 2:throw t=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",t),t;case 3:return[2]}})})},e.prototype.handleServerEventsInternel=function(e){return r(this,void 0,void 0,function(){var t,n,r,s,a,h,d,v,y,m,b,_;return o(this,function(E){switch(E.label){case 0:if(t=e.requestId,n=e.msgData.events,r=e.msgType,!n.length||!this.sessionInfo)return[2];s=this.sessionInfo;try{a=n.map(g)}catch(e){return this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}h=i([],s.currentDocs,!0),d=!1,v=function(n,v){var g,m,b,_,E,w,S,I,O,A,T,P;return o(this,function(o){switch(o.label){case 0:return g=a[n],s.currentEventId>=g.id?(!a[n-1]||g.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur ".concat(s.currentEventId," but got ").concat(g.id)):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId ".concat(t,")")),[2,"continue"]):[3,1];case 1:if(s.currentEventId!==g.id-1)return[3,2];switch(g.dataType){case"update":if(!g.doc)switch(g.queueType){case"update":case"dequeue":if(m=h.find(function(e){return e._id===g.docId}),m){if(b=(0,l.default)(m),g.updatedFields&&Object.keys(g.updatedFields).forEach(function(e){(0,c.default)(b,e,g.updatedFields[e])}),g.removedFields)for(_=0,E=g.removedFields;_<E.length;_++)w=E[_],(0,u.default)(b,w);g.doc=b}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw I=new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '.concat(e.requestId,")")}),y.closeWithError(I),I}break;case"replace":if(!g.doc)throw I=new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '.concat(e.requestId,")")}),y.closeWithError(I),I;break;case"remove":(S=h.find(function(e){return e._id===g.docId}))?g.doc=S:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!g.doc)switch(g.queueType){case"dequeue":(S=h.find(function(e){return e._id===g.docId}))?g.doc=S:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw I=new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '.concat(e.requestId,")")}),y.closeWithError(I),I}}switch(g.queueType){case"init":d?h.push(g.doc):(d=!0,h=[g.doc]);break;case"enqueue":h.push(g.doc);break;case"dequeue":O=h.findIndex(function(e){return e._id===g.docId}),O>-1?h.splice(O,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":O=h.findIndex(function(e){return e._id===g.docId}),O>-1?h[O]=g.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===v-1||a[n+1]&&a[n+1].id!==g.id)&&(A=i([],h,!0),T=a.slice(0,n+1).filter(function(e){return e.id===g.id}),y.sessionInfo.currentEventId=g.id,y.sessionInfo.currentDocs=h,P=new f.Snapshot({id:g.id,docChanges:T,docs:A,msgType:r}),y.listener.onChange(P)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(y.sessionInfo.currentEventId," but got ").concat(g.id)),[4,y.rebuildWatch()];case 3:return o.sent(),[2,{value:void 0}];case 4:return[2]}})},y=this,m=0,b=a.length,E.label=1;case 1:return m<b?[5,v(m,b)]:[3,4];case 2:if("object"==typeof(_=E.sent()))return[2,_.value];E.label=3;case 3:return m++,[3,1];case 4:return[2]}})})},e.prototype.postHandleServerEventsValidityCheck=function(e){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<e.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},e.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},e}();function g(e){var t={id:e.ID,dataType:e.DataType,queueType:e.QueueType,docId:e.DocID,doc:e.Doc&&"{}"!==e.Doc?JSON.parse(e.Doc):void 0};return"update"===e.DataType&&(e.UpdatedFields&&(t.updatedFields=JSON.parse(e.UpdatedFields)),(e.removedFields||e.RemovedFields)&&(t.removedFields=JSON.parse(e.removedFields))),t}t.VirtualWebSocketClient=y},2347:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.RealtimeWebSocketClient=void 0;var s=n(4151),a=n(3994),c=n(636),u=n(2917),l=n(6511),h=n(7589),d=function(){function e(e){var t=this;this.virtualWSClient=new Set,this.queryIdClientMap=new Map,this.watchIdClientMap=new Map,this.pingFailed=0,this.pongMissed=0,this.logins=new Map,this.wsReadySubsribers=[],this.wsResponseWait=new Map,this.rttObserved=[],this.send=function(e){return o(t,void 0,Promise,function(){var t=this;return i(this,function(n){return[2,new Promise(function(n,r){o(t,void 0,void 0,function(){var t,s,a,c,l,d,f,p,v=this;return i(this,function(y){switch(y.label){case 0:s=!1,a=!1,c=function(e){s=!0,t&&clearTimeout(t),n(e)},l=function(e){a=!0,t&&clearTimeout(t),r(e)},e.timeout&&(t=setTimeout(function(){o(v,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return s&&a?[3,2]:[4,(0,h.sleep)(0)];case 1:e.sent(),s&&a||l(new u.TimeoutError("wsclient.send timedout")),e.label=2;case 2:return[2]}})})},e.timeout)),y.label=1;case 1:return y.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:y.sent(),y.label=3;case 3:if(!this.ws)return l(new Error("invalid state: ws connection not exists, can not send message")),[2];if(1!==this.ws.readyState)return l(new Error("ws readyState invalid: ".concat(this.ws.readyState,", can not send message"))),[2];e.waitResponse&&(d={resolve:c,reject:l,skipOnMessage:e.skipOnMessage},this.wsResponseWait.set(e.msg.requestId,d)),y.label=4;case 4:return y.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(e.msg))];case 5:return y.sent(),e.waitResponse||c(void 0),[3,7];case 6:return(f=y.sent())&&(l(f),e.waitResponse&&this.wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return p=y.sent(),l(p),[3,9];case 9:return[2]}})})})]})})},this.closeAllClients=function(e){t.virtualWSClient.forEach(function(t){t.closeWithError(e)})},this.pauseClients=function(e){(e||t.virtualWSClient).forEach(function(e){e.pause()})},this.resumeClients=function(e){(e||t.virtualWSClient).forEach(function(e){e.resume()})},this.initWebSocketConnection=function(e,n){return void 0===n&&(n=t.maxReconnect),o(t,void 0,Promise,function(){var t=this;return i(this,function(r){switch(r.label){case 0:if(e&&this.reconnectState)return[2];if(e&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];e&&this.pauseClients(),this.close(c.CloseEventCode.ReconnectWebSocket),this.wsInitPromise=new Promise(function(r,s){o(t,void 0,void 0,function(){var t,o,a=this;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=i.sent(),[4,new Promise(function(e){var n=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=(0,l.getWsClass)();a.ws=r?new r(n):new WebSocket(n),e(void 0)})];case 2:return i.sent(),this.ws.connect?[4,this.ws.connect()]:[3,4];case 3:i.sent(),i.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return i.sent(),r(),e&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return o=i.sent(),console.error("[realtime] initWebSocketConnection connect fail",o),n>0?(this.wsInitPromise=void 0,[4,(0,h.sleep)(this.reconnectInterval)]):[3,9];case 7:i.sent(),e&&(this.reconnectState=!1),i.label=8;case 8:return r(this.initWebSocketConnection(e,n-1)),[3,10];case 9:s(o),e&&this.closeAllClients(new u.CloudSDKError({errCode:u.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:o})),i.label=10;case 10:return[3,11];case 11:return[2]}})})}),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return r.sent(),this.wsReadySubsribers.forEach(function(e){return(0,e.resolve)()}),[3,5];case 3:return r.sent(),this.wsReadySubsribers.forEach(function(e){return(0,e.reject)()}),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}})})},this.initWebSocketEvent=function(){return new Promise(function(e,n){if(!t.ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;t.ws.onopen=function(t){console.warn("[realtime] ws event: open",t),r=!0,e()},t.ws.onerror=function(e){t.logins=new Map,r?(console.error("[realtime] ws event: error",e),t.clearHeartbeat(),t.virtualWSClient.forEach(function(t){return t.closeWithError(new u.CloudSDKError({errCode:u.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:e}))})):(console.error("[realtime] ws open failed with ws event: error",e),n(e))},t.ws.onclose=function(e){switch(console.warn("[realtime] ws event: close",e),t.logins=new Map,t.clearHeartbeat(),e.code){case c.CloseEventCode.ReconnectWebSocket:case c.CloseEventCode.NoRealtimeListeners:break;case c.CloseEventCode.HeartbeatPingError:case c.CloseEventCode.HeartbeatPongTimeoutError:case c.CloseEventCode.NormalClosure:case c.CloseEventCode.AbnormalClosure:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients((0,c.getWSCloseError)(e.code));break;case c.CloseEventCode.NoAuthentication:t.closeAllClients((0,c.getWSCloseError)(e.code,e.reason));break;default:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients((0,c.getWSCloseError)(e.code))}},t.ws.onmessage=function(e){var n,r,o=(null===(n=e.data)||void 0===n?void 0:n.data)||e.data;t.heartbeat();try{r="string"==typeof o?JSON.parse(o):o}catch(e){throw new Error("[realtime] onMessage parse res.data error: ".concat(e))}if("ERROR"===r.msgType){var i=null;t.virtualWSClient.forEach(function(e){e.watchId===r.watchId&&(i=e)}),i&&i.listener.onError(r)}var s=t.wsResponseWait.get(r.requestId);if(s){try{"ERROR"===r.msgType?s.reject(new u.RealtimeErrorMessageError(r)):s.resolve(r)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t.wsResponseWait.delete(r.requestId)}if(s.skipOnMessage)return}if("PONG"!==r.msgType){var a=r.watchId&&t.watchIdClientMap.get(r.watchId);if(a)a.onMessage(r);else switch(console.error("[realtime] no realtime listener found responsible for watchId ".concat(r.watchId,": "),r),r.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(a=t.queryIdClientMap.get(r.msgData.queryID))&&a.onMessage(r);break;default:for(var c=0,l=Array.from(t.watchIdClientMap.entries());c<l.length;c++){l[c][1].onMessage(r);break}}}else if(t.lastPingSendTS){var h=Date.now()-t.lastPingSendTS;if(h>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(h));t.rttObserved.length>=3&&t.rttObserved.splice(0,t.rttObserved.length-3+1),t.rttObserved.push(h)}},t.heartbeat()})},this.isWSConnected=function(){return Boolean(t.ws&&1===t.ws.readyState)},this.onceWSConnected=function(){return o(t,void 0,Promise,function(){var e=this;return i(this,function(t){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise(function(t,n){e.wsReadySubsribers.push({resolve:t,reject:n})})]})})},this.webLogin=function(e,n){return o(t,void 0,Promise,function(){var t,r,s,c,u,h,d,f,p=this;return i(this,function(v){switch(v.label){case 0:if(!n)if(e){if(t=this.logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(null!==t.loggingInPromise&&void 0!==t.loggingInPromise)return[2,t.loggingInPromise]}}else if(null!==(null==(r=this.logins.get(""))?void 0:r.loggingInPromise)&&void 0!==(null==r?void 0:r.loggingInPromise))return[2,r.loggingInPromise];s=new Promise(function(e,t){o(p,void 0,void 0,function(){var n,r,o,s,c;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=i.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:(0,a.genRequestId)(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:(0,l.getRuntime)(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(s=i.sent()).msgData.code?t(new Error("".concat(s.msgData.code," ").concat(s.msgData.message))):e({envId:n.envId}),[3,4];case 3:return c=i.sent(),t(c),[3,4];case 4:return[2]}})})}),c=e&&this.logins.get(e),u=Date.now(),c?(c.loggedIn=!1,c.loggingInPromise=s,c.loginStartTS=u):(c={loggedIn:!1,loggingInPromise:s,loginStartTS:u},this.logins.set(e||"",c)),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,s];case 2:if(h=v.sent(),(d=e&&this.logins.get(e))&&d===c&&d.loginStartTS===u)return c.loggedIn=!0,c.loggingInPromise=void 0,c.loginStartTS=void 0,c.loginResult=h,[2,h];if(d){if(d.loggedIn&&d.loginResult)return[2,d.loginResult];if(null!==d.loggingInPromise&&void 0!==d.loggingInPromise)return[2,d.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=v.sent(),c.loggedIn=!1,c.loggingInPromise=void 0,c.loginStartTS=void 0,c.loginResult=void 0,f;case 4:return[2]}})})},this.getWsSign=function(){return o(t,void 0,Promise,function(){var e,t,n,r,o,s,a;return i(this,function(i){switch(i.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(e=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:(0,l.getRuntime)()})]);case 1:if((t=i.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(t.code));if(t.data)return n=t.data,r=n.signStr,o=n.wsUrl,s=n.secretVersion,a=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:s,envId:a,expiredTs:e}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}})})},this.getWaitExpectedTimeoutLength=function(){return t.rttObserved.length?t.rttObserved.reduce(function(e,t){return e+t})/t.rttObserved.length*1.5:5e3},this.ping=function(){return o(t,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:(0,a.genRequestId)(),msgType:"PING",msgData:null},[4,this.send({msg:e})];case 1:return t.sent(),[2]}})})},this.onWatchStart=function(e,n){t.queryIdClientMap.set(n,e)},this.onWatchClose=function(e,n){n&&t.queryIdClientMap.delete(n),t.watchIdClientMap.delete(e.watchId),t.virtualWSClient.delete(e),t.virtualWSClient.size||t.close(c.CloseEventCode.NoRealtimeListeners)},this.maxReconnect=e.maxReconnect||5,this.reconnectInterval=e.reconnectInterval||1e4,this.context=e.context}return e.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},e.prototype.close=function(e){this.clearHeartbeat(),this.ws&&(this.ws.close(e,c.CLOSE_EVENT_CODE_INFO[e].name),this.ws=void 0)},e.prototype.watch=function(e){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var t=new s.VirtualWebSocketClient(r(r({},e),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this.virtualWSClient.add(t),this.watchIdClientMap.set(t.watchId,t),t.listener},e.prototype.heartbeat=function(e){var t=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout(function(){o(t,void 0,void 0,function(){var e=this;return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.ws&&1===this.ws.readyState?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return t.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout(function(){console.error("pong timed out"),e.pongMissed<2?(e.pongMissed+=1,e.heartbeat(!0)):e.initWebSocketConnection(!0)},this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(c.CloseEventCode.HeartbeatPingError),[3,3];case 3:return[2]}})})},e?0:this.context.appConfig.realtimePingInterval)},e}();t.RealtimeWebSocketClient=d},636:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWSCloseError=t.CloseEventCode=t.CLOSE_EVENT_CODE_INFO=void 0;var r,o=n(2917);t.CLOSE_EVENT_CODE_INFO={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}},(r=t.CloseEventCode||(t.CloseEventCode={}))[r.NormalClosure=1e3]="NormalClosure",r[r.GoingAway=1001]="GoingAway",r[r.ProtocolError=1002]="ProtocolError",r[r.UnsupportedData=1003]="UnsupportedData",r[r.NoStatusReceived=1005]="NoStatusReceived",r[r.AbnormalClosure=1006]="AbnormalClosure",r[r.InvalidFramePayloadData=1007]="InvalidFramePayloadData",r[r.PolicyViolation=1008]="PolicyViolation",r[r.MessageTooBig=1009]="MessageTooBig",r[r.MissingExtension=1010]="MissingExtension",r[r.InternalError=1011]="InternalError",r[r.ServiceRestart=1012]="ServiceRestart",r[r.TryAgainLater=1013]="TryAgainLater",r[r.BadGateway=1014]="BadGateway",r[r.TLSHandshake=1015]="TLSHandshake",r[r.ReconnectWebSocket=3e3]="ReconnectWebSocket",r[r.NoRealtimeListeners=3001]="NoRealtimeListeners",r[r.HeartbeatPingError=3002]="HeartbeatPingError",r[r.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",r[r.NoAuthentication=3050]="NoAuthentication",t.getWSCloseError=function(e,n){var r=t.CLOSE_EVENT_CODE_INFO[e],i=r?"".concat(r.name,", code ").concat(e,", reason ").concat(n||r.description):"code ".concat(e);return new o.CloudSDKError({errCode:o.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:i})}},5891:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseStorage=t.isValidTempUrlMaxAge=t.TEMP_URL_MAX_AGE_MAX=t.TEMP_URL_MAX_AGE_MIN=t.COMPONENT_NAME=t.EUploadMethod=void 0;var c,u=n(2877),l=n(7090),h=n(3388);!function(e){e.put="put",e.post="post"}(c=t.EUploadMethod||(t.EUploadMethod={}));var d=u.constants.getSdkName,f=u.constants.ERRORS,p=u.constants.COMMUNITY_SITE_URL,v=u.utils.isArray,y=u.utils.isString,g=u.utils.isPalinObject,m=u.utils.execCallback,b=u.utils.maybeThrow,_=u.utils.printWarn,E=u.helpers.catchErrorsDecorator;function w(e,t){return t&&"function"!=typeof t?[r(r({},e),{customReqOpts:t}),void 0]:[e,t]}t.COMPONENT_NAME="storage";var S=function(e,t,n){return s(void 0,void 0,void 0,function(){var o,i,s;return a(this,function(a){switch(a.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-upload-info",data:[r({objectId:t.path},t.signedHeader?{signedHeader:t.signedHeader}:{})]},n)];case 1:return o=a.sent(),o=u.utils.promoteGatewayError(o),i=(null===(s=o.data)||void 0===s?void 0:s[0])||{},[2,r(r({},o),{data:r(r({},i.code?r({},i):{}),{authorization:i.authorization,token:i.token,url:i.uploadUrl,fileId:i.cloudObjectId,cosFileId:i.cloudObjectMeta,download_url:i.downloadUrl})})]}})})},I=function(e,t,n){return s(void 0,void 0,void 0,function(){var o;return a(this,function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-download-info",data:t.convertedFileList.map(function(e){return r({cloudObjectId:e.fileid},null!=e.max_age?{maxAge:e.max_age}:{})})},n)];case 1:return o=i.sent(),o=u.utils.promoteGatewayError(o),[2,r(r({},o),{data:{download_list:Array.isArray(o.data)?o.data.map(function(e){return{code:e.code||"SUCCESS",message:e.message,fileid:e.cloudObjectId,download_url:e.downloadUrl,fileID:e.cloudObjectId,tempFileURL:e.downloadUrl,mime_type:e.contentType||P(null,e.cloudObjectId||"")}}):[]}})]}})})},O=function(e,t,n){return s(void 0,void 0,void 0,function(){var o;return a(this,function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"delete-objects",data:t.fileList.map(function(e){return{cloudObjectId:e}})},n)];case 1:return o=i.sent(),o=u.utils.promoteGatewayError(o),[2,r(r({},o),{data:{delete_list:Array.isArray(o.data)?o.data.map(function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,message:e.message}}):[]}})]}})})},A=function(e,t,n){return s(void 0,void 0,void 0,function(){var o;return a(this,function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"copy-objects",data:t.convertedFileList.map(function(e){return{srcPath:e.src_path,dstPath:e.dst_path,overwrite:e.overwrite,removeOriginal:e.remove_original}})},n)];case 1:return o=i.sent(),o=u.utils.promoteGatewayError(o),[2,r(r({},o),{data:{copy_list:Array.isArray(o.data)?o.data.map(function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,fileId:e.cloudObjectId,message:e.message}}):[]}})]}})})},T={txt:"text/plain",json:"application/json",html:"text/html",htm:"text/html",css:"text/css",js:"application/javascript",csv:"text/csv",xml:"application/xml",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",pdf:"application/pdf",zip:"application/zip",gz:"application/gzip",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav"};function P(e,t){if("undefined"!=typeof Blob&&e instanceof Blob&&e.type)return e.type;var n=/\.([a-zA-Z0-9]+)$/.exec(t||""),r=n?n[1].toLowerCase():"";return T[r]||"application/octet-stream"}function C(){var e=globalThis.wx;return"function"==typeof(null==e?void 0:e.getFileSystemManager)}function R(e,t){var n=t.toLowerCase();return Object.keys(e).some(function(e){return e.toLowerCase()===n})}function N(e){return Object.keys(e).reduce(function(t,n){var o;return r(r({},t),((o={})[n]=[e[n]],o))},{})}function k(e){return"number"==typeof e&&Number.isInteger(e)&&e>=t.TEMP_URL_MAX_AGE_MIN}t.TEMP_URL_MAX_AGE_MIN=1,t.TEMP_URL_MAX_AGE_MAX=3600,t.isValidTempUrlMaxAge=k,t.CloudbaseStorage=function(){function e(e){this.context=e}var n,u,T,U,D,L,j,x,M,q,F,B,W,H,G,V,K;return Object.defineProperty(e.prototype,"config",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.request},enumerable:!1,configurable:!0}),e.prototype.isGateWay=function(){return"GATEWAY"===(this.config.endPointMode||"CLOUD_API")},e.prototype.uploadFile=function(e,n){var o,i;return s(this,void 0,Promise,function(){var s,u,h,p,v,g,_,E,S,I,O,A,T,k,U,D,L,j,x,M,q,F,B,W,H,G,V,K,J,Y,z,$,Q,X;return a(this,function(a){switch(a.label){case 0:if(z=w(e,n),e=z[0],n=z[1],s=e.cloudPath,u=e.filePath,h=e.onUploadProgress,$=e.method,p=void 0===$?"put":$,Q=e.headers,v=void 0===Q?{}:Q,g=e.fileContent,!y(s)||!u&&!g)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".uploadFile] invalid params")})];if(u&&g&&console.warn("[".concat(d(),"][").concat(t.COMPONENT_NAME,".uploadFile] fileContent 是兼容字段,与 filePath 同时传入时忽略,实际使用 filePath")),_=null!=u?u:g,(E={put:c.put,post:c.post}[p.toLocaleLowerCase()]||c.put)===c.post&&console.warn("[".concat(d(),"][").concat(t.COMPONENT_NAME,".uploadFile] method: 'post' 已废弃,请改用 'put'")),S=this.isGateWay(),I=r({},v),O=Object.keys(v).reduce(function(e,t){return"content-length"!==t.toLowerCase()&&(e[t]=v[t]),e},{}),E===c.put&&S){if(!R(I,"content-length")){if(A=null===(i=null===(o=this.request)||void 0===o?void 0:o.getUploadByteLength)||void 0===i?void 0:i.call(o,_),T="number"==typeof A?A:function(e){if((!C()||"string"!=typeof e)&&null!==e){if("undefined"!=typeof Blob&&e instanceof Blob)return e.size;if("undefined"!=typeof ArrayBuffer){if(e instanceof ArrayBuffer)return e.byteLength;if("function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e))return e.byteLength}if("string"==typeof e){if("undefined"!=typeof Blob)return new Blob([e]).size;var t=(0,l.getStringByteLength)(e);return"number"==typeof t?t:e.length}return"object"==typeof e&&"number"==typeof e.size?e.size:void 0}}(_),"number"!=typeof T)return[2,b(this.config,{code:f.INVALID_PARAMS,message:C()?"[".concat(t.COMPONENT_NAME,".uploadFile] 无法计算 content-length,请确认上传内容为有效的本地临时路径,或传入 ArrayBuffer"):"[".concat(t.COMPONENT_NAME,".uploadFile] 无法计算 content-length,请传入 File/Blob/Buffer/ArrayBuffer,或在 headers 中提供 content-length")})];I["content-length"]=String(T)}R(I,"content-type")||(I["content-type"]=P(_,s)),R(O,"content-type")||(O["content-type"]=P(_,s))}return[4,this.getUploadMetadata({cloudPath:s,method:E,headers:E!==c.put||S?void 0:O,signedHeader:E===c.put&&S?N(I):void 0,customReqOpts:e.customReqOpts})];case 1:return k=a.sent(),U=k.data,D=k.requestId,(null==(L=U)?void 0:L.code)||!(null==L?void 0:L.url)?(j=(null==L?void 0:L.code)||f.OPERATION_FAIL,x=(null==L?void 0:L.message)||"get upload info failed",[2,m(n,new Error("[".concat(d(),"][").concat(j,"][").concat(t.COMPONENT_NAME,"]:").concat(x)))]):(M=U.url,q=U.authorization,F=U.token,B=U.fileId,W=U.cosFileId,H=U.download_url,V=r(r({},G={url:M,file:_,name:s,onUploadProgress:h,fileId:B,requestId:D}),{method:c.put,headers:r(r({},O),{authorization:q,"x-cos-meta-fileid":W,"x-cos-security-token":F})}),K=r(r({},G),{method:c.post,data:{key:s,signature:q,"x-cos-meta-fileid":W,success_action_status:"201","x-cos-security-token":F}}),(X={})[c.put]={params:V,isSuccess:function(e){return e>=200&&e<300}},X[c.post]={params:K,isSuccess:function(e){return 201===e}},J=X,[4,this.request.upload(J[E].params)]);case 2:return Y=a.sent(),J[E].isSuccess(Y.statusCode)?[2,m(n,null,{fileID:B,download_url:H,requestId:D})]:[2,m(n,new Error("[".concat(d(),"][").concat(f.OPERATION_FAIL,"][").concat(t.COMPONENT_NAME,"]:").concat(Y.data)))]}})})},e.prototype.getUploadMetadata=function(e,n){return s(this,void 0,Promise,function(){var r,o,i,s,u,l,h,d,p,v;return a(this,function(a){switch(a.label){case 0:if(r=e.cloudPath,o=e.method,i=e.headers,s=e.signedHeader,!y(r))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getUploadMetadata] invalid cloudPath")})];u=this.request,l="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,6,,7]),h=void 0,d={path:r},p=this.isGateWay(),o&&(d.method=o),o===c.put&&(p&&s?d.signedHeader=s:!p&&i&&(d.headers=i)),o!==c.post&&p?[3,3]:[4,u.send(l,d,{endPointMode:"CLOUD_API"},e.customReqOpts)];case 2:return h=a.sent(),[3,5];case 3:return[4,S(u,d,e.customReqOpts)];case 4:h=a.sent(),a.label=5;case 5:return[2,m(n,null,h)];case 6:return v=a.sent(),[2,m(n,v)];case 7:return[2]}})})},e.prototype.deleteFile=function(e,n){return s(this,void 0,Promise,function(){var r,o,i,s,c,u,l,h,d;return a(this,function(a){switch(a.label){case 0:if(d=w(e,n),e=d[0],n=d[1],!(r=e.fileList)||!v(r)||0===r.length)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".deleteFile] fileList must not be empty")})];for(o=0,i=r;o<i.length;o++)if(!(s=i[o])||!y(s))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".deleteFile] fileID must be string")})];return c="storage.batchDeleteFile",u=this.request,l={},this.isGateWay()?[4,O(u,{fileList:r},e.customReqOpts)]:[3,2];case 1:return l=a.sent(),[3,4];case 2:return[4,u.send(c,{fileid_list:r},e.customReqOpts)];case 3:l=a.sent(),a.label=4;case 4:return l.code?[2,m(n,null,l)]:(h={fileList:l.data.delete_list,requestId:l.requestId},[2,m(n,null,h)])}})})},e.prototype.getTempFileURL=function(e,n){var r;return s(this,void 0,Promise,function(){var o,i,s,c,u,l,h,d,p,E,S,O;return a(this,function(a){switch(a.label){case 0:if(O=w(e,n),e=O[0],n=O[1],!(o=e.fileList)||!v(o)||0===o.length)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] fileList must not be empty")})];for(i=[],s=!1,c=0,u=o;c<u.length;c++)if(l=u[c],g(l)){if(!Object.prototype.hasOwnProperty.call(l,"fileID"))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] file info must include fileID")})];if(h={fileid:l.fileID},Object.prototype.hasOwnProperty.call(l,"maxAge")){if(!k(d=l.maxAge))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] maxAge must be an integer greater than or equal to ").concat(t.TEMP_URL_MAX_AGE_MIN)})];d>t.TEMP_URL_MAX_AGE_MAX&&!s&&(_(f.INVALID_PARAMS,"[".concat(t.COMPONENT_NAME,".getTempFileURL] maxAge ").concat(d," 大于 ").concat(t.TEMP_URL_MAX_AGE_MAX,",仍按原值下发")),s=!0),h.max_age=d}i.push(h)}else{if(!y(l))return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] invalid fileList")})];i.push({fileid:l})}return p="storage.batchGetDownloadUrl",E=this.request,S={},this.isGateWay()?[4,I(E,{convertedFileList:i},e.customReqOpts)]:[3,2];case 1:return S=a.sent(),[3,4];case 2:return[4,E.send(p,{file_list:i},e.customReqOpts)];case 3:S=a.sent(),a.label=4;case 4:return S.code?[2,m(n,null,S)]:[2,m(n,null,{fileList:Array.isArray(null===(r=S.data)||void 0===r?void 0:r.download_list)?S.data.download_list:[],requestId:S.requestId})]}})})},e.prototype.downloadFile=function(e,n){return s(this,void 0,Promise,function(){var r,o,i,s,c,u,l;return a(this,function(a){switch(a.label){case 0:return l=w(e,n),e=l[0],n=l[1],r=e.fileID,y(r)?[4,this.getTempFileURL.call(this,{fileList:[{fileID:r,maxAge:600}],customReqOpts:e.customReqOpts})]:[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".getTempFileURL] fileID must be string")})];case 1:return o=a.sent(),"SUCCESS"!==(i=o.fileList[0]).code?[2,m(n,i)]:(s=this.request,c=encodeURI(i.download_url),[4,s.download({url:c,tempFilePath:e.tempFilePath})]);case 2:return u=a.sent(),[2,m(n,null,u)]}})})},e.prototype.copyFile=function(e,n){return s(this,void 0,Promise,function(){var r,o,i,s,c,u,l,h,d,p;return a(this,function(a){switch(a.label){case 0:if(p=w(e,n),e=p[0],n=p[1],!(r=e.fileList)||!v(r)||0===r.length)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".copyFile] fileList must not be empty")})];for(o=[],i=0,s=r;i<s.length;i++){if(c=s[i],u=c.srcPath,l=c.dstPath,!u||!l||"string"!=typeof u||"string"!=typeof l)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".copyFile] srcPath and dstPath may not be empty")})];if(u===l)return[2,b(this.config,{code:f.INVALID_PARAMS,message:"[".concat(t.COMPONENT_NAME,".copyFile] srcPath and dstPath can not be the same")})];o.push({src_path:u,dst_path:l,overwrite:c.overwrite,remove_original:c.removeOriginal})}return h=this.request,d={},this.isGateWay()?[4,A(h,{convertedFileList:o},e.customReqOpts)]:[3,2];case 1:return d=a.sent(),[3,4];case 2:return[4,h.send("storage.batchCopyFile",{file_list:o},e.customReqOpts)];case 3:d=a.sent(),a.label=4;case 4:return d.code?[2,m(n,null,d)]:[2,m(n,null,{fileList:d.data.copy_list,requestId:d.requestId})]}})})},e.prototype.getFileInfo=function(e){var t;return s(this,void 0,Promise,function(){var n,r=this;return a(this,function(o){switch(o.label){case 0:return[4,this.getTempFileURL(e)];case 1:return(null==(n=o.sent())?void 0:n.fileList)&&(null===(t=null==n?void 0:n.fileList)||void 0===t?void 0:t.length)>0?[4,Promise.all(n.fileList.map(function(e){return s(r,void 0,void 0,function(){var t,n,r,o,i,s,c;return a(this,function(a){switch(a.label){case 0:if("SUCCESS"!==e.code)return[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,message:e.message}];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.request.fetch({url:e.tempFileURL,method:"HEAD"})];case 2:return t=a.sent(),n=t.header,"undefined"!=typeof Headers&&n instanceof Headers&&(r={},n.forEach(function(e,t){r[t]=e}),n=r),o=parseInt(n["content-length"])||0,i=n["content-type"]||"",[400,404].includes(Number(t.statusCode))?[2,{code:"FILE_NOT_FOUND",fileID:e.fileID,tempFileURL:e.tempFileURL,message:"file not found"}]:[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,cloudId:e.fileID,fileName:e.fileID.split("/").pop(),contentType:i,mime:i.split(";")[0].trim(),size:o,etag:n.etag||"",lastModified:n["last-modified"]||"",cacheControl:n["cache-control"]||""}];case 3:return s=a.sent(),c="object"==typeof s&&null!==s&&"message"in s?String(s.message):void 0,[2,{code:"FETCH_FILE_INFO_ERROR",fileID:e.fileID,tempFileURL:e.tempFileURL,message:c}];case 4:return[2]}})})}))]:[3,3];case 2:return[2,{fileList:o.sent(),requestId:n.requestId}];case 3:return[2,{fileList:[],requestId:n.requestId}]}})})},o([E({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(n=void 0!==h.ICloudbaseUploadFileParams&&h.ICloudbaseUploadFileParams)?n:Object,"function"==typeof(u="undefined"!=typeof Function&&Function)?u:Object]),i("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],e.prototype,"uploadFile",null),o([E({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",[Object,"function"==typeof(U="undefined"!=typeof Function&&Function)?U:Object]),i("design:returntype","function"==typeof(D="undefined"!=typeof Promise&&Promise)?D:Object)],e.prototype,"getUploadMetadata",null),o([E({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(L=void 0!==h.ICloudbaseDeleteFileParams&&h.ICloudbaseDeleteFileParams)?L:Object,"function"==typeof(j="undefined"!=typeof Function&&Function)?j:Object]),i("design:returntype","function"==typeof(x="undefined"!=typeof Promise&&Promise)?x:Object)],e.prototype,"deleteFile",null),o([E({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(M=void 0!==h.ICloudbaseGetTempFileURLParams&&h.ICloudbaseGetTempFileURLParams)?M:Object,"function"==typeof(q="undefined"!=typeof Function&&Function)?q:Object]),i("design:returntype","function"==typeof(F="undefined"!=typeof Promise&&Promise)?F:Object)],e.prototype,"getTempFileURL",null),o([E({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(B=void 0!==h.ICloudbaseDownloadFileParams&&h.ICloudbaseDownloadFileParams)?B:Object,"function"==typeof(W="undefined"!=typeof Function&&Function)?W:Object]),i("design:returntype","function"==typeof(H="undefined"!=typeof Promise&&Promise)?H:Object)],e.prototype,"downloadFile",null),o([E({customInfo:{className:"Cloudbase",methodName:"copyFile"},title:"批量复制文件",messages:["请确认以下各项:"," 1 - 调用 copyFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(G=void 0!==h.ICloudbaseCopyFileParams&&h.ICloudbaseCopyFileParams)?G:Object,"function"==typeof(V="undefined"!=typeof Function&&Function)?V:Object]),i("design:returntype","function"==typeof(K="undefined"!=typeof Promise&&Promise)?K:Object)],e.prototype,"copyFile",null),e}()},9656:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DownloadBuilder=t.StreamDownloadBuilder=void 0;var s=n(7957),a=n(7090);function c(e){return(0,s.isStorageError)(e)?e:new s.StorageError((null==e?void 0:e.message)||String(e))}function u(e){var t={};return void 0!==(null==e?void 0:e.download)&&(t.download=!0===e.download?"":e.download),void 0!==(null==e?void 0:e.cacheNonce)&&(t.cacheNonce=String(e.cacheNonce)),{headers:{},query:t}}var l=function(){function e(e){this.ctx=e}return e.prototype.then=function(e,t){return this.execute().then(e,t)},e.prototype.execute=function(){var e,t;return o(this,void 0,Promise,function(){var n,o,l,h,d;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=u(this.ctx.options),o=n.headers,l=n.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,a.encodeObjectName)(this.ctx.cleanName)),headers:r(r({},this.ctx.headers),o),query:l,signal:null===(e=this.ctx.parameters)||void 0===e?void 0:e.signal,cache:null===(t=this.ctx.parameters)||void 0===t?void 0:t.cache})];case 1:if(!(h=i.sent().response).body)throw new s.StorageApiError("Response body is empty",h.status,"STORAGE_PG_EMPTY_BODY");return[2,{data:h.body,error:null}];case 2:if(d=i.sent(),this.ctx.shouldThrowOnError)throw d;return[2,{data:null,error:c(d)}];case 3:return[2]}})})},e}();t.StreamDownloadBuilder=l;var h=function(){function e(e){this.ctx=e}return e.prototype.asStream=function(){return new l(this.ctx)},e.prototype.then=function(e,t){return this.execute().then(e,t)},e.prototype.execute=function(){var e,t;return o(this,void 0,Promise,function(){var n,o,s,l,h,d;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),n=u(this.ctx.options),o=n.headers,s=n.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,a.encodeObjectName)(this.ctx.cleanName)),headers:r(r({},this.ctx.headers),o),query:s,signal:null===(e=this.ctx.parameters)||void 0===e?void 0:e.signal,cache:null===(t=this.ctx.parameters)||void 0===t?void 0:t.cache})];case 1:return l=i.sent().response,d={},[4,l.blob()];case 2:return[2,(d.data=i.sent(),d.error=null,d)];case 3:if(h=i.sent(),this.ctx.shouldThrowOnError)throw h;return[2,{data:null,error:c(h)}];case 4:return[2]}})})},e}();t.DownloadBuilder=h},7090:function(e,t){"use strict";function n(){return globalThis.Buffer}Object.defineProperty(t,"__esModule",{value:!0}),t.encodeObjectName=t.toBase64=t.getStringByteLength=void 0,t.getStringByteLength=function(e){var t;return null===(t=n())||void 0===t?void 0:t.byteLength(e)},t.toBase64=function(e){var t=n();return t?t.from(e).toString("base64"):btoa(e)},t.encodeObjectName=function(e){return e.split("/").map(function(e){return encodeURIComponent(e)}).join("/")}},5098:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Http=t.handleOperation=void 0;var s=n(7957),a="/v1/storages";t.handleOperation=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e()];case 1:return[2,{data:r.sent(),error:null}];case 2:if(n=r.sent(),t)throw n;return(0,s.isStorageError)(n)?[2,{data:null,error:n}]:[2,{data:null,error:new s.StorageError((null==n?void 0:n.message)||String(n))}];case 3:return[2]}})})};var c=function(){function e(e){this.ctx=e}return Object.defineProperty(e.prototype,"request",{get:function(){return this.ctx.request},enumerable:!1,configurable:!0}),e.prototype.gatewayOrigin=function(){return this.request.getBaseEndPoint("GATEWAY")},e.prototype.buildUrl=function(e,t){var n="".concat(this.gatewayOrigin()).concat(a).concat(e),r=function(e){if(!e)return"";var t=[];return Object.keys(e).forEach(function(n){var r=e[n];null!=r&&t.push("".concat(encodeURIComponent(n),"=").concat(encodeURIComponent(String(r))))}),t.join("&")}(t);return r&&(n+=(n.includes("?")?"&":"?")+r),n},e.prototype.toFullUrl=function(e){return e?/^https?:\/\//.test(e)||e.startsWith("//")?e:"".concat(this.gatewayOrigin()).concat(a).concat(e.startsWith("/")?"":"/").concat(e):e},e.prototype.send=function(e){return o(this,void 0,Promise,function(){var t,n,o,s,a,c;return i(this,function(i){switch(i.label){case 0:return t=this.buildUrl(e.path,e.query),n=e.method.toUpperCase(),o=["GET","HEAD"].includes(n),s=r({},e.headers||{}),o||(void 0!==e.rawBody?a=e.rawBody:void 0!==e.json&&(s["Content-Type"]=s["Content-Type"]||"application/json",a=JSON.stringify(e.json))),[4,this.request.fetch(r(r(r(r({url:t,method:n,headers:s},void 0!==a?{body:a}:{}),{withCredentials:!1!==e.withCredentials,shouldThrowOnError:!1}),e.signal?{signal:e.signal}:{}),e.cache?{cache:e.cache}:{}))];case 1:return c=i.sent(),[2,this.unwrap(c,t)]}})})},e.prototype.download=function(e){var t,n;return o(this,void 0,Promise,function(){var o,a,c,u;return i(this,function(i){switch(i.label){case 0:return o=this.buildUrl(e.path,e.query),[4,this.request.fetch(r(r({url:o,method:"GET",headers:r({},e.headers||{}),stream:!0,withCredentials:!1!==e.withCredentials,shouldThrowOnError:!1},e.signal?{signal:e.signal}:{}),e.cache?{cache:e.cache}:{}))];case 1:if(a=i.sent(),null===(t=e.signal)||void 0===t?void 0:t.aborted)throw new s.StorageApiError("The download was aborted",0,"STORAGE_PG_ABORTED");if(304===(c=Number(null!==(n=null==a?void 0:a.statusCode)&&void 0!==n?n:200)))throw new s.StorageApiError("Not Modified",c,"STORAGE_PG_NOT_MODIFIED");if(c>=400)throw new s.StorageApiError("Download failed with status ".concat(c),c,"STORAGE_PG_REQUEST_FAIL");if(!(u=null==a?void 0:a.response))throw new s.StorageApiError("Underlying adapter did not expose the raw Response",c,"STORAGE_PG_NO_RESPONSE");return[2,{response:u,status:c,header:null==a?void 0:a.header}]}})})},e.prototype.unwrap=function(e,t){var n,r;return o(this,void 0,Promise,function(){var o,a,c,u;return i(this,function(i){switch(i.label){case 0:o=Number(null!==(r=null!==(n=null==e?void 0:e.statusCode)&&void 0!==n?n:null==e?void 0:e.status)&&void 0!==r?r:200),a=null==e?void 0:e.data,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,a];case 2:return a=i.sent(),[3,4];case 3:return i.sent(),a=void 0,[3,4];case 4:if(o>=200&&o<300)return[2,a];throw c=(null==a?void 0:a.code)||(null==a?void 0:a.error)||"STORAGE_PG_REQUEST_FAIL",u=(null==a?void 0:a.message)||"Storage request failed with status ".concat(o,": ").concat(t),new s.StorageApiError(u,o,c)}})})},e}();t.Http=c},3456:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.registerStorage=t.StorageClient=t.StorageFileApi=t.ClassicStorageFileApi=t.CloudbaseStorage=t.COMPONENT_NAME=void 0;var i=n(1502),s=n(2014),a=n(5504),c=n(5891),u=n(3077),l=n(5891);Object.defineProperty(t,"COMPONENT_NAME",{enumerable:!0,get:function(){return l.COMPONENT_NAME}}),Object.defineProperty(t,"CloudbaseStorage",{enumerable:!0,get:function(){return l.CloudbaseStorage}});var h=n(3077);Object.defineProperty(t,"ClassicStorageFileApi",{enumerable:!0,get:function(){return h.ClassicStorageFileApi}});var d=n(1502);Object.defineProperty(t,"StorageFileApi",{enumerable:!0,get:function(){return d.StorageFileApi}});var f=new c.CloudbaseStorage,p={name:c.COMPONENT_NAME,entity:{uploadFile:f.uploadFile,deleteFile:f.deleteFile,getTempFileURL:f.getTempFileURL,downloadFile:f.downloadFile,getUploadMetadata:f.getUploadMetadata,copyFile:f.copyFile,getFileInfo:f.getFileInfo,isGateWay:f.isGateWay}},v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.from=function(e){return e?((0,a.assertValidBucketId)(e,"from"),new i.StorageFileApi(this.http,e,this.shouldThrowOnError)):new u.ClassicStorageFileApi(this.http.ctx,this.shouldThrowOnError)},t}(s.StorageBucketApi);t.StorageClient=v;var y={name:"".concat(c.COMPONENT_NAME,"/supabase"),IIFE:!0,entity:function(){var e=new WeakMap;Object.defineProperty(this.prototype,"storage",{get:function(){if(e.has(this))return e.get(this);var t=this,n=new Proxy({},{get:function(e,n){return"config"===n?t.config:"request"===n?t.request:void 0}}),r=new v(n);return e.set(this,r),r},configurable:!0,enumerable:!0})}};try{cloudbase.registerComponent(p),cloudbase.registerComponent(y)}catch(e){}function g(e){try{e.registerComponent(p),e.registerComponent(y)}catch(e){console.warn(e)}}t.registerStorage=g;try{window.registerStorage=g}catch(e){}},2014:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.StorageBucketApi=void 0;var i=n(5098),s=n(5504),a=function(){function e(e,t){void 0===t&&(t=!1),this.http=new i.Http(e),this.shouldThrowOnError=t}return e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.listBuckets=function(e){return r(this,void 0,Promise,function(){var t=this;return o(this,function(n){return[2,(0,i.handleOperation)(function(){var n={};return void 0!==(null==e?void 0:e.limit)&&(n.limit=e.limit),void 0!==(null==e?void 0:e.offset)&&(n.offset=e.offset),(null==e?void 0:e.sortColumn)&&(n.sortColumn=e.sortColumn),(null==e?void 0:e.sortOrder)&&(n.sortOrder=e.sortOrder),(null==e?void 0:e.search)&&(n.search=e.search),t.http.send({method:"GET",path:"/bucket/",query:n})},this.shouldThrowOnError)]})})},e.prototype.getBucket=function(e){return r(this,void 0,Promise,function(){var t=this;return o(this,function(n){return[2,(0,i.handleOperation)(function(){return(0,s.assertValidBucketId)(e,"getBucket"),t.http.send({method:"GET",path:"/bucket/".concat(e)})},this.shouldThrowOnError)]})})},e.prototype.createBucket=function(e,t){return r(this,void 0,Promise,function(){var n=this;return o(this,function(r){return[2,(0,i.handleOperation)(function(){var r;return(0,s.assertValidBucketId)(e,"createBucket"),n.http.send({method:"POST",path:"/bucket/",json:{id:e,name:e,public:null!==(r=null==t?void 0:t.public)&&void 0!==r&&r,type:null==t?void 0:t.type,file_size_limit:null==t?void 0:t.fileSizeLimit,allowed_mime_types:null==t?void 0:t.allowedMimeTypes}})},this.shouldThrowOnError)]})})},e.prototype.updateBucket=function(e,t){return r(this,void 0,Promise,function(){var n=this;return o(this,function(r){return[2,(0,i.handleOperation)(function(){return(0,s.assertValidBucketId)(e,"updateBucket"),n.http.send({method:"PUT",path:"/bucket/".concat(e),json:{public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes}})},this.shouldThrowOnError)]})})},e.prototype.deleteBucket=function(e){return r(this,void 0,Promise,function(){var t=this;return o(this,function(n){return[2,(0,i.handleOperation)(function(){return(0,s.assertValidBucketId)(e,"deleteBucket"),t.http.send({method:"DELETE",path:"/bucket/".concat(e)})},this.shouldThrowOnError)]})})},e}();t.StorageBucketApi=a},3077:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ClassicStorageFileApi=void 0;var s=n(2877),a=n(7957),c=n(5891),u=n(7090),l=s.constants.ERRORS,h=function(){function e(e,t){void 0===t&&(t=!1),this.shouldThrowOnError=!1,this.bucketId="",this.context=e,this.shouldThrowOnError=t,this.storage=new c.CloudbaseStorage(e)}return Object.defineProperty(e.prototype,"config",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.request},enumerable:!1,configurable:!0}),e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.upload=function(e,t,n){return o(this,void 0,Promise,function(){var o,s,u,h,d,f,p,v,y;return i(this,function(i){switch(i.label){case 0:o=r({upsert:!0},n),s=o.cacheControl,u=o.contentType,h=o.metadata,i.label=1;case 1:return i.trys.push([1,3,,4]),d=this.getCloudPath(e),f={cloudPath:d,filePath:t},(s||u||h)&&(p={},s&&(p["cache-control"]=s),u&&(p["content-type"]=u),h&&(p["x-cos-metadata-metadata"]=this.toBase64(JSON.stringify(h))),f.headers=p),[4,this.storage.uploadFile(f)];case 2:if(!(v=i.sent()).fileID)throw new Error(JSON.stringify({code:l.OPERATION_FAIL,msg:"[".concat(c.COMPONENT_NAME,".update] no fileID returned")}));return[2,{data:{id:v.fileID,path:e,fullPath:e},error:null}];case 3:if(y=i.sent(),this.shouldThrowOnError)throw y;if((0,a.isStorageError)(y))return[2,{data:null,error:y}];throw y;case 4:return[2]}})})},e.prototype.uploadToSignedUrl=function(e,t,n,r){return o(this,void 0,Promise,function(){return i(this,function(t){return[2,this.upload(e,n,r)]})})},e.prototype.createSignedUploadUrl=function(e){return o(this,void 0,Promise,function(){var t,n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this.getCloudPath(e),[4,this.storage.getUploadMetadata({cloudPath:t})];case 1:return[2,{data:{signedUrl:(n=o.sent().data).url,token:n.token,path:e,authorization:n.authorization,id:n.fileId,cosFileId:n.cosFileId,downloadUrl:n.download_url},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;return[2,{data:null,error:r instanceof a.StorageError?r:new a.StorageError(r.message)}];case 3:return[2]}})})},e.prototype.update=function(e,t,n){return o(this,void 0,Promise,function(){return i(this,function(o){return[2,this.upload(e,t,r(r({},n),{upsert:!0}))]})})},e.prototype.move=function(e,t){return o(this,void 0,Promise,function(){var n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(e),dstPath:this.getCloudPath(t),overwrite:!0,removeOriginal:!0}]})];case 1:if((n=o.sent()).fileList[0].code&&"SUCCESS"!==n.fileList[0].code)throw new a.StorageError(n.fileList[0].message||"Move failed");return[2,{data:{message:"File moved from ".concat(e," to ").concat(t)},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}})})},e.prototype.copy=function(e,t){return o(this,void 0,Promise,function(){var n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(e),dstPath:this.getCloudPath(t),overwrite:!0,removeOriginal:!1}]})];case 1:if((n=o.sent()).fileList[0].code&&"SUCCESS"!==n.fileList[0].code)throw new a.StorageError(n.fileList[0].message||"Copy failed");return[2,{data:{path:this.getCloudPath(t)},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}})})},e.prototype.createSignedUrl=function(e,t,n){return o(this,void 0,Promise,function(){var r,o,s,u,l,h,d;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,2,,3]),!(0,c.isValidTempUrlMaxAge)(t))throw new a.StorageError("[".concat(c.COMPONENT_NAME,".createSignedUrl] expiresIn must be an integer greater than or equal to ").concat(c.TEMP_URL_MAX_AGE_MIN));return r=this.normalizeCloudId(e),[4,this.storage.getTempFileURL({fileList:[{fileID:r,maxAge:t}]})];case 1:if("SUCCESS"!==(o=i.sent()).fileList[0].code)throw new a.StorageError("Failed to create signed URL: [".concat(o.fileList[0].code,"] ").concat(o.fileList[0].fileID));return s=o.fileList[0].download_url,u=[],void 0!==(null==n?void 0:n.download)&&("string"==typeof n.download?u.push("download=".concat(encodeURIComponent(n.download))):!0===n.download&&u.push("download=true")),(null==n?void 0:n.transform)&&(l=this.transformOptsToQueryString(n.transform))&&u.push(l),u.length>0&&(h=s.includes("?")?"&":"?",s="".concat(s).concat(h).concat(u.join("&"))),[2,{data:{signedUrl:s},error:null}];case 2:if(d=i.sent(),this.shouldThrowOnError)throw d;if((0,a.isStorageError)(d))return[2,{data:null,error:d}];throw d;case 3:return[2]}})})},e.prototype.createSignedUrls=function(e,t){return o(this,void 0,Promise,function(){var n,r,o=this;return i(this,function(i){switch(i.label){case 0:if(i.trys.push([0,2,,3]),!(0,c.isValidTempUrlMaxAge)(t))throw new a.StorageError("[".concat(c.COMPONENT_NAME,".createSignedUrls] expiresIn must be an integer greater than or equal to ").concat(c.TEMP_URL_MAX_AGE_MIN));return n=e.map(function(e){return{fileID:o.normalizeCloudId(e),maxAge:t}}),[4,this.storage.getTempFileURL({fileList:n})];case 1:return[2,{data:i.sent().fileList.map(function(t,n){return{path:e[n],signedUrl:t.tempFileURL||"",error:"SUCCESS"===t.code?null:t.message}}),error:null}];case 2:if(r=i.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}})})},e.prototype.download=function(e,t){return o(this,void 0,Promise,function(){var n,r,s=this;return i(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),r={},[4,o(s,void 0,void 0,function(){var n,r,o,s;return i(this,function(i){switch(i.label){case 0:return[4,this.createSignedUrl(e,600,{transform:t})];case 1:if((n=i.sent()).error)throw n.error;return r=encodeURI(null===(s=n.data)||void 0===s?void 0:s.signedUrl),[4,this.request.reqClass.get({url:r,headers:{},responseType:"blob"})];case 2:if(!(o=i.sent().data))throw new a.StorageError("Download failed: no file content");return[2,new Blob([o])]}})})];case 1:return[2,(r.data=c.sent(),r.error=null,r)];case 2:if(n=c.sent(),this.shouldThrowOnError)throw n;if((0,a.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}})})},e.prototype.info=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,c,u,l;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=e.startsWith("cloud://"),n=t?this.extractPathFromFileId(e):e,r=t?this.extractBucketFromFileId(e):this.bucketId,[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(e)]})];case 1:if(o=i.sent(),"SUCCESS"!==(s=o.fileList[0]).code)throw new a.StorageError(s.message);return c=(new Date).toISOString(),u=(s.lastModified?new Date(s.lastModified):new Date).toISOString(),[2,{data:{id:s.fileID,version:"1",name:n,bucketId:r,updatedAt:u,createdAt:u,lastAccessedAt:c,size:s.size,cacheControl:s.cacheControl,contentType:s.contentType,etag:s.etag,lastModified:u,metadata:{}},error:null}];case 2:if(l=i.sent(),this.shouldThrowOnError)throw l;return[2,{data:null,error:l instanceof a.StorageError?l:new a.StorageError(l.message)}];case 3:return[2]}})})},e.prototype.exists=function(e){return o(this,void 0,Promise,function(){var t,n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(e)]})];case 1:if(t=o.sent(),"FILE_NOT_FOUND"===(n=t.fileList[0]).code)return[2,{data:!1,error:null}];if("SUCCESS"!==n.code)throw new a.StorageError(n.message);return[2,{data:!0,error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}})})},e.prototype.getPublicUrl=function(e,t){return o(this,void 0,Promise,function(){var n;return i(this,function(r){switch(r.label){case 0:return[4,this.createSignedUrl(e,600,t)];case 1:return(n=r.sent()).data?[2,{data:{publicUrl:n.data.signedUrl}}]:[2,{data:null,error:n.error}]}})})},e.prototype.remove=function(e){return o(this,void 0,Promise,function(){var t,n,r,o,s,c,u,l,h,d,f=this;return i(this,function(i){switch(i.label){case 0:for(i.trys.push([0,3,,4]),t=10,n=[],r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return[4,Promise.all(n.map(function(e){return Promise.all(e.map(function(e){return f.info(e)}))}))];case 1:return o=i.sent(),s=new Map,o.forEach(function(n,r){n.forEach(function(n,o){n.data&&s.set(e[r*t+o],n.data)})}),c=e.map(function(e){return f.normalizeCloudId(e)}),[4,this.storage.deleteFile({fileList:c})];case 2:if(u=i.sent(),(l=u.fileList.filter(function(e){return"SUCCESS"!==e.code})).length>0)throw new a.StorageError("Delete failed for ".concat(l.length," file(s)"));return h=(new Date).toISOString(),[2,{data:e.map(function(e){var t=s.get(e);return{name:null==t?void 0:t.name,id:null==t?void 0:t.id,bucket_id:null==t?void 0:t.bucketId,owner:void 0,updated_at:(null==t?void 0:t.updatedAt)||h,created_at:null==t?void 0:t.createdAt,last_accessed_at:(null==t?void 0:t.lastAccessedAt)||h,metadata:(null==t?void 0:t.metadata)||{},buckets:{id:null==t?void 0:t.bucketId,name:null==t?void 0:t.bucketId,owner:void 0,public:!1,created_at:"",updated_at:h}}}),error:null}];case 3:if(d=i.sent(),this.shouldThrowOnError)throw d;if((0,a.isStorageError)(d))return[2,{data:null,error:d}];throw d;case 4:return[2]}})})},e.prototype.list=function(){return o(this,void 0,void 0,function(){return i(this,function(e){throw new a.StorageError("Not implemented")})})},e.prototype.getCloudPath=function(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")},e.prototype.normalizeCloudId=function(e){var t;if(/^cloud:\/\//.test(e))return e;var n=this.getCloudPath(e);if(!this.bucketId)throw new a.StorageError("bucketId is not set");var r=(null===(t=this.config)||void 0===t?void 0:t.env)||"";return r?"cloud://".concat(r,".").concat(this.bucketId,"/").concat(n):void 0},e.prototype.toBase64=function(e){return(0,u.toBase64)(e)},e.prototype.transformOptsToQueryString=function(e){var t=["imageMogr2"];if(e.width||e.height){var n=e.width||"",r=e.height||"";"fill"===e.resize?t.push("thumbnail/".concat(n,"x").concat(r,"!")):"contain"===e.resize?t.push("thumbnail/".concat(n,"x").concat(r)):t.push("thumbnail/".concat(n,"x").concat(r,"^"))}if(e.format&&"origin"!==e.format&&t.push("format/".concat(e.format)),void 0!==e.quality){var o=Math.max(1,Math.min(100,e.quality));t.push("quality/".concat(o))}return t.join("/")},e.prototype.extractPathFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");return t.length<2?e:t.slice(1).join("/")},e.prototype.extractBucketFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");if(t.length<1)return"";var n=t[0],r=n.indexOf(".");return-1===r?n:n.substring(r+1)},e}();t.ClassicStorageFileApi=h},1502:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.StorageFileApi=void 0;var s=n(7957),a=n(7090),c=n(5098),u=n(9656),l="3600",h=function(){function e(e,t,n){void 0===n&&(n=!1),this.headers={},this.http=e,this.bucketId=t,this.shouldThrowOnError=n}return e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.setHeader=function(e,t){var n;if("string"!=typeof e||""===e.trim())throw new s.StorageError("setHeader requires a non-empty header name");if(/[\r\n]/.test(e)||"string"==typeof t&&/[\r\n]/.test(t))throw new s.StorageError("setHeader does not allow CR/LF characters in header name or value");return this.headers=r(r({},this.headers),((n={})[e]=String(t),n)),this},e.prototype.upload=function(e,t,n){return o(this,void 0,Promise,function(){return i(this,function(r){return[2,this.uploadOrUpdate("POST",e,t,n)]})})},e.prototype.update=function(e,t,n){return o(this,void 0,Promise,function(){return i(this,function(r){return[2,this.uploadOrUpdate("PUT",e,t,n)]})})},e.prototype.download=function(e,t,n){return new u.DownloadBuilder({http:this.http,bucketId:this.bucketId,cleanName:this.cleanPath(e),options:t,parameters:n,headers:this.headers,shouldThrowOnError:this.shouldThrowOnError})},e.prototype.list=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){var r;return i(this,function(o){return r={prefix:e||""},void 0!==(null==t?void 0:t.limit)&&(r.limit=t.limit),void 0!==(null==t?void 0:t.cursor)&&(r.cursor=t.cursor),void 0!==(null==t?void 0:t.withDelimiter)&&(r.with_delimiter=t.withDelimiter),void 0!==(null==t?void 0:t.sortBy)&&(r.sortBy=t.sortBy),[2,this.send({method:"POST",path:"/object/list/".concat(this.bucketId),json:r,signal:null==n?void 0:n.signal,cache:null==n?void 0:n.cache})]})})},this.shouldThrowOnError)]})})},e.prototype.remove=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){return[2,(0,c.handleOperation)(function(){return o(t,void 0,void 0,function(){var t,n,r,o,s,a=this;return i(this,function(i){switch(i.label){case 0:t=e.map(function(e){return a.cleanPath(e)}),n=[],r=0,i.label=1;case 1:return r<t.length?(o=t.slice(r,r+100),[4,this.send({method:"DELETE",path:"/object/".concat(this.bucketId),json:{prefixes:o}})]):[3,4];case 2:s=i.sent(),Array.isArray(s)&&n.push.apply(n,s),i.label=3;case 3:return r+=100,[3,1];case 4:return[2,n]}})})},this.shouldThrowOnError)]})})},e.prototype.copy=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){var r;return i(this,function(o){switch(o.label){case 0:return r=this.buildCopyMoveHeaders(n),[4,this.send({method:"POST",path:"/object/copy",json:{bucketId:this.bucketId,sourceKey:this.cleanPath(e),destinationKey:this.cleanPath(t),destinationBucket:null==n?void 0:n.destinationBucket,copyMetadata:null==n?void 0:n.copyMetadata,metadata:null==n?void 0:n.metadata},headers:r})];case 1:return[2,{path:o.sent().Key}]}})})},this.shouldThrowOnError)]})})},e.prototype.move=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,this.send({method:"POST",path:"/object/move",json:{bucketId:this.bucketId,sourceKey:this.cleanPath(e),destinationKey:this.cleanPath(t),destinationBucket:null==n?void 0:n.destinationBucket}})];case 1:return[2,{message:r.sent().message||"Successfully moved"}]}})})},this.shouldThrowOnError)]})})},e.prototype.info=function(e){return o(this,void 0,Promise,function(){var t=this;return i(this,function(n){return[2,(0,c.handleOperation)(function(){return o(t,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return t=this.cleanPath(e),[4,this.send({method:"GET",path:"/object/info/".concat(this.bucketId,"/").concat(this.encodePath(t))})];case 1:return[2,{id:(n=r.sent()).id,name:n.name,version:n.version,bucketId:n.bucket_id,size:n.size,contentType:n.content_type,cacheControl:n.cache_control,etag:n.etag,metadata:n.metadata,lastModified:n.last_modified,createdAt:n.created_at}]}})})},this.shouldThrowOnError)]})})},e.prototype.exists=function(e){return o(this,void 0,Promise,function(){var t,n,r;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this.cleanPath(e),[4,this.send({method:"GET",path:"/object/info/".concat(this.bucketId,"/").concat(this.encodePath(t))})];case 1:return o.sent(),[2,{data:!0,error:null}];case 2:if(n=o.sent(),void 0!==(r=null==n?void 0:n.status)&&[400,404].includes(Number(r)))return[2,{data:!1,error:null}];if(this.shouldThrowOnError)throw n;return[2,{data:null,error:n instanceof s.StorageError?n:new s.StorageError((null==n?void 0:n.message)||String(n))}];case 3:return[2]}})})},e.prototype.createSignedUrl=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){var r,o,s;return i(this,function(i){switch(i.label){case 0:return r=this.cleanPath(e),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId,"/").concat(this.encodePath(r)),json:{expiresIn:t}})];case 1:return o=i.sent(),s=o.fullSignedURL||this.http.toFullUrl(o.signedURL||""),[2,{fullSignedURL:this.appendUrlOptions(s,n)}]}})})},this.shouldThrowOnError)]})})},e.prototype.createSignedUrls=function(e,t,n){return o(this,void 0,Promise,function(){var r=this;return i(this,function(s){return[2,(0,c.handleOperation)(function(){return o(r,void 0,void 0,function(){var r,o,s,a,c=this;return i(this,function(i){switch(i.label){case 0:r=e.map(function(e){return c.cleanPath(e)}),o=[],s=0,i.label=1;case 1:return s<r.length?(a=r.slice(s,s+500),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId),json:{expiresIn:t,paths:a}})]):[3,4];case 2:i.sent().forEach(function(e){var t,r=e.fullSignedURL||(e.signedURL?c.http.toFullUrl(e.signedURL):null);o.push({path:e.path,fullSignedURL:r?c.appendUrlOptions(r,n):null,error:null!==(t=e.error)&&void 0!==t?t:null})}),i.label=3;case 3:return s+=500,[3,1];case 4:return[2,o]}})})},this.shouldThrowOnError)]})})},e.prototype.createSignedUploadUrl=function(e,t){return o(this,void 0,Promise,function(){var n=this;return i(this,function(r){return[2,(0,c.handleOperation)(function(){return o(n,void 0,void 0,function(){var n,r,o;return i(this,function(i){switch(i.label){case 0:return n=this.cleanPath(e),r={},(null==t?void 0:t.upsert)&&(r["x-upsert"]="true"),[4,this.send({method:"POST",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(n)),headers:r})];case 1:return[2,{fullSignedURL:(o=i.sent()).fullURL||this.http.toFullUrl(o.url||""),path:n,token:o.token}]}})})},this.shouldThrowOnError)]})})},e.prototype.uploadToSignedUrl=function(e,t,n,r){return o(this,void 0,Promise,function(){var s=this;return i(this,function(a){return[2,(0,c.handleOperation)(function(){return o(s,void 0,void 0,function(){var o,s,a,c,u;return i(this,function(i){switch(i.label){case 0:return o=this.cleanPath(e),s=this.buildUploadBody(n,r),a=s.body,c=s.headers,[4,this.send({method:"PUT",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(o)),query:{token:t},rawBody:a,headers:c,withCredentials:!1})];case 1:return u=i.sent(),[2,{path:o,fullPath:u.Key}]}})})},this.shouldThrowOnError)]})})},e.prototype.getPublicUrl=function(e,t){var n=this.cleanPath(e),r=this.http.buildUrl("/object/public/".concat(this.bucketId,"/").concat(this.encodePath(n)));return{data:{publicUrl:this.appendUrlOptions(r,t)}}},e.prototype.send=function(e){return this.http.send(r(r({},e),{headers:r(r({},this.headers),e.headers||{})}))},e.prototype.uploadOrUpdate=function(e,t,n,r){return o(this,void 0,Promise,function(){var s=this;return i(this,function(a){return[2,(0,c.handleOperation)(function(){return o(s,void 0,void 0,function(){var o,s,a,c,u;return i(this,function(i){switch(i.label){case 0:return o=this.cleanPath(t),s=this.buildUploadBody(n,r),a=s.body,c=s.headers,"POST"===e&&(c["x-upsert"]=String(Boolean(null==r?void 0:r.upsert))),[4,this.send({method:e,path:"/object/".concat(this.bucketId,"/").concat(this.encodePath(o)),rawBody:a,headers:c})];case 1:return[2,{id:(u=i.sent()).Id,path:o,fullPath:u.Key}]}})})},this.shouldThrowOnError)]})})},e.prototype.cleanPath=function(e){var t=e.replace(/^\/+|\/+$/g,"").replace(/\/+/g,"/");if(t.split("/").some(function(e){return".."===e}))throw new s.StorageError('invalid path: ".." segment is not allowed');return t},e.prototype.encodePath=function(e){return(0,a.encodeObjectName)(e)},e.prototype.buildUploadBody=function(e,t){var n,o,i,s,a,c=r({},(null==t?void 0:t.headers)||{}),u=e,h="undefined"!=typeof FormData&&e instanceof FormData;if("undefined"!=typeof Blob&&e instanceof Blob||h){var d=void 0,f={};if(h){var p=this.extractFromFormData(e);d=p.file,f=p.fields}else d=e;var v=null!==(o=null!==(n=null==t?void 0:t.cacheControl)&&void 0!==n?n:f.cacheControl)&&void 0!==o?o:l,y=null!==(i=null==t?void 0:t.contentType)&&void 0!==i?i:f.contentType,g=void 0!==(null==t?void 0:t.metadata)?JSON.stringify(t.metadata):f.metadata,m=new FormData;void 0!==v&&m.append("cacheControl",String(v)),void 0!==y&&m.append("contentType",y),void 0!==g&&m.append("metadata",g),m.append("",d),u=m}else u=e,v=null!==(s=null==t?void 0:t.cacheControl)&&void 0!==s?s:l,y=null!==(a=null==t?void 0:t.contentType)&&void 0!==a?a:"text/plain;charset=UTF-8",c["cache-control"]="max-age=".concat(v),y&&(c["content-type"]=y),(null==t?void 0:t.metadata)&&(c["x-metadata"]=this.toBase64(JSON.stringify(t.metadata)));return{body:u,headers:c}},e.prototype.extractFromFormData=function(e){var t,n={},r=0,o=[];if(e.forEach(function(e,i){if("undefined"!=typeof Blob&&e instanceof Blob)return t=e,void(r+=1);"cacheControl"!==i&&"contentType"!==i&&"metadata"!==i?o.push(i):n[i]=String(e)}),o.length>0&&console.warn("Ignored unsupported FormData field(s): [".concat(o.join(", "),"]. Only file, cacheControl, contentType and metadata are supported")),0===r||!t)throw new s.StorageError("FormData must contain a file");if(r>1)throw new s.StorageError("FormData must contain exactly one file");return{file:t,fields:n}},e.prototype.buildCopyMoveHeaders=function(e){var t={};return(null==e?void 0:e.upsert)&&(t["x-upsert"]="true"),!1===(null==e?void 0:e.copyMetadata)&&(null==e?void 0:e.metadata)&&(t["x-metadata"]=this.toBase64(JSON.stringify(e.metadata))),t},e.prototype.appendUrlOptions=function(e,t){var n=[];if(void 0!==(null==t?void 0:t.download)){var r=!0===t.download?"":String(t.download);n.push("download=".concat(encodeURIComponent(r)))}if(void 0!==(null==t?void 0:t.cacheNonce)&&n.push("cacheNonce=".concat(encodeURIComponent(String(t.cacheNonce)))),0===n.length)return e;var o=e.includes("?")?"&":"?";return"".concat(e).concat(o).concat(n.join("&"))},e.prototype.toBase64=function(e){return(0,a.toBase64)(e)},e}();t.StorageFileApi=h},7957:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.StorageUnknownError=t.StorageApiError=t.isStorageError=t.StorageError=void 0;var o=function(e){function t(t){var n=e.call(this,t)||this;return n.__isStorageError=!0,n.name="StorageError",n}return r(t,e),t}(Error);t.StorageError=o,t.isStorageError=function(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e};var i=function(e){function t(t,n,r){var o=e.call(this,t)||this;return o.name="StorageApiError",o.status=n,o.statusCode=r,o}return r(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}},t}(o);t.StorageApiError=i;var s=function(e){function t(t,n){var r=e.call(this,t)||this;return r.name="StorageUnknownError",r.originalError=n,r}return r(t,e),t}(o);t.StorageUnknownError=s},5504:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertValidBucketId=t.isValidBucketId=void 0;var r=n(7957),o=/[\x00-\x20\x7f/\\?#%]/;t.isValidBucketId=function(e){return"string"==typeof e&&e.length>0&&e.length<=256&&!o.test(e)},t.assertValidBucketId=function(e,t){if("string"!=typeof e||0===e.length)throw new r.StorageError("[storage.".concat(t,"] bucketId is required"));if(e.length>256)throw new r.StorageError("[storage.".concat(t,"] invalid bucketId: length must be 1-").concat(256));var n=o.exec(e);if(n){var i="[storage.".concat(t,'] invalid bucketId "').concat(e,'": ')+"contains forbidden character ".concat(JSON.stringify(n[0]),"; ")+'must not contain whitespace, control chars, "/", "\\", "?", "#" or "%"';throw new r.StorageError(i)}}},2563:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,c=s(n(92)),u=n(962);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var n=0,o=(0,u.isArray)(e)?e:[e];n<o.length;n++){var i=o[n],s=i.isMatch,a=i.genAdapter,c=i.runtime;if(s())return{adapter:r({isMatch:s},a(t)),runtime:c}}},t.useDefaultAdapter=function(){return{adapter:r({},c.genAdapter()),runtime:a.WEB}}},92:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var c=n(2764),u=n(962),l=n(8464);function h(e){try{return JSON.parse(e)}catch(t){return e}}var d=function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e,n=t.data,r=t.file,o=t.fileContent,s=t.name,a=t.method,c=t.headers,u=void 0===c?{}:c,l=null!=r?r:o,h={post:"post",put:"put"}[null==a?void 0:a.toLowerCase()]||"put",d=new FormData;return"post"===h?(Object.keys(n).forEach(function(e){d.append(e,n[e])}),d.append("key",s),d.append("file",l instanceof Blob?l:new Blob([l])),this.request(i(i({},e),{data:d,method:h}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:u,body:l}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,Promise,function(){var t,n,r,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(t){t({statusCode:200,tempFilePath:e.url})})]}})})},t.prototype.fetch=function(e){var t;return s(this,void 0,Promise,function(){var n,r,o,c,u,l,d,f,p,v,y,g,m,b,_,E=this;return a(this,function(w){switch(w.label){case 0:return n=new AbortController,r=e.url,o=e.enableAbort,c=void 0!==o&&o,u=e.stream,l=void 0!==u&&u,d=e.signal,f=e.timeout,p=e.shouldThrowOnError,v=void 0===p||p,y=null!=f?f:this.timeout,d&&(d.aborted&&n.abort(),d.addEventListener("abort",function(){return n.abort()})),g=null,c&&y&&(g=setTimeout(function(){console.warn(E.timeoutMsg),n.abort(new Error(E.timeoutMsg))},y)),[4,fetch(r,i(i({},e),{signal:n.signal})).then(function(e){return s(E,void 0,void 0,function(){var t,n,r;return a(this,function(o){switch(o.label){case 0:return clearTimeout(g),v?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,e.json()];case 2:t=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(g),Promise.reject(e)})];case 1:return m=w.sent(),l?(b=m.body,[3,5]):[3,2];case 2:return(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?(_=h,[4,m.text()]):[3,4];case 3:return b=_.apply(void 0,[w.sent()]),[3,5];case 4:b=m.text(),w.label=5;case 5:return[2,{data:b,statusCode:m.status,header:m.headers,response:m}]}})})},t.prototype.request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i=e.url,s=e.headers,a=void 0===s?{}:s,c=e.data,h=e.responseType,d=e.withCredentials,f=e.body,p=e.onUploadProgress,v=(0,u.formatUrl)((0,l.getProtocol)(),i,"get"===r?c:{}),y=new XMLHttpRequest;y.open(r,v),h&&(y.responseType=h);var g,m,b=e.signal;b&&(b.aborted?y.abort():b.addEventListener("abort",function(){return y.abort()},{once:!0})),Object.keys(a).forEach(function(e){y.setRequestHeader(e,a[e])}),p&&y.upload.addEventListener("progress",p),y.onreadystatechange=function(){var e={};if(4===y.readyState){var t=y.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach(function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o}),e.header=n,e.statusCode=y.status;try{e.data="blob"===h?y.response:JSON.parse(y.responseText)}catch(t){e.data="blob"===h?y.response:y.responseText}clearTimeout(g),o(e)}},t&&n.timeout&&(g=setTimeout(function(){console.warn(n.timeoutMsg),y.abort()},n.timeout)),m=(0,u.isFormData)(c)?c:"application/x-www-form-urlencoded"===a["content-type"]?(0,u.toQueryString)(c):f||(c?JSON.stringify(c):void 0),d&&(y.withCredentials=!0),y.send(m)})},t}(c.AbstractSDKRequest);t.WebRequest=d,t.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage:localStorage}}},8464:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var n="@cloudbase/js-sdk";t.setSdkName=function(e){n=e},t.getSdkName=function(){return n};var r="https:";t.setProtocol=function(e){r=e},t.getProtocol=function(){return r},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},3519:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},1778:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(n(8464),t),o(n(3519),t),t.OATUH_LOGINTYPE="constants"},9517:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=n(962),s=n(1778),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,n=e.className,r=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),h=s.findIndex(function(e){return c.test(e)});if(-1!==h){var d=s.filter(function(e,t){return t>h});d.unshift(s[h].replace(l,"".concat(n,".").concat(r)).replace(u,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,a=e.customInfo,h=void 0===a?{}:a,d=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=h.className||e.constructor.name,v=h.methodName||t,y=a.value,g=function(){var e="",t=(new Error).stack.split("\n"),n=t.findIndex(function(e){return c.test(e)});if(-1!==n){var r=u.exec(t[n+1]||"");e=r?r[0]:""}return e}();a.value="sync"===n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=l({err:new Error,className:f,methodName:v,sourceLink:g});try{return y.apply(this,e)}catch(e){var r=e,o=e.message,s=e.error,a=e.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(n?(n.code=u.code,n.msg=u.msg):(e.code=u.code,e.message=u.msg),r=n||e,c.content=p.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(c.subtitle=a,n?(n.code=s,n.msg=a):(e.code=s,e.message=a),r=n||e,c.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(c),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,function(){var t,n,r,s,a,c,u,h;return o(this,function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,c=n.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(h=JSON.parse(s),u.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(n.code=h.code,n.message=h.msg),r=t||n,u.content=p.map(function(e){return{type:"info",body:e}}))),a&&c&&(u.subtitle=c,t?(t.code=a,t.msg=c):(n.code=a,n.message=c),r=t||n,u.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(u),r;case 4:return[2]}})})}}}}},3260:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(9517),t)},2877:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.langEvent=t.AbortController=t.jwt=t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var a=i(n(1778));t.constants=a;var c=i(n(2563));t.adapters=c;var u=i(n(6865));t.cache=u;var l=i(n(6940));t.events=l;var h=i(n(3991));t.langEvent=h;var d=i(n(962));t.utils=d;var f=i(n(3260));t.helpers=f;var p=s(n(829));t.AbortController=p.default;var v={decode:s(n(3107)).default};t.jwt=v},829:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,n){"abort"===t&&e.listeners.push(n)}}}return e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach(function(e){return e()}))},e}();t.default=n},6865:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=n(2764),c=n(962),u=n(1778),l=function(e){function t(t){var n=e.call(this)||this;return n.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),h=function(){function e(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return i(this,void 0,void 0,function(){var r;return s(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var r=this.storage.getItem(e);return r&&r.indexOf(t)>=0?JSON.parse(r).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return i(this,void 0,void 0,function(){var r;return s(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(r=o.sent())&&r.indexOf(t)>=0?[2,JSON.parse(r).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}();t.CloudbaseCache=h},6940:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=n(962),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var c=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return o(t,e),t}(a);t.IErrorEvent=c;var u=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,c))return console.error(e.error),this;var n=(0,s.isString)(e)?new a(e,t||{}):e,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,u=this.listeners[r]?i([],this.listeners[r],!0):[];o<u.length;o++)u[o].call(this,n)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=u;var l=new u;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},3991:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LANG_CHANGE_EVENT=t.bus=void 0;var r=n(6940);t.bus=new r.CloudbaseEventEmitter,t.LANG_CHANGE_EVENT="lang_change"},962:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.errorToResult=t.promoteGatewayError=t.maybeThrow=t.resolveThrow=t.createCloudbaseError=t.CloudbaseError=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var a=n(1778);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var r=16*Math.random();return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:7&r|8).toString(16)})},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";return Object.keys(n).forEach(function(e){""===o?!r&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(n[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(n){t.push("".concat(n,"=").concat(encodeURIComponent(e[n])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||decodeURIComponent(window.location.search),r=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('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}var n=new Promise(function(t,n){e=function(e,r){return e?n(e):t(r)}});return e.promise=n,e},t.execCallback=function(e,t,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(t,n);if(t)throw t;return n},t.printWarn=function(e,t){console.warn("[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){var n=new Error(JSON.stringify({code:e,msg:"[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t)}));throw n.code=e,n};var c=function(e){function t(t){var n=e.call(this,t.msg||t.message||"")||this;return n.code=t.code||"",n.requestId=t.requestId||"",Object.defineProperty(n,"message",{value:t.msg||t.message||"",enumerable:!0,writable:!0,configurable:!0}),n}return o(t,e),t}(Error);t.CloudbaseError=c;var u=function(e){return new c(e)};function l(e,t){return(t||u)(e)}function h(e){return!e||"boolean"!=typeof e.throw||e.throw}t.createCloudbaseError=l,t.resolveThrow=h,t.maybeThrow=function(e,t){if(h(e))throw l(i(i({},t),{msg:t.message}),null==e?void 0:e.errorFactory);return i({code:t.code,message:t.message},t.requestId?{requestId:t.requestId}:{})},t.promoteGatewayError=function(e){if(e&&"object"==typeof e&&e.data&&"object"==typeof e.data){var t=e.data,n=t.code,r=t.message;if(!e.code&&n||!e.message&&r)return i(i(i({},e),!e.code&&n?{code:n}:{}),!e.message&&r?{message:r}:{})}return e},t.errorToResult=function(e){if(e instanceof Error&&"string"==typeof e.message)try{var t=JSON.parse(e.message);if(t&&"string"==typeof t.code)return{code:t.code,message:t.msg||t.message||"",requestId:t.requestId}}catch(e){}return e&&"string"==typeof e.code?{code:e.code,message:e.message||"",requestId:e.requestId}:{code:"UNKNOWN_ERROR",message:String((null==e?void 0:e.message)||e||"")}},t.printGroupLog=function(e){var t,n=e.title,r=e.subtitle,o=void 0===r?"":r,i=e.content,s=void 0===i?[]:i,a=e.printTrace,c=void 0!==a&&a,u=e.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var l=0,h=s;l<h.length;l++){var d=h[l],f=d.type,p=d.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}c&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var n=e.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(t[r]?Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]:t[r]=o)}),t},t.parseCaptcha=function(e){var n={},r=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){e=r[1];var o=r[2];o&&(n=(0,t.parseQueryString)(o))}var i=n.token,a=s(n,["token"]);return/^data:/.test(e)&&!i?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:i?{state:a.state,token:i,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},4954:function(e,t,n){"use strict";n.r(t),n.d(t,{CollectionReference:function(){return ut},Db:function(){return It},DocumentReference:function(){return Ze},Query:function(){return it}});var r,o,i={};n.r(i),n.d(i,{LineString:function(){return V},MultiLineString:function(){return $},MultiPoint:function(){return Y},MultiPolygon:function(){return X},Point:function(){return we},Polygon:function(){return J}}),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.BooleanError="must be boolean",e.ArrayError="must be array",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined",e.CentersPhereError="centersPhere结构不合法"}(o||(o={}));var s,a,c="Object",u="GeoPoint",l="GeoLineString",h="GeoPolygon",d="GeoMultiPoint",f="GeoMultiLineString",p="GeoMultiPolygon",v="Date",y="ServerDate",g=["desc","asc"],m=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={})),(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte",function(e){e.WHERE="WHERE",e.DOC="DOC"}(a||(a={}));var b,_=(b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},b(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),E=[],w={},S=function(e){function t(t,n){if(n!==w)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return _(t,e),t.for=function(e){for(var n=0,r=E.length;n<r;n++)if(E[n].target===e)return E[n].instance;var o=new t(e,w);return E.push({target:e,instance:o}),o},t}(function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})}),I=S,O=I.for("UNSET_FIELD_NAME"),A=I.for("UPDATE_COMMAND"),T=I.for("QUERY_COMMAND"),P=I.for("LOGIC_COMMAND"),C=I.for("GEO_POINT"),R=I.for("SYMBOL_GEO_LINE_STRING"),N=I.for("SYMBOL_GEO_POLYGON"),k=I.for("SYMBOL_GEO_MULTI_POINT"),U=I.for("SYMBOL_GEO_MULTI_LINE_STRING"),D=I.for("SYMBOL_GEO_MULTI_POLYGON"),L=I.for("SERVER_DATE"),j=I.for("REGEXP"),x=I.for("OBJECTID"),M=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},q=function(e){return"object"===M(e)},F=function(e){return"number"===M(e)},B=function(e){return Array.isArray(e)},W=function(e){return"date"===M(e)},H=function(e){return"regexp"===M(e)},G=function(e){return e&&e._internalType instanceof S},V=function(){function e(e){if(!B(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach(function(e){if(!(e instanceof we))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))}),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map(function(e){return e.toJSON().coordinates})},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map(function(e){return e.toJSON().coordinates})}},e.validate=function(e){var t,n;if("LineString"!==e.type||!B(e.coordinates))return!1;try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!F(i[0])||!F(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],n=e.points[e.points.length-1];if(t.latitude===n.latitude&&t.longitude===n.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return R},enumerable:!1,configurable:!0}),e}(),K=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},J=function(){function e(e){if(!B(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach(function(e){if(!(e instanceof V))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"));if(!V.isClosed(e))throw new Error("LineString ".concat(e.points.map(function(e){return e.toReadableString()})," is not a closed cycle"))}),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})}},e.validate=function(e){var t,n,r,o;if("Polygon"!==e.type||!B(e.coordinates))return!1;try{for(var i=K(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var c=(r=void 0,K(a)),u=c.next();!u.done;u=c.next()){var l=u.value;if(!F(l[0])||!F(l[1]))return!1}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return N},enumerable:!1,configurable:!0}),e}(),Y=function(){function e(e){if(!B(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach(function(e){if(!(e instanceof we))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))}),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map(function(e){return e.toJSON().coordinates})},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map(function(e){return e.toJSON().coordinates})}},e.validate=function(e){var t,n;if("MultiPoint"!==e.type||!B(e.coordinates))return!1;try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!F(i[0])||!F(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return k},enumerable:!1,configurable:!0}),e}(),z=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},$=function(){function e(e){if(!B(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach(function(e){if(!(e instanceof V))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"))}),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})}},e.validate=function(e){var t,n,r,o;if("MultiLineString"!==e.type||!B(e.coordinates))return!1;try{for(var i=z(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var c=(r=void 0,z(a)),u=c.next();!u.done;u=c.next()){var l=u.value;if(!F(l[0])||!F(l[1]))return!1}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!1,configurable:!0}),e}(),Q=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},X=function(){function e(e){var t,n;if(!B(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=Q(e),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof J))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof i,"[]"))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map(function(e){return e.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})})},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map(function(e){return e.lines.map(function(e){return e.points.map(function(e){return[e.longitude,e.latitude]})})})}},e.validate=function(e){var t,n,r,o,i,s;if("MultiPolygon"!==e.type||!B(e.coordinates))return!1;try{for(var a=Q(e.coordinates),c=a.next();!c.done;c=a.next()){var u=c.value;try{for(var l=(r=void 0,Q(u)),h=l.next();!h.done;h=l.next()){var d=h.value;try{for(var f=(i=void 0,Q(d)),p=f.next();!p.done;p=f.next()){var v=p.value;if(!F(v[0])||!F(v[1]))return!1}}catch(e){i={error:e}}finally{try{p&&!p.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return D},enumerable:!1,configurable:!0}),e}(),Z=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},ee=function(){function e(){}return e.formatResDocumentData=function(t){return t.map(function(t){return e.formatField(t)})},e.formatField=function(t){var n=Object.keys(t),r={};return Array.isArray(t)&&(r=[]),n.forEach(function(n){var o,i=t[n];switch(e.whichType(i)){case u:o=new we(i.coordinates[0],i.coordinates[1]);break;case l:o=new V(i.coordinates.map(function(e){return new we(e[0],e[1])}));break;case h:o=new J(i.coordinates.map(function(e){return new V(e.map(function(e){var t=Z(e,2),n=t[0],r=t[1];return new we(n,r)}))}));break;case d:o=new Y(i.coordinates.map(function(e){return new we(e[0],e[1])}));break;case f:o=new $(i.coordinates.map(function(e){return new V(e.map(function(e){var t=Z(e,2),n=t[0],r=t[1];return new we(n,r)}))}));break;case p:o=new X(i.coordinates.map(function(e){return new J(e.map(function(e){return new V(e.map(function(e){var t=Z(e,2),n=t[0],r=t[1];return new we(n,r)}))}))}));break;case v:o=i;break;case c:case"Array":o=e.formatField(i);break;case y:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o}),r},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);return t===v?v:(t===c&&(e.$date?t=y:we.validate(e)?t=u:V.validate(e)?t=l:J.validate(e)?t=h:Y.validate(e)?t=d:$.validate(e)?t=f:X.validate(e)&&(t=p)),t)},e.generateDocId=function(){for(var e="",t=0;t<24;t++)e+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return e},e}(),te={code:"INVALID_PARAM",message:"Invalid request param"},ne="DATABASE_TRANSACTION_CONFLICT",re={code:"DATABASE_REQUEST_FAILED",message:"database request failed"},oe=n(2701),ie=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),se=function(){return se=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},se.apply(this,arguments)};function ae(e,t){if("function"!=typeof t)return e;e.then(function(e){return t(0,e)},function(e){return t(e)})}var ce={};function ue(e){if(!It.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return ce[t]||(ce[t]=new It.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:It.createRequest(e.config)}}})),ce[t]}var le=function(e){return void 0!==e.timeout?{timeout:e.timeout}:{}},he=function(e){if(!q(e))return e;for(var t in e)void 0===e[t]?delete e[t]:q(e[t])&&(e[t]=he(e[t]));return e},de=function(e){return e=he(e),oe.EJSON.stringify(e,{relaxed:!1})},fe=function(e){var t,n;if(e instanceof Date)return{$date:+e};if(e instanceof RegExp)return{$regex:e.source,$options:e.flags};if(e&&"object"==typeof e){if("ObjectId"===e._bsontype)return{$oid:e.toHexString()};if("BSONRegExp"===e._bsontype)return{$regex:e.pattern,$options:e.options};if(Array.isArray(e))return e.map(fe);var r={};try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(e)),i=o.next();!i.done;i=o.next()){var s=i.value;r[s]=fe(e[s])}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return r}return e},pe=function(e){if(!e)return"{}";try{var t=oe.EJSON.parse(e);return JSON.stringify(fe(t))}catch(t){return e}},ve=function(e){function t(t){var n=e.call(this,t.message)||this;return n.code=t.code,n.message=t.message,n}return ie(t,e),t}(Error),ye=function(e){return new ve(e)};function ge(e,t){if(!1===e)return t;throw ye(se({},t))}var me,be=function(){return be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},_e=["limit","offset","projection","order","multiple","timeout","raw"],Ee=function(){function e(){}return e.isGeopoint=function(e,t){if("Number"!==ee.whichType(t))throw new Error("Geo Point must be number type");var n=Math.abs(t);if("latitude"===e&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+o.IntergerError);return!0},e.mustBeBoolean=function(e,t){if("boolean"!=typeof t)throw new Error(e+o.BooleanError);return!0},e.isProjection=function(e,t){if("object"!==M(t))throw ye(be(be({},te),{message:"".concat(e," projection must be an object")}));for(var n in t){var r=t[n];if("number"===M(r)){if(0!==r&&1!==r)throw ye(be(be({},te),{message:"if the value in projection is of number, it must be 0 or 1"}))}else if("object"!==M(r))throw ye(be(be({},te),{message:"invalid projection"}))}return!0},e.isOrder=function(e,t){if("object"!==M(t))throw ye(be(be({},te),{message:"".concat(e," order must be an object")}));for(var n in t){var r=t[n];if(1!==r&&-1!==r)throw ye(be(be({},te),{message:"order value must be 1 or -1"}))}return!0},e.isFieldOrder=function(e){if(-1===g.indexOf(e))throw new Error(o.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===m.indexOf(e))throw new Error(o.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(o.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(o.DocIDError);return!0},e.isValidOptions=function(t){if(void 0===t&&(t={}),"object"!==M(t))throw ye(be(be({},te),{message:"options must be an object"}));var n=Object.keys(t);for(var r in n)if(_e.indexOf(n[r])<0)throw ye(be(be({},te),{message:"".concat(n[r]," is invalid options key")}));var o=t,i=o.limit,s=o.offset,a=o.projection,c=o.order,u=t.multiple;return void 0!==i&&e.isInteger("limit",i),void 0!==s&&e.isInteger("offset",s),void 0!==a&&e.isProjection("projection",a),void 0!==c&&e.isOrder("order",c),void 0!==u&&e.mustBeBoolean("multiple",u),void 0!==t.timeout&&e.isInteger("timeout",t.timeout),!0},e.isValidAggregation=function(e){if(1!==Object.keys(e).length)throw ye(be(be({},te),{message:"aggregation stage must have one key"}));return!0},e.isCentersPhere=function(t){if(Array.isArray(t)&&2===t.length){if("object"===M(t[0])&&t[0]._internalType===C&&"number"==typeof t[1])return!0;if(Array.isArray(t[0])&&2===t[0].length){var n=t[0][0],r=t[0][1];if(e.isGeopoint("longitude",n),e.isGeopoint("latitude",r),"number"==typeof t[1])return!0}}throw new Error("".concat(o.CentersPhereError))},e}(),we=function(){function e(e,t){Ee.isGeopoint("longitude",e),Ee.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"[".concat(this.longitude,",").concat(this.latitude,"]")},e.validate=function(e){return"Point"===e.type&&B(e.coordinates)&&Ee.isGeopoint("longitude",e.coordinates[0])&&Ee.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return C},enumerable:!1,configurable:!0}),e}();!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(me||(me={}));var Se,Ie=function(){function e(e,t,n){this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||O}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function Oe(e){return e&&e instanceof Ie&&e._internalType===A}!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(Se||(Se={}));var Ae=function(){function e(e,t,n){if(this._internalType=P,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||O,this.fieldName!==O)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,o=t.length;r<o;r++)(Te(i=t[r])||Ne(i))&&(t[r]=i._setFieldName(this.fieldName))}else{var i;(Te(i=t)||Ne(i))&&(t=i._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var n=this.operands.map(function(n){return n instanceof e?n._setFieldName(t):n});return new e(this.operator,n,t)},e.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(Se.AND,r,this.fieldName)},e.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(Se.OR,r,this.fieldName)},e}();function Te(e){return e&&e instanceof Ae&&e._internalType===P}var Pe,Ce=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(Pe||(Pe={}));var Re=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.operator=t,o._internalType=T,o}return Ce(t,e),t.prototype.toJSON=function(){var e,t,n;switch(this.operator){case Pe.IN:case Pe.NIN:return(e={})["$"+this.operator]=this.operands,e;case Pe.NEQ:return(t={}).$ne=this.operands[0],t;default:return(n={})["$"+this.operator]=this.operands[0],n}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var n=new t(Pe.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(Pe.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(Pe.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(Pe.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(Pe.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(Pe.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(Pe.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(Pe.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof we))throw new TypeError('"geometry" must be of type Point. Received type '.concat(typeof e.geometry));if(void 0!==e.maxDistance&&!F(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof e.maxDistance));if(void 0!==e.minDistance&&!F(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '.concat(typeof e.minDistance));var n=new t(Pe.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof X||e.geometry instanceof J||Ee.isCentersPhere(e.centerSphere)))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof e.geometry));var n=new t(Pe.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof we||e.geometry instanceof V||e.geometry instanceof J||e.geometry instanceof Y||e.geometry instanceof $||e.geometry instanceof X))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '.concat(typeof e.geometry));var n=new t(Pe.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(Ae);function Ne(e){return e&&e instanceof Re&&e._internalType===T}function ke(e){return Ne(e)}var Ue={};for(var De in Pe)Ue[De]="$"+De;for(var De in Se)Ue[De]="$"+De;for(var De in me)Ue[De]="$"+De;function Le(e){return Ue[e]||"$"+e}Ue[Pe.NEQ]="$ne",Ue[me.REMOVE]="$unset",Ue[me.SHIFT]="$pop",Ue[me.UNSHIFT]="$push";var je=function(){return je=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},je.apply(this,arguments)},xe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},Me=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function qe(e){return Fe(e,[e])}function Fe(e,t){if(!G(e)){if(W(e))return e;if(H(e))return{$regularExpression:{pattern:e.source,options:e.flags}};if(B(e))return e.map(function(e){if(t.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return Fe(e,Me(Me([],xe(t),!1),[e],!1))});if(q(e)){var n=je({},e),r={};for(var o in n){if(t.indexOf(n[o])>-1)throw new Error("Cannot convert circular structure to JSON");void 0!==n[o]&&(r[o]=Fe(n[o],Me(Me([],xe(t),!1),[n[o]],!1)))}return r}return e}switch(e._internalType){case C:return e.toJSON();case L:case j:case x:return e.parse();default:return e.toJSON?e.toJSON():e}}var Be=function(){return Be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Be.apply(this,arguments)},We=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},He=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function Ge(e,t,n,r){var o=Be({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(void 0!==s){if(s&&q(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ge(s,t,He(He([],We(n),!1),[i],!1),He(He([],We(r),!1),[s],!1));o[i]=a;var c=!1;for(var u in a)/^\$/.test(u)?c=!0:(o["".concat(i,".").concat(u)]=a[u],delete o[i][u]);c||delete o[i]}}else delete o[i]}return o}function Ve(e){return Ge(e,Je,[],[e])}function Ke(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?B(e[r])?e[r].push(t[r]):q(e[r])?q(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is ".concat(M(t),", can only overwrite"),t,n),e[r]=t[r]):(console.warn("to-merge query is of type ".concat(M(e),", can only overwrite"),e,t,n),e[r]=t[r]):e[r]=t[r]}function Je(e){return G(e)||W(e)||H(e)}function Ye(e){return qe(e)}var ze=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.encodeEJSON=function(t,n){var r=new e;return de(n?t:r.encodeUpdate(t))},e.prototype.encodeUpdate=function(e){return Oe(e)?this.encodeUpdateCommand(e):"object"===M(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case me.PUSH:case me.PULL:case me.PULL_ALL:case me.POP:case me.SHIFT:case me.UNSHIFT:case me.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,o,i=Le(e.operator);return e.operator===me.REMOVE?((t={})[i]=((n={})[e.fieldName]="",n),t):((r={})[i]=((o={})[e.fieldName]=e.operands[0],o),r)},e.prototype.encodeArrayUpdateCommand=function(e){var t,n,r,o,i,s,a,c,u,l,h=Le(e.operator);switch(e.operator){case me.PUSH:var d=void 0;return d=B(e.operands)?{$each:e.operands.map(Ye)}:e.operands,(t={})[h]=((n={})[e.fieldName]=d,n),t;case me.UNSHIFT:return d={$each:e.operands.map(Ye),$position:0},(r={})[h]=((o={})[e.fieldName]=d,o),r;case me.POP:return(i={})[h]=((s={})[e.fieldName]=1,s),i;case me.SHIFT:return(a={})[h]=((c={})[e.fieldName]=-1,c),a;default:return(u={})[h]=((l={})[e.fieldName]=Ye(e.operands),l),u}},e.prototype.encodeUpdateObject=function(e){var t=Ve(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(Oe(r))t[n]=r._setFieldName(n),Ke(t,this.encodeUpdateCommand(t[n]),n);else{t[n]=r=Ye(r);var o=new Ie(me.SET,[r],n);Ke(t,this.encodeUpdateCommand(o),n)}}return t},e}(),$e=function(){return $e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},$e.apply(this,arguments)},Qe=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},Xe=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Ze=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){return ue(i._db).watch($e($e({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify({_id:i.id})}))},this._db=e,this._coll=t,this.id=r,this._transactionId=o,this.request=It.createRequest(this._db.config),this._apiOptions=n}return e.prototype.create=function(e,t){return ae(this._create(e),t)},e.prototype._create=function(e){return Qe(this,void 0,void 0,function(){var t,n,r;return Xe(this,function(o){switch(o.label){case 0:return!(t=Array.isArray(e))&&this.id&&(e._id=this.id),n={collectionName:this._coll,data:t?e.map(function(e){return de(qe(e))}):[de(qe(e))],transactionId:this._transactionId},[4,this.request.send("database.insertDocument",n,le(this._apiOptions))];case 1:return(r=o.sent()).code?[2,r]:this._transactionId?[2,{inserted:1,ok:1,id:r.data.insertedIds[0],requestId:r.requestId}]:t?[2,{ids:r.data&&r.data.insertedIds||[],requestId:r.requestId}]:[2,{id:r.data.insertedIds[0],requestId:r.requestId}]}})})},e.prototype.set=function(e,t){return ae(this._set(e),t)},e.prototype._set=function(e){return Qe(this,void 0,void 0,function(){var t,n,r,o;return Xe(this,function(i){switch(i.label){case 0:return this.id?e&&"object"==typeof e?e.hasOwnProperty("_id")?[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"不能更新_id的值"}))]:(t=!1,n=function(e){if("object"==typeof e)for(var r in e)e[r]instanceof Ie?t=!0:"object"==typeof e[r]&&n(e[r])},n(e),t?[2,ge(this._db.config.throwOnCode,$e($e({},re),{message:"update operator complicit"}))]:(r={collectionName:this._coll,queryType:a.DOC,data:de(qe(e)),transactionId:this._transactionId,multi:!1,merge:!1,upsert:!0},this.id&&(r.query=de({_id:this.id})),[4,this.request.send("database.modifyDocument",r,le(this._apiOptions))])):[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"参数必需是非空对象"}))]:[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"docId不能为空"}))];case 1:return(o=i.sent()).code?[2,o]:this._transactionId?[2,{updated:o.data.updated,upserted:[{_id:o.data.upsert_id}],requestId:o.requestId}]:[2,{updated:o.data.updated,upsertedId:o.data.upsert_id,requestId:o.requestId}]}})})},e.prototype.update=function(e,t){return ae(this._update(e),t)},e.prototype._update=function(e){return Qe(this,void 0,void 0,function(){var t,n,r;return Xe(this,function(o){switch(o.label){case 0:return e&&"object"==typeof e?e.hasOwnProperty("_id")?[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"不能更新_id的值"}))]:(t=de({_id:this.id}),n={collectionName:this._coll,transactionId:this._transactionId,data:ze.encodeEJSON(e,this._apiOptions.raw||!1),query:t,queryType:a.DOC,multi:!1,merge:!0,upsert:!1},[4,this.request.send("database.modifyDocument",n,le(this._apiOptions))]):[2,ge(this._db.config.throwOnCode,$e($e({},te),{message:"参数必需是非空对象"}))];case 1:return(r=o.sent()).code?[2,r]:[2,{updated:r.data.updated,requestId:r.requestId}]}})})},e.prototype.delete=function(e){return this.remove(e)},e.prototype.remove=function(e){return ae(this._remove(),e)},e.prototype._remove=function(){return Qe(this,void 0,void 0,function(){var e,t,n;return Xe(this,function(r){switch(r.label){case 0:return e=de({_id:this.id}),t={collectionName:this._coll,transactionId:this._transactionId,query:e,queryType:a.DOC,multi:!1},[4,this.request.send("database.removeDocument",t,le(this._apiOptions))];case 1:return(n=r.sent()).code?[2,n]:[2,{deleted:n.data.deleted,requestId:n.requestId}]}})})},e.prototype.get=function(e){return ae(this._get(),e)},e.prototype._get=function(){return Qe(this,void 0,void 0,function(){var e,t,n,r,o,i;return Xe(this,function(s){switch(s.label){case 0:return e=de({_id:this.id}),t=this._apiOptions.projection,n={collectionName:this._coll,query:e,transactionId:this._transactionId,queryType:a.DOC,multi:!1},t&&(n.projection=de(t)),[4,this.request.send("database.getDocument",n,le(this._apiOptions))];case 1:return(r=s.sent()).code?[2,r]:(o=r.data.list.map(function(e){return oe.EJSON.parse(e)}),i=ee.formatResDocumentData(o),this._transactionId?[2,{data:i[0]||null,requestId:r.requestId}]:[2,{data:i,requestId:r.requestId}])}})})},e.prototype.field=function(t){var n={};for(var r in t)"boolean"==typeof t[r]&&(n[r]=!0===t[r]?1:0),"number"==typeof t[r]&&(n[r]=t[r]>0?1:0),"object"==typeof t[r]&&(n[r]=t[r]);var o=$e({},this._apiOptions);return o.projection=n,new e(this._db,this._coll,o,this.id,this._transactionId)},e}(),et=function(){function e(){}return e.encode=function(e){return(new tt).encodeQuery(e)},e.encodeEJSON=function(e,t){var n=new tt;return de(t?e:n.encodeQuery(e))},e}(),tt=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n,r,o;return Je(e)?Te(e)?this.encodeLogicCommand(e):Ne(e)?this.encodeQueryCommand(e):H(e)?((n={})[t]=this.encodeRegExp(e),n):W(e)?((r={})[t]=Ye(e),r):((o={})[t]=this.encodeQueryObject(e),o):q(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regularExpression:{pattern:e.source,options:e.flags}}},e.prototype.encodeLogicCommand=function(e){var t,n,r,o,i,s,a,c=this;switch(e.operator){case Se.NOR:case Se.AND:case Se.OR:var u=Le(e.operator),l=e.operands.map(function(t){return c.encodeQuery(t,e.fieldName)});return(t={})[u]=l,t;case Se.NOT:u=Le(e.operator);var h=e.operands[0];return H(h)?((n={})[e.fieldName]=((r={})[u]=this.encodeRegExp(h),r),n):(l=this.encodeQuery(h)[e.fieldName],(o={})[e.fieldName]=((i={})[u]=l,i),o);default:if(u=Le(e.operator),1===e.operands.length){var d=this.encodeQuery(e.operands[0]);return(s={})[u]=d,s}return l=e.operands.map(this.encodeQuery.bind(this)),(a={})[u]=l,a}},e.prototype.encodeQueryCommand=function(e){return ke(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,o,i,s,a,c,u,l,h;if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var d=Le(e.operator);switch(e.operator){case Pe.EQ:case Pe.NEQ:case Pe.LT:case Pe.LTE:case Pe.GT:case Pe.GTE:case Pe.ELEM_MATCH:case Pe.EXISTS:case Pe.SIZE:case Pe.MOD:return(t={})[e.fieldName]=((n={})[d]=Ye(e.operands[0]),n),t;case Pe.IN:case Pe.NIN:case Pe.ALL:return(r={})[e.fieldName]=((o={})[d]=Ye(e.operands),o),r;case Pe.GEO_NEAR:var f=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:f.geometry.toJSON(),$maxDistance:f.maxDistance,$minDistance:f.minDistance}},i;case Pe.GEO_WITHIN:if((f=e.operands[0]).centerSphere){Ee.isCentersPhere(f.centerSphere);var p=f.centerSphere;return p[0]._internalType===C?((s={})[e.fieldName]={$geoWithin:{$centerSphere:[p[0].toJSON().coordinates,p[1]]}},s):((a={})[e.fieldName]={$geoWithin:{$centerSphere:f.centerSphere}},a)}return(c={})[e.fieldName]={$geoWithin:{$geometry:f.geometry.toJSON()}},c;case Pe.GEO_INTERSECTS:return f=e.operands[0],(u={})[e.fieldName]={$geoIntersects:{$geometry:f.geometry.toJSON()}},u;default:return(l={})[e.fieldName]=((h={})[d]=Ye(e.operands[0]),h),l}},e.prototype.encodeQueryObject=function(e){var t=Ve(e);for(var n in t){var r=t[n];if(Te(r)){t[n]=r._setFieldName(n);var o=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else ke(r)?(t[n]=r._setFieldName(n),o=this.encodeComparisonCommand(t[n]),this.mergeConditionAfterEncode(t,o,n)):Je(r)&&(t[n]=Ye(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?B(e[r])?e[r]=e[r].concat(t[r]):q(e[r])?q(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is ".concat(M(t),", can only overwrite"),t,n),e[r]=t[r]):(console.warn("to-merge query is of type ".concat(M(e),", can only overwrite"),e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),nt=function(){return nt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},nt.apply(this,arguments)},rt=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},ot=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},it=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){var t=ue(i._db),n=i._apiOptions,r=n.limit,o=n.order,s=o?Object.entries(o).reduce(function(e,t){var n=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}(t,2),r=n[0],o=n[1];return e[r]=-1===o?"desc":"asc",e},{}):void 0;return t.watch(nt(nt({},e),{envId:i._db.config.env,collectionName:i._coll,query:pe(i._fieldFilters),limit:r,orderBy:s}))},this._db=e,this._coll=t,this._fieldFilters=n,this._apiOptions=r||{},this._request=It.createRequest(this._db.config),this._transactionId=o}return e.prototype.get=function(e){return ae(this._get(),e)},e.prototype._get=function(){return rt(this,void 0,void 0,function(){var e,t,n,r,o,i,s,c,u;return ot(this,function(l){switch(l.label){case 0:return e=this._apiOptions.order,t={collectionName:this._coll,queryType:a.WHERE,transactionId:this._transactionId},this._fieldFilters&&(t.query=this._fieldFilters),e&&(t.order=de(e)),(n=this._apiOptions.offset)&&(t.offset=n),r=this._apiOptions.limit,t.limit=r?r<1e3?r:1e3:100,(o=this._apiOptions.projection)&&(t.projection=de(o)),[4,this._request.send("database.getDocument",t,le(this._apiOptions))];case 1:return(i=l.sent()).code?[2,i]:(s=i.data.list.map(function(e){return oe.EJSON.parse(e)}),c=ee.formatResDocumentData(s),u={data:c,requestId:i.requestId},i.total&&(u.total=i.total),i.limit&&(u.limit=i.limit),i.offset&&(u.offset=i.offset),[2,u])}})})},e.prototype.count=function(e){return ae(this._count(),e)},e.prototype._count=function(){return rt(this,void 0,void 0,function(){var e,t;return ot(this,function(n){switch(n.label){case 0:return e={collectionName:this._coll,queryType:a.WHERE},this._fieldFilters&&(e.query=this._fieldFilters),[4,this._request.send("database.calculateDocument",e,le(this._apiOptions))];case 1:return(t=n.sent()).code?[2,t]:[2,{requestId:t.requestId,total:t.data.total}]}})})},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(t),r=n.some(function(e){return void 0!==t[e]});if(n.length&&!r)throw Error(o.QueryParamValueError);return new e(this._db,this._coll,et.encodeEJSON(t,this._apiOptions.raw||!1),this._apiOptions,this._transactionId)},e.prototype.options=function(t){return Ee.isValidOptions(t),new e(this._db,this._coll,this._fieldFilters,t,this._transactionId)},e.prototype.orderBy=function(t,n){var r;Ee.isFieldPath(t),Ee.isFieldOrder(n);var o=((r={})[t]="desc"===n?-1:1,r),i=this._apiOptions.order||{},s=Object.assign({},this._apiOptions,{order:Object.assign({},i,o)});return new e(this._db,this._coll,this._fieldFilters,s,this._transactionId)},e.prototype.limit=function(t){Ee.isInteger("limit",t);var n=nt({},this._apiOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,n,this._transactionId)},e.prototype.skip=function(t){Ee.isInteger("offset",t);var n=nt({},this._apiOptions);return n.offset=t,new e(this._db,this._coll,this._fieldFilters,n,this._transactionId)},e.prototype.update=function(e,t){return ae(this._update(e),t)},e.prototype._update=function(e){return rt(this,void 0,void 0,function(){var t,n,r,o;return ot(this,function(i){switch(i.label){case 0:return e&&"object"==typeof e?e.hasOwnProperty("_id")?[2,ge(this._db.config.throwOnCode,nt(nt({},te),{message:"不能更新_id的值"}))]:(t=this._apiOptions.multiple,n=void 0===t||t,r={collectionName:this._coll,queryType:a.WHERE,multi:n,merge:!0,upsert:!1,data:ze.encodeEJSON(e,this._apiOptions.raw||!1)},this._transactionId&&(r.transactionId=this._transactionId),this._fieldFilters&&(r.query=this._fieldFilters),[4,this._request.send("database.modifyDocument",r,le(this._apiOptions))]):[2,ge(this._db.config.throwOnCode,nt(nt({},te),{message:"参数必需是非空对象"}))];case 1:return(o=i.sent()).code?[2,o]:[2,{requestId:o.requestId,updated:o.data.updated,upsertId:o.data.upsert_id}]}})})},e.prototype.field=function(t){var n={};for(var r in t)"boolean"==typeof t[r]&&(n[r]=!0===t[r]?1:0),"number"==typeof t[r]&&(n[r]=t[r]>0?1:0),"object"==typeof t[r]&&(n[r]=t[r]);var o=nt({},this._apiOptions);return o.projection=n,new e(this._db,this._coll,this._fieldFilters,o,this._transactionId)},e.prototype.remove=function(e){return ae(this._remove(),e)},e.prototype._remove=function(){return rt(this,void 0,void 0,function(){var e,t,n,r,o,i,s,c,u;return ot(this,function(l){switch(l.label){case 0:return e=this._apiOptions,t=e.offset,n=e.limit,r=e.projection,o=e.order,void 0===t&&void 0===n&&void 0===r&&void 0===o||console.warn("`offset`, `limit`, `projection`, `orderBy` are not supported in remove() operation"),i=this._apiOptions.multiple,s=void 0===i||i,c={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:s},this._transactionId&&(c.transactionId=this._transactionId),[4,this._request.send("database.removeDocument",c,le(this._apiOptions))];case 1:return(u=l.sent()).code?[2,u]:[2,{requestId:u.requestId,deleted:u.data.deleted}]}})})},e.prototype.updateAndReturn=function(e){return rt(this,void 0,void 0,function(){var t,n;return ot(this,function(r){switch(r.label){case 0:return e&&"object"==typeof e?e.hasOwnProperty("_id")?[2,ge(this._db.config.throwOnCode,nt(nt({},te),{message:"不能更新_id的值"}))]:(t={collectionName:this._coll,queryType:a.WHERE,data:ze.encodeEJSON(e,!1)},this._transactionId&&(t.transactionId=this._transactionId),this._fieldFilters&&(t.query=this._fieldFilters),[4,this._request.send("database.modifyAndReturnDoc",t,le(this._apiOptions))]):[2,ge(this._db.config.throwOnCode,nt(nt({},te),{message:"参数必需是非空对象"}))];case 1:return(n=r.sent()).code?[2,n]:[2,{requestId:n.requestId,updated:n.data.updated,doc:n.data.doc&&oe.EJSON.parse(n.data.doc)}]}})})},e}(),st=function(){function e(e,t,n){var r=this;this._stages=[],e&&t&&(this._db=e,this._request=It.createRequest(this._db.config),this._collectionName=t,n&&n.length>0&&n.forEach(function(e){Ee.isValidAggregation(e);var t=Object.keys(e)[0];r._pipe(t,e[t],!0)}))}return e.prototype.end=function(){return e=this,t=void 0,r=function(){var e;return function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,function(t){switch(t.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregateDocuments",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:e.data.list.map(oe.EJSON.parse)}]:[2,e]}})},new((n=void 0)||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())});var e,t,n,r},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map(function(e){var t,n=e.stageKey,r=e.stageValue;return(t={})[n]=JSON.parse(r),t})},e.prototype._pipe=function(e,t,n){void 0===n&&(n=!1);var r;return r="object"===M(t)?de(t):JSON.stringify(t),this._stages.push({stageKey:n?e:"$".concat(e),stageValue:r}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return e.query&&(e.query=et.encode(e.query)),e.distanceMultiplier&&"number"==typeof e.distanceMultiplier&&(e.distanceMultiplier=e.distanceMultiplier),e.near&&(e.near=new we(e.near.longitude,e.near.latitude).toJSON()),this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",et.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),at=st,ct=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ut=function(e){function t(t,n,r,o){var i=e.call(this,t,n,"",r,o)||this;return o&&(i._transactionId=o),i}return ct(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new Ze(this._db,this._coll,this._apiOptions,e,this._transactionId)},t.prototype.add=function(e,t){return ae(this._add(e),t)},t.prototype._add=function(e){return t=this,n=void 0,o=function(){var t,n,r;return function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,function(o){switch(o.label){case 0:return t=e,B(e)||(t=[e]),t=t.map(function(e){return de(qe(e))}),n={collectionName:this._coll,data:t},this._transactionId&&(n.transactionId=this._transactionId),[4,this._request.send("database.insertDocument",n,le(this._apiOptions))];case 1:return(r=o.sent()).code?[2,r]:B(e)?[2,{ids:r.data.insertedIds,requestId:r.requestId}]:this._transactionId?[2,{inserted:1,ok:1,id:r.data.insertedIds[0],requestId:r.requestId}]:[2,{id:r.data.insertedIds[0],requestId:r.requestId}]}})},new((r=void 0)||(r=Promise))(function(e,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(s,a)}c((o=o.apply(t,n||[])).next())});var t,n,r,o},t.prototype.aggregate=function(e){return void 0===e&&(e=[]),new at(this._db,this._coll,this._apiOptions.raw?e:[])},t.prototype.options=function(e){return Ee.isValidOptions(e),new t(this._db,this._coll,e,this._transactionId)},t}(it),lt={eq:function(e){return new Re(Pe.EQ,[e])},neq:function(e){return new Re(Pe.NEQ,[e])},lt:function(e){return new Re(Pe.LT,[e])},lte:function(e){return new Re(Pe.LTE,[e])},gt:function(e){return new Re(Pe.GT,[e])},gte:function(e){return new Re(Pe.GTE,[e])},in:function(e){return new Re(Pe.IN,e)},nin:function(e){return new Re(Pe.NIN,e)},all:function(e){return new Re(Pe.ALL,e)},elemMatch:function(e){return new Re(Pe.ELEM_MATCH,[e])},exists:function(e){return new Re(Pe.EXISTS,[e])},size:function(e){return new Re(Pe.SIZE,[e])},mod:function(){return new Re(Pe.MOD,1==arguments.length?[arguments[0]]:2==arguments.length?[[arguments[0],arguments[1]]]:arguments)},geoNear:function(e){return new Re(Pe.GEO_NEAR,[e])},geoWithin:function(e){return new Re(Pe.GEO_WITHIN,[e])},geoIntersects:function(e){return new Re(Pe.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ae(Se.AND,n)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ae(Se.NOR,n)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ae(Se.OR,n)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ae(Se.NOT,n)},set:function(e){return new Ie(me.SET,[e])},remove:function(){return new Ie(me.REMOVE,[])},inc:function(e){return new Ie(me.INC,[e])},mul:function(e){return new Ie(me.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(q(t[0])&&t[0].hasOwnProperty("each")){e={};var r=t[0];void 0!==r.each&&(e.$each=r.each),void 0!==r.position&&(e.$position=r.position),void 0!==r.sort&&(e.$sort=r.sort),void 0!==r.slice&&(e.$slice=r.slice)}else e=B(t[0])?t[0]:Array.from(t);return new Ie(me.PUSH,e)},pull:function(e){return new Ie(me.PULL,e)},pullAll:function(e){return new Ie(me.PULL_ALL,e)},pop:function(){return new Ie(me.POP,[])},shift:function(){return new Ie(me.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new Ie(me.UNSHIFT,n)},addToSet:function(e){return new Ie(me.ADD_TO_SET,e)},rename:function(e){return new Ie(me.RENAME,[e])},bit:function(e){return new Ie(me.BIT,[e])},max:function(e){return new Ie(me.MAX,[e])},min:function(e){return new Ie(me.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===M(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new at},abs:function(e){return new ht("abs",e)},add:function(e){return new ht("add",e)},ceil:function(e){return new ht("ceil",e)},divide:function(e){return new ht("divide",e)},exp:function(e){return new ht("exp",e)},floor:function(e){return new ht("floor",e)},ln:function(e){return new ht("ln",e)},log:function(e){return new ht("log",e)},log10:function(e){return new ht("log10",e)},mod:function(e){return new ht("mod",e)},multiply:function(e){return new ht("multiply",e)},pow:function(e){return new ht("pow",e)},sqrt:function(e){return new ht("sqrt",e)},subtract:function(e){return new ht("subtract",e)},trunc:function(e){return new ht("trunc",e)},arrayElemAt:function(e){return new ht("arrayElemAt",e)},arrayToObject:function(e){return new ht("arrayToObject",e)},concatArrays:function(e){return new ht("concatArrays",e)},filter:function(e){return new ht("filter",e)},in:function(e){return new ht("in",e)},indexOfArray:function(e){return new ht("indexOfArray",e)},isArray:function(e){return new ht("isArray",e)},map:function(e){return new ht("map",e)},range:function(e){return new ht("range",e)},reduce:function(e){return new ht("reduce",e)},reverseArray:function(e){return new ht("reverseArray",e)},size:function(e){return new ht("size",e)},slice:function(e){return new ht("slice",e)},zip:function(e){return new ht("zip",e)},and:function(e){return new ht("and",e)},not:function(e){return new ht("not",e)},or:function(e){return new ht("or",e)},cmp:function(e){return new ht("cmp",e)},eq:function(e){return new ht("eq",e)},gt:function(e){return new ht("gt",e)},gte:function(e){return new ht("gte",e)},lt:function(e){return new ht("lt",e)},lte:function(e){return new ht("lte",e)},neq:function(e){return new ht("ne",e)},cond:function(e){return new ht("cond",e)},ifNull:function(e){return new ht("ifNull",e)},switch:function(e){return new ht("switch",e)},dateFromParts:function(e){return new ht("dateFromParts",e)},dateFromString:function(e){return new ht("dateFromString",e)},dayOfMonth:function(e){return new ht("dayOfMonth",e)},dayOfWeek:function(e){return new ht("dayOfWeek",e)},dayOfYear:function(e){return new ht("dayOfYear",e)},isoDayOfWeek:function(e){return new ht("isoDayOfWeek",e)},isoWeek:function(e){return new ht("isoWeek",e)},isoWeekYear:function(e){return new ht("isoWeekYear",e)},millisecond:function(e){return new ht("millisecond",e)},minute:function(e){return new ht("minute",e)},month:function(e){return new ht("month",e)},second:function(e){return new ht("second",e)},hour:function(e){return new ht("hour",e)},week:function(e){return new ht("week",e)},year:function(e){return new ht("year",e)},literal:function(e){return new ht("literal",e)},mergeObjects:function(e){return new ht("mergeObjects",e)},objectToArray:function(e){return new ht("objectToArray",e)},allElementsTrue:function(e){return new ht("allElementsTrue",e)},anyElementTrue:function(e){return new ht("anyElementTrue",e)},setDifference:function(e){return new ht("setDifference",e)},setEquals:function(e){return new ht("setEquals",e)},setIntersection:function(e){return new ht("setIntersection",e)},setIsSubset:function(e){return new ht("setIsSubset",e)},setUnion:function(e){return new ht("setUnion",e)},concat:function(e){return new ht("concat",e)},dateToString:function(e){return new ht("dateToString",e)},indexOfBytes:function(e){return new ht("indexOfBytes",e)},indexOfCP:function(e){return new ht("indexOfCP",e)},split:function(e){return new ht("split",e)},strLenBytes:function(e){return new ht("strLenBytes",e)},strLenCP:function(e){return new ht("strLenCP",e)},strcasecmp:function(e){return new ht("strcasecmp",e)},substr:function(e){return new ht("substr",e)},substrBytes:function(e){return new ht("substrBytes",e)},substrCP:function(e){return new ht("substrCP",e)},toLower:function(e){return new ht("toLower",e)},toUpper:function(e){return new ht("toUpper",e)},meta:function(e){return new ht("meta",e)},addToSet:function(e){return new ht("addToSet",e)},avg:function(e){return new ht("avg",e)},first:function(e){return new ht("first",e)},last:function(e){return new ht("last",e)},max:function(e){return new ht("max",e)},min:function(e){return new ht("min",e)},push:function(e){return new ht("push",e)},stdDevPop:function(e){return new ht("stdDevPop",e)},stdDevSamp:function(e){return new ht("stdDevSamp",e)},sum:function(e){return new ht("sum",e)},let:function(e){return new ht("let",e)}},project:{slice:function(e){return new dt("slice",e)},elemMatch:function(e){return new dt("elemMatch",e)}}},ht=function(e,t){this["$"+e]=t},dt=function(e,t){this["$"+e]=t},ft=function(){function e(e){var t=(void 0===e?{}:e).offset,n=void 0===t?0:t;this.offset=n}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return L},enumerable:!1,configurable:!0}),e.prototype.parse=function(){return{$tcb_server_date:{offset:this.offset}}},e}();function pt(e){return new ft(e)}var vt=function(){function e(e){var t=e.regexp,n=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regularExpression={pattern:t||"",options:n||""}}return e.prototype.parse=function(){return{$regularExpression:{pattern:this.$regularExpression.pattern,options:this.$regularExpression.options}}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return j},enumerable:!1,configurable:!0}),e}();function yt(e){return new vt(e)}var gt=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},mt=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},bt=function(){function e(e){this._db=e,this._request=It.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return gt(this,void 0,void 0,function(){var e;return mt(this,function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}})})},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new ut(this._db,e,{},this._id)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return gt(this,void 0,void 0,function(){var e,t;return mt(this,function(n){switch(n.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=n.sent()).code)throw t;return this.commited=!0,[2,t]}})})},e.prototype.rollback=function(e){return gt(this,void 0,void 0,function(){var t,n;return mt(this,function(r){switch(r.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=e,[2,n]}})})},e}();function _t(){return gt(this,void 0,void 0,function(){var e;return mt(this,function(t){switch(t.label){case 0:return[4,(e=new bt(this)).init()];case 1:return t.sent(),[2,e]}})})}function Et(e,t){return void 0===t&&(t=3),gt(this,void 0,void 0,function(){var n,r,o,i,s=this;return mt(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new bt(this)).init()];case 1:return a.sent(),[4,e(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(e){return gt(s,void 0,void 0,function(){return mt(this,function(t){switch(t.label){case 0:if(n.aborted||n.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===n.aborted)throw n.abortReason;throw e}})})},t<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===ne?[4,Et.bind(this)(e,--t)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}})})}var wt=function(){function e(e){var t=(void 0===e?{}:e).id,n=void 0===t?"":t;this.id=n}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return x},enumerable:!1,configurable:!0}),e.prototype.parse=function(){return{$oid:this.id}},e}();function St(e){return new wt(e)}var It=function(){function e(e){this.config=e,this.Geo=i,this.serverDate=pt,this.command=lt,this.RegExp=yt,this.ObjectId=St,this.startTransaction=_t,this.runTransaction=Et,this.logicCommand=Ae,this.updateCommand=Ie,this.queryCommand=Re}return e.createRequest=function(t){var n=new e.reqClass(t),r=n.send;return n.send=function(e,n){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];return n&&(t.instance&&(n.instance=t.instance),t.database&&(n.database=t.database)),r.call.apply(r,function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([this,e,n],function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}(o),!1))},n},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new ut(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return e.createRequest(this.config).send("database.addCollection",n)},e}()},3388:function(e){e.exports={}},1012:function(e,t,n){"use strict";var r;if(n.r(t),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function j(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function x(e,t){return e&t}function M(e,t){return e|t}function q(e,t){return e^t}function F(e,t){return e&~t}function B(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function W(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function H(e){var t,n,r="";for(t=0;t+3<=e.length;t+=3)n=parseInt(e.substring(t,t+3),16),r+=i.charAt(n>>6)+i.charAt(63&n);for(t+1==e.length?(n=parseInt(e.substring(t,t+1),16),r+=i.charAt(n<<2)):t+2==e.length&&(n=parseInt(e.substring(t,t+2),16),r+=i.charAt(n>>2)+i.charAt((3&n)<<4));(3&r.length)>0;)r+="=";return r}function G(e){var t,n="",r=0,o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var s=i.indexOf(e.charAt(t));s<0||(0==r?(n+=j(s>>2),o=3&s,r=1):1==r?(n+=j(o<<2|s>>4),o=15&s,r=2):2==r?(n+=j(o),n+=j(s>>2),o=3&s,r=3):(n+=j(o<<2|s>>4),n+=j(15&s),r=0))}return 1==r&&(n+=j(o<<2)),n}var s,a,c={decode:function(e){var t;if(void 0===s){var n="0123456789ABCDEF";for(s={},t=0;t<16;++t)s[n.charAt(t)]=t;for(n=n.toLowerCase(),t=10;t<16;++t)s[n.charAt(t)]=t;for(t=0;t<8;++t)s[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],o=0,i=0;for(t=0;t<e.length;++t){var a=e.charAt(t);if("="==a)break;if(-1!=(a=s[a])){if(void 0===a)throw new Error("Illegal character at offset "+t);o|=a,++i>=2?(r[r.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return r}},u={decode:function(e){var t;if(void 0===a){for(a=Object.create(null),t=0;t<64;++t)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)a["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],r=0,o=0;for(t=0;t<e.length;++t){var i=e.charAt(t);if("="==i)break;if(-1!=(i=a[i])){if(void 0===i)throw new Error("Illegal character at offset "+t);r|=i,++o>=4?(n[n.length]=r>>16,n[n.length]=r>>8&255,n[n.length]=255&r,r=0,o=0):r<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=r>>10;break;case 3:n[n.length]=r>>16,n[n.length]=r>>8&255}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(e){var t=u.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return u.decode(e)}},l=1e13;class V{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var n,r,o=this.buf,i=o.length;for(n=0;n<i;++n)(r=o[n]*e+t)<l?t=0:r-=(t=0|r/l)*l,o[n]=r;t>0&&(o[n]=t)}sub(e){var t,n,r=this.buf,o=r.length;for(t=0;t<o;++t)(n=r[t]-e)<0?(n+=l,e=1):e=0,r[t]=n;for(;0===r[r.length-1];)r.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,n=t[t.length-1].toString(),r=t.length-2;r>=0;--r)n+=(l+t[r]).toString().substring(1);return n}valueOf(){for(var e=this.buf,t=0,n=e.length-1;n>=0;--n)t=t*l+e[n];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var h,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,f=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function K(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class J{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof J?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,n){for(var r="",o=e;o<t;++o)if(r+=this.hexByte(this.get(o)),!0!==n)switch(15&o){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r}isASCII(e,t){for(var n=e;n<t;++n){var r=this.get(n);if(r<32||r>176)return!1}return!0}parseStringISO(e,t){for(var n="",r=e;r<t;++r)n+=String.fromCharCode(this.get(r));return n}parseStringUTF(e,t){for(var n="",r=e;r<t;){var o=this.get(r++);n+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(r++)):String.fromCharCode((15&o)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return n}parseStringBMP(e,t){for(var n,r,o="",i=e;i<t;)n=this.get(i++),r=this.get(i++),o+=String.fromCharCode(n<<8|r);return o}parseTime(e,t,n){var r=this.parseStringISO(e,t),o=(n?d:f).exec(r);return o?(n&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),r=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(r+=":"+o[5],o[6]&&(r+=":"+o[6],o[7]&&(r+="."+o[7]))),o[8]&&(r+=" UTC","Z"!=o[8]&&(r+=o[8],o[9]&&(r+=":"+o[9]))),r):"Unrecognized time: "+r}parseInteger(e,t){for(var n,r=this.get(e),o=r>127,i=o?255:0,s="";r==i&&++e<t;)r=this.get(e);if(0===(n=t-e))return o?-1:0;if(n>4){for(s=r,n<<=3;!(128&(+s^i));)s=+s<<1,--n;s="("+n+" bit)\n"}o&&(r-=256);for(var a=new V(r),c=e+1;c<t;++c)a.mulAdd(256,this.get(c));return s+a.toString()}parseBitString(e,t,n){for(var r=this.get(e),o="("+((t-e-1<<3)-r)+" bit)\n",i="",s=e+1;s<t;++s){for(var a=this.get(s),c=s==t-1?r:0,u=7;u>=c;--u)i+=a>>u&1?"1":"0";if(i.length>n)return o+K(i,n)}return o+i}parseOctetString(e,t,n){if(this.isASCII(e,t))return K(this.parseStringISO(e,t),n);var r=t-e,o="("+r+" byte)\n";r>(n/=2)&&(t=e+n);for(var i=e;i<t;++i)o+=this.hexByte(this.get(i));return r>n&&(o+="…"),o}parseOID(e,t,n){for(var r="",o=new V,i=0,s=e;s<t;++s){var a=this.get(s);if(o.mulAdd(128,127&a),i+=7,!(128&a)){if(""===r)if((o=o.simplify())instanceof V)o.sub(80),r="2."+o.toString();else{var c=o<80?o<40?0:1:2;r=c+"."+(o-40*c)}else r+="."+o.toString();if(r.length>n)return K(r,n);o=new V,i=0}}return i>0&&(r+=".incomplete"),r}}class Y{constructor(e,t,n,r,o){if(!(r instanceof z))throw new Error("Invalid tag value.");this.stream=e,this.header=t,this.length=n,this.tag=r,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),n=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+n,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+n);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+n,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+n,e);case 6:return this.stream.parseOID(t,t+n,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return K(this.stream.parseStringUTF(t,t+n),e);case 18:case 19:case 20:case 21:case 22:case 26:return K(this.stream.parseStringISO(t,t+n),e);case 30:return K(this.stream.parseStringBMP(t,t+n),e);case 23:case 24:return this.stream.parseTime(t,t+n,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var n=0,r=this.sub.length;n<r;++n)t+=this.sub[n].toPrettyString(e)}return t}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(e){var t=e.get(),n=127&t;if(n==t)return n;if(n>6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(0===n)return null;t=0;for(var r=0;r<n;++r)t=256*t+e.get();return t}getHexStringValue(){var e=this.toHexString(),t=2*this.header,n=2*this.length;return e.substr(t,n)}static decode(e){var t;t=e instanceof J?e:new J(e,0);var n=new J(t),r=new z(t),o=Y.decodeLength(t),i=t.pos,s=i-n.pos,a=null,c=function(){var e=[];if(null!==o){for(var n=i+o;t.pos<n;)e[e.length]=Y.decode(t);if(t.pos!=n)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var r=Y.decode(t);if(r.tag.isEOC())break;e[e.length]=r}o=i-t.pos}catch(e){throw new Error("Exception while decoding undefined length content: "+e)}return e};if(r.tagConstructed)a=c();else if(r.isUniversal()&&(3==r.tagNumber||4==r.tagNumber))try{if(3==r.tagNumber&&0!=t.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=c();for(var u=0;u<a.length;++u)if(a[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(e){a=null}if(null===a){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+i);t.pos=i+Math.abs(o)}return new Y(n,s,o,r,a)}}class z{constructor(e){var t=e.get();if(this.tagClass=t>>6,this.tagConstructed=!!(32&t),this.tagNumber=31&t,31==this.tagNumber){var n=new V;do{t=e.get(),n.mulAdd(128,127&t)}while(128&t);this.tagNumber=n.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/p[p.length-1];class ${constructor(e,t,n){null!=e&&("number"==typeof e?this.fromNumber(e,t,n):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}toString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var n,r=(1<<t)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(n=this[s]>>a)>0&&(o=!0,i=j(n));s>=0;)a<t?(n=(this[s]&(1<<a)-1)<<t-a,n|=this[--s]>>(a+=this.DB-t)):(n=this[s]>>(a-=t)&r,a<=0&&(a+=this.DB,--s)),n>0&&(o=!0),o&&(i+=j(n));return o?i:"0"}negate(){var e=Q();return $.ZERO.subTo(this,e),e}abs(){return this.s<0?this.negate():this}compareTo(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+oe(this[this.t-1]^this.s&this.DM)}mod(e){var t=Q();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo($.ZERO)>0&&e.subTo(t,t),t}modPowInt(e,t){var n;return n=e<256||t.isEven()?new g(t):new m(t),this.exp(e,n)}clone(){var e=Q();return this.copyTo(e),e}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var e=this.t,t=[];t[0]=this.s;var n,r=this.DB-e*this.DB%8,o=0;if(e-- >0)for(r<this.DB&&(n=this[e]>>r)!=(this.s&this.DM)>>r&&(t[o++]=n|this.s<<this.DB-r);e>=0;)r<8?(n=(this[e]&(1<<r)-1)<<8-r,n|=this[--e]>>(r+=this.DB-8)):(n=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),128&n&&(n|=-256),0==o&&(128&this.s)!=(128&n)&&++o,(o>0||n!=this.s)&&(t[o++]=n);return t}equals(e){return 0==this.compareTo(e)}min(e){return this.compareTo(e)<0?this:e}max(e){return this.compareTo(e)>0?this:e}and(e){var t=Q();return this.bitwiseTo(e,x,t),t}or(e){var t=Q();return this.bitwiseTo(e,M,t),t}xor(e){var t=Q();return this.bitwiseTo(e,q,t),t}andNot(e){var t=Q();return this.bitwiseTo(e,F,t),t}not(){for(var e=Q(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}shiftLeft(e){var t=Q();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}shiftRight(e){var t=Q();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}getLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+B(this[e]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var e=0,t=this.s&this.DM,n=0;n<this.t;++n)e+=W(this[n]^t);return e}testBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)}setBit(e){return this.changeBit(e,M)}clearBit(e){return this.changeBit(e,F)}flipBit(e){return this.changeBit(e,q)}add(e){var t=Q();return this.addTo(e,t),t}subtract(e){var t=Q();return this.subTo(e,t),t}multiply(e){var t=Q();return this.multiplyTo(e,t),t}divide(e){var t=Q();return this.divRemTo(e,t,null),t}remainder(e){var t=Q();return this.divRemTo(e,null,t),t}divideAndRemainder(e){var t=Q(),n=Q();return this.divRemTo(e,t,n),[t,n]}modPow(e,t){var n,r,o=e.bitLength(),i=re(1);if(o<=0)return i;n=o<18?1:o<48?3:o<144?4:o<768?5:6,r=o<8?new g(t):t.isEven()?new b(t):new m(t);var s=[],a=3,c=n-1,u=(1<<n)-1;if(s[1]=r.convert(this),n>1){var l=Q();for(r.sqrTo(s[1],l);a<=u;)s[a]=Q(),r.mulTo(l,s[a-2],s[a]),a+=2}var h,d,f=e.t-1,p=!0,v=Q();for(o=oe(e[f])-1;f>=0;){for(o>=c?h=e[f]>>o-c&u:(h=(e[f]&(1<<o+1)-1)<<c-o,f>0&&(h|=e[f-1]>>this.DB+o-c)),a=n;!(1&h);)h>>=1,--a;if((o-=a)<0&&(o+=this.DB,--f),p)s[h].copyTo(i),p=!1;else{for(;a>1;)r.sqrTo(i,v),r.sqrTo(v,i),a-=2;a>0?r.sqrTo(i,v):(d=i,i=v,v=d),r.mulTo(v,s[h],i)}for(;f>=0&&!(e[f]&1<<o);)r.sqrTo(i,v),d=i,i=v,v=d,--o<0&&(o=this.DB-1,--f)}return r.revert(i)}modInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return $.ZERO;for(var n=e.clone(),r=this.clone(),o=re(1),i=re(0),s=re(0),a=re(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),t?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(e,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;r.isEven();)r.rShiftTo(1,r),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);n.compareTo(r)>=0?(n.subTo(r,n),t&&o.subTo(s,o),i.subTo(a,i)):(r.subTo(n,r),t&&s.subTo(o,s),a.subTo(i,a))}return 0!=r.compareTo($.ONE)?$.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a}pow(e){return this.exp(e,new y)}gcd(e){var t=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(t.compareTo(n)<0){var r=t;t=n,n=r}var o=t.getLowestSetBit(),i=n.getLowestSetBit();if(i<0)return t;for(o<i&&(i=o),i>0&&(t.rShiftTo(i,t),n.rShiftTo(i,n));t.signum()>0;)(o=t.getLowestSetBit())>0&&t.rShiftTo(o,t),(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),t.compareTo(n)>=0?(t.subTo(n,t),t.rShiftTo(1,t)):(n.subTo(t,n),n.rShiftTo(1,n));return i>0&&n.lShiftTo(i,n),n}isProbablePrime(e){var t,n=this.abs();if(1==n.t&&n[0]<=p[p.length-1]){for(t=0;t<p.length;++t)if(n[0]==p[t])return!0;return!1}if(n.isEven())return!1;for(t=1;t<p.length;){for(var r=p[t],o=t+1;o<p.length&&r<v;)r*=p[o++];for(r=n.modInt(r);t<o;)if(r%p[t++]==0)return!1}return n.millerRabin(e)}copyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}fromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}fromString(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var r=e.length,o=!1,i=0;--r>=0;){var s=8==n?255&+e[r]:ne(e,r);s<0?"-"==e.charAt(r)&&(o=!0):(o=!1,0==i?this[this.t++]=s:i+n>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,(i+=n)>=this.DB&&(i-=this.DB))}8==n&&128&+e[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&$.ZERO.subTo(this,this)}clamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}dlShiftTo(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s}drShiftTo(e,t){for(var n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s}lShiftTo(e,t){for(var n=e%this.DB,r=this.DB-n,o=(1<<r)-1,i=Math.floor(e/this.DB),s=this.s<<n&this.DM,a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>r|s,s=(this[a]&o)<<n;for(a=i-1;a>=0;--a)t[a]=0;t[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}rShiftTo(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var r=e%this.DB,o=this.DB-r,i=(1<<r)-1;t[0]=this[n]>>r;for(var s=n+1;s<this.t;++s)t[s-n-1]|=(this[s]&i)<<o,t[s-n]=this[s]>>r;r>0&&(t[this.t-n-1]|=(this.s&i)<<o),t.t=this.t-n,t.clamp()}}subTo(e,t){for(var n=0,r=0,o=Math.min(e.t,this.t);n<o;)r+=this[n]-e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r-=e[n],t[n++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t[n++]=this.DV+r:r>0&&(t[n++]=r),t.t=n,t.clamp()}multiplyTo(e,t){var n=this.abs(),r=e.abs(),o=n.t;for(t.t=o+r.t;--o>=0;)t[o]=0;for(o=0;o<r.t;++o)t[o+n.t]=n.am(0,r[o],t,o,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&$.ZERO.subTo(t,t)}squareTo(e){for(var t=this.abs(),n=e.t=2*t.t;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){var r=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,r,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()}divRemTo(e,t,n){var r=e.abs();if(!(r.t<=0)){var o=this.abs();if(o.t<r.t)return null!=t&&t.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=Q());var i=Q(),s=this.s,a=e.s,c=this.DB-oe(r[r.t-1]);c>0?(r.lShiftTo(c,i),o.lShiftTo(c,n)):(r.copyTo(i),o.copyTo(n));var u=i.t,l=i[u-1];if(0!=l){var h=l*(1<<this.F1)+(u>1?i[u-2]>>this.F2:0),d=this.FV/h,f=(1<<this.F1)/h,p=1<<this.F2,v=n.t,y=v-u,g=null==t?Q():t;for(i.dlShiftTo(y,g),n.compareTo(g)>=0&&(n[n.t++]=1,n.subTo(g,n)),$.ONE.dlShiftTo(u,g),g.subTo(i,i);i.t<u;)i[i.t++]=0;for(;--y>=0;){var m=n[--v]==l?this.DM:Math.floor(n[v]*d+(n[v-1]+p)*f);if((n[v]+=i.am(0,m,n,y,0,u))<m)for(i.dlShiftTo(y,g),n.subTo(g,n);n[v]<--m;)n.subTo(g,n)}null!=t&&(n.drShiftTo(u,t),s!=a&&$.ZERO.subTo(t,t)),n.t=u,n.clamp(),c>0&&n.rShiftTo(c,n),s<0&&$.ZERO.subTo(n,n)}}}invDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(e,t){if(e>4294967295||e<1)return $.ONE;var n=Q(),r=Q(),o=t.convert(this),i=oe(e)-1;for(o.copyTo(n);--i>=0;)if(t.sqrTo(n,r),(e&1<<i)>0)t.mulTo(r,o,n);else{var s=n;n=r,r=s}return t.revert(n)}chunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}toRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),n=Math.pow(e,t),r=re(n),o=Q(),i=Q(),s="";for(this.divRemTo(r,o,i);o.signum()>0;)s=(n+i.intValue()).toString(e).substr(1)+s,o.divRemTo(r,o,i);return i.intValue().toString(e)+s}fromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),r=Math.pow(t,n),o=!1,i=0,s=0,a=0;a<e.length;++a){var c=ne(e,a);c<0?"-"==e.charAt(a)&&0==this.signum()&&(o=!0):(s=t*s+c,++i>=n&&(this.dMultiply(r),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(s,0)),o&&$.ZERO.subTo(this,this)}fromNumber(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo($.ONE.shiftLeft(e-1),M,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo($.ONE.shiftLeft(e-1),this);else{var r=[],o=7&e;r.length=1+(e>>3),t.nextBytes(r),o>0?r[0]&=(1<<o)-1:r[0]=0,this.fromString(r,256)}}bitwiseTo(e,t,n){var r,o,i=Math.min(e.t,this.t);for(r=0;r<i;++r)n[r]=t(this[r],e[r]);if(e.t<this.t){for(o=e.s&this.DM,r=i;r<this.t;++r)n[r]=t(this[r],o);n.t=this.t}else{for(o=this.s&this.DM,r=i;r<e.t;++r)n[r]=t(o,e[r]);n.t=e.t}n.s=t(this.s,e.s),n.clamp()}changeBit(e,t){var n=$.ONE.shiftLeft(e);return this.bitwiseTo(n,t,n),n}addTo(e,t){for(var n=0,r=0,o=Math.min(e.t,this.t);n<o;)r+=this[n]+e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r+=e[n],t[n++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t[n++]=r:r<-1&&(t[n++]=this.DV+r),t.t=n,t.clamp()}dMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}multiplyLowerTo(e,t,n){var r=Math.min(this.t+e.t,t);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(var o=n.t-this.t;r<o;++r)n[r+this.t]=this.am(0,e[r],n,r,0,this.t);for(o=Math.min(e.t,t);r<o;++r)this.am(0,e[r],n,r,0,t-r);n.clamp()}multiplyUpperTo(e,t,n){--t;var r=n.t=this.t+e.t-t;for(n.s=0;--r>=0;)n[r]=0;for(r=Math.max(t-this.t,0);r<e.t;++r)n[this.t+r-t]=this.am(t-r,e[r],n,0,0,this.t+r-t);n.clamp(),n.drShiftTo(1,n)}modInt(e){if(e<=0)return 0;var t=this.DV%e,n=this.s<0?e-1:0;if(this.t>0)if(0==t)n=this[0]%e;else for(var r=this.t-1;r>=0;--r)n=(t*n+this[r])%e;return n}millerRabin(e){var t=this.subtract($.ONE),n=t.getLowestSetBit();if(n<=0)return!1;var r=t.shiftRight(n);(e=e+1>>1)>p.length&&(e=p.length);for(var o=Q(),i=0;i<e;++i){o.fromInt(p[Math.floor(Math.random()*p.length)]);var s=o.modPow(r,this);if(0!=s.compareTo($.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<n&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo($.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0}square(){var e=Q();return this.squareTo(e),e}gcda(e,t){var n=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(n.compareTo(r)<0){var o=n;n=r,r=o}var i=n.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)t(n);else{i<s&&(s=i),s>0&&(n.rShiftTo(s,n),r.rShiftTo(s,r));var a=()=>{(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),n.compareTo(r)>=0?(n.subTo(r,n),n.rShiftTo(1,n)):(r.subTo(n,r),r.rShiftTo(1,r)),n.signum()>0?setTimeout(a,0):(s>0&&r.lShiftTo(s,r),setTimeout(function(){t(r)},0))};setTimeout(a,10)}}fromNumberAsync(e,t,n,r){if("number"==typeof t)if(e<2)this.fromInt(1);else{this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo($.ONE.shiftLeft(e-1),M,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo($.ONE.shiftLeft(e-1),o),o.isProbablePrime(t)?setTimeout(function(){r()},0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&e;s.length=1+(e>>3),t.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var y=function(){function e(){}return e.prototype.convert=function(e){return e},e.prototype.revert=function(e){return e},e.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n)},e.prototype.sqrTo=function(e,t){e.squareTo(t)},e}(),g=function(){function e(e){this.m=e}return e.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},e.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),m=function(){function e(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}return e.prototype.convert=function(e){var t=Q();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo($.ZERO)>0&&this.m.subTo(t,t),t},e.prototype.revert=function(e){var t=Q();return e.copyTo(t),this.reduce(t),t},e.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var n=32767&e[t],r=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,r,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),b=function(){function e(e){this.m=e,this.r2=Q(),this.q3=Q(),$.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e)}return e.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=Q();return e.copyTo(t),this.reduce(t),t},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}();function Q(){return new $(null)}function X(e,t){return new $(e,t)}function Z(e,t,n,r,o,i){for(;--i>=0;){var s=t*this[e++]+n[r]+o;o=Math.floor(s/67108864),n[r++]=67108863&s}return o}function ee(e,t,n,r,o,i){for(var s=32767&t,a=t>>15;--i>=0;){var c=32767&this[e],u=this[e++]>>15,l=a*c+u*s;o=((c=s*c+((32767&l)<<15)+n[r]+(1073741823&o))>>>30)+(l>>>15)+a*u+(o>>>30),n[r++]=1073741823&c}return o}function te(e,t,n,r,o,i){for(var s=16383&t,a=t>>14;--i>=0;){var c=16383&this[e],u=this[e++]>>14,l=a*c+u*s;o=((c=s*c+((16383&l)<<14)+n[r]+o)>>28)+(l>>14)+a*u,n[r++]=268435455&c}return o}void 0!==o&&"Microsoft Internet Explorer"==(null==o?void 0:o.appName)?($.prototype.am=ee,h=30):"Netscape"!=(null==o?void 0:o.appName)?($.prototype.am=Z,h=26):($.prototype.am=te,h=28),$.prototype.DB=h,$.prototype.DM=(1<<h)-1,$.prototype.DV=1<<h,$.prototype.FV=Math.pow(2,52),$.prototype.F1=52-h,$.prototype.F2=2*h-52;var _,E,w=[];for(_="0".charCodeAt(0),E=0;E<=9;++E)w[_++]=E;for(_="a".charCodeAt(0),E=10;E<36;++E)w[_++]=E;for(_="A".charCodeAt(0),E=10;E<36;++E)w[_++]=E;function ne(e,t){var n=w[e.charCodeAt(t)];return null==n?-1:n}function re(e){var t=Q();return t.fromInt(e),t}function oe(e){var t,n=1;return 0!=(t=e>>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}$.ZERO=re(0),$.ONE=re(1);class ie{constructor(){this.i=0,this.j=0,this.S=[]}init(e){var t,n,r;for(t=0;t<256;++t)this.S[t]=t;for(n=0,t=0;t<256;++t)n=n+this.S[t]+e[t%e.length]&255,r=this.S[t],this.S[t]=this.S[n],this.S[n]=r;this.i=0,this.j=0}next(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}var S,I,O=null;if(null==O){O=[],I=0;var A,T,P=void 0;if("undefined"!=typeof window&&null!==(A=window)&&void 0!==A&&A.crypto&&null!==(T=window)&&void 0!==T&&T.crypto.getRandomValues){var C,R=new Uint32Array(256);for(null===(C=window)||void 0===C||C.crypto.getRandomValues(R),P=0;P<R.length;++P)O[I++]=255&R[P]}var N,k,U,D=function(e){var t,n,r;if(this.count=this.count||0,this.count>=256||I>=256){if("undefined"!=typeof window)if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(r=window)||void 0===r||r.removeEventListener("mousemove",D,!1);else if(null!==(n=window)&&void 0!==n&&n.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",D)}}else try{var i=e.x+e.y;O[I++]=255&i,this.count+=1}catch(e){}};if("undefined"!=typeof window)if(null!==(N=window)&&void 0!==N&&N.addEventListener)null===(U=window)||void 0===U||U.addEventListener("mousemove",D,!1);else if(null!==(k=window)&&void 0!==k&&k.attachEvent){var L;null===(L=window)||void 0===L||L.attachEvent("onmousemove",D)}}function se(){if(null==S){for(S=new ie;I<256;){var e=Math.floor(65536*Math.random());O[I++]=255&e}for(S.init(O),I=0;I<O.length;++I)O[I]=0;I=0}return S.next()}class ae{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=se()}}function ce(e,t){if(t<e.length+11)return console.error("Message too long for RSA"),null;for(var n=[],r=e.length-1;r>=0&&t>0;){var o=e.charCodeAt(r--);o<128?n[--t]=o:o>127&&o<2048?(n[--t]=63&o|128,n[--t]=o>>6|192):(n[--t]=63&o|128,n[--t]=o>>6&63|128,n[--t]=o>>12|224)}n[--t]=0;for(var i=new ae,s=[];t>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);n[--t]=s[0]}return n[--t]=2,n[--t]=0,new $(n)}class ue{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(e){return e.modPowInt(this.e,this.n)}doPrivate(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),n=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(n)<0;)t=t.add(this.p);return t.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)}setPublic(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")}encrypt(e){var t=ce(e,this.n.bitLength()+7>>3);if(null==t)return null;var n=this.doPublic(t);if(null==n)return null;var r=n.toString(16);return 1&r.length?"0"+r:r}encryptLong(e){var t=this,n=(this.n.bitLength()+7>>3)-11;try{var r="";return e.length>n?(e.match(/.{1,117}/g).forEach(function(e){var n=t.encrypt(e);r+=n}),H(r)):H(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,n=this.n.bitLength()+7>>3;e=G(e);try{if(e.length>n){var r="";return e.match(/.{1,256}/g).forEach(function(e){var n=t.decrypt(e);r+=n}),r}return this.decrypt(e)}catch(e){return!1}}setPrivate(e,t,n){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16),this.d=X(n,16)):console.error("Invalid RSA private key")}setPrivateEx(e,t,n,r,o,i,s,a){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=X(e,16),this.e=parseInt(t,16),this.d=X(n,16),this.p=X(r,16),this.q=X(o,16),this.dmp1=X(i,16),this.dmq1=X(s,16),this.coeff=X(a,16)):console.error("Invalid RSA private key")}generate(e,t){var n=new ae,r=e>>1;this.e=parseInt(t,16);for(var o=new $(t,16);;){for(;this.p=new $(e-r,1,n),0!=this.p.subtract($.ONE).gcd(o).compareTo($.ONE)||!this.p.isProbablePrime(10););for(;this.q=new $(r,1,n),0!=this.q.subtract($.ONE).gcd(o).compareTo($.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q,this.q=i}var s=this.p.subtract($.ONE),a=this.q.subtract($.ONE),c=s.multiply(a);if(0==c.gcd(o).compareTo($.ONE)){this.n=this.p.multiply(this.q),this.d=o.modInverse(c),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(e){var t=X(e,16),n=this.doPrivate(t);return null==n?null:le(n,this.n.bitLength()+7>>3)}generateAsync(e,t,n){var r=new ae,o=e>>1;this.e=parseInt(t,16);var i=new $(t,16),s=this,a=()=>{var t=()=>{if(s.p.compareTo(s.q)<=0){var e=s.p;s.p=s.q,s.q=e}var t=s.p.subtract($.ONE),r=s.q.subtract($.ONE),o=t.multiply(r);0==o.gcd(i).compareTo($.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(t),s.dmq1=s.d.mod(r),s.coeff=s.q.modInverse(s.p),setTimeout(function(){n()},0)):setTimeout(a,0)},c=()=>{s.q=Q(),s.q.fromNumberAsync(o,1,r,function(){s.q.subtract($.ONE).gcda(i,function(e){0==e.compareTo($.ONE)&&s.q.isProbablePrime(10)?setTimeout(t,0):setTimeout(c,0)})})},u=()=>{s.p=Q(),s.p.fromNumberAsync(e-o,1,r,function(){s.p.subtract($.ONE).gcda(i,function(e){0==e.compareTo($.ONE)&&s.p.isProbablePrime(10)?setTimeout(c,0):setTimeout(u,0)})})};setTimeout(u,0)};setTimeout(a,0)}}function le(e,t){for(var n=e.toByteArray(),r=0;r<n.length&&0==n[r];)++r;if(n.length-r!=t-1||2!=n[r])return null;for(++r;0!=n[r];)if(++r>=n.length)return null;for(var o="";++r<n.length;){var i=255&n[r];i<128?o+=String.fromCharCode(i):i>191&&i<224?(o+=String.fromCharCode((31&i)<<6|63&n[r+1]),++r):(o+=String.fromCharCode((15&i)<<12|(63&n[r+1])<<6|63&n[r+2]),r+=2)}return o}class he extends ue{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),e&&("string"==typeof e?this.parseKey(e):(this.hasPrivateKeyProperty(e)||this.hasPublicKeyProperty(e))&&this.parsePropertiesFrom(e))}parseKey(e){try{var t=0,n=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?c.decode(e):u.unarmor(e),o=Y.decode(r);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){t=o.sub[1].getHexStringValue(),this.n=X(t,16),n=o.sub[2].getHexStringValue(),this.e=parseInt(n,16);var i=o.sub[3].getHexStringValue();this.d=X(i,16);var s=o.sub[4].getHexStringValue();this.p=X(s,16);var a=o.sub[5].getHexStringValue();this.q=X(a,16);var l=o.sub[6].getHexStringValue();this.dmp1=X(l,16);var h=o.sub[7].getHexStringValue();this.dmq1=X(h,16);var d=o.sub[8].getHexStringValue();this.coeff=X(d,16)}else{if(2!==o.sub.length)return!1;var f=o.sub[1].sub[0];t=f.sub[0].getHexStringValue(),this.n=X(t,16),n=f.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(e){return!1}}hasPublicKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")}hasPrivateKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")}parsePropertiesFrom(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)}}(r=function(e){e=e||{},this.default_key_size=parseInt(e.default_key_size,10)||1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}).prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new he(e)},r.prototype.setPrivateKey=function(e){this.setKey(e)},r.prototype.setPublicKey=function(e){this.setKey(e)},r.prototype.decrypt=function(e){try{return this.getKey().decrypt(G(e))}catch(e){return!1}},r.prototype.encrypt=function(e){try{return H(this.getKey().encrypt(e))}catch(e){return!1}},r.prototype.encryptLong=function(e){try{for(var t=this.getKey().encryptLong(e)||"",n=this.getKey().decryptLong(t)||"",r=0,o=/null$/g;o.test(n)&&(r++,t=this.getKey().encryptLong(e)||"",n=this.getKey().decryptLong(t)||"",!(r>10)););return t}catch(e){return!1}},r.prototype.getKey=function(e){if(!this.key){if(this.key=new he,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},r.version="3.1.4"}t.default=r},8182:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,c=s(n(4274)),u=n(3616);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var n=0,o=(0,u.isArray)(e)?e:[e];n<o.length;n++){var i=o[n],s=i.isMatch,a=i.genAdapter,c=i.runtime;if(s())return{adapter:r({isMatch:s},a(t)),runtime:c}}},t.useDefaultAdapter=function(){return{adapter:r({},c.genAdapter()),runtime:a.WEB}}},4274:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var c=n(2764),u=n(3616),l=n(2946);function h(e){try{return JSON.parse(e)}catch(t){return e}}var d=function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e,n=t.data,r=t.file,o=t.fileContent,s=t.name,a=t.method,c=t.headers,u=void 0===c?{}:c,l=null!=r?r:o,h={post:"post",put:"put"}[null==a?void 0:a.toLowerCase()]||"put",d=new FormData;return"post"===h?(Object.keys(n).forEach(function(e){d.append(e,n[e])}),d.append("key",s),d.append("file",l instanceof Blob?l:new Blob([l])),this.request(i(i({},e),{data:d,method:h}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:u,body:l}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,function(){var t,n,r,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(t){t({statusCode:200,tempFilePath:e.url})})]}})})},t.prototype.fetch=function(e){var t;return s(this,void 0,void 0,function(){var n,r,o,c,u,l,d,f,p,v,y,g,m,b,_,E=this;return a(this,function(w){switch(w.label){case 0:return n=new AbortController,r=e.url,o=e.enableAbort,c=void 0!==o&&o,u=e.stream,l=void 0!==u&&u,d=e.signal,f=e.timeout,p=e.shouldThrowOnError,v=void 0===p||p,y=null!=f?f:this.timeout,d&&(d.aborted&&n.abort(),d.addEventListener("abort",function(){return n.abort()})),g=null,c&&y&&(g=setTimeout(function(){console.warn(E.timeoutMsg),n.abort(new Error(E.timeoutMsg))},y)),[4,fetch(r,i(i({},e),{signal:n.signal})).then(function(e){return s(E,void 0,void 0,function(){var t,n,r;return a(this,function(o){switch(o.label){case 0:return clearTimeout(g),v?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,e.json()];case 2:t=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(g),Promise.reject(e)})];case 1:return m=w.sent(),l?(b=m.body,[3,5]):[3,2];case 2:return(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?(_=h,[4,m.text()]):[3,4];case 3:return b=_.apply(void 0,[w.sent()]),[3,5];case 4:b=m.text(),w.label=5;case 5:return[2,{data:b,statusCode:m.status,header:m.headers,response:m}]}})})},t.prototype.request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i=e.url,s=e.headers,a=void 0===s?{}:s,c=e.data,h=e.responseType,d=e.withCredentials,f=e.body,p=e.onUploadProgress,v=(0,u.formatUrl)((0,l.getProtocol)(),i,"get"===r?c:{}),y=new XMLHttpRequest;y.open(r,v),h&&(y.responseType=h);var g,m,b=e.signal;b&&(b.aborted?y.abort():b.addEventListener("abort",function(){return y.abort()},{once:!0})),Object.keys(a).forEach(function(e){y.setRequestHeader(e,a[e])}),p&&y.upload.addEventListener("progress",p),y.onreadystatechange=function(){var e={};if(4===y.readyState){var t=y.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach(function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o}),e.header=n,e.statusCode=y.status;try{e.data="blob"===h?y.response:JSON.parse(y.responseText)}catch(t){e.data="blob"===h?y.response:y.responseText}clearTimeout(g),o(e)}},t&&n.timeout&&(g=setTimeout(function(){console.warn(n.timeoutMsg),y.abort()},n.timeout)),m=(0,u.isFormData)(c)?c:"application/x-www-form-urlencoded"===a["content-type"]?(0,u.toQueryString)(c):f||(c?JSON.stringify(c):void 0),d&&(y.withCredentials=!0),y.send(m)})},t}(c.AbstractSDKRequest);t.WebRequest=d,t.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage:localStorage}}},2946:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var n="@cloudbase/js-sdk";t.setSdkName=function(e){n=e},t.getSdkName=function(){return n};var r="https:";t.setProtocol=function(e){r=e},t.getProtocol=function(){return r},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},6205:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},794:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(n(2946),t),o(n(6205),t),t.OATUH_LOGINTYPE="constants"},7718:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=n(3616),s=n(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,n=e.className,r=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),h=s.findIndex(function(e){return c.test(e)});if(-1!==h){var d=s.filter(function(e,t){return t>h});d.unshift(s[h].replace(l,"".concat(n,".").concat(r)).replace(u,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,a=e.customInfo,h=void 0===a?{}:a,d=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=h.className||e.constructor.name,v=h.methodName||t,y=a.value,g=function(){var e="",t=(new Error).stack.split("\n"),n=t.findIndex(function(e){return c.test(e)});if(-1!==n){var r=u.exec(t[n+1]||"");e=r?r[0]:""}return e}();a.value="sync"===n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=l({err:new Error,className:f,methodName:v,sourceLink:g});try{return y.apply(this,e)}catch(e){var r=e,o=e.message,s=e.error,a=e.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(n?(n.code=u.code,n.msg=u.msg):(e.code=u.code,e.message=u.msg),r=n||e,c.content=p.map(function(e){return{type:"info",body:e}}))}throw s&&a&&(c.subtitle=a,n?(n.code=s,n.msg=a):(e.code=s,e.message=a),r=n||e,c.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(c),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,function(){var t,n,r,s,a,c,u,h;return o(this,function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,c=n.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(h=JSON.parse(s),u.subtitle=h,h.code&&(t?(t.code=h.code,t.message=h.msg):(n.code=h.code,n.message=h.msg),r=t||n,u.content=p.map(function(e){return{type:"info",body:e}}))),a&&c&&(u.subtitle=c,t?(t.code=a,t.msg=c):(n.code=a,n.message=c),r=t||n,u.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(u),r;case 4:return[2]}})})}}}}},141:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(7718),t)},6197:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=n(2764),c=n(3616),u=n(794),l=function(e){function t(t){var n=e.call(this)||this;return n.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),h=function(){function e(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return i(this,void 0,void 0,function(){var r;return s(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var r=this.storage.getItem(e);return r&&r.indexOf(t)>=0?JSON.parse(r).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return i(this,void 0,void 0,function(){var r;return s(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(r=o.sent())&&r.indexOf(t)>=0?[2,JSON.parse(r).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}();t.CloudbaseCache=h},9689:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=n(3616),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var c=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return o(t,e),t}(a);t.IErrorEvent=c;var u=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,c))return console.error(e.error),this;var n=(0,s.isString)(e)?new a(e,t||{}):e,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,u=this.listeners[r]?i([],this.listeners[r],!0):[];o<u.length;o++)u[o].call(this,n)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=u;var l=new u;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},3616:function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.errorToResult=t.promoteGatewayError=t.maybeThrow=t.resolveThrow=t.createCloudbaseError=t.CloudbaseError=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var a=n(794);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var r=16*Math.random();return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:7&r|8).toString(16)})},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";return Object.keys(n).forEach(function(e){""===o?!r&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(n[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(n){t.push("".concat(n,"=").concat(encodeURIComponent(e[n])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||decodeURIComponent(window.location.search),r=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('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}var n=new Promise(function(t,n){e=function(e,r){return e?n(e):t(r)}});return e.promise=n,e},t.execCallback=function(e,t,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(t,n);if(t)throw t;return n},t.printWarn=function(e,t){console.warn("[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){var n=new Error(JSON.stringify({code:e,msg:"[".concat((0,a.getSdkName)(),"][").concat(e,"]:").concat(t)}));throw n.code=e,n};var c=function(e){function t(t){var n=e.call(this,t.msg||t.message||"")||this;return n.code=t.code||"",n.requestId=t.requestId||"",Object.defineProperty(n,"message",{value:t.msg||t.message||"",enumerable:!0,writable:!0,configurable:!0}),n}return o(t,e),t}(Error);t.CloudbaseError=c;var u=function(e){return new c(e)};function l(e,t){return(t||u)(e)}function h(e){return!e||"boolean"!=typeof e.throw||e.throw}t.createCloudbaseError=l,t.resolveThrow=h,t.maybeThrow=function(e,t){if(h(e))throw l(i(i({},t),{msg:t.message}),null==e?void 0:e.errorFactory);return i({code:t.code,message:t.message},t.requestId?{requestId:t.requestId}:{})},t.promoteGatewayError=function(e){if(e&&"object"==typeof e&&e.data&&"object"==typeof e.data){var t=e.data,n=t.code,r=t.message;if(!e.code&&n||!e.message&&r)return i(i(i({},e),!e.code&&n?{code:n}:{}),!e.message&&r?{message:r}:{})}return e},t.errorToResult=function(e){if(e instanceof Error&&"string"==typeof e.message)try{var t=JSON.parse(e.message);if(t&&"string"==typeof t.code)return{code:t.code,message:t.msg||t.message||"",requestId:t.requestId}}catch(e){}return e&&"string"==typeof e.code?{code:e.code,message:e.message||"",requestId:e.requestId}:{code:"UNKNOWN_ERROR",message:String((null==e?void 0:e.message)||e||"")}},t.printGroupLog=function(e){var t,n=e.title,r=e.subtitle,o=void 0===r?"":r,i=e.content,s=void 0===i?[]:i,a=e.printTrace,c=void 0!==a&&a,u=e.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var l=0,h=s;l<h.length;l++){var d=h[l],f=d.type,p=d.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}c&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise(function(t){return setTimeout(t,e)})},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var n=e.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(t[r]?Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]:t[r]=o)}),t},t.parseCaptcha=function(e){var n={},r=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){e=r[1];var o=r[2];o&&(n=(0,t.parseQueryString)(o))}var i=n.token,a=s(n,["token"]);return/^data:/.test(e)&&!i?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:i?{state:a.state,token:i,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},9515:function(e,t,n){var r=n(8761)(n(7772),"DataView");e.exports=r},9612:function(e,t,n){var r=n(2118),o=n(6909),i=n(8138),s=n(4174),a=n(7942);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,e.exports=c},235:function(e,t,n){var r=n(3945),o=n(1846),i=n(8028),s=n(6018),a=n(4769);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,e.exports=c},326:function(e,t,n){var r=n(8761)(n(7772),"Map");e.exports=r},6738:function(e,t,n){var r=n(2411),o=n(6417),i=n(6928),s=n(9493),a=n(4150);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=o,c.prototype.get=i,c.prototype.has=s,c.prototype.set=a,e.exports=c},2760:function(e,t,n){var r=n(8761)(n(7772),"Promise");e.exports=r},2143:function(e,t,n){var r=n(8761)(n(7772),"Set");e.exports=r},6571:function(e,t,n){var r=n(235),o=n(5243),i=n(2858),s=n(4417),a=n(8605),c=n(1418);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=o,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=a,u.prototype.set=c,e.exports=u},857:function(e,t,n){var r=n(7772).Symbol;e.exports=r},9162:function(e,t,n){var r=n(7772).Uint8Array;e.exports=r},3215:function(e,t,n){var r=n(8761)(n(7772),"WeakMap");e.exports=r},2517:function(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},7552:function(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[o++]=s)}return i}},1634:function(e,t,n){var r=n(6473),o=n(9631),i=n(6152),s=n(3226),a=n(9045),c=n(7598),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),l=!n&&o(e),h=!n&&!l&&s(e),d=!n&&!l&&!h&&c(e),f=n||l||h||d,p=f?r(e.length,String):[],v=p.length;for(var y in e)!t&&!u.call(e,y)||f&&("length"==y||h&&("offset"==y||"parent"==y)||d&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||a(y,v))||p.push(y);return p}},343:function(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}},5067:function(e){e.exports=function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}},91:function(e,t,n){var r=n(3940),o=n(1225),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&o(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},2218:function(e,t,n){var r=n(1225);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},7993:function(e,t,n){var r=n(752),o=n(249);e.exports=function(e,t){return e&&r(t,o(t),e)}},5906:function(e,t,n){var r=n(752),o=n(8582);e.exports=function(e,t){return e&&r(t,o(t),e)}},3940:function(e,t,n){var r=n(3043);e.exports=function(e,t,n){"__proto__"==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},8874:function(e,t,n){var r=n(6571),o=n(2517),i=n(91),s=n(7993),a=n(5906),c=n(2175),u=n(1522),l=n(7680),h=n(9987),d=n(3483),f=n(6939),p=n(940),v=n(9917),y=n(8222),g=n(8725),m=n(6152),b=n(3226),_=n(4714),E=n(9259),w=n(3679),S=n(249),I=n(8582),O="[object Arguments]",A="[object Function]",T="[object Object]",P={};P[O]=P["[object Array]"]=P["[object ArrayBuffer]"]=P["[object DataView]"]=P["[object Boolean]"]=P["[object Date]"]=P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Map]"]=P["[object Number]"]=P[T]=P["[object RegExp]"]=P["[object Set]"]=P["[object String]"]=P["[object Symbol]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P["[object Error]"]=P[A]=P["[object WeakMap]"]=!1,e.exports=function e(t,n,C,R,N,k){var U,D=1&n,L=2&n,j=4&n;if(C&&(U=N?C(t,R,N,k):C(t)),void 0!==U)return U;if(!E(t))return t;var x=m(t);if(x){if(U=v(t),!D)return u(t,U)}else{var M=p(t),q=M==A||"[object GeneratorFunction]"==M;if(b(t))return c(t,D);if(M==T||M==O||q&&!N){if(U=L||q?{}:g(t),!D)return L?h(t,a(U,t)):l(t,s(U,t))}else{if(!P[M])return N?t:{};U=y(t,M,D)}}k||(k=new r);var F=k.get(t);if(F)return F;k.set(t,U),w(t)?t.forEach(function(r){U.add(e(r,n,C,r,t,k))}):_(t)&&t.forEach(function(r,o){U.set(o,e(r,n,C,o,t,k))});var B=x?void 0:(j?L?f:d:L?I:S)(t);return o(B||t,function(r,o){B&&(r=t[o=r]),i(U,o,e(r,n,C,o,t,k))}),U}},9413:function(e,t,n){var r=n(9259),o=Object.create,i=function(){function e(){}return function(t){if(!r(t))return{};if(o)return o(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();e.exports=i},3324:function(e,t,n){var r=n(7297),o=n(3812);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[o(t[n++])];return n&&n==i?e:void 0}},1897:function(e,t,n){var r=n(5067),o=n(6152);e.exports=function(e,t,n){var i=t(e);return o(e)?i:r(i,n(e))}},3366:function(e,t,n){var r=n(857),o=n(2107),i=n(7157),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},5183:function(e,t,n){var r=n(3366),o=n(5125);e.exports=function(e){return o(e)&&"[object Arguments]"==r(e)}},4511:function(e,t,n){var r=n(940),o=n(5125);e.exports=function(e){return o(e)&&"[object Map]"==r(e)}},6840:function(e,t,n){var r=n(1049),o=n(7394),i=n(9259),s=n(7035),a=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,h=u.hasOwnProperty,d=RegExp("^"+l.call(h).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(r(e)?d:a).test(s(e))}},8436:function(e,t,n){var r=n(940),o=n(5125);e.exports=function(e){return o(e)&&"[object Set]"==r(e)}},5522:function(e,t,n){var r=n(3366),o=n(1158),i=n(5125),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,e.exports=function(e){return i(e)&&o(e.length)&&!!s[r(e)]}},6411:function(e,t,n){var r=n(6001),o=n(4248),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return o(e);var t=[];for(var n in Object(e))i.call(e,n)&&"constructor"!=n&&t.push(n);return t}},8390:function(e,t,n){var r=n(9259),o=n(6001),i=n(2966),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=o(e),n=[];for(var a in e)("constructor"!=a||!t&&s.call(e,a))&&n.push(a);return n}},2857:function(e,t,n){var r=n(91),o=n(7297),i=n(9045),s=n(9259),a=n(3812);e.exports=function(e,t,n,c){if(!s(e))return e;for(var u=-1,l=(t=o(t,e)).length,h=l-1,d=e;null!=d&&++u<l;){var f=a(t[u]),p=n;if("__proto__"===f||"constructor"===f||"prototype"===f)return e;if(u!=h){var v=d[f];void 0===(p=c?c(v,f,d):void 0)&&(p=s(v)?v:i(t[u+1])?[]:{})}r(d,f,p),d=d[f]}return e}},9872:function(e){e.exports=function(e,t,n){var r=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=e[r+t];return i}},6473:function(e){e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},1054:function(e,t,n){var r=n(857),o=n(343),i=n(6152),s=n(4795),a=r?r.prototype:void 0,c=a?a.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(i(t))return o(t,e)+"";if(s(t))return c?c.call(t):"";var n=t+"";return"0"==n&&1/t==-1/0?"-0":n}},7826:function(e){e.exports=function(e){return function(t){return e(t)}}},9078:function(e,t,n){var r=n(7297),o=n(6974),i=n(2721),s=n(3812),a=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=-1,c=(t=r(t,e)).length;if(!c)return!0;for(;++n<c;){var u=s(t[n]);if("__proto__"===u&&!a.call(e,"__proto__"))return!1;if(("constructor"===u||"prototype"===u)&&n<c-1)return!1}var l=i(e,t);return null==l||delete l[s(o(t))]}},7297:function(e,t,n){var r=n(6152),o=n(1401),i=n(4452),s=n(6188);e.exports=function(e,t){return r(e)?e:o(e,t)?[e]:i(s(e))}},9882:function(e,t,n){var r=n(9162);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},2175:function(e,t,n){e=n.nmd(e);var r=n(7772),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=a?a(n):new e.constructor(n);return e.copy(r),r}},4727:function(e,t,n){var r=n(9882);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}},6058:function(e){var t=/\w*$/;e.exports=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}},169:function(e,t,n){var r=n(857),o=r?r.prototype:void 0,i=o?o.valueOf:void 0;e.exports=function(e){return i?Object(i.call(e)):{}}},6190:function(e,t,n){var r=n(9882);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},1522:function(e){e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},752:function(e,t,n){var r=n(91),o=n(3940);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var a=-1,c=t.length;++a<c;){var u=t[a],l=i?i(n[u],e[u],u,n,e):void 0;void 0===l&&(l=e[u]),s?o(n,u,l):r(n,u,l)}return n}},7680:function(e,t,n){var r=n(752),o=n(633);e.exports=function(e,t){return r(e,o(e),t)}},9987:function(e,t,n){var r=n(752),o=n(2680);e.exports=function(e,t){return r(e,o(e),t)}},4019:function(e,t,n){var r=n(7772)["__core-js_shared__"];e.exports=r},3043:function(e,t,n){var r=n(8761),o=function(){try{var e=r(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=o},1242:function(e,t,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},3483:function(e,t,n){var r=n(1897),o=n(633),i=n(249);e.exports=function(e){return r(e,i,o)}},6939:function(e,t,n){var r=n(1897),o=n(2680),i=n(8582);e.exports=function(e){return r(e,i,o)}},7937:function(e,t,n){var r=n(8304);e.exports=function(e,t){var n=e.__data__;return r(t)?n["string"==typeof t?"string":"hash"]:n.map}},8761:function(e,t,n){var r=n(6840),o=n(8109);e.exports=function(e,t){var n=o(e,t);return r(n)?n:void 0}},7353:function(e,t,n){var r=n(241)(Object.getPrototypeOf,Object);e.exports=r},2107:function(e,t,n){var r=n(857),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},633:function(e,t,n){var r=n(7552),o=n(981),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:o;e.exports=a},2680:function(e,t,n){var r=n(5067),o=n(7353),i=n(633),s=n(981),a=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)r(t,i(e)),e=o(e);return t}:s;e.exports=a},940:function(e,t,n){var r=n(9515),o=n(326),i=n(2760),s=n(2143),a=n(3215),c=n(3366),u=n(7035),l="[object Map]",h="[object Promise]",d="[object Set]",f="[object WeakMap]",p="[object DataView]",v=u(r),y=u(o),g=u(i),m=u(s),b=u(a),_=c;(r&&_(new r(new ArrayBuffer(1)))!=p||o&&_(new o)!=l||i&&_(i.resolve())!=h||s&&_(new s)!=d||a&&_(new a)!=f)&&(_=function(e){var t=c(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):"";if(r)switch(r){case v:return p;case y:return l;case g:return h;case m:return d;case b:return f}return t}),e.exports=_},8109:function(e){e.exports=function(e,t){return null==e?void 0:e[t]}},2118:function(e,t,n){var r=n(9191);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},6909:function(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},8138:function(e,t,n){var r=n(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return o.call(t,e)?t[e]:void 0}},4174:function(e,t,n){var r=n(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:o.call(t,e)}},7942:function(e,t,n){var r=n(9191);e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?"__lodash_hash_undefined__":t,this}},9917:function(e){var t=Object.prototype.hasOwnProperty;e.exports=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r}},8222:function(e,t,n){var r=n(9882),o=n(4727),i=n(6058),s=n(169),a=n(6190);e.exports=function(e,t,n){var c=e.constructor;switch(t){case"[object ArrayBuffer]":return r(e);case"[object Boolean]":case"[object Date]":return new c(+e);case"[object DataView]":return o(e,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return a(e,n);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(e);case"[object RegExp]":return i(e);case"[object Symbol]":return s(e)}}},8725:function(e,t,n){var r=n(9413),o=n(7353),i=n(6001);e.exports=function(e){return"function"!=typeof e.constructor||i(e)?{}:r(o(e))}},9045:function(e){var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n}},1401:function(e,t,n){var r=n(6152),o=n(4795),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!o(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},8304:function(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},7394:function(e,t,n){var r,o=n(4019),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!i&&i in e}},6001:function(e){var t=Object.prototype;e.exports=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}},3945:function(e){e.exports=function(){this.__data__=[],this.size=0}},1846:function(e,t,n){var r=n(2218),o=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():o.call(t,n,1),--this.size,0))}},8028:function(e,t,n){var r=n(2218);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},6018:function(e,t,n){var r=n(2218);e.exports=function(e){return r(this.__data__,e)>-1}},4769:function(e,t,n){var r=n(2218);e.exports=function(e,t){var n=this.__data__,o=r(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this}},2411:function(e,t,n){var r=n(9612),o=n(235),i=n(326);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||o),string:new r}}},6417:function(e,t,n){var r=n(7937);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},6928:function(e,t,n){var r=n(7937);e.exports=function(e){return r(this,e).get(e)}},9493:function(e,t,n){var r=n(7937);e.exports=function(e){return r(this,e).has(e)}},4150:function(e,t,n){var r=n(7937);e.exports=function(e,t){var n=r(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this}},7777:function(e,t,n){var r=n(733);e.exports=function(e){var t=r(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}},9191:function(e,t,n){var r=n(8761)(Object,"create");e.exports=r},4248:function(e,t,n){var r=n(241)(Object.keys,Object);e.exports=r},2966:function(e){e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},4146:function(e,t,n){e=n.nmd(e);var r=n(1242),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o&&r.process,a=function(){try{return i&&i.require&&i.require("util").types||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=a},7157:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},241:function(e){e.exports=function(e,t){return function(n){return e(t(n))}}},2721:function(e,t,n){var r=n(3324),o=n(9872);e.exports=function(e,t){return t.length<2?e:r(e,o(t,0,-1))}},7772:function(e,t,n){var r=n(1242),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},5243:function(e,t,n){var r=n(235);e.exports=function(){this.__data__=new r,this.size=0}},2858:function(e){e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},4417:function(e){e.exports=function(e){return this.__data__.get(e)}},8605:function(e){e.exports=function(e){return this.__data__.has(e)}},1418:function(e,t,n){var r=n(235),o=n(326),i=n(6738);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!o||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},4452:function(e,t,n){var r=n(7777),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=r(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(o,function(e,n,r,o){t.push(r?o.replace(i,"$1"):n||e)}),t});e.exports=s},3812:function(e,t,n){var r=n(4795);e.exports=function(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}},7035:function(e){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},9850:function(e,t,n){var r=n(8874);e.exports=function(e){return r(e,5)}},1225:function(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},9631:function(e,t,n){var r=n(5183),o=n(5125),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,c=r(function(){return arguments}())?r:function(e){return o(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=c},6152:function(e){var t=Array.isArray;e.exports=t},7878:function(e,t,n){var r=n(1049),o=n(1158);e.exports=function(e){return null!=e&&o(e.length)&&!r(e)}},3226:function(e,t,n){e=n.nmd(e);var r=n(7772),o=n(6330),i=t&&!t.nodeType&&t,s=i&&e&&!e.nodeType&&e,a=s&&s.exports===i?r.Buffer:void 0,c=(a?a.isBuffer:void 0)||o;e.exports=c},1049:function(e,t,n){var r=n(3366),o=n(9259);e.exports=function(e){if(!o(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1158:function(e){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},4714:function(e,t,n){var r=n(4511),o=n(7826),i=n(4146),s=i&&i.isMap,a=s?o(s):r;e.exports=a},9259:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5125:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},3679:function(e,t,n){var r=n(8436),o=n(7826),i=n(4146),s=i&&i.isSet,a=s?o(s):r;e.exports=a},4795:function(e,t,n){var r=n(3366),o=n(5125);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},7598:function(e,t,n){var r=n(5522),o=n(7826),i=n(4146),s=i&&i.isTypedArray,a=s?o(s):r;e.exports=a},249:function(e,t,n){var r=n(1634),o=n(6411),i=n(7878);e.exports=function(e){return i(e)?r(e):o(e)}},8582:function(e,t,n){var r=n(1634),o=n(8390),i=n(7878);e.exports=function(e){return i(e)?r(e,!0):o(e)}},6974:function(e){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},733:function(e,t,n){var r=n(6738);function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(o.Cache||r),n}o.Cache=r,e.exports=o},6765:function(e,t,n){var r=n(2857);e.exports=function(e,t,n){return null==e?e:r(e,t,n)}},981:function(e){e.exports=function(){return[]}},6330:function(e){e.exports=function(){return!1}},6188:function(e,t,n){var r=n(1054);e.exports=function(e){return null==e?"":r(e)}},7195:function(e,t,n){var r=n(9078);e.exports=function(e,t){return null==e||r(e,t)}},2764:function(e){"use strict";e.exports=require("@cloudbase/adapter-interface")},7917:function(e){"use strict";e.exports=require("@cloudbase/adapter-wx_mp")},8630:function(e){"use strict";e.exports=require("@cloudbase/wx-cloud-client-sdk")},766:function(e){"use strict";e.exports=require("@mattiasbuelens/web-streams-adapter")},2701:function(e){"use strict";e.exports=require("bson")},3107:function(e){"use strict";e.exports=require("jwt-decode")},6282:function(e){"use strict";e.exports=require("text-encoding-shim")},8775:function(e){"use strict";e.exports=require("web-streams-polyfill")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={id:e,loaded:!1,exports:{}};return n[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}t=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&r&&n;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach(function(e){s[e]=function(){return n[e]}});return s.default=function(){return n},o.d(i,s),i},o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e};var i=o(8795);module.exports=i}();
3
3
  //# sourceMappingURL=index.cjs.js.map