@cloudbase/js-sdk 2.0.0-alpha.0 → 2.0.0-alpha.1
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/miniprogram_dist/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase",[],e):"object"==typeof exports?exports.cloudbase=e():t.cloudbase=e()}("undefined"!=typeof window?window:this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}([function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&n(e,t,r);return o(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.jwt=e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var s=i(r(5));e.constants=s;var c=i(r(12));e.adapters=c;var u=i(r(19));e.cache=u;var f=i(r(20));e.events=f;var l=i(r(3));e.utils=l;var p=i(r(21));e.helpers=p;var h={decode:a(r(23)).default};e.jwt=h},function(t,e,r){"use strict";(function(t){r.d(e,"i",(function(){return c})),r.d(e,"e",(function(){return u})),r.d(e,"h",(function(){return f})),r.d(e,"d",(function(){return l})),r.d(e,"a",(function(){return h})),r.d(e,"f",(function(){return y})),r.d(e,"g",(function(){return g})),r.d(e,"c",(function(){return m})),r.d(e,"b",(function(){return b}));var n=r(0),o=n.constants.setSdkName,i=n.constants.setProtocol,a="",s="@cloudbase/js-sdk";function c(t){a=t}function u(){return a}function f(t){s=t,o(t)}function l(){return s}var p,h="2020-01-10",d="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",v="//tcb-api.tencentcloudapi.com/web";function y(t,e){v=t,e&&(d=e,i(e))}function g(t,e,r){y(e?"//"+t+"."+e+".tcb-api.tencentcloudapi.com/web":"//"+t+".ap-shanghai.tcb-api.tencentcloudapi.com/web",r)}function m(){return{BASE_URL:v,PROTOCOL:d}}function b(){var t=m(),e=t.PROTOCOL,r=t.BASE_URL;return""+new URL(""+e+r).origin}!function(t){t.NULL="NULL",t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.PHONE="PHONE"}(p||(p={}))}).call(this,r(7))},function(t,e,r){"use strict";var n;r.r(e),r.d(e,"StorageType",(function(){return n})),r.d(e,"AbstractSDKRequest",(function(){return o})),r.d(e,"AbstractStorage",(function(){return i})),r.d(e,"formatUrl",(function(){return a})),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},i=function(){};function a(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.createSign=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=n(r(14)),i=n(r(17)),a=n(r(18)),s=r(5);function c(t){var e=i.default.stringify(t);return e=(e=(e=e.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e},e.createSign=function(t,e){var r=c(a.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+c(a.default.parse(JSON.stringify(t)));return r+"."+c(o.default(r,e))},e.toQueryString=function(t){void 0===t&&(t={});var e=[];for(var r in t)e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||window.location.search,n=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]"+t+"=([^&#]*)"));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r=r+"?"+n.join("&")}return r},e.createPromiseCallback=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("["+s.getSdkName()+"]["+t+"]:"+e)},e.printError=function(t,e){console.error({code:t,msg:"["+s.getSdkName()+"]["+t+"]:"+e})},e.printInfo=function(t,e){console.log("["+s.getSdkName()+"]["+t+"]:"+e)},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"["+s.getSdkName()+"]["+t+"]:"+e}))},e.printGroupLog=function(t){var e=t.title,r=t.subtitle,n=void 0===r?"":r,o=t.content,i=void 0===o?[]:o,a=t.printTrace,s=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?console.groupCollapsed(e,n):console.group(e,n);for(var u=0,f=i;u<f.length;u++){var l=f[u],p=l.type,h=l.body;switch(p){case"info":console.log(h);break;case"warn":console.warn(h);break;case"error":console.error(h)}}s&&console.trace("stack trace:"),console.groupEnd()},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86"+t}},function(t,e,r){var n;t.exports=(n=n||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},o=n.lib={},i=o.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=o.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,o=t.sigBytes;if(this.clamp(),n%4)for(var i=0;i<o;i++){var a=r[i>>>2]>>>24-i%4*8&255;e[n+i>>>2]|=a<<24-(n+i)%4*8}else for(i=0;i<o;i+=4)e[n+i>>>2]=r[i>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],o=function(e){e=e;var r=987654321,n=4294967295;return function(){var o=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return o/=4294967296,(o+=.5)*(t.random()>.5?1:-1)}},i=0;i<e;i+=4){var s=o(4294967296*(r||t.random()));r=987654071*s(),n.push(4294967296*s()|0)}return new a.init(n,e)}}),s=n.enc={},c=s.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o<r;o++){var i=e[o>>>2]>>>24-o%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n+=2)r[n>>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new a.init(r,e/2)}},u=s.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o<r;o++){var i=e[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(i))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n++)r[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new a.init(r,e)}},f=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},l=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,o=r.sigBytes,i=this.blockSize,s=o/(4*i),c=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*i,u=t.min(4*c,o);if(c){for(var f=0;f<c;f+=i)this._doProcessBlock(n,f);var l=n.splice(0,c);r.sigBytes-=u}return new a.init(l,u)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),p=(o.Hasher=l.extend({cfg:i.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new p.HMAC.init(t,r).finalize(e)}}}),n.algo={});return n}(Math),n)},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(r(6),e),o(r(11),e),e.OATUH_LOGINTYPE="constants"},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var o="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";e.setProtocol=function(t){o=t},e.getProtocol=function(){return o},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},function(t,e){var r,n,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(r===setTimeout)return setTimeout(t,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(t){r=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(t){n=a}}();var c,u=[],f=!1,l=-1;function p(){f&&c&&(f=!1,c.length?u=c.concat(u):l=-1,u.length&&h())}function h(){if(!f){var t=s(p);f=!0;for(var e=u.length;e;){for(c=u,u=[];++l<e;)c&&c[l].run();l=-1,e=u.length}c=null,f=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function v(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new d(t,e)),1!==u.length||f||s(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=v,o.addListener=v,o.once=v,o.off=v,o.removeListener=v,o.removeAllListeners=v,o.emit=v,o.prependListener=v,o.prependOnceListener=v,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,r){r(9),t.exports=r(10)},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof l?e:l,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return A()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function l(){}function p(){}function h(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=h.prototype=l.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(l).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return p.prototype=g.constructor=h,h.constructor=p,p.displayName=s(h,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,s(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(b.prototype),b.prototype[i]=function(){return this},t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),s(g,a,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&n(e,t,r);return o(e,t),e},a=(this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}})(r(25)),s=i(r(24)).version;a.default.registerVersion(s);try{window.cloudbase=a.default}catch(t){}e.default=a.default,t.exports=a.default},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.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"}},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&n(e,t,r);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,s=i(r(13)),c=r(3);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,r=c.isArray(t)?t:[t];e<r.length;e++){var n=r[e],o=n.isMatch,i=n.genAdapter,a=n.runtime;if(o())return{adapter:i(),runtime:a}}},e.useDefaultAdapter=function(){return{adapter:s.genAdapter(),runtime:a.WEB}}},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},a=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=r(2),u=r(3),f=r(6),l=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return o(e,t),e.prototype.get=function(t){return this._request(i(i({},t),{method:"get"}),this._restrictedMethods.includes("get"))},e.prototype.post=function(t){return this._request(i(i({},t),{method:"post"}),this._restrictedMethods.includes("post"))},e.prototype.put=function(t){return this._request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=new FormData;for(var a in e)o.append(a,e[a]);return o.append("key",n),o.append("file",r),this._request(i(i({},t),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},e.prototype.download=function(t){return a(this,void 0,void 0,(function(){var e,r,n,o;return s(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=a.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return a.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype._request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,a,s=t.url,c=t.headers,l=void 0===c?{}:c,p=t.data,h=t.responseType,d=t.withCredentials,v=t.body,y=t.onUploadProgress,g=u.formatUrl(f.getProtocol(),s,"get"===n?p:{}),m=new XMLHttpRequest;for(var b in m.open(n,g),h&&(m.responseType=h),l)m.setRequestHeader(b,l[b]);y&&m.upload.addEventListener("progress",y),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=m.status;try{t.data="blob"===h?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===h?m.response:m.responseText}clearTimeout(i),o(t)}},e&&r._timeout&&(i=setTimeout((function(){console.warn(r._timeoutMsg),m.abort()}),r._timeout)),a=u.isFormData(p)?p:"application/x-www-form-urlencoded"===l["content-type"]?u.toQueryString(p):v||(p?JSON.stringify(p):void 0),d&&(m.withCredentials=!0),m.send(a)}))},e}(c.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},function(t,e,r){var n;t.exports=(n=r(4),r(15),r(16),n.HmacSHA256)},function(t,e,r){var n;t.exports=(n=r(4),function(t){var e=n,r=e.lib,o=r.WordArray,i=r.Hasher,a=e.algo,s=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,o=0;o<64;)e(n)&&(o<8&&(s[o]=r(t.pow(n,.5))),c[o]=r(t.pow(n,1/3)),o++),n++}();var u=[],f=a.SHA256=i.extend({_doReset:function(){this._hash=new o.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],o=r[1],i=r[2],a=r[3],s=r[4],f=r[5],l=r[6],p=r[7],h=0;h<64;h++){if(h<16)u[h]=0|t[e+h];else{var d=u[h-15],v=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=u[h-2],g=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[h]=v+u[h-7]+g+u[h-16]}var m=n&o^n&i^o&i,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=p+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&f^~s&l)+c[h]+u[h];p=l,l=f,f=s,s=a+w|0,a=i,i=o,o=n,n=w+(b+m)|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+a|0,r[4]=r[4]+s|0,r[5]=r[5]+f|0,r[6]=r[6]+l|0,r[7]=r[7]+p|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return r[o>>>5]|=128<<24-o%32,r[14+(o+64>>>9<<4)]=t.floor(n/4294967296),r[15+(o+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(f),e.HmacSHA256=i._createHmacHelper(f)}(Math),n.SHA256)},function(t,e,r){var n,o,i,a;t.exports=(n=r(4),i=(o=n).lib.Base,a=o.enc.Utf8,void(o.algo.HMAC=i.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=a.parse(e));var r=t.blockSize,n=4*r;e.sigBytes>n&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),i=this._iKey=e.clone(),s=o.words,c=i.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=i.sigBytes=n,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,r=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(r))}})))},function(t,e,r){var n,o,i;t.exports=(i=r(4),o=(n=i).lib.WordArray,n.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,n=this._map;t.clamp();for(var o=[],i=0;i<r;i+=3)for(var a=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;s<4&&i+.75*s<r;s++)o.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(t){var e=t.length,r=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var i=0;i<r.length;i++)n[r.charCodeAt(i)]=i}var a=r.charAt(64);if(a){var s=t.indexOf(a);-1!==s&&(e=s)}return function(t,e,r){for(var n=[],i=0,a=0;a<e;a++)if(a%4){var s=r[t.charCodeAt(a-1)]<<a%4*2,c=r[t.charCodeAt(a)]>>>6-a%4*2;n[i>>>2]|=(s|c)<<24-i%4*8,i++}return o.create(n,i)}(t,e,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)},function(t,e,r){var n;t.exports=(n=r(4),n.enc.Utf8)},function(t,e,r){"use strict";(function(t){var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var s=r(2),c=r(3),u=r(5),f=function(t){function e(e){var r=t.call(this)||this;return r._root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return o(e,t),e.prototype.setItem=function(t,e){this._root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this._root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this._root.tcbCacheObject[t]},e.prototype.clear=function(){delete this._root.tcbCacheObject},e}(s.AbstractStorage);var l=function(){function e(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this._platformInfo=n,this._storage||(this._persistence=this._platformInfo.adapter.primaryStorage||e,this._storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(c.printWarn(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root));case"none":return new f(e.root);default:return e.localStorage?e.localStorage:(c.printWarn(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root))}}(this._persistence,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._persistence},enumerable:!1,configurable:!0}),e.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this._storage)try{var n={version:r||"localCachev1",content:e};this._storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"["+u.getSdkName()+"]["+u.ERRORS.OPERATION_FAIL+"]setStore failed",info:t}))}}else c.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(t,e,r){return i(this,void 0,void 0,(function(){var n;return a(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]),n={version:r||"localCachev1",content:e},[4,this._storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,r){var n;if("async"!==this.mode){try{if(void 0!==t&&(null===(n=t.env)||void 0===n?void 0:n.tcb_token))return t.env.tcb_token;if(!this._storage)return""}catch(t){return""}r=r||"localCachev1";var o=this._storage.getItem(e);return o&&o.indexOf(r)>=0?JSON.parse(o).content:""}c.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,r){var n;return i(this,void 0,void 0,(function(){var o;return a(this,(function(i){switch(i.label){case 0:try{if(void 0!==t&&(null===(n=t.env)||void 0===n?void 0:n.tcb_token))return[2,t.env.tcb_token];if(!this._storage)return[2,""]}catch(t){return[2,""]}return r=r||"localCachev1",[4,this._storage.getItem(e)];case 1:return(o=i.sent())&&o.indexOf(r)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},e.prototype.removeStore=function(t){"async"!==this.mode?this._storage.removeItem(t):c.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},e}();e.CloudbaseCache=l}).call(this,r(7))},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var a=r(3);var s=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=s;var c=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return o(e,t),e}(s);e.IErrorEvent=c;var u=function(){function t(){this._listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this._listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this._listeners),this},t.prototype.fire=function(t,e){if(a.isInstanceOf(t,c))return console.error(t.error),this;var r=a.isString(t)?new s(t,e||{}):t,n=r.name;if(this._listens(n)){r.target=this;for(var o=0,u=this._listeners[n]?i(this._listeners[n]):[];o<u.length;o++){u[o].call(this,r)}}return this},t.prototype._listens=function(t){return this._listeners[t]&&this._listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var f=new u;e.addEventListener=function(t,e){f.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),f.fire(t,e)},e.removeEventListener=function(t,e){f.off(t,e)}},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(22),e)},function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=r(3),a=r(5),s=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(s=-1!==navigator.userAgent.indexOf("Firefox"));var c=s?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function f(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,a=e.stack.split("\n"),c=s?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(r+"\\.descriptor.value\\s*\\[as\\s"+n+"\\]\\s*\\(.*\\)$"),f=s?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(r+"\\.descriptor.value\\s*\\[as\\s"+n+"\\]"),l=a.findIndex((function(t){return c.test(t)}));if(-1!==l){var p=a.filter((function(t,e){return e>l}));p.unshift(a[l].replace(f,r+"."+n).replace(u,o)),(i=new Error).stack=(s?"@debugger":"Error")+"\n"+p.join("\n")}return i}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,s=t.customInfo,l=void 0===s?{}:s,p=t.title,h=t.messages,d=void 0===h?[]:h;return function(t,e,s){if(a.IS_DEBUG_MODE){var h=l.className||t.constructor.name,v=l.methodName||e,y=s.value,g=function(t){var e="",r=t.stack.split("\n"),n=r.findIndex((function(t){return c.test(t)}));if(-1!==n){var o=u.exec(r[n+1]||"");e=o?o[0]:""}return e}(new Error);s.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=f({err:new Error,className:h,methodName:v,sourceLink:g});try{return y.apply(this,t)}catch(t){var n=t,o=t.message,a=t.error,s=t.error_description,c={title:p||h+"."+v+" failed",content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(r?(r.code=u.code,r.msg=u.msg):(t.code=u.code,t.message=u.msg),n=r||t,c.content=d.map((function(t){return{type:"info",body:t}})))}throw a&&s&&(c.subtitle=s,r?(r.code=a,r.msg=s):(t.code=a,t.message=s),n=r||t,c.content=d.map((function(t){return{type:"info",body:t}}))),i.printGroupLog(c),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,(function(){var e,r,n,a,s,c,u,l;return o(this,(function(o){switch(o.label){case 0:e=f({err:new Error,className:h,methodName:v,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,t)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,a=r.message,s=r.error,c=r.error_description,u={title:p||h+"."+v+" failed",content:[{type:"error",body:r}]},a&&/^\{.*\}$/.test(a)&&(l=JSON.parse(a),u.subtitle=l,l.code&&(e?(e.code=l.code,e.message=l.msg):(r.code=l.code,r.message=l.msg),n=e||r,u.content=d.map((function(t){return{type:"info",body:t}})))),s&&c&&(u.subtitle=c,e?(e.code=s,e.msg=c):(r.code=s,r.message=c),n=e||r,u.content=d.map((function(t){return{type:"info",body:t}}))),i.printGroupLog(u),n;case 4:return[2]}}))}))}}}}},function(t,e,r){"use strict";function n(t){this.message=t}r.r(e),r.d(e,"InvalidTokenError",(function(){return a})),n.prototype=new Error,n.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,a=0,s="";o=e.charAt(a++);~o&&(r=i%4?64*r+o:o,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function i(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(o(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return o(e)}}function a(t){this.message=t}a.prototype=new Error,a.prototype.name="InvalidTokenError",e.default=function(t,e){if("string"!=typeof t)throw new a("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(i(t.split(".")[r]))}catch(t){throw new a("Invalid token specified: "+t.message)}}},function(t){t.exports=JSON.parse('{"version":"1.8.4-alpha.0"}')},function(t,e,r){"use strict";r.r(e),r.d(e,"getBaseEndPoint",(function(){return A.b})),r.d(e,"cloudbase",(function(){return tt}));var n,o=r(0),i=r(2),a=(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),s=function(){return(s=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},c=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},u=function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};var f=function(t){function e(e){void 0===e&&(e={});var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return a(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(r,n){var o=t.url,a=t.data,s=t.headers,c=wx.request({url:Object(i.formatUrl)("https:",o),data:a,timeout:e._timeout,method:"POST",header:s,success:function(t){r(t)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&(e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg)){console.warn(e._timeoutMsg);try{c.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,r=this;return new Promise((function(n){return c(e,void 0,void 0,(function(){var e,o,i,a,c,f;return u(this,(function(u){return e=t.url,o=t.file,i=t.data,a=t.headers,c=t.onUploadProgress,f=wx.uploadFile({url:e,filePath:o,name:"file",formData:s({},i),header:a,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&i.success_action_status&&(e.statusCode=parseInt(i.success_action_status,10)),n(e)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&(r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg)){console.warn(r._timeoutMsg);try{f.abort()}catch(t){}}}}),c&&f.onProgressUpdate((function(t){c(t)})),[2]}))}))}))},e.prototype.download=function(t){var e=this,r=this;return new Promise((function(n,o){var a=t.url,s=t.headers,c=wx.downloadFile({url:Object(i.formatUrl)("https:",a),header:s,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?n({statusCode:200,tempFilePath:t.tempFilePath}):n(t)},fail:function(t){o(t)},complete:function(t){if(t&&t.errMsg&&(r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg)){console.warn(r._timeoutMsg);try{c.abort()}catch(t){}}}})}))},e}(i.AbstractSDKRequest),l={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},p=function(t,e){void 0===e&&(e={});var r=wx.connectSocket(s({url:t},e));return{set onopen(t){r.onOpen(t)},set onmessage(t){r.onMessage(t)},set onclose(t){r.onClose(t)},set onerror(t){r.onError(t)},send:function(t){return r.send({data:t})},close:function(t,e){return r.close({code:t,reason:e})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var h={genAdapter:function(){return{root:{},reqClass:f,wsClass:p,localStorage:l,primaryStorage:i.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0},runtime:"wx_mp"},d=function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n},v=o.constants.ERRORS,y={};function g(t,e){var r=e.name,n=e.namespace,o=e.entity,i=e.injectEvents,a=e.IIFE,s=void 0!==a&&a;if(y[r]||n&&t[n])throw new Error(JSON.stringify({code:v.INVALID_OPERATION,msg:"Duplicate component "+r}));if(s){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(y[r]=e,n?t.prototype[n]=o:function t(e,r){if(!(r instanceof Object))return r;switch(r.constructor){case Date:return new Date(r.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return r}for(var n in r)r.hasOwnProperty(n)&&(e[n]=t(e[n],r[n]));return e}(t.prototype,o),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var f=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[r]?t.prototype.events[r].events=d(t.prototype.events[r].events,u):t.prototype.events[r]={bus:c,events:u},t.prototype.fire=function(t,e){for(var r in f(t,e),this.events){var n=this.events[r],o=n.bus;if(n.events.includes(t)){o.fire(t,e);break}}}}}var m={},b=function(){return(b=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},w=o.cache.CloudbaseCache,_={},O={};function S(t){var e=t.env,r=t.persistence,n=t.platformInfo,o={userInfoKey:"user_info_"+e};_[e]?_[e].updatePersistence(r):_[e]=new w(b(b({},t),{keys:o,platformInfo:n})),O[e]=O[e]||new w(b(b({},t),{keys:o,platformInfo:n,persistence:"local"}))}function E(t){return O[t]}var A=r(1),P=function(){return(P=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},I=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},x=function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},j=o.constants.ERRORS,R=o.utils.genSeqId,N=o.utils.isFormData,T=o.utils.formatUrl,k=o.utils.createSign,C=o.adapters.RUNTIME,L=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function M(t,e,r){var n=t[e];t[e]=function(e){var o={},i={};r.forEach((function(r){var n=r.call(t,e),a=n.data,s=n.headers;Object.assign(o,a),Object.assign(i,s)}));var a=e.data;return a&&function(){if(N(a))for(var t in o)a.append(t,o[t]);else e.data=P(P({},a),o)}(),e.headers=P(P({},e.headers||{}),i),n.call(t,e)}}function U(){var t=R();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+Object(A.e)(),"x-seqid":t}}}var D=function(){function t(t){this._throwWhenRequestFail=!1,this.config=t,this._reqClass=new m.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=t.throw||!1,this._localCache=E(this.config.env),M(this._reqClass,"post",[U]),M(this._reqClass,"upload",[U]),M(this._reqClass,"download",[U])}return t.prototype.post=function(t){return I(this,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return I(this,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.upload(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return I(this,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.download(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(){return Object(A.b)()},t.prototype.getOauthAccessTokenV2=function(t){return I(this,void 0,void 0,(function(){var e,r;return x(this,(function(n){switch(n.label){case 0:return[4,t.getAccessToken()];case 1:return e=n.sent(),[4,t._getCredentials()];case 2:return r=n.sent(),[2,{accessToken:e,accessTokenExpire:new Date(r.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,r){return I(this,void 0,void 0,(function(){var n,o,i,a,s,c,u,f,l,p,h,d,v,y,g,b,w,_,O,S,E,I,j,R,N,M,U;return x(this,(function(x){switch(x.label){case 0:return n="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=P({action:t,dataVersion:A.a,env:this.config.env},e),-1!==L.indexOf(t)?[3,2]:(a=this.config._fromApp,s=a.oauthInstance.oauth2client,c=i,[4,this.getOauthAccessTokenV2(s)]);case 1:c.access_token=x.sent().accessToken,x.label=2;case 2:if("storage.uploadFile"===t){for(f in u=new FormData)u.hasOwnProperty(f)&&void 0!==u[f]&&u.append(f,i[f]);o="multipart/form-data"}else for(f in o="application/json;charset=UTF-8",u={},i)void 0!==i[f]&&(u[f]=i[f]);return l={headers:{"content-type":o}},(null==r?void 0:r.onUploadProgress)&&(l.onUploadProgress=r.onUploadProgress),this.config.region&&(l.headers["X-TCB-Region"]=this.config.region),(p=this._localCache.getStore(n))&&(l.headers["X-TCB-Trace"]=p),m.runtime!==C.WEB&&(h=this.config,d=h.appSign,v=h.appSecret,y=Date.now(),g=v.appAccessKey,b=v.appAccessKeyId,w=k({data:{},timestamp:y,appAccessKeyId:b,appSign:d},g),l.headers["X-TCB-App-Source"]="timestamp="+y+";appAccessKeyId="+b+";appSign="+d+";sign="+w),_=e.parse,O=e.inQuery,S=e.search,E={env:this.config.env},_&&(E.parse=!0),O&&(E=P(P({},O),E)),I=Object(A.c)(),j=I.BASE_URL,R=I.PROTOCOL,N=T(R,j,E),S&&(N+=S),[4,this.post(P({url:N,data:u},l))];case 3:if(M=x.sent(),(U=M.header&&M.header["x-tcb-trace"])&&this._localCache.setStore(n,U),200!==Number(M.status)&&200!==Number(M.statusCode)||!M.data)throw new Error("network request error");return[2,M]}}))}))},t.prototype.send=function(t,e){return void 0===e&&(e={}),I(this,void 0,void 0,(function(){var r;return x(this,(function(n){switch(n.label){case 0:return[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 1:if((r=n.sent()).data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:j.OPERATION_FAIL,msg:"["+r.data.code+"] "+r.data.message}));return[2,r.data]}}))}))},t}(),B={};var q=function(){return(q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},F=function(t,e,r,n){var o,i=arguments.length,a=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},H=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},W=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},V=function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},J=o.adapters.useAdapters,G=o.adapters.useDefaultAdapter,K=o.adapters.RUNTIME,z=o.constants.ERRORS,Y=o.constants.COMMUNITY_SITE_URL,$=o.utils.printWarn,X=o.helpers.catchErrorsDecorator,Q={timeout:15e3,persistence:"local"},Z={},tt=new(function(){function t(t){this._config=t||this._config,this.authInstance=null,this.oauthInstance=null}return Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return m},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this._config.env,_[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return E(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this._config.env,B[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){if(!e.env)throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"env must not be specified"}));if(m.adapter||this._useDefaultAdapter(),this.requestClient=new m.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:"["+Object(A.d)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+e.timeout/1e3+"s"}),m.runtime!==K.WEB){if(!e.appSecret)throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"invalid appSecret"}));var r=m.adapter.getAppSign?m.adapter.getAppSign():"";if(e.appSign&&r&&e.appSign!==r)throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"invalid appSign"}));if(r&&(e.appSign=r),!e.appSign)throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=q(q({},Q),e),this._config.timeout=this._formatTimeout(this._config.timeout);var n=this._config,o=n.env,i=n.persistence,a=n.debug,s=n.timeout,c=n.appSecret,u=n.appSign,f=n.oauthClient;S({env:o,persistence:i,debug:a,platformInfo:this.platform}),e.region&&Object(A.g)(o,e.region||"");var l=new t(this._config);return function(t){B[t.env]=new D(P(P({},t),{throw:!0}))}({env:o,region:e.region||"",timeout:s,appSecret:c,appSign:u,oauthClient:f,_fromApp:l}),l.requestClient=this.requestClient,l},t.prototype.updateConfig=function(t){var e=t.persistence,r=t.debug;this._config.persistence=e,this._config.debug=r,S({env:this._config.env,persistence:e,debug:r,platformInfo:this.platform})},t.prototype.registerExtension=function(t){Z[t.name]=t},t.prototype.invokeExtension=function(t,e){return W(this,void 0,void 0,(function(){var r;return V(this,(function(n){switch(n.label){case 0:if(!(r=Z[t]))throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"extension:"+t+" must be registered before invoke"}));return[4,r.invoke(e,this)];case 1:return[2,n.sent()]}}))}))},t.prototype.useAdapters=function(t){var e=J(t)||{},r=e.adapter,n=e.runtime;r&&(m.adapter=r),n&&(m.runtime=n)},t.prototype.registerHook=function(e){!function(t,e){var r=e.entity,n=e.target;if(!t.prototype.hasOwnProperty(n))throw new Error(JSON.stringify({code:v.INVALID_OPERATION,msg:"target:"+n+" is not exist"}));var o=t.prototype[n];if("function"!=typeof o)throw new Error(JSON.stringify({code:v.INVALID_OPERATION,msg:"target:"+n+" is not a function which is the only type supports hook"}));t.prototype[n]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.call.apply(r,d([this],t)),o.call.apply(o,d([this],t))}}(t,e)},t.prototype.registerComponent=function(e){g(t,e)},t.prototype.registerVersion=function(t){Object(A.i)(t)},t.prototype.registerSdkName=function(t){Object(A.h)(t)},t.prototype.registerEndPoint=function(t,e){Object(A.f)(t,e)},t.prototype._useDefaultAdapter=function(){var t=G(),e=t.adapter,r=t.runtime;m.adapter=e,m.runtime=r},t.prototype._formatTimeout=function(t){switch(!0){case t>6e5:return $(z.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case t<100:return $(z.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},F([X({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Y]}),H("design:type",Function),H("design:paramtypes",[Object]),H("design:returntype",t)],t.prototype,"init",null),F([X({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Y]}),H("design:type",Function),H("design:paramtypes",[String,Object]),H("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}());tt.useAdapters(h);e.default=tt}])}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase",[],e):"object"==typeof exports?exports.cloudbase=e():t.cloudbase=e()}("undefined"!=typeof window?window:this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}([function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&n(e,t,r);return o(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.jwt=e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var s=i(r(5));e.constants=s;var c=i(r(12));e.adapters=c;var u=i(r(19));e.cache=u;var f=i(r(20));e.events=f;var l=i(r(3));e.utils=l;var p=i(r(21));e.helpers=p;var h={decode:a(r(23)).default};e.jwt=h},function(t,e,r){"use strict";(function(t){r.d(e,"i",(function(){return c})),r.d(e,"e",(function(){return u})),r.d(e,"h",(function(){return f})),r.d(e,"d",(function(){return l})),r.d(e,"a",(function(){return h})),r.d(e,"f",(function(){return y})),r.d(e,"g",(function(){return g})),r.d(e,"c",(function(){return m})),r.d(e,"b",(function(){return b}));var n=r(0),o=n.constants.setSdkName,i=n.constants.setProtocol,a="",s="@cloudbase/js-sdk";function c(t){a=t}function u(){return a}function f(t){s=t,o(t)}function l(){return s}var p,h="2020-01-10",d="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",v="//tcb-api.tencentcloudapi.com/web";function y(t,e){v=t,e&&(d=e,i(e))}function g(t,e,r){y(e?"//"+t+"."+e+".tcb-api.tencentcloudapi.com/web":"//"+t+".ap-shanghai.tcb-api.tencentcloudapi.com/web",r)}function m(){return{BASE_URL:v,PROTOCOL:d}}function b(){var t=m(),e=t.PROTOCOL,r=t.BASE_URL;return""+new URL(""+e+r).origin}!function(t){t.NULL="NULL",t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.PHONE="PHONE"}(p||(p={}))}).call(this,r(7))},function(t,e,r){"use strict";var n;r.r(e),r.d(e,"StorageType",(function(){return n})),r.d(e,"AbstractSDKRequest",(function(){return o})),r.d(e,"AbstractStorage",(function(){return i})),r.d(e,"formatUrl",(function(){return a})),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},i=function(){};function a(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.createSign=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=n(r(14)),i=n(r(17)),a=n(r(18)),s=r(5);function c(t){var e=i.default.stringify(t);return e=(e=(e=e.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e},e.createSign=function(t,e){var r=c(a.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+c(a.default.parse(JSON.stringify(t)));return r+"."+c(o.default(r,e))},e.toQueryString=function(t){void 0===t&&(t={});var e=[];for(var r in t)e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||window.location.search,n=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]"+t+"=([^&#]*)"));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r=r+"?"+n.join("&")}return r},e.createPromiseCallback=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("["+s.getSdkName()+"]["+t+"]:"+e)},e.printError=function(t,e){console.error({code:t,msg:"["+s.getSdkName()+"]["+t+"]:"+e})},e.printInfo=function(t,e){console.log("["+s.getSdkName()+"]["+t+"]:"+e)},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"["+s.getSdkName()+"]["+t+"]:"+e}))},e.printGroupLog=function(t){var e=t.title,r=t.subtitle,n=void 0===r?"":r,o=t.content,i=void 0===o?[]:o,a=t.printTrace,s=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?console.groupCollapsed(e,n):console.group(e,n);for(var u=0,f=i;u<f.length;u++){var l=f[u],p=l.type,h=l.body;switch(p){case"info":console.log(h);break;case"warn":console.warn(h);break;case"error":console.error(h)}}s&&console.trace("stack trace:"),console.groupEnd()},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86"+t}},function(t,e,r){var n;t.exports=(n=n||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},o=n.lib={},i=o.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=o.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,o=t.sigBytes;if(this.clamp(),n%4)for(var i=0;i<o;i++){var a=r[i>>>2]>>>24-i%4*8&255;e[n+i>>>2]|=a<<24-(n+i)%4*8}else for(i=0;i<o;i+=4)e[n+i>>>2]=r[i>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],o=function(e){e=e;var r=987654321,n=4294967295;return function(){var o=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return o/=4294967296,(o+=.5)*(t.random()>.5?1:-1)}},i=0;i<e;i+=4){var s=o(4294967296*(r||t.random()));r=987654071*s(),n.push(4294967296*s()|0)}return new a.init(n,e)}}),s=n.enc={},c=s.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o<r;o++){var i=e[o>>>2]>>>24-o%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n+=2)r[n>>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new a.init(r,e/2)}},u=s.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o<r;o++){var i=e[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(i))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n<e;n++)r[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new a.init(r,e)}},f=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},l=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,o=r.sigBytes,i=this.blockSize,s=o/(4*i),c=(s=e?t.ceil(s):t.max((0|s)-this._minBufferSize,0))*i,u=t.min(4*c,o);if(c){for(var f=0;f<c;f+=i)this._doProcessBlock(n,f);var l=n.splice(0,c);r.sigBytes-=u}return new a.init(l,u)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),p=(o.Hasher=l.extend({cfg:i.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new p.HMAC.init(t,r).finalize(e)}}}),n.algo={});return n}(Math),n)},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(r(6),e),o(r(11),e),e.OATUH_LOGINTYPE="constants"},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var o="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";e.setProtocol=function(t){o=t},e.getProtocol=function(){return o},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},function(t,e){var r,n,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(r===setTimeout)return setTimeout(t,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(t){r=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(t){n=a}}();var c,u=[],f=!1,l=-1;function p(){f&&c&&(f=!1,c.length?u=c.concat(u):l=-1,u.length&&h())}function h(){if(!f){var t=s(p);f=!0;for(var e=u.length;e;){for(c=u,u=[];++l<e;)c&&c[l].run();l=-1,e=u.length}c=null,f=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function v(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new d(t,e)),1!==u.length||f||s(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=v,o.addListener=v,o.once=v,o.off=v,o.removeListener=v,o.removeAllListeners=v,o.emit=v,o.prependListener=v,o.prependOnceListener=v,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,r){r(9),t.exports=r(10)},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof l?e:l,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return A()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function l(){}function p(){}function h(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=h.prototype=l.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(l).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return p.prototype=g.constructor=h,h.constructor=p,p.displayName=s(h,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,s(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(b.prototype),b.prototype[i]=function(){return this},t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),s(g,a,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&n(e,t,r);return o(e,t),e},a=(this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}})(r(25)),s=i(r(24)).version;a.default.registerVersion(s);try{window.cloudbase=a.default}catch(t){}e.default=a.default,t.exports=a.default},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.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"}},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&n(e,t,r);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,s=i(r(13)),c=r(3);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,r=c.isArray(t)?t:[t];e<r.length;e++){var n=r[e],o=n.isMatch,i=n.genAdapter,a=n.runtime;if(o())return{adapter:i(),runtime:a}}},e.useDefaultAdapter=function(){return{adapter:s.genAdapter(),runtime:a.WEB}}},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},a=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=r(2),u=r(3),f=r(6),l=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return o(e,t),e.prototype.get=function(t){return this._request(i(i({},t),{method:"get"}),this._restrictedMethods.includes("get"))},e.prototype.post=function(t){return this._request(i(i({},t),{method:"post"}),this._restrictedMethods.includes("post"))},e.prototype.put=function(t){return this._request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=new FormData;for(var a in e)o.append(a,e[a]);return o.append("key",n),o.append("file",r),this._request(i(i({},t),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},e.prototype.download=function(t){return a(this,void 0,void 0,(function(){var e,r,n,o;return s(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=a.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return a.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype._request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,a,s=t.url,c=t.headers,l=void 0===c?{}:c,p=t.data,h=t.responseType,d=t.withCredentials,v=t.body,y=t.onUploadProgress,g=u.formatUrl(f.getProtocol(),s,"get"===n?p:{}),m=new XMLHttpRequest;for(var b in m.open(n,g),h&&(m.responseType=h),l)m.setRequestHeader(b,l[b]);y&&m.upload.addEventListener("progress",y),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=m.status;try{t.data="blob"===h?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===h?m.response:m.responseText}clearTimeout(i),o(t)}},e&&r._timeout&&(i=setTimeout((function(){console.warn(r._timeoutMsg),m.abort()}),r._timeout)),a=u.isFormData(p)?p:"application/x-www-form-urlencoded"===l["content-type"]?u.toQueryString(p):v||(p?JSON.stringify(p):void 0),d&&(m.withCredentials=!0),m.send(a)}))},e}(c.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},function(t,e,r){var n;t.exports=(n=r(4),r(15),r(16),n.HmacSHA256)},function(t,e,r){var n;t.exports=(n=r(4),function(t){var e=n,r=e.lib,o=r.WordArray,i=r.Hasher,a=e.algo,s=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,o=0;o<64;)e(n)&&(o<8&&(s[o]=r(t.pow(n,.5))),c[o]=r(t.pow(n,1/3)),o++),n++}();var u=[],f=a.SHA256=i.extend({_doReset:function(){this._hash=new o.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],o=r[1],i=r[2],a=r[3],s=r[4],f=r[5],l=r[6],p=r[7],h=0;h<64;h++){if(h<16)u[h]=0|t[e+h];else{var d=u[h-15],v=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=u[h-2],g=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[h]=v+u[h-7]+g+u[h-16]}var m=n&o^n&i^o&i,b=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=p+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+(s&f^~s&l)+c[h]+u[h];p=l,l=f,f=s,s=a+w|0,a=i,i=o,o=n,n=w+(b+m)|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+a|0,r[4]=r[4]+s|0,r[5]=r[5]+f|0,r[6]=r[6]+l|0,r[7]=r[7]+p|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return r[o>>>5]|=128<<24-o%32,r[14+(o+64>>>9<<4)]=t.floor(n/4294967296),r[15+(o+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(f),e.HmacSHA256=i._createHmacHelper(f)}(Math),n.SHA256)},function(t,e,r){var n,o,i,a;t.exports=(n=r(4),i=(o=n).lib.Base,a=o.enc.Utf8,void(o.algo.HMAC=i.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=a.parse(e));var r=t.blockSize,n=4*r;e.sigBytes>n&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),i=this._iKey=e.clone(),s=o.words,c=i.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=i.sigBytes=n,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,r=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(r))}})))},function(t,e,r){var n,o,i;t.exports=(i=r(4),o=(n=i).lib.WordArray,n.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,n=this._map;t.clamp();for(var o=[],i=0;i<r;i+=3)for(var a=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;s<4&&i+.75*s<r;s++)o.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(t){var e=t.length,r=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var i=0;i<r.length;i++)n[r.charCodeAt(i)]=i}var a=r.charAt(64);if(a){var s=t.indexOf(a);-1!==s&&(e=s)}return function(t,e,r){for(var n=[],i=0,a=0;a<e;a++)if(a%4){var s=r[t.charCodeAt(a-1)]<<a%4*2,c=r[t.charCodeAt(a)]>>>6-a%4*2;n[i>>>2]|=(s|c)<<24-i%4*8,i++}return o.create(n,i)}(t,e,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)},function(t,e,r){var n;t.exports=(n=r(4),n.enc.Utf8)},function(t,e,r){"use strict";(function(t){var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var s=r(2),c=r(3),u=r(5),f=function(t){function e(e){var r=t.call(this)||this;return r._root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return o(e,t),e.prototype.setItem=function(t,e){this._root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this._root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this._root.tcbCacheObject[t]},e.prototype.clear=function(){delete this._root.tcbCacheObject},e}(s.AbstractStorage);var l=function(){function e(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this._platformInfo=n,this._storage||(this._persistence=this._platformInfo.adapter.primaryStorage||e,this._storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(c.printWarn(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root));case"none":return new f(e.root);default:return e.localStorage?e.localStorage:(c.printWarn(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root))}}(this._persistence,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._persistence},enumerable:!1,configurable:!0}),e.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this._storage)try{var n={version:r||"localCachev1",content:e};this._storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"["+u.getSdkName()+"]["+u.ERRORS.OPERATION_FAIL+"]setStore failed",info:t}))}}else c.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(t,e,r){return i(this,void 0,void 0,(function(){var n;return a(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]),n={version:r||"localCachev1",content:e},[4,this._storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,r){var n;if("async"!==this.mode){try{if(void 0!==t&&(null===(n=t.env)||void 0===n?void 0:n.tcb_token))return t.env.tcb_token;if(!this._storage)return""}catch(t){return""}r=r||"localCachev1";var o=this._storage.getItem(e);return o&&o.indexOf(r)>=0?JSON.parse(o).content:""}c.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,r){var n;return i(this,void 0,void 0,(function(){var o;return a(this,(function(i){switch(i.label){case 0:try{if(void 0!==t&&(null===(n=t.env)||void 0===n?void 0:n.tcb_token))return[2,t.env.tcb_token];if(!this._storage)return[2,""]}catch(t){return[2,""]}return r=r||"localCachev1",[4,this._storage.getItem(e)];case 1:return(o=i.sent())&&o.indexOf(r)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},e.prototype.removeStore=function(t){"async"!==this.mode?this._storage.removeItem(t):c.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},e}();e.CloudbaseCache=l}).call(this,r(7))},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var a=r(3);var s=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=s;var c=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return o(e,t),e}(s);e.IErrorEvent=c;var u=function(){function t(){this._listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this._listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this._listeners),this},t.prototype.fire=function(t,e){if(a.isInstanceOf(t,c))return console.error(t.error),this;var r=a.isString(t)?new s(t,e||{}):t,n=r.name;if(this._listens(n)){r.target=this;for(var o=0,u=this._listeners[n]?i(this._listeners[n]):[];o<u.length;o++){u[o].call(this,r)}}return this},t.prototype._listens=function(t){return this._listeners[t]&&this._listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var f=new u;e.addEventListener=function(t,e){f.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),f.fire(t,e)},e.removeEventListener=function(t,e){f.off(t,e)}},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(22),e)},function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=r(3),a=r(5),s=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(s=-1!==navigator.userAgent.indexOf("Firefox"));var c=s?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function f(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,a=e.stack.split("\n"),c=s?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(r+"\\.descriptor.value\\s*\\[as\\s"+n+"\\]\\s*\\(.*\\)$"),f=s?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(r+"\\.descriptor.value\\s*\\[as\\s"+n+"\\]"),l=a.findIndex((function(t){return c.test(t)}));if(-1!==l){var p=a.filter((function(t,e){return e>l}));p.unshift(a[l].replace(f,r+"."+n).replace(u,o)),(i=new Error).stack=(s?"@debugger":"Error")+"\n"+p.join("\n")}return i}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,s=t.customInfo,l=void 0===s?{}:s,p=t.title,h=t.messages,d=void 0===h?[]:h;return function(t,e,s){if(a.IS_DEBUG_MODE){var h=l.className||t.constructor.name,v=l.methodName||e,y=s.value,g=function(t){var e="",r=t.stack.split("\n"),n=r.findIndex((function(t){return c.test(t)}));if(-1!==n){var o=u.exec(r[n+1]||"");e=o?o[0]:""}return e}(new Error);s.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=f({err:new Error,className:h,methodName:v,sourceLink:g});try{return y.apply(this,t)}catch(t){var n=t,o=t.message,a=t.error,s=t.error_description,c={title:p||h+"."+v+" failed",content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(r?(r.code=u.code,r.msg=u.msg):(t.code=u.code,t.message=u.msg),n=r||t,c.content=d.map((function(t){return{type:"info",body:t}})))}throw a&&s&&(c.subtitle=s,r?(r.code=a,r.msg=s):(t.code=a,t.message=s),n=r||t,c.content=d.map((function(t){return{type:"info",body:t}}))),i.printGroupLog(c),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,(function(){var e,r,n,a,s,c,u,l;return o(this,(function(o){switch(o.label){case 0:e=f({err:new Error,className:h,methodName:v,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,t)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,a=r.message,s=r.error,c=r.error_description,u={title:p||h+"."+v+" failed",content:[{type:"error",body:r}]},a&&/^\{.*\}$/.test(a)&&(l=JSON.parse(a),u.subtitle=l,l.code&&(e?(e.code=l.code,e.message=l.msg):(r.code=l.code,r.message=l.msg),n=e||r,u.content=d.map((function(t){return{type:"info",body:t}})))),s&&c&&(u.subtitle=c,e?(e.code=s,e.msg=c):(r.code=s,r.message=c),n=e||r,u.content=d.map((function(t){return{type:"info",body:t}}))),i.printGroupLog(u),n;case 4:return[2]}}))}))}}}}},function(t,e,r){"use strict";function n(t){this.message=t}r.r(e),r.d(e,"InvalidTokenError",(function(){return a})),n.prototype=new Error,n.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,a=0,s="";o=e.charAt(a++);~o&&(r=i%4?64*r+o:o,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function i(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(o(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return o(e)}}function a(t){this.message=t}a.prototype=new Error,a.prototype.name="InvalidTokenError",e.default=function(t,e){if("string"!=typeof t)throw new a("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(i(t.split(".")[r]))}catch(t){throw new a("Invalid token specified: "+t.message)}}},function(t){t.exports=JSON.parse('{"version":"2.0.0-alpha.0"}')},function(t,e,r){"use strict";r.r(e),r.d(e,"getBaseEndPoint",(function(){return A.b})),r.d(e,"cloudbase",(function(){return tt}));var n,o=r(0),i=r(2),a=(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),s=function(){return(s=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},c=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},u=function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};var f=function(t){function e(e){void 0===e&&(e={});var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return a(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(r,n){var o=t.url,a=t.data,s=t.headers,c=wx.request({url:Object(i.formatUrl)("https:",o),data:a,timeout:e._timeout,method:"POST",header:s,success:function(t){r(t)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&(e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg)){console.warn(e._timeoutMsg);try{c.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,r=this;return new Promise((function(n){return c(e,void 0,void 0,(function(){var e,o,i,a,c,f;return u(this,(function(u){return e=t.url,o=t.file,i=t.data,a=t.headers,c=t.onUploadProgress,f=wx.uploadFile({url:e,filePath:o,name:"file",formData:s({},i),header:a,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&i.success_action_status&&(e.statusCode=parseInt(i.success_action_status,10)),n(e)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&(r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg)){console.warn(r._timeoutMsg);try{f.abort()}catch(t){}}}}),c&&f.onProgressUpdate((function(t){c(t)})),[2]}))}))}))},e.prototype.download=function(t){var e=this,r=this;return new Promise((function(n,o){var a=t.url,s=t.headers,c=wx.downloadFile({url:Object(i.formatUrl)("https:",a),header:s,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?n({statusCode:200,tempFilePath:t.tempFilePath}):n(t)},fail:function(t){o(t)},complete:function(t){if(t&&t.errMsg&&(r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg)){console.warn(r._timeoutMsg);try{c.abort()}catch(t){}}}})}))},e}(i.AbstractSDKRequest),l={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},p=function(t,e){void 0===e&&(e={});var r=wx.connectSocket(s({url:t},e));return{set onopen(t){r.onOpen(t)},set onmessage(t){r.onMessage(t)},set onclose(t){r.onClose(t)},set onerror(t){r.onError(t)},send:function(t){return r.send({data:t})},close:function(t,e){return r.close({code:t,reason:e})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var h={genAdapter:function(){return{root:{},reqClass:f,wsClass:p,localStorage:l,primaryStorage:i.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0},runtime:"wx_mp"},d=function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n},v=o.constants.ERRORS,y={};function g(t,e){var r=e.name,n=e.namespace,o=e.entity,i=e.injectEvents,a=e.IIFE,s=void 0!==a&&a;if(y[r]||n&&t[n])throw new Error(JSON.stringify({code:v.INVALID_OPERATION,msg:"Duplicate component "+r}));if(s){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(y[r]=e,n?t.prototype[n]=o:function t(e,r){if(!(r instanceof Object))return r;switch(r.constructor){case Date:return new Date(r.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return r}for(var n in r)r.hasOwnProperty(n)&&(e[n]=t(e[n],r[n]));return e}(t.prototype,o),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var f=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[r]?t.prototype.events[r].events=d(t.prototype.events[r].events,u):t.prototype.events[r]={bus:c,events:u},t.prototype.fire=function(t,e){for(var r in f(t,e),this.events){var n=this.events[r],o=n.bus;if(n.events.includes(t)){o.fire(t,e);break}}}}}var m={},b=function(){return(b=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},w=o.cache.CloudbaseCache,_={},O={};function S(t){var e=t.env,r=t.platformInfo,n={userInfoKey:"user_info_"+e};_[e]=_[e]||new w(b(b({},t),{keys:n,platformInfo:r})),O[e]=O[e]||new w(b(b({},t),{keys:n,platformInfo:r,persistence:"local"}))}function E(t){return O[t]}var A=r(1),I=function(){return(I=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},P=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},x=function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},j=o.constants.ERRORS,R=o.utils.genSeqId,N=o.utils.isFormData,T=o.utils.formatUrl,k=o.utils.createSign,C=o.adapters.RUNTIME,L=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function M(t,e,r){var n=t[e];t[e]=function(e){var o={},i={};r.forEach((function(r){var n=r.call(t,e),a=n.data,s=n.headers;Object.assign(o,a),Object.assign(i,s)}));var a=e.data;return a&&function(){if(N(a))for(var t in o)a.append(t,o[t]);else e.data=I(I({},a),o)}(),e.headers=I(I({},e.headers||{}),i),n.call(t,e)}}function U(){var t=R();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+Object(A.e)(),"x-seqid":t}}}var D=function(){function t(t){this._throwWhenRequestFail=!1,this.config=t,this._reqClass=new m.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=t.throw||!1,this._localCache=E(this.config.env),M(this._reqClass,"post",[U]),M(this._reqClass,"upload",[U]),M(this._reqClass,"download",[U])}return t.prototype.post=function(t){return P(this,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return P(this,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.upload(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return P(this,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.download(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(){return Object(A.b)()},t.prototype.getOauthAccessTokenV2=function(t){return P(this,void 0,void 0,(function(){var e,r;return x(this,(function(n){switch(n.label){case 0:return[4,t.getAccessToken()];case 1:return e=n.sent(),[4,t._getCredentials()];case 2:return r=n.sent(),[2,{accessToken:e,accessTokenExpire:new Date(r.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,r){return P(this,void 0,void 0,(function(){var n,o,i,a,s,c,u,f,l,p,h,d,v,y,g,b,w,_,O,S,E,P,j,R,N,M,U;return x(this,(function(x){switch(x.label){case 0:return n="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=I({action:t,dataVersion:A.a,env:this.config.env},e),-1!==L.indexOf(t)?[3,2]:(a=this.config._fromApp,s=a.oauthInstance.oauth2client,c=i,[4,this.getOauthAccessTokenV2(s)]);case 1:c.access_token=x.sent().accessToken,x.label=2;case 2:if("storage.uploadFile"===t){for(f in u=new FormData)u.hasOwnProperty(f)&&void 0!==u[f]&&u.append(f,i[f]);o="multipart/form-data"}else for(f in o="application/json;charset=UTF-8",u={},i)void 0!==i[f]&&(u[f]=i[f]);return l={headers:{"content-type":o}},(null==r?void 0:r.onUploadProgress)&&(l.onUploadProgress=r.onUploadProgress),this.config.region&&(l.headers["X-TCB-Region"]=this.config.region),(p=this._localCache.getStore(n))&&(l.headers["X-TCB-Trace"]=p),m.runtime!==C.WEB&&(h=this.config,d=h.appSign,v=h.appSecret,y=Date.now(),g=v.appAccessKey,b=v.appAccessKeyId,w=k({data:{},timestamp:y,appAccessKeyId:b,appSign:d},g),l.headers["X-TCB-App-Source"]="timestamp="+y+";appAccessKeyId="+b+";appSign="+d+";sign="+w),_=e.parse,O=e.inQuery,S=e.search,E={env:this.config.env},_&&(E.parse=!0),O&&(E=I(I({},O),E)),P=Object(A.c)(),j=P.BASE_URL,R=P.PROTOCOL,N=T(R,j,E),S&&(N+=S),[4,this.post(I({url:N,data:u},l))];case 3:if(M=x.sent(),(U=M.header&&M.header["x-tcb-trace"])&&this._localCache.setStore(n,U),200!==Number(M.status)&&200!==Number(M.statusCode)||!M.data)throw new Error("network request error");return[2,M]}}))}))},t.prototype.send=function(t,e){return void 0===e&&(e={}),P(this,void 0,void 0,(function(){var r;return x(this,(function(n){switch(n.label){case 0:return[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 1:if((r=n.sent()).data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:j.OPERATION_FAIL,msg:"["+r.data.code+"] "+r.data.message}));return[2,r.data]}}))}))},t}(),B={};var q=function(){return(q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},F=function(t,e,r,n){var o,i=arguments.length,a=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},H=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},W=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},V=function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},J=o.adapters.useAdapters,G=o.adapters.useDefaultAdapter,K=o.adapters.RUNTIME,z=o.constants.ERRORS,Y=o.constants.COMMUNITY_SITE_URL,$=o.utils.printWarn,X=o.helpers.catchErrorsDecorator,Q={timeout:15e3,persistence:"local"},Z={},tt=new(function(){function t(t){this._config=t||this._config,this.authInstance=null,this.oauthInstance=null}return Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return m},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this._config.env,_[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return E(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this._config.env,B[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){if(!e.env)throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"env must not be specified"}));if(m.adapter||this._useDefaultAdapter(),this.requestClient=new m.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:"["+Object(A.d)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+e.timeout/1e3+"s"}),m.runtime!==K.WEB){if(!e.appSecret)throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"invalid appSecret"}));var r=m.adapter.getAppSign?m.adapter.getAppSign():"";if(e.appSign&&r&&e.appSign!==r)throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"invalid appSign"}));if(r&&(e.appSign=r),!e.appSign)throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=q(q({},Q),e),this._config.timeout=this._formatTimeout(this._config.timeout);var n=this._config,o=n.env,i=n.persistence,a=n.debug,s=n.timeout,c=n.appSecret,u=n.appSign,f=n.oauthClient;S({env:o,persistence:i,debug:a,platformInfo:this.platform}),Object(A.g)(o,e.region||"");var l=new t(this._config);return function(t){B[t.env]=new D(I(I({},t),{throw:!0}))}({env:o,region:e.region||"",timeout:s,appSecret:c,appSign:u,oauthClient:f,_fromApp:l}),l.requestClient=this.requestClient,l},t.prototype.updateConfig=function(t){var e=t.persistence,r=t.debug;this._config.persistence=e,this._config.debug=r,S({env:this._config.env,persistence:e,debug:r,platformInfo:this.platform})},t.prototype.registerExtension=function(t){Z[t.name]=t},t.prototype.invokeExtension=function(t,e){return W(this,void 0,void 0,(function(){var r;return V(this,(function(n){switch(n.label){case 0:if(!(r=Z[t]))throw new Error(JSON.stringify({code:z.INVALID_PARAMS,msg:"extension:"+t+" must be registered before invoke"}));return[4,r.invoke(e,this)];case 1:return[2,n.sent()]}}))}))},t.prototype.useAdapters=function(t){var e=J(t)||{},r=e.adapter,n=e.runtime;r&&(m.adapter=r),n&&(m.runtime=n)},t.prototype.registerHook=function(e){!function(t,e){var r=e.entity,n=e.target;if(!t.prototype.hasOwnProperty(n))throw new Error(JSON.stringify({code:v.INVALID_OPERATION,msg:"target:"+n+" is not exist"}));var o=t.prototype[n];if("function"!=typeof o)throw new Error(JSON.stringify({code:v.INVALID_OPERATION,msg:"target:"+n+" is not a function which is the only type supports hook"}));t.prototype[n]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.call.apply(r,d([this],t)),o.call.apply(o,d([this],t))}}(t,e)},t.prototype.registerComponent=function(e){g(t,e)},t.prototype.registerVersion=function(t){Object(A.i)(t)},t.prototype.registerSdkName=function(t){Object(A.h)(t)},t.prototype.registerEndPoint=function(t,e){Object(A.f)(t,e)},t.prototype._useDefaultAdapter=function(){var t=G(),e=t.adapter,r=t.runtime;m.adapter=e,m.runtime=r},t.prototype._formatTimeout=function(t){switch(!0){case t>6e5:return $(z.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case t<100:return $(z.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},F([X({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Y]}),H("design:type",Function),H("design:paramtypes",[Object]),H("design:returntype",t)],t.prototype,"init",null),F([X({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Y]}),H("design:type",Function),H("design:paramtypes",[String,Object]),H("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}());tt.useAdapters(h);e.default=tt}])}));
|
|
@@ -23,4 +23,4 @@ var de=function(e,t){return(de=Object.setPrototypeOf||{__proto__:[]}instanceof A
|
|
|
23
23
|
*/
|
|
24
24
|
var r=n(45),o=n(46),i=n(47);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,t,n)}function c(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(t,n),o=(e=a(e,r)).write(t,n);o!==r&&(e=e.slice(0,o));return e}(e,t,n):function(e,t){if(u.isBuffer(t)){var n=0|p(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):h(e,t);if("Buffer"===t.type&&i(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(f(t),e=a(e,t<0?0:0|p(t)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|p(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return F(e).length;default:if(r)return q(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,n);case"utf8":case"utf-8":return I(this,t,n);case"ascii":return N(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return A(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:v(e,t,n,r,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,r,o){var i,s=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=n;i<a;i++)if(c(e,i)===c(t,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){l=!1;break}if(l)return i}return-1}function m(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function b(e,t,n,r){return W(q(t,e.length-n),e,n,r)}function w(e,t,n,r){return W(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function E(e,t,n,r){return w(e,t,n,r)}function S(e,t,n,r){return W(F(t),e,n,r)}function O(e,t,n,r){return W(function(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function A(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function I(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),o+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,n){return c(null,e,t,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,n){return function(e,t,n,r){return f(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},u.allocUnsafe=function(e){return l(null,e)},u.allocUnsafeSlow=function(e){return l(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=u.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?I(this,0,e):y.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,n,r,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(r,o),f=e.slice(t,n),l=0;l<a;++l)if(c[l]!==f[l]){i=c[l],s=f[l];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return _(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return _(this,e,t,n,!1)},u.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return m(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return w(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function N(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function T(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function R(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=k(e[i]);return o}function B(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function D(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,n,r,o,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function L(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function U(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function x(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function C(e,t,n,r,i){return i||x(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function j(e,t,n,r,i){return i||x(e,0,n,8),o.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=u.prototype;else{var o=t-e;n=new u(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},u.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},u.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},u.prototype.readUInt8=function(e,t){return t||D(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||D(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||D(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||D(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){t||D(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(e,t){return t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||D(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||D(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||D(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||D(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},u.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):U(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):U(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):U(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):U(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,n){return C(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return C(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},u.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=u.isBuffer(e)?e:q(new u(e,r).toString()),a=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%a]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function k(e){return e<16?"0"+e.toString(16):e.toString(16)}function q(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function F(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function W(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this,n(6))},function(e,t,n){"use strict";t.byteLength=function(e){var t=c(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=c(e),s=r[0],a=r[1],u=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),f=0,l=a>0?s-4:s;for(n=0;n<l;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,u[f++]=255&t);1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t);return u},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],s=0,a=n-o;s<a;s+=16383)i.push(f(e,s,s+16383>a?a:s+16383));1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return i.join("")};for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function f(e,t,n){for(var o,i,s=[],a=t;a<n;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){
|
|
25
25
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
26
|
-
t.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,f=-7,l=n?o-1:0,h=n?-1:1,p=e[t+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=c}return(p?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[n+p]=255&s,p+=d,s/=256,c-=8);e[n+p-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e){e.exports=JSON.parse('{"version":"1.8.4-alpha.0"}')},function(e,t,n){"use strict";n.r(t),n.d(t,"registerDatabase",(function(){return bt}));var r,o,i={};n.r(i),n.d(i,"Point",(function(){return ce})),n.d(i,"LineString",(function(){return J})),n.d(i,"Polygon",(function(){return z})),n.d(i,"MultiPoint",(function(){return Q})),n.d(i,"MultiLineString",(function(){return ee})),n.d(i,"MultiPolygon",(function(){return ne})),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a="Number",u="Object",c="Array",f="GeoPoint",l="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",d="GeoMultiLineString",y="GeoMultiPolygon",g="Date",_="ServerDate",v="BsonDate",m=["desc","asc"],b=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={}));var w;(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"}(w||(w={}));var E,S=(E=function(e,t){return(E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}E(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),O=[],A={},I=function(e){function t(t,n){if(n!==A)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return S(t,e),t.for=function(e){for(var n=0,r=O.length;n<r;n++)if(O[n].target===e)return O[n].instance;var o=new t(e,A);return O.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),N=I,T=N.for("UNSET_FIELD_NAME"),R=N.for("UPDATE_COMMAND"),B=N.for("QUERY_COMMAND"),D=N.for("LOGIC_COMMAND"),P=N.for("GEO_POINT"),L=N.for("SYMBOL_GEO_LINE_STRING"),U=N.for("SYMBOL_GEO_POLYGON"),x=N.for("SYMBOL_GEO_MULTI_POINT"),C=N.for("SYMBOL_GEO_MULTI_LINE_STRING"),j=N.for("SYMBOL_GEO_MULTI_POLYGON"),M=N.for("SERVER_DATE"),k=N.for("REGEXP"),q=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},F=function(e){return"object"===q(e)},W=function(e){return"number"===q(e)},Y=function(e){return Array.isArray(e)},$=function(e){return"date"===q(e)},H=function(e){return"regexp"===q(e)},V=function(e){return e&&e._internalType instanceof I},G=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(!Y(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof ce))throw new TypeError('"points" must be of type Point[]. Received type '+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||!Y(e.coordinates))return!1;try{for(var r=G(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(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 L},enumerable:!0,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.")},z=function(){function e(e){if(!Y(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof J))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]");if(!J.isClosed(e))throw new Error("LineString "+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||!Y(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 u=(r=void 0,K(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}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 j},enumerable:!0,configurable:!0}),e}(),X=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.")},Q=function(){function e(e){if(!Y(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof ce))throw new TypeError('"points" must be of type Point[]. Received type '+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||!Y(e.coordinates))return!1;try{for(var r=X(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(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 x},enumerable:!0,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.")},ee=function(){function e(e){if(!Y(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof J))throw new TypeError('"lines" must be of type LineString[]. Received type '+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||!Y(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 u=(r=void 0,Z(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}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 C},enumerable:!0,configurable:!0}),e}(),te=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.")},ne=function(){function e(e){var t,n;if(!Y(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof e);if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=te(e),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof z))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+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||!Y(e.coordinates))return!1;try{for(var a=te(e.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var f=(r=void 0,te(c)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,te(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!W(y[0])||!W(y[1]))return!1}}catch(e){i={error:e}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),e}(),re=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 M},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function oe(e){return new re(e)}var ie,se=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},ae=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 f:o=new ce(i.coordinates[0],i.coordinates[1]);break;case l:o=new J(i.coordinates.map((function(e){return new ce(e[0],e[1])})));break;case h:o=new z(i.coordinates.map((function(e){return new J(e.map((function(e){var t=se(e,2),n=t[0],r=t[1];return new ce(n,r)})))})));break;case p:o=new Q(i.coordinates.map((function(e){return new ce(e[0],e[1])})));break;case d:o=new ee(i.coordinates.map((function(e){return new J(e.map((function(e){var t=se(e,2),n=t[0],r=t[1];return new ce(n,r)})))})));break;case y:o=new ne(i.coordinates.map((function(e){return new z(e.map((function(e){return new J(e.map((function(e){var t=se(e,2),n=t[0],r=t[1];return new ce(n,r)})))})))})));break;case g:o=new Date(1e3*i.$timestamp);break;case u:case c:o=e.formatField(i);break;case _: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);if(t===g)return v;if(t===u){if(e instanceof ce)return f;if(e instanceof Date)return g;if(e instanceof re)return _;e.$timestamp?t=g:e.$date?t=_:ce.validate(e)?t=f:J.validate(e)?t=l:z.validate(e)?t=h:Q.validate(e)?t=p:ee.validate(e)?t=d:ne.validate(e)&&(t=y)}return t},e.generateDocId=function(){for(var e="ABCDEFabcdef0123456789",t="",n=0;n<24;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return t},e}(),ue=function(){function e(){}return e.isGeopoint=function(e,t){if(ae.whichType(t)!==a)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.isFieldOrder=function(e){if(-1===m.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===b.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}(),ce=function(){function e(e,t){ue.isGeopoint("longitude",e),ue.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"["+this.longitude+","+this.latitude+"]"},e.validate=function(e){return"Point"===e.type&&Y(e.coordinates)&&ue.isGeopoint("longitude",e.coordinates[0])&&ue.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),e}(),fe=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};!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"}(ie||(ie={}));var le=function(){function e(e,t,n){this._internalType=R,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||T}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function he(e){return e&&e instanceof le&&e._internalType===R}var pe;!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(pe||(pe={}));var de=function(){function e(e,t,n){if(this._internalType=D,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||T,this.fieldName!==T)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,o=t.length;r<o;r++){(ye(i=t[r])||me(i))&&(t[r]=i._setFieldName(this.fieldName))}}else{var i;(ye(i=t)||me(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(pe.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(pe.OR,r,this.fieldName)},e}();function ye(e){return e&&e instanceof de&&e._internalType===D}var ge,_e=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)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){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"}(ge||(ge={}));var ve=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.operator=t,o._internalType=B,o}return _e(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case ge.IN:case ge.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var n=new t(ge.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(ge.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(ge.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(ge.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(ge.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(ge.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(ge.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(ge.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof ce))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!W(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!W(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var n=new t(ge.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof ne||e.geometry instanceof z))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var n=new t(ge.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof ce||e.geometry instanceof J||e.geometry instanceof z||e.geometry instanceof Q||e.geometry instanceof ee||e.geometry instanceof ne))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var n=new t(ge.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(de);function me(e){return e&&e instanceof ve&&e._internalType===B}function be(e){return me(e)}var we={};for(var Ee in ge)we[Ee]="$"+Ee;for(var Ee in pe)we[Ee]="$"+Ee;for(var Ee in ie)we[Ee]="$"+Ee;function Se(e){return we[e]||"$"+e}we[ge.NEQ]="$ne",we[ie.REMOVE]="$unset",we[ie.SHIFT]="$pop",we[ie.UNSHIFT]="$push";var Oe=function(){return(Oe=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}).apply(this,arguments)},Ae=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},Ie=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ae(arguments[t]));return e};function Ne(e){return function e(t,n){if(!V(t)){if($(t))return{$date:+t};if(H(t))return{$regex:t.source,$options:t.flags};if(Y(t))return t.map((function(t){if(n.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return e(t,Ie(n,[t]))}));if(F(t)){var r=Oe({},t);for(var o in r){if(n.indexOf(r[o])>-1)throw new Error("Cannot convert circular structure to JSON");r[o]=e(r[o],Ie(n,[r[o]]))}return r}return t}switch(t._internalType){case P:return t.toJSON();case M:case k:return t.parse();default:return t.toJSON?t.toJSON():t}}(e,[e])}var Te=function(){return(Te=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}).apply(this,arguments)},Re=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},Be=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Re(arguments[t]));return e};function De(e,t,n,r){var o=Te({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&F(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=De(s,t,Be(n,[i]),Be(r,[s]));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o[i+"."+c]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Pe(e){return De(e,Ue,[],[e])}function Le(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Y(e[r])?e[r].push(t[r]):F(e[r])?F(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is "+q(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+q(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]}function Ue(e){return V(e)||$(e)||H(e)}function xe(e){return Ne(e)}var Ce=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return he(e)?this.encodeUpdateCommand(e):"object"===q(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===T)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case ie.PUSH:case ie.PULL:case ie.PULL_ALL:case ie.POP:case ie.SHIFT:case ie.UNSHIFT:case ie.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,o,i=Se(e.operator);switch(e.operator){case ie.REMOVE:return(t={})[i]=((n={})[e.fieldName]="",n),t;default:return(r={})[i]=((o={})[e.fieldName]=e.operands[0],o),r}},e.prototype.encodeArrayUpdateCommand=function(e){var t,n,r,o,i,s,a,u,c,f,l=Se(e.operator);switch(e.operator){case ie.PUSH:var h=void 0;return h=Y(e.operands)?{$each:e.operands.map(xe)}:e.operands,(t={})[l]=((n={})[e.fieldName]=h,n),t;case ie.UNSHIFT:h={$each:e.operands.map(xe),$position:0};return(r={})[l]=((o={})[e.fieldName]=h,o),r;case ie.POP:return(i={})[l]=((s={})[e.fieldName]=1,s),i;case ie.SHIFT:return(a={})[l]=((u={})[e.fieldName]=-1,u),a;default:return(c={})[l]=((f={})[e.fieldName]=xe(e.operands),f),c}},e.prototype.encodeUpdateObject=function(e){var t=Pe(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(he(r)){t[n]=r._setFieldName(n),Le(t,this.encodeUpdateCommand(t[n]),n)}else{t[n]=r=xe(r);var o=new le(ie.SET,[r],n);Le(t,this.encodeUpdateCommand(o),n)}}return t},e}(),je={};function Me(e){if(!_t.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return je[t]||(je[t]=new _t.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new _t.reqClass(e.config)}}})),je[t]}var ke=function(){return(ke=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}).apply(this,arguments)},qe=function(){function e(e,t,n,r){var o=this;void 0===r&&(r={}),this.watch=function(e){return Me(o._db).watch(ke(ke({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=e,this._coll=t,this.id=n,this.request=new _t.reqClass(this._db.config),this.projection=r}return e.prototype.create=function(e,t){t=t||fe();var n={collectionName:this._coll,data:Ne(e)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(e){e.code?t(0,e):t(0,{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||fe(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof le?n=!0:"object"==typeof e[t]&&r(e[t])};if(r(e),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:w.DOC,data:Ne(e),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||fe(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Ce.encode(e),query:n,queryType:w.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||fe();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:w.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||fe();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:w.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n=ae.formatResDocumentData(t.data.list);e(0,{data:n,requestId:t.requestId,total:t.TotalCount,limit:t.Limit,offset:t.Offset})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var n in t)t[n]?t[n]=1:t[n]=0;return new e(this._db,this._coll,this.id,t)},e}(),Fe=function(){function e(){}return e.encode=function(e){return(new We).encodeQuery(e)},e}(),We=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n;return Ue(e)?ye(e)?this.encodeLogicCommand(e):me(e)?this.encodeQueryCommand(e):((n={})[t]=this.encodeQueryObject(e),n):F(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,n,r,o,i,s,a,u=this;switch(e.operator){case pe.NOR:case pe.AND:case pe.OR:var c=Se(e.operator),f=e.operands.map((function(t){return u.encodeQuery(t,e.fieldName)}));return(t={})[c]=f,t;case pe.NOT:c=Se(e.operator);var l=e.operands[0];if(H(l))return(n={})[e.fieldName]=((r={})[c]=this.encodeRegExp(l),r),n;f=this.encodeQuery(l)[e.fieldName];return(o={})[e.fieldName]=((i={})[c]=f,i),o;default:c=Se(e.operator);if(1===e.operands.length){var h=this.encodeQuery(e.operands[0]);return(s={})[c]=h,s}f=e.operands.map(this.encodeQuery.bind(this));return(a={})[c]=f,a}},e.prototype.encodeQueryCommand=function(e){return be(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,o,i,s,a,u,c;if(e.fieldName===T)throw new Error("Cannot encode a comparison command with unset field name");var f=Se(e.operator);switch(e.operator){case ge.EQ:case ge.NEQ:case ge.LT:case ge.LTE:case ge.GT:case ge.GTE:case ge.ELEM_MATCH:case ge.EXISTS:case ge.SIZE:case ge.MOD:return(t={})[e.fieldName]=((n={})[f]=xe(e.operands[0]),n),t;case ge.IN:case ge.NIN:case ge.ALL:return(r={})[e.fieldName]=((o={})[f]=xe(e.operands),o),r;case ge.GEO_NEAR:var l=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case ge.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case ge.GEO_INTERSECTS:l=e.operands[0];return(a={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(u={})[e.fieldName]=((c={})[f]=xe(e.operands[0]),c),u}},e.prototype.encodeQueryObject=function(e){var t=Pe(e);for(var n in t){var r=t[n];if(ye(r)){t[n]=r._setFieldName(n);var o=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else if(be(r)){t[n]=r._setFieldName(n);o=this.encodeComparisonCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else Ue(r)&&(t[n]=xe(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Y(e[r])?e[r]=e[r].concat(t[r]):F(e[r])?F(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+q(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+q(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),Ye=function(){return(Ye=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}).apply(this,arguments)},$e=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){return Me(i._db).watch(Ye(Ye({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new _t.reqClass(this._db.config)}return e.prototype.get=function(e){e=e||fe();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var n={collectionName:this._coll,queryType:w.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),t.length>0&&(n.order=t),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n={data:ae.formatResDocumentData(t.data.list),requestId:t.requestId};t.TotalCount&&(n.total=t.TotalCount),t.Limit&&(n.limit=t.Limit),t.Offset&&(n.offset=t.Offset),e(0,n)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||fe();var t={collectionName:this._coll,queryType:w.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},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,Fe.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,n){ue.isFieldPath(t),ue.isFieldOrder(n);var r={field:t,direction:n},o=this._fieldOrders.concat(r);return new e(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},e.prototype.limit=function(t){ue.isInteger("limit",t);var n=Ye({},this._queryOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.skip=function(t){ue.isInteger("offset",t);var n=Ye({},this._queryOptions);return n.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.update=function(e,t){if(t=t||fe(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:w.WHERE,multi:!0,merge:!0,upsert:!1,data:Ce.encode(e)};return this._request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var n in t)t[n]?"object"!=typeof t[n]&&(t[n]=1):t[n]=0;var r=Ye({},this._queryOptions);return r.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.remove=function(e){e=e||fe(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var t={collectionName:this._coll,query:Fe.encode(this._fieldFilters),queryType:w.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}(),He=n(2),Ve=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},Ge=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Je=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new _t.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Ve(this,void 0,void 0,(function(){var e;return Ge(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.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map(He.a.parse)}]:[2,e]}}))}))},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){return this._stages.push({stageKey:"$"+e,stageValue:JSON.stringify(t)}),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 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",Fe.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}(),Ke=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)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ze=function(e){function t(t,n){return e.call(this,t,n)||this}return Ke(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new qe(this._db,this._coll,e)},t.prototype.add=function(e,t){return new qe(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new Je(this._db,this._coll)},t}($e),Xe={eq:function(e){return new ve(ge.EQ,[e])},neq:function(e){return new ve(ge.NEQ,[e])},lt:function(e){return new ve(ge.LT,[e])},lte:function(e){return new ve(ge.LTE,[e])},gt:function(e){return new ve(ge.GT,[e])},gte:function(e){return new ve(ge.GTE,[e])},in:function(e){return new ve(ge.IN,e)},nin:function(e){return new ve(ge.NIN,e)},all:function(e){return new ve(ge.ALL,e)},elemMatch:function(e){return new ve(ge.ELEM_MATCH,[e])},exists:function(e){return new ve(ge.EXISTS,[e])},size:function(e){return new ve(ge.SIZE,[e])},mod:function(e){return new ve(ge.MOD,[e])},geoNear:function(e){return new ve(ge.GEO_NEAR,[e])},geoWithin:function(e){return new ve(ge.GEO_WITHIN,[e])},geoIntersects:function(e){return new ve(ge.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.AND,n)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOR,n)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.OR,n)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOT,n)},set:function(e){return new le(ie.SET,[e])},remove:function(){return new le(ie.REMOVE,[])},inc:function(e){return new le(ie.INC,[e])},mul:function(e){return new le(ie.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(F(t[0])&&t[0].hasOwnProperty("each")){var r=t[0];e={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else e=Y(t[0])?t[0]:Array.from(t);return new le(ie.PUSH,e)},pull:function(e){return new le(ie.PULL,e)},pullAll:function(e){return new le(ie.PULL_ALL,e)},pop:function(){return new le(ie.POP,[])},shift:function(){return new le(ie.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new le(ie.UNSHIFT,n)},addToSet:function(e){return new le(ie.ADD_TO_SET,e)},rename:function(e){return new le(ie.RENAME,[e])},bit:function(e){return new le(ie.BIT,[e])},max:function(e){return new le(ie.MAX,[e])},min:function(e){return new le(ie.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===q(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new Je},abs:function(e){return new Qe("abs",e)},add:function(e){return new Qe("add",e)},ceil:function(e){return new Qe("ceil",e)},divide:function(e){return new Qe("divide",e)},exp:function(e){return new Qe("exp",e)},floor:function(e){return new Qe("floor",e)},ln:function(e){return new Qe("ln",e)},log:function(e){return new Qe("log",e)},log10:function(e){return new Qe("log10",e)},mod:function(e){return new Qe("mod",e)},multiply:function(e){return new Qe("multiply",e)},pow:function(e){return new Qe("pow",e)},sqrt:function(e){return new Qe("sqrt",e)},subtract:function(e){return new Qe("subtract",e)},trunc:function(e){return new Qe("trunc",e)},arrayElemAt:function(e){return new Qe("arrayElemAt",e)},arrayToObject:function(e){return new Qe("arrayToObject",e)},concatArrays:function(e){return new Qe("concatArrays",e)},filter:function(e){return new Qe("filter",e)},in:function(e){return new Qe("in",e)},indexOfArray:function(e){return new Qe("indexOfArray",e)},isArray:function(e){return new Qe("isArray",e)},map:function(e){return new Qe("map",e)},range:function(e){return new Qe("range",e)},reduce:function(e){return new Qe("reduce",e)},reverseArray:function(e){return new Qe("reverseArray",e)},size:function(e){return new Qe("size",e)},slice:function(e){return new Qe("slice",e)},zip:function(e){return new Qe("zip",e)},and:function(e){return new Qe("and",e)},not:function(e){return new Qe("not",e)},or:function(e){return new Qe("or",e)},cmp:function(e){return new Qe("cmp",e)},eq:function(e){return new Qe("eq",e)},gt:function(e){return new Qe("gt",e)},gte:function(e){return new Qe("gte",e)},lt:function(e){return new Qe("lt",e)},lte:function(e){return new Qe("lte",e)},neq:function(e){return new Qe("ne",e)},cond:function(e){return new Qe("cond",e)},ifNull:function(e){return new Qe("ifNull",e)},switch:function(e){return new Qe("switch",e)},dateFromParts:function(e){return new Qe("dateFromParts",e)},dateFromString:function(e){return new Qe("dateFromString",e)},dayOfMonth:function(e){return new Qe("dayOfMonth",e)},dayOfWeek:function(e){return new Qe("dayOfWeek",e)},dayOfYear:function(e){return new Qe("dayOfYear",e)},isoDayOfWeek:function(e){return new Qe("isoDayOfWeek",e)},isoWeek:function(e){return new Qe("isoWeek",e)},isoWeekYear:function(e){return new Qe("isoWeekYear",e)},millisecond:function(e){return new Qe("millisecond",e)},minute:function(e){return new Qe("minute",e)},month:function(e){return new Qe("month",e)},second:function(e){return new Qe("second",e)},hour:function(e){return new Qe("hour",e)},week:function(e){return new Qe("week",e)},year:function(e){return new Qe("year",e)},literal:function(e){return new Qe("literal",e)},mergeObjects:function(e){return new Qe("mergeObjects",e)},objectToArray:function(e){return new Qe("objectToArray",e)},allElementsTrue:function(e){return new Qe("allElementsTrue",e)},anyElementTrue:function(e){return new Qe("anyElementTrue",e)},setDifference:function(e){return new Qe("setDifference",e)},setEquals:function(e){return new Qe("setEquals",e)},setIntersection:function(e){return new Qe("setIntersection",e)},setIsSubset:function(e){return new Qe("setIsSubset",e)},setUnion:function(e){return new Qe("setUnion",e)},concat:function(e){return new Qe("concat",e)},dateToString:function(e){return new Qe("dateToString",e)},indexOfBytes:function(e){return new Qe("indexOfBytes",e)},indexOfCP:function(e){return new Qe("indexOfCP",e)},split:function(e){return new Qe("split",e)},strLenBytes:function(e){return new Qe("strLenBytes",e)},strLenCP:function(e){return new Qe("strLenCP",e)},strcasecmp:function(e){return new Qe("strcasecmp",e)},substr:function(e){return new Qe("substr",e)},substrBytes:function(e){return new Qe("substrBytes",e)},substrCP:function(e){return new Qe("substrCP",e)},toLower:function(e){return new Qe("toLower",e)},toUpper:function(e){return new Qe("toUpper",e)},meta:function(e){return new Qe("meta",e)},addToSet:function(e){return new Qe("addToSet",e)},avg:function(e){return new Qe("avg",e)},first:function(e){return new Qe("first",e)},last:function(e){return new Qe("last",e)},max:function(e){return new Qe("max",e)},min:function(e){return new Qe("min",e)},push:function(e){return new Qe("push",e)},stdDevPop:function(e){return new Qe("stdDevPop",e)},stdDevSamp:function(e){return new Qe("stdDevSamp",e)},sum:function(e){return new Qe("sum",e)},let:function(e){return new Qe("let",e)}},project:{slice:function(e){return new Ze("slice",e)},elemMatch:function(e){return new Ze("elemMatch",e)}}},Qe=function(e,t){this["$"+e]=t},Ze=function(e,t){this["$"+e]=t},et=function(){function e(e){var t=e.regexp,n=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=n}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return k},enumerable:!0,configurable:!0}),e}();function tt(e){return new et(e)}var nt={code:"INSERT_DOC_FAIL",message:"insert document failed"},rt={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},ot=function(){return(ot=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}).apply(this,arguments)},it=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},st=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},at="database.updateDocInTransaction",ut=function(){function e(e,t,n){this._coll=t,this.id=n,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return it(this,void 0,void 0,(function(){var t,n,r,o;return st(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:He.a.stringify(Ne(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((n=i.sent()).code)throw n;if(r=He.a.parse(n.inserted),1==(o=He.a.parse(n.ok))&&1==r)return[2,ot(ot({},n),{ok:o,inserted:r})];throw new Error(nt.message)}}))}))},e.prototype.get=function(){return it(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,{data:"null"!==t.data?ae.formatField(He.a.parse(t.data)):He.a.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return it(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:He.a.stringify(Ne(e),{relaxed:!1}),upsert:!0},[4,this._request.send(at,t)];case 1:if((n=r.sent()).code)throw n;return[2,ot(ot({},n),{updated:He.a.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},e.prototype.update=function(e){return it(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:He.a.stringify(Ce.encode(e),{relaxed:!1})},[4,this._request.send(at,t)];case 1:if((n=r.sent()).code)throw n;return[2,ot(ot({},n),{updated:He.a.parse(n.updated)})]}}))}))},e.prototype.delete=function(){return it(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,ot(ot({},t),{deleted:He.a.parse(t.deleted)})]}}))}))},e}(),ct=function(e,t){this._coll=t,this._transaction=e},ft=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)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),lt=function(e){function t(t,n){return e.call(this,t,n)||this}return ft(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new ut(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new ut(this._transaction,this._coll,t).create(e)},t}(ct),ht=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},pt=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},dt=function(){function e(e){this._db=e,this._request=new _t.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return ht(this,void 0,void 0,(function(){var e;return pt(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 lt(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return ht(this,void 0,void 0,(function(){var e,t;return pt(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 ht(this,void 0,void 0,(function(){var t,n;return pt(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 yt(){return ht(this,void 0,void 0,(function(){var e;return pt(this,(function(t){switch(t.label){case 0:return[4,(e=new dt(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function gt(e,t){return void 0===t&&(t=3),ht(this,void 0,void 0,(function(){var n,r,o,i,s=this;return pt(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new dt(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 ht(s,void 0,void 0,(function(){return pt(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:return t.sent(),[3,4];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===rt.code?[4,gt.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 _t=function(){function e(e){this.config=e,this.Geo=i,this.serverDate=oe,this.command=Xe,this.RegExp=tt,this.startTransaction=yt,this.runTransaction=gt,this.logicCommand=de,this.updateCommand=le,this.queryCommand=ve}return e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new ze(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",n)},e}(),vt=function(){return(vt=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}).apply(this,arguments)};var mt={name:"database",entity:{database:function(e){var t=this.platform,n=t.adapter,r=t.runtime;return _t.reqClass=this.request.constructor,_t.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},_t.runtime=r,this.wsClientClass&&(_t.wsClass=n.wsClass,_t.wsClientClass=this.wsClientClass),_t.ws||(_t.ws=null),new _t(vt(vt({},this.config),e))}}};try{cloudbase.registerComponent(mt)}catch(e){}function bt(e){try{e.registerComponent(mt)}catch(e){console.warn(e)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"registerRealtime",(function(){return q}));var r=n(14),o=n.n(r),i=n(15),s=n.n(i),a=n(16),u=n.n(a);function c(e){return void 0===e&&(e=""),(e?e+"_":"")+ +new Date+"_"+Math.random()}var f,l,h=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}})},p=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}})},d=(f=function(e,t){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}f(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),y=function(e){function t(t){var n=e.call(this,"Watch Error "+JSON.stringify(t.msgData)+" (requestid: "+t.requestId+")")||this;return n.isRealtimeErrorMessageError=!0,n.payload=t,n}return d(t,e),t}(Error),g=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},_=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 d(t,e),t}(Error),v=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 d(t,e),t}(Error),m=function(e){function t(t){var n=e.call(this,t.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: "+this.errCode+" "+(b[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e}}}),n.errCode=t.errCode||"UNKNOWN_ERROR",n.errMsg=t.errMsg,n}return d(t,e),Object.defineProperty(t.prototype,"message",{get:function(){return"errCode: "+this.errCode+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),t}(Error),b={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"},w=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},E=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},S=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},O=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};!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"}(l||(l={}));var A=function(){function e(e){var t=this;this.watchStatus=l.INITING,this._login=function(e,n){return E(t,void 0,void 0,(function(){var t;return S(this,(function(r){switch(r.label){case 0:return this.watchStatus=l.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 E(t,void 0,void 0,(function(){var t,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(t,r){return E(n,void 0,void 0,(function(){var n,o,i,s,a,u,f,h,d,y;return S(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];case 1:return n=g.sent().envId,this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=l.INITING,o={watchId:this.watchId,requestId:c(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=g.sent(),s=i.msgData,a=s.events,u=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:u-1,currentDocs:[]},a.length>0){for(f=0,h=a;f<h.length;f++)h[f].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,d=new p({id:u,docChanges:[],docs:[],type:"init"}),this.listener.onChange(d),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=l.ACTIVE,this._availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return y=g.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._initWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch "+(t?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(e){return E(t,void 0,void 0,(function(){var t,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(t,r){return E(n,void 0,void 0,(function(){var n,o,i,s;return S(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=l.REBUILDING,o={watchId:this.watchId,requestId:c(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=l.ACTIVE,this._availableRetries.REBUILD_WATCH=2,t(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._rebuildWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch "+(t?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(e,n){return E(t,void 0,void 0,(function(){var t,r,o,i=this;return S(this,(function(s){return t="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new m({errCode:t?b.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:b.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),n.reject(e)},o=function(e){i.useRetryTicket(n.operationName)?t?(i._initWatchPromise=void 0,n.resolve(i.initWatch(e))):(i._rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(e))):r()},this.handleCommonError(e,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){return E(i,void 0,void 0,(function(){var e,t=this;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),e=function(){return E(t,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];case 1:return r.sent(),[3,7];case 2:return[4,w(100)];case 3:return r.sent(),this.watchStatus!==l.PAUSED?[3,4]:(n.reject(new v(n.operationName+" cancelled due to pause after unknownError")),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return E(t,void 0,void 0,(function(){var e,t,n;return S(this,(function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==l.ACTIVE)return this.watchStatus=l.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=l.CLOSING,t={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=l.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new m({errCode:b.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 E(t,void 0,void 0,(function(){var e,t,n;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==l.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:c(),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(),g(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 m({errCode:b.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--,this.scheduleSendACK()):this.closeWithError(new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(g(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);case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":default:return void t.onNotRetryableError(e)}}else{if(function(e){return"timeout"===e.type}(e))return void t.onTimeoutError(e);if(function(e){return"cancelled"===e.type}(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_"+ +new Date+"_"+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 h({close:this.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 l.PAUSED:if("ERROR"!==e.msgType)return;break;case l.LOGGINGIN:case l.INITING:case l.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case l.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case l.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 "+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 "+this.getWaitExpectedTimeoutLength()));break;case"ERROR":this.closeWithError(new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:e.msgData.code+" - "+e.msgData.message}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg "+e.msgType+": ",e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){this.watchStatus=l.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,this.sessionInfo&&this.sessionInfo.queryID||""),console.log("[realtime] client closed ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.pause=function(){this.watchStatus=l.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.resume=function(){return E(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:this.watchStatus=l.RESUMING,console.log("[realtime] client resuming with "+(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH")+" ("+this.collectionName+" "+this.query+") ("+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 ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed ("+this.collectionName+" "+this.query+") ("+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]--,console.log("[realtime] "+e+" use a retry ticket, now only "+this._availableRetries[e]+" retry left"),!0)},e.prototype.handleServerEvents=function(e){return E(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this._handleServerEvents(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._handleServerEvents=function(e){return E(this,void 0,void 0,(function(){var t,n,r,i,a,c,f,l,h,d,y,g;return S(this,(function(_){switch(_.label){case 0:if(t=e.requestId,n=e.msgData.events,r=e.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(I)}catch(e){return this.closeWithError(new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}c=O(i.currentDocs),f=!1,l=function(n,l){var d,y,g,_,v,w,E,A,I,N,T;return S(this,(function(S){switch(S.label){case 0:return d=a[n],i.currentEventId>=d.id?(!a[n-1]||d.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur "+i.currentEventId+" but got "+d.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 "+t+")"),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==d.id-1)return[3,2];switch(d.dataType){case"update":if(!d.doc)switch(d.queueType){case"update":case"dequeue":if(y=c.find((function(e){return e._id===d.docId}))){if(w=u()(y),d.updatedFields)for(v in d.updatedFields)o()(w,v,d.updatedFields[v]);if(d.removedFields)for(g=0,_=d.removedFields;g<_.length;g++)v=_[g],s()(w,v);d.doc=w}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw E=new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '+e.requestId+")"}),h.closeWithError(E),E}break;case"replace":if(!d.doc)throw E=new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '+e.requestId+")"}),h.closeWithError(E),E;break;case"remove":(w=c.find((function(e){return e._id===d.docId})))?d.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!d.doc)switch(d.queueType){case"dequeue":(w=c.find((function(e){return e._id===d.docId})))?d.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw E=new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '+e.requestId+")"}),h.closeWithError(E),E}}switch(d.queueType){case"init":f?c.push(d.doc):(f=!0,c=[d.doc]);break;case"enqueue":c.push(d.doc);break;case"dequeue":(A=c.findIndex((function(e){return e._id===d.docId})))>-1?c.splice(A,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":(A=c.findIndex((function(e){return e._id===d.docId})))>-1?c[A]=d.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===l-1||a[n+1]&&a[n+1].id!==d.id)&&(I=O(c),N=a.slice(0,n+1).filter((function(e){return e.id===d.id})),h.sessionInfo.currentEventId=d.id,h.sessionInfo.currentDocs=c,T=new p({id:d.id,docChanges:N,docs:I,msgType:r}),h.listener.onChange(T)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur "+h.sessionInfo.currentEventId+" but got "+d.id),[4,h.rebuildWatch()];case 3:return S.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,d=0,y=a.length,_.label=1;case 1:return d<y?[5,l(d,y)]:[3,4];case 2:if("object"==typeof(g=_.sent()))return[2,g.value];_.label=3;case 3:return d++,[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 I(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}var N,T={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"}};!function(e){e[e.NormalClosure=1e3]="NormalClosure",e[e.GoingAway=1001]="GoingAway",e[e.ProtocolError=1002]="ProtocolError",e[e.UnsupportedData=1003]="UnsupportedData",e[e.NoStatusReceived=1005]="NoStatusReceived",e[e.AbnormalClosure=1006]="AbnormalClosure",e[e.InvalidFramePayloadData=1007]="InvalidFramePayloadData",e[e.PolicyViolation=1008]="PolicyViolation",e[e.MessageTooBig=1009]="MessageTooBig",e[e.MissingExtension=1010]="MissingExtension",e[e.InternalError=1011]="InternalError",e[e.ServiceRestart=1012]="ServiceRestart",e[e.TryAgainLater=1013]="TryAgainLater",e[e.BadGateway=1014]="BadGateway",e[e.TLSHandshake=1015]="TLSHandshake",e[e.ReconnectWebSocket=3e3]="ReconnectWebSocket",e[e.NoRealtimeListeners=3001]="NoRealtimeListeners",e[e.HeartbeatPingError=3002]="HeartbeatPingError",e[e.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",e[e.NoAuthentication=3050]="NoAuthentication"}(N||(N={}));var R=function(e,t){var n=T[e],r=n?n.name+", code "+e+", reason "+(t||n.description):"code "+e;return new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},B=null,D="web";function P(){return D}var L=function(){return(L=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}).apply(this,arguments)},U=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},x=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},C=1,j=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 U(t,void 0,void 0,(function(){var t=this;return x(this,(function(n){return[2,new Promise((function(n,r){return U(t,void 0,void 0,(function(){var t,o,i,s,a,u,c,f=this;return x(this,(function(l){switch(l.label){case 0:o=!1,i=!1,s=function(e){o=!0,t&&clearTimeout(t),n(e)},a=function(e){i=!0,t&&clearTimeout(t),r(e)},e.timeout&&(t=setTimeout((function(){return U(f,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,w(0)];case 1:e.sent(),o&&i||a(new _("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),l.label=1;case 1:return l.trys.push([1,8,,9]),this._wsInitPromise?[4,this._wsInitPromise]:[3,3];case 2:l.sent(),l.label=3;case 3:if(!this._ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(this._ws.readyState!==C)return a(new Error("ws readyState invalid: "+this._ws.readyState+", can not send message")),[2];e.waitResponse&&this._wsResponseWait.set(e.msg.requestId,{resolve:s,reject:a,skipOnMessage:e.skipOnMessage}),l.label=4;case 4:return l.trys.push([4,6,,7]),[4,this._ws.send(JSON.stringify(e.msg))];case 5:return l.sent(),e.waitResponse||s(),[3,7];case 6:return(u=l.sent())&&(a(u),e.waitResponse&&this._wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return c=l.sent(),a(c),[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),U(t,void 0,void 0,(function(){var t=this;return x(this,(function(r){switch(r.label){case 0:if(e&&this._reconnectState)return[2];if(e&&(this._reconnectState=!0),this._wsInitPromise)return[2,this._wsInitPromise];e&&this.pauseClients(),this.close(N.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,o){return U(t,void 0,void 0,(function(){var t,i,s=this;return x(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=a.sent(),[4,new Promise((function(e){var n=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=B;s._ws=r?new r(n):new WebSocket(n),e()}))];case 2:return a.sent(),this._ws.connect?[4,this._ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),e&&(this.resumeClients(),this._reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(!0,this._wsInitPromise=void 0,[4,w(this._reconnectInterval)]):[3,9];case 7:a.sent(),e&&(this._reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(e,n-1)),[3,10];case 9:o(i),e&&this.closeAllClients(new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.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 m({errCode:b.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 N.ReconnectWebSocket:case N.NoRealtimeListeners:break;case N.HeartbeatPingError:case N.HeartbeatPongTimeoutError:case N.NormalClosure:case N.AbnormalClosure:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(R(e.code));break;case N.NoAuthentication:t.closeAllClients(R(e.code,e.reason));break;default:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(R(e.code))}},t._ws.onmessage=function(e){var n,r=e.data;t.heartbeat();try{n=JSON.parse(r)}catch(e){throw new Error("[realtime] onMessage parse res.data error: "+e)}if("ERROR"===n.msgType){var o=null;t._virtualWSClient.forEach((function(e){e.watchId===n.watchId&&(o=e)})),o&&o.listener.onError(n)}var i=t._wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new y(n)):i.resolve(n)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t._wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&t._watchIdClientMap.get(n.watchId);if(s)s.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId "+n.watchId+": ",n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(s=t._queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,u=Array.from(t._watchIdClientMap.entries());a<u.length;a++){u[a][1].onMessage(n);break}}}else if(t._lastPingSendTS){var c=Date.now()-t._lastPingSendTS;if(c>1e4)return void console.warn("[realtime] untrusted rtt observed: "+c);t._rttObserved.length>=3&&t._rttObserved.splice(0,t._rttObserved.length-3+1),t._rttObserved.push(c)}},t.heartbeat()}))},this.isWSConnected=function(){return Boolean(t._ws&&t._ws.readyState===C)},this.onceWSConnected=function(){return U(t,void 0,void 0,(function(){var e=this;return x(this,(function(t){return this.isWSConnected()?[2]:this._wsInitPromise?[2,this._wsInitPromise]:[2,new Promise((function(t,n){e._wsReadySubsribers.push({resolve:t,reject:n})}))]}))}))},this.webLogin=function(e,n){return U(t,void 0,void 0,(function(){var t,r,o,i,s,a,u,f,l=this;return x(this,(function(h){switch(h.label){case 0:if(!n)if(e){if(t=this._logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(t.loggingInPromise)return[2,t.loggingInPromise]}}else if(null==(r=this._logins.get(""))?void 0:r.loggingInPromise)return[2,r.loggingInPromise];o=new Promise((function(e,t){return U(l,void 0,void 0,(function(){var n,r,o,i,s;return x(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=a.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:c(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:P(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(i=a.sent()).msgData.code?t(new Error(i.msgData.code+" "+i.msgData.message)):e({envId:n.envId}),[3,4];case 3:return s=a.sent(),t(s),[3,4];case 4:return[2]}}))}))})),i=e&&this._logins.get(e),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this._logins.set(e||"",i)),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,o];case 2:if(a=h.sent(),(u=e&&this._logins.get(e))&&u===i&&u.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(u){if(u.loggedIn&&u.loginResult)return[2,u.loginResult];if(u.loggingInPromise)return[2,u.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return U(t,void 0,void 0,(function(){var e,t,n,r,o,i,s;return x(this,(function(a){switch(a.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:P()})]);case 1:if((t=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: "+t.code);if(t.data)return n=t.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,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 U(t,void 0,void 0,(function(){var e;return x(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:c(),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(N.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,T[e].name),this._ws=void 0)},e.prototype.watch=function(e){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var t=new A(L(L({},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(){return U(t,void 0,void 0,(function(){var e=this;return x(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this._ws&&this._ws.readyState===C?(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++,e.heartbeat(!0)):e.initWebSocketConnection(!0)}),this._context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this._pingFailed<2?(this._pingFailed++,this.heartbeat()):this.close(N.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this._context.appConfig.realtimePingInterval)},e}(),M={target:"database",entity:function(){var e,t=this.platform,n=t.adapter,r=t.runtime;e=n.wsClass,B=e,function(e){D=e}(r)}},k={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=j}};try{cloudbase.registerComponent(k),cloudbase.registerHook(M)}catch(e){}function q(e){try{e.registerComponent(k),e.registerHook(M)}catch(e){console.warn(e)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"getBaseEndPoint",(function(){return A.b})),n.d(t,"cloudbase",(function(){return ee}));var r,o=n(0),i=n(3),s=(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)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=function(){return(a=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}).apply(this,arguments)},u=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},c=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};var f=function(e){function t(t){void 0===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 s(t,e),t.prototype.post=function(e){var t=this;return new Promise((function(n,r){var o=e.url,s=e.data,a=e.headers,u=wx.request({url:Object(i.formatUrl)("https:",o),data:s,timeout:t._timeout,method:"POST",header:a,success:function(e){n(e)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg)){console.warn(t._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t.prototype.upload=function(e){var t=this,n=this;return new Promise((function(r){return u(t,void 0,void 0,(function(){var t,o,i,s,u,f;return c(this,(function(c){return t=e.url,o=e.file,i=e.data,s=e.headers,u=e.onUploadProgress,f=wx.uploadFile({url:t,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(t.statusCode=parseInt(i.success_action_status,10)),r(t)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{f.abort()}catch(e){}}}}),u&&f.onProgressUpdate((function(e){u(e)})),[2]}))}))}))},t.prototype.download=function(e){var t=this,n=this;return new Promise((function(r,o){var s=e.url,a=e.headers,u=wx.downloadFile({url:Object(i.formatUrl)("https:",s),header:a,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?r({statusCode:200,tempFilePath:e.tempFilePath}):r(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t}(i.AbstractSDKRequest),l={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},h=function(e,t){void 0===t&&(t={});var n=wx.connectSocket(a({url:e},t));return{set onopen(e){n.onOpen(e)},set onmessage(e){n.onMessage(e)},set onclose(e){n.onClose(e)},set onerror(e){n.onError(e)},send:function(e){return n.send({data:e})},close:function(e,t){return n.close({code:e,reason:t})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var p={genAdapter:function(){return{root:{},reqClass:f,wsClass:h,localStorage:l,primaryStorage:i.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:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0},runtime:"wx_mp"},d=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},y=o.constants.ERRORS,g={};function _(e,t){var n=t.name,r=t.namespace,o=t.entity,i=t.injectEvents,s=t.IIFE,a=void 0!==s&&s;if(g[n]||r&&e[r])throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(e)}if(g[n]=t,r?e.prototype[r]=o:function e(t,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:return new Date(n.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return n}for(var r in n)n.hasOwnProperty(r)&&(t[r]=e(t[r],n[r]));return t}(e.prototype,o),i){var u=i.bus,c=i.events;if(!u||!c||0===c.length)return;var f=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[n]?e.prototype.events[n].events=d(e.prototype.events[n].events,c):e.prototype.events[n]={bus:u,events:c},e.prototype.fire=function(e,t){for(var n in f(e,t),this.events){var r=this.events[n],o=r.bus;if(r.events.includes(e)){o.fire(e,t);break}}}}}var v={},m=function(){return(m=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}).apply(this,arguments)},b=o.cache.CloudbaseCache,w={},E={};function S(e){var t=e.env,n=e.persistence,r=e.platformInfo,o={userInfoKey:"user_info_"+t};w[t]?w[t].updatePersistence(n):w[t]=new b(m(m({},e),{keys:o,platformInfo:r})),E[t]=E[t]||new b(m(m({},e),{keys:o,platformInfo:r,persistence:"local"}))}function O(e){return E[e]}var A=n(1),I=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}).apply(this,arguments)},N=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},T=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},R=o.constants.ERRORS,B=o.utils.genSeqId,D=o.utils.isFormData,P=o.utils.formatUrl,L=o.utils.createSign,U=o.adapters.RUNTIME,x=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function C(e,t,n){var r=e[t];e[t]=function(t){var o={},i={};n.forEach((function(n){var r=n.call(e,t),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=t.data;return s&&function(){if(D(s))for(var e in o)s.append(e,o[e]);else t.data=I(I({},s),o)}(),t.headers=I(I({},t.headers||{}),i),r.call(e,t)}}function j(){var e=B();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+Object(A.e)(),"x-seqid":e}}}var M=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new v.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e.throw||!1,this._localCache=O(this.config.env),C(this._reqClass,"post",[j]),C(this._reqClass,"upload",[j]),C(this._reqClass,"download",[j])}return e.prototype.post=function(e){return N(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.post(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.upload=function(e){return N(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.upload(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.download=function(e){return N(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.download(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getBaseEndPoint=function(){return Object(A.b)()},e.prototype.getOauthAccessTokenV2=function(e){return N(this,void 0,void 0,(function(){var t,n;return T(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){return N(this,void 0,void 0,(function(){var r,o,i,s,a,u,c,f,l,h,p,d,y,g,_,m,b,w,E,S,O,N,R,B,D,C,j;return T(this,(function(T){switch(T.label){case 0:return r="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=I({action:e,dataVersion:A.a,env:this.config.env},t),-1!==x.indexOf(e)?[3,2]:(s=this.config._fromApp,a=s.oauthInstance.oauth2client,u=i,[4,this.getOauthAccessTokenV2(a)]);case 1:u.access_token=T.sent().accessToken,T.label=2;case 2:if("storage.uploadFile"===e){for(f in c=new FormData)c.hasOwnProperty(f)&&void 0!==c[f]&&c.append(f,i[f]);o="multipart/form-data"}else for(f in o="application/json;charset=UTF-8",c={},i)void 0!==i[f]&&(c[f]=i[f]);return l={headers:{"content-type":o}},(null==n?void 0:n.onUploadProgress)&&(l.onUploadProgress=n.onUploadProgress),this.config.region&&(l.headers["X-TCB-Region"]=this.config.region),(h=this._localCache.getStore(r))&&(l.headers["X-TCB-Trace"]=h),v.runtime!==U.WEB&&(p=this.config,d=p.appSign,y=p.appSecret,g=Date.now(),_=y.appAccessKey,m=y.appAccessKeyId,b=L({data:{},timestamp:g,appAccessKeyId:m,appSign:d},_),l.headers["X-TCB-App-Source"]="timestamp="+g+";appAccessKeyId="+m+";appSign="+d+";sign="+b),w=t.parse,E=t.inQuery,S=t.search,O={env:this.config.env},w&&(O.parse=!0),E&&(O=I(I({},E),O)),N=Object(A.c)(),R=N.BASE_URL,B=N.PROTOCOL,D=P(B,R,O),S&&(D+=S),[4,this.post(I({url:D,data:c},l))];case 3:if(C=T.sent(),(j=C.header&&C.header["x-tcb-trace"])&&this._localCache.setStore(r,j),200!==Number(C.status)&&200!==Number(C.statusCode)||!C.data)throw new Error("network request error");return[2,C]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t={}),N(this,void 0,void 0,(function(){var n;return T(this,(function(r){switch(r.label){case 0:return[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 1:if((n=r.sent()).data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:R.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},e}(),k={};var q=function(){return(q=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}).apply(this,arguments)},F=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},W=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Y=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},$=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},H=o.adapters.useAdapters,V=o.adapters.useDefaultAdapter,G=o.adapters.RUNTIME,J=o.constants.ERRORS,K=o.constants.COMMUNITY_SITE_URL,z=o.utils.printWarn,X=o.helpers.catchErrorsDecorator,Q={timeout:15e3,persistence:"local"},Z={},ee=new(function(){function e(e){this._config=e||this._config,this.authInstance=null,this.oauthInstance=null}return Object.defineProperty(e.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return v},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return e=this._config.env,w[e];var e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return O(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this._config.env,k[e];var e},enumerable:!1,configurable:!0}),e.prototype.init=function(t){if(!t.env)throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"env must not be specified"}));if(v.adapter||this._useDefaultAdapter(),this.requestClient=new v.adapter.reqClass({timeout:t.timeout||5e3,timeoutMsg:"["+Object(A.d)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+t.timeout/1e3+"s"}),v.runtime!==G.WEB){if(!t.appSecret)throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"invalid appSecret"}));var n=v.adapter.getAppSign?v.adapter.getAppSign():"";if(t.appSign&&n&&t.appSign!==n)throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(t.appSign=n),!t.appSign)throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=q(q({},Q),t),this._config.timeout=this._formatTimeout(this._config.timeout);var r=this._config,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,u=r.appSecret,c=r.appSign,f=r.oauthClient;S({env:o,persistence:i,debug:s,platformInfo:this.platform}),t.region&&Object(A.g)(o,t.region||"");var l=new e(this._config);return function(e){k[e.env]=new M(I(I({},e),{throw:!0}))}({env:o,region:t.region||"",timeout:a,appSecret:u,appSign:c,oauthClient:f,_fromApp:l}),l.requestClient=this.requestClient,l},e.prototype.updateConfig=function(e){var t=e.persistence,n=e.debug;this._config.persistence=t,this._config.debug=n,S({env:this._config.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.registerExtension=function(e){Z[e.name]=e},e.prototype.invokeExtension=function(e,t){return Y(this,void 0,void 0,(function(){var n;return $(this,(function(r){switch(r.label){case 0:if(!(n=Z[e]))throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"extension:"+e+" must be registered before invoke"}));return[4,n.invoke(t,this)];case 1:return[2,r.sent()]}}))}))},e.prototype.useAdapters=function(e){var t=H(e)||{},n=t.adapter,r=t.runtime;n&&(v.adapter=n),r&&(v.runtime=r)},e.prototype.registerHook=function(t){!function(e,t){var n=t.entity,r=t.target;if(!e.prototype.hasOwnProperty(r))throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=e.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not a function which is the only type supports hook"}));e.prototype[r]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.call.apply(n,d([this],e)),o.call.apply(o,d([this],e))}}(e,t)},e.prototype.registerComponent=function(t){_(e,t)},e.prototype.registerVersion=function(e){Object(A.i)(e)},e.prototype.registerSdkName=function(e){Object(A.h)(e)},e.prototype.registerEndPoint=function(e,t){Object(A.f)(e,t)},e.prototype._useDefaultAdapter=function(){var e=V(),t=e.adapter,n=e.runtime;v.adapter=t,v.runtime=n},e.prototype._formatTimeout=function(e){switch(!0){case e>6e5:return z(J.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case e<100:return z(J.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},F([X({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+K]}),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",e)],e.prototype,"init",null),F([X({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+K]}),W("design:type",Function),W("design:paramtypes",[String,Object]),W("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}());ee.useAdapters(p);t.default=ee}])}));
|
|
26
|
+
t.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,f=-7,l=n?o-1:0,h=n?-1:1,p=e[t+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=c}return(p?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[n+p]=255&s,p+=d,s/=256,c-=8);e[n+p-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e){e.exports=JSON.parse('{"version":"2.0.0-alpha.0"}')},function(e,t,n){"use strict";n.r(t),n.d(t,"registerDatabase",(function(){return bt}));var r,o,i={};n.r(i),n.d(i,"Point",(function(){return ce})),n.d(i,"LineString",(function(){return J})),n.d(i,"Polygon",(function(){return z})),n.d(i,"MultiPoint",(function(){return Q})),n.d(i,"MultiLineString",(function(){return ee})),n.d(i,"MultiPolygon",(function(){return ne})),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a="Number",u="Object",c="Array",f="GeoPoint",l="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",d="GeoMultiLineString",y="GeoMultiPolygon",g="Date",_="ServerDate",v="BsonDate",m=["desc","asc"],b=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={}));var w;(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"}(w||(w={}));var E,S=(E=function(e,t){return(E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}E(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),O=[],A={},I=function(e){function t(t,n){if(n!==A)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return S(t,e),t.for=function(e){for(var n=0,r=O.length;n<r;n++)if(O[n].target===e)return O[n].instance;var o=new t(e,A);return O.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),N=I,T=N.for("UNSET_FIELD_NAME"),R=N.for("UPDATE_COMMAND"),B=N.for("QUERY_COMMAND"),D=N.for("LOGIC_COMMAND"),P=N.for("GEO_POINT"),L=N.for("SYMBOL_GEO_LINE_STRING"),U=N.for("SYMBOL_GEO_POLYGON"),x=N.for("SYMBOL_GEO_MULTI_POINT"),C=N.for("SYMBOL_GEO_MULTI_LINE_STRING"),j=N.for("SYMBOL_GEO_MULTI_POLYGON"),M=N.for("SERVER_DATE"),k=N.for("REGEXP"),q=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},F=function(e){return"object"===q(e)},W=function(e){return"number"===q(e)},Y=function(e){return Array.isArray(e)},$=function(e){return"date"===q(e)},H=function(e){return"regexp"===q(e)},V=function(e){return e&&e._internalType instanceof I},G=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(!Y(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof ce))throw new TypeError('"points" must be of type Point[]. Received type '+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||!Y(e.coordinates))return!1;try{for(var r=G(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(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 L},enumerable:!0,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.")},z=function(){function e(e){if(!Y(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof J))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]");if(!J.isClosed(e))throw new Error("LineString "+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||!Y(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 u=(r=void 0,K(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}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 j},enumerable:!0,configurable:!0}),e}(),X=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.")},Q=function(){function e(e){if(!Y(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof ce))throw new TypeError('"points" must be of type Point[]. Received type '+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||!Y(e.coordinates))return!1;try{for(var r=X(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(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 x},enumerable:!0,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.")},ee=function(){function e(e){if(!Y(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof J))throw new TypeError('"lines" must be of type LineString[]. Received type '+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||!Y(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 u=(r=void 0,Z(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}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 C},enumerable:!0,configurable:!0}),e}(),te=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.")},ne=function(){function e(e){var t,n;if(!Y(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof e);if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=te(e),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof z))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+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||!Y(e.coordinates))return!1;try{for(var a=te(e.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var f=(r=void 0,te(c)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,te(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!W(y[0])||!W(y[1]))return!1}}catch(e){i={error:e}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),e}(),re=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 M},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function oe(e){return new re(e)}var ie,se=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},ae=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 f:o=new ce(i.coordinates[0],i.coordinates[1]);break;case l:o=new J(i.coordinates.map((function(e){return new ce(e[0],e[1])})));break;case h:o=new z(i.coordinates.map((function(e){return new J(e.map((function(e){var t=se(e,2),n=t[0],r=t[1];return new ce(n,r)})))})));break;case p:o=new Q(i.coordinates.map((function(e){return new ce(e[0],e[1])})));break;case d:o=new ee(i.coordinates.map((function(e){return new J(e.map((function(e){var t=se(e,2),n=t[0],r=t[1];return new ce(n,r)})))})));break;case y:o=new ne(i.coordinates.map((function(e){return new z(e.map((function(e){return new J(e.map((function(e){var t=se(e,2),n=t[0],r=t[1];return new ce(n,r)})))})))})));break;case g:o=new Date(1e3*i.$timestamp);break;case u:case c:o=e.formatField(i);break;case _: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);if(t===g)return v;if(t===u){if(e instanceof ce)return f;if(e instanceof Date)return g;if(e instanceof re)return _;e.$timestamp?t=g:e.$date?t=_:ce.validate(e)?t=f:J.validate(e)?t=l:z.validate(e)?t=h:Q.validate(e)?t=p:ee.validate(e)?t=d:ne.validate(e)&&(t=y)}return t},e.generateDocId=function(){for(var e="ABCDEFabcdef0123456789",t="",n=0;n<24;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return t},e}(),ue=function(){function e(){}return e.isGeopoint=function(e,t){if(ae.whichType(t)!==a)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.isFieldOrder=function(e){if(-1===m.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===b.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}(),ce=function(){function e(e,t){ue.isGeopoint("longitude",e),ue.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"["+this.longitude+","+this.latitude+"]"},e.validate=function(e){return"Point"===e.type&&Y(e.coordinates)&&ue.isGeopoint("longitude",e.coordinates[0])&&ue.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),e}(),fe=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};!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"}(ie||(ie={}));var le=function(){function e(e,t,n){this._internalType=R,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||T}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function he(e){return e&&e instanceof le&&e._internalType===R}var pe;!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(pe||(pe={}));var de=function(){function e(e,t,n){if(this._internalType=D,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||T,this.fieldName!==T)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,o=t.length;r<o;r++){(ye(i=t[r])||me(i))&&(t[r]=i._setFieldName(this.fieldName))}}else{var i;(ye(i=t)||me(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(pe.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(pe.OR,r,this.fieldName)},e}();function ye(e){return e&&e instanceof de&&e._internalType===D}var ge,_e=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)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){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"}(ge||(ge={}));var ve=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.operator=t,o._internalType=B,o}return _e(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case ge.IN:case ge.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var n=new t(ge.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(ge.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(ge.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(ge.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(ge.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(ge.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(ge.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(ge.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof ce))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!W(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!W(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var n=new t(ge.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof ne||e.geometry instanceof z))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var n=new t(ge.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof ce||e.geometry instanceof J||e.geometry instanceof z||e.geometry instanceof Q||e.geometry instanceof ee||e.geometry instanceof ne))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var n=new t(ge.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(de);function me(e){return e&&e instanceof ve&&e._internalType===B}function be(e){return me(e)}var we={};for(var Ee in ge)we[Ee]="$"+Ee;for(var Ee in pe)we[Ee]="$"+Ee;for(var Ee in ie)we[Ee]="$"+Ee;function Se(e){return we[e]||"$"+e}we[ge.NEQ]="$ne",we[ie.REMOVE]="$unset",we[ie.SHIFT]="$pop",we[ie.UNSHIFT]="$push";var Oe=function(){return(Oe=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}).apply(this,arguments)},Ae=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},Ie=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ae(arguments[t]));return e};function Ne(e){return function e(t,n){if(!V(t)){if($(t))return{$date:+t};if(H(t))return{$regex:t.source,$options:t.flags};if(Y(t))return t.map((function(t){if(n.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return e(t,Ie(n,[t]))}));if(F(t)){var r=Oe({},t);for(var o in r){if(n.indexOf(r[o])>-1)throw new Error("Cannot convert circular structure to JSON");r[o]=e(r[o],Ie(n,[r[o]]))}return r}return t}switch(t._internalType){case P:return t.toJSON();case M:case k:return t.parse();default:return t.toJSON?t.toJSON():t}}(e,[e])}var Te=function(){return(Te=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}).apply(this,arguments)},Re=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},Be=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Re(arguments[t]));return e};function De(e,t,n,r){var o=Te({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&F(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=De(s,t,Be(n,[i]),Be(r,[s]));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o[i+"."+c]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Pe(e){return De(e,Ue,[],[e])}function Le(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Y(e[r])?e[r].push(t[r]):F(e[r])?F(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is "+q(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+q(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]}function Ue(e){return V(e)||$(e)||H(e)}function xe(e){return Ne(e)}var Ce=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return he(e)?this.encodeUpdateCommand(e):"object"===q(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===T)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case ie.PUSH:case ie.PULL:case ie.PULL_ALL:case ie.POP:case ie.SHIFT:case ie.UNSHIFT:case ie.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,o,i=Se(e.operator);switch(e.operator){case ie.REMOVE:return(t={})[i]=((n={})[e.fieldName]="",n),t;default:return(r={})[i]=((o={})[e.fieldName]=e.operands[0],o),r}},e.prototype.encodeArrayUpdateCommand=function(e){var t,n,r,o,i,s,a,u,c,f,l=Se(e.operator);switch(e.operator){case ie.PUSH:var h=void 0;return h=Y(e.operands)?{$each:e.operands.map(xe)}:e.operands,(t={})[l]=((n={})[e.fieldName]=h,n),t;case ie.UNSHIFT:h={$each:e.operands.map(xe),$position:0};return(r={})[l]=((o={})[e.fieldName]=h,o),r;case ie.POP:return(i={})[l]=((s={})[e.fieldName]=1,s),i;case ie.SHIFT:return(a={})[l]=((u={})[e.fieldName]=-1,u),a;default:return(c={})[l]=((f={})[e.fieldName]=xe(e.operands),f),c}},e.prototype.encodeUpdateObject=function(e){var t=Pe(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(he(r)){t[n]=r._setFieldName(n),Le(t,this.encodeUpdateCommand(t[n]),n)}else{t[n]=r=xe(r);var o=new le(ie.SET,[r],n);Le(t,this.encodeUpdateCommand(o),n)}}return t},e}(),je={};function Me(e){if(!_t.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return je[t]||(je[t]=new _t.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new _t.reqClass(e.config)}}})),je[t]}var ke=function(){return(ke=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}).apply(this,arguments)},qe=function(){function e(e,t,n,r){var o=this;void 0===r&&(r={}),this.watch=function(e){return Me(o._db).watch(ke(ke({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=e,this._coll=t,this.id=n,this.request=new _t.reqClass(this._db.config),this.projection=r}return e.prototype.create=function(e,t){t=t||fe();var n={collectionName:this._coll,data:Ne(e)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(e){e.code?t(0,e):t(0,{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||fe(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof le?n=!0:"object"==typeof e[t]&&r(e[t])};if(r(e),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:w.DOC,data:Ne(e),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||fe(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Ce.encode(e),query:n,queryType:w.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||fe();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:w.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||fe();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:w.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n=ae.formatResDocumentData(t.data.list);e(0,{data:n,requestId:t.requestId,total:t.TotalCount,limit:t.Limit,offset:t.Offset})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var n in t)t[n]?t[n]=1:t[n]=0;return new e(this._db,this._coll,this.id,t)},e}(),Fe=function(){function e(){}return e.encode=function(e){return(new We).encodeQuery(e)},e}(),We=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n;return Ue(e)?ye(e)?this.encodeLogicCommand(e):me(e)?this.encodeQueryCommand(e):((n={})[t]=this.encodeQueryObject(e),n):F(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,n,r,o,i,s,a,u=this;switch(e.operator){case pe.NOR:case pe.AND:case pe.OR:var c=Se(e.operator),f=e.operands.map((function(t){return u.encodeQuery(t,e.fieldName)}));return(t={})[c]=f,t;case pe.NOT:c=Se(e.operator);var l=e.operands[0];if(H(l))return(n={})[e.fieldName]=((r={})[c]=this.encodeRegExp(l),r),n;f=this.encodeQuery(l)[e.fieldName];return(o={})[e.fieldName]=((i={})[c]=f,i),o;default:c=Se(e.operator);if(1===e.operands.length){var h=this.encodeQuery(e.operands[0]);return(s={})[c]=h,s}f=e.operands.map(this.encodeQuery.bind(this));return(a={})[c]=f,a}},e.prototype.encodeQueryCommand=function(e){return be(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,o,i,s,a,u,c;if(e.fieldName===T)throw new Error("Cannot encode a comparison command with unset field name");var f=Se(e.operator);switch(e.operator){case ge.EQ:case ge.NEQ:case ge.LT:case ge.LTE:case ge.GT:case ge.GTE:case ge.ELEM_MATCH:case ge.EXISTS:case ge.SIZE:case ge.MOD:return(t={})[e.fieldName]=((n={})[f]=xe(e.operands[0]),n),t;case ge.IN:case ge.NIN:case ge.ALL:return(r={})[e.fieldName]=((o={})[f]=xe(e.operands),o),r;case ge.GEO_NEAR:var l=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case ge.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case ge.GEO_INTERSECTS:l=e.operands[0];return(a={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(u={})[e.fieldName]=((c={})[f]=xe(e.operands[0]),c),u}},e.prototype.encodeQueryObject=function(e){var t=Pe(e);for(var n in t){var r=t[n];if(ye(r)){t[n]=r._setFieldName(n);var o=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else if(be(r)){t[n]=r._setFieldName(n);o=this.encodeComparisonCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else Ue(r)&&(t[n]=xe(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Y(e[r])?e[r]=e[r].concat(t[r]):F(e[r])?F(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+q(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+q(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),Ye=function(){return(Ye=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}).apply(this,arguments)},$e=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){return Me(i._db).watch(Ye(Ye({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new _t.reqClass(this._db.config)}return e.prototype.get=function(e){e=e||fe();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var n={collectionName:this._coll,queryType:w.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),t.length>0&&(n.order=t),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n={data:ae.formatResDocumentData(t.data.list),requestId:t.requestId};t.TotalCount&&(n.total=t.TotalCount),t.Limit&&(n.limit=t.Limit),t.Offset&&(n.offset=t.Offset),e(0,n)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||fe();var t={collectionName:this._coll,queryType:w.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},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,Fe.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,n){ue.isFieldPath(t),ue.isFieldOrder(n);var r={field:t,direction:n},o=this._fieldOrders.concat(r);return new e(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},e.prototype.limit=function(t){ue.isInteger("limit",t);var n=Ye({},this._queryOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.skip=function(t){ue.isInteger("offset",t);var n=Ye({},this._queryOptions);return n.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.update=function(e,t){if(t=t||fe(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:w.WHERE,multi:!0,merge:!0,upsert:!1,data:Ce.encode(e)};return this._request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var n in t)t[n]?"object"!=typeof t[n]&&(t[n]=1):t[n]=0;var r=Ye({},this._queryOptions);return r.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.remove=function(e){e=e||fe(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var t={collectionName:this._coll,query:Fe.encode(this._fieldFilters),queryType:w.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}(),He=n(2),Ve=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},Ge=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Je=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new _t.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Ve(this,void 0,void 0,(function(){var e;return Ge(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.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map(He.a.parse)}]:[2,e]}}))}))},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){return this._stages.push({stageKey:"$"+e,stageValue:JSON.stringify(t)}),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 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",Fe.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}(),Ke=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)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ze=function(e){function t(t,n){return e.call(this,t,n)||this}return Ke(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new qe(this._db,this._coll,e)},t.prototype.add=function(e,t){return new qe(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new Je(this._db,this._coll)},t}($e),Xe={eq:function(e){return new ve(ge.EQ,[e])},neq:function(e){return new ve(ge.NEQ,[e])},lt:function(e){return new ve(ge.LT,[e])},lte:function(e){return new ve(ge.LTE,[e])},gt:function(e){return new ve(ge.GT,[e])},gte:function(e){return new ve(ge.GTE,[e])},in:function(e){return new ve(ge.IN,e)},nin:function(e){return new ve(ge.NIN,e)},all:function(e){return new ve(ge.ALL,e)},elemMatch:function(e){return new ve(ge.ELEM_MATCH,[e])},exists:function(e){return new ve(ge.EXISTS,[e])},size:function(e){return new ve(ge.SIZE,[e])},mod:function(e){return new ve(ge.MOD,[e])},geoNear:function(e){return new ve(ge.GEO_NEAR,[e])},geoWithin:function(e){return new ve(ge.GEO_WITHIN,[e])},geoIntersects:function(e){return new ve(ge.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.AND,n)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOR,n)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.OR,n)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOT,n)},set:function(e){return new le(ie.SET,[e])},remove:function(){return new le(ie.REMOVE,[])},inc:function(e){return new le(ie.INC,[e])},mul:function(e){return new le(ie.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(F(t[0])&&t[0].hasOwnProperty("each")){var r=t[0];e={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else e=Y(t[0])?t[0]:Array.from(t);return new le(ie.PUSH,e)},pull:function(e){return new le(ie.PULL,e)},pullAll:function(e){return new le(ie.PULL_ALL,e)},pop:function(){return new le(ie.POP,[])},shift:function(){return new le(ie.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new le(ie.UNSHIFT,n)},addToSet:function(e){return new le(ie.ADD_TO_SET,e)},rename:function(e){return new le(ie.RENAME,[e])},bit:function(e){return new le(ie.BIT,[e])},max:function(e){return new le(ie.MAX,[e])},min:function(e){return new le(ie.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===q(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new Je},abs:function(e){return new Qe("abs",e)},add:function(e){return new Qe("add",e)},ceil:function(e){return new Qe("ceil",e)},divide:function(e){return new Qe("divide",e)},exp:function(e){return new Qe("exp",e)},floor:function(e){return new Qe("floor",e)},ln:function(e){return new Qe("ln",e)},log:function(e){return new Qe("log",e)},log10:function(e){return new Qe("log10",e)},mod:function(e){return new Qe("mod",e)},multiply:function(e){return new Qe("multiply",e)},pow:function(e){return new Qe("pow",e)},sqrt:function(e){return new Qe("sqrt",e)},subtract:function(e){return new Qe("subtract",e)},trunc:function(e){return new Qe("trunc",e)},arrayElemAt:function(e){return new Qe("arrayElemAt",e)},arrayToObject:function(e){return new Qe("arrayToObject",e)},concatArrays:function(e){return new Qe("concatArrays",e)},filter:function(e){return new Qe("filter",e)},in:function(e){return new Qe("in",e)},indexOfArray:function(e){return new Qe("indexOfArray",e)},isArray:function(e){return new Qe("isArray",e)},map:function(e){return new Qe("map",e)},range:function(e){return new Qe("range",e)},reduce:function(e){return new Qe("reduce",e)},reverseArray:function(e){return new Qe("reverseArray",e)},size:function(e){return new Qe("size",e)},slice:function(e){return new Qe("slice",e)},zip:function(e){return new Qe("zip",e)},and:function(e){return new Qe("and",e)},not:function(e){return new Qe("not",e)},or:function(e){return new Qe("or",e)},cmp:function(e){return new Qe("cmp",e)},eq:function(e){return new Qe("eq",e)},gt:function(e){return new Qe("gt",e)},gte:function(e){return new Qe("gte",e)},lt:function(e){return new Qe("lt",e)},lte:function(e){return new Qe("lte",e)},neq:function(e){return new Qe("ne",e)},cond:function(e){return new Qe("cond",e)},ifNull:function(e){return new Qe("ifNull",e)},switch:function(e){return new Qe("switch",e)},dateFromParts:function(e){return new Qe("dateFromParts",e)},dateFromString:function(e){return new Qe("dateFromString",e)},dayOfMonth:function(e){return new Qe("dayOfMonth",e)},dayOfWeek:function(e){return new Qe("dayOfWeek",e)},dayOfYear:function(e){return new Qe("dayOfYear",e)},isoDayOfWeek:function(e){return new Qe("isoDayOfWeek",e)},isoWeek:function(e){return new Qe("isoWeek",e)},isoWeekYear:function(e){return new Qe("isoWeekYear",e)},millisecond:function(e){return new Qe("millisecond",e)},minute:function(e){return new Qe("minute",e)},month:function(e){return new Qe("month",e)},second:function(e){return new Qe("second",e)},hour:function(e){return new Qe("hour",e)},week:function(e){return new Qe("week",e)},year:function(e){return new Qe("year",e)},literal:function(e){return new Qe("literal",e)},mergeObjects:function(e){return new Qe("mergeObjects",e)},objectToArray:function(e){return new Qe("objectToArray",e)},allElementsTrue:function(e){return new Qe("allElementsTrue",e)},anyElementTrue:function(e){return new Qe("anyElementTrue",e)},setDifference:function(e){return new Qe("setDifference",e)},setEquals:function(e){return new Qe("setEquals",e)},setIntersection:function(e){return new Qe("setIntersection",e)},setIsSubset:function(e){return new Qe("setIsSubset",e)},setUnion:function(e){return new Qe("setUnion",e)},concat:function(e){return new Qe("concat",e)},dateToString:function(e){return new Qe("dateToString",e)},indexOfBytes:function(e){return new Qe("indexOfBytes",e)},indexOfCP:function(e){return new Qe("indexOfCP",e)},split:function(e){return new Qe("split",e)},strLenBytes:function(e){return new Qe("strLenBytes",e)},strLenCP:function(e){return new Qe("strLenCP",e)},strcasecmp:function(e){return new Qe("strcasecmp",e)},substr:function(e){return new Qe("substr",e)},substrBytes:function(e){return new Qe("substrBytes",e)},substrCP:function(e){return new Qe("substrCP",e)},toLower:function(e){return new Qe("toLower",e)},toUpper:function(e){return new Qe("toUpper",e)},meta:function(e){return new Qe("meta",e)},addToSet:function(e){return new Qe("addToSet",e)},avg:function(e){return new Qe("avg",e)},first:function(e){return new Qe("first",e)},last:function(e){return new Qe("last",e)},max:function(e){return new Qe("max",e)},min:function(e){return new Qe("min",e)},push:function(e){return new Qe("push",e)},stdDevPop:function(e){return new Qe("stdDevPop",e)},stdDevSamp:function(e){return new Qe("stdDevSamp",e)},sum:function(e){return new Qe("sum",e)},let:function(e){return new Qe("let",e)}},project:{slice:function(e){return new Ze("slice",e)},elemMatch:function(e){return new Ze("elemMatch",e)}}},Qe=function(e,t){this["$"+e]=t},Ze=function(e,t){this["$"+e]=t},et=function(){function e(e){var t=e.regexp,n=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=n}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return k},enumerable:!0,configurable:!0}),e}();function tt(e){return new et(e)}var nt={code:"INSERT_DOC_FAIL",message:"insert document failed"},rt={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},ot=function(){return(ot=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}).apply(this,arguments)},it=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},st=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},at="database.updateDocInTransaction",ut=function(){function e(e,t,n){this._coll=t,this.id=n,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return it(this,void 0,void 0,(function(){var t,n,r,o;return st(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:He.a.stringify(Ne(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((n=i.sent()).code)throw n;if(r=He.a.parse(n.inserted),1==(o=He.a.parse(n.ok))&&1==r)return[2,ot(ot({},n),{ok:o,inserted:r})];throw new Error(nt.message)}}))}))},e.prototype.get=function(){return it(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,{data:"null"!==t.data?ae.formatField(He.a.parse(t.data)):He.a.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return it(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:He.a.stringify(Ne(e),{relaxed:!1}),upsert:!0},[4,this._request.send(at,t)];case 1:if((n=r.sent()).code)throw n;return[2,ot(ot({},n),{updated:He.a.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},e.prototype.update=function(e){return it(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:He.a.stringify(Ce.encode(e),{relaxed:!1})},[4,this._request.send(at,t)];case 1:if((n=r.sent()).code)throw n;return[2,ot(ot({},n),{updated:He.a.parse(n.updated)})]}}))}))},e.prototype.delete=function(){return it(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,ot(ot({},t),{deleted:He.a.parse(t.deleted)})]}}))}))},e}(),ct=function(e,t){this._coll=t,this._transaction=e},ft=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)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),lt=function(e){function t(t,n){return e.call(this,t,n)||this}return ft(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new ut(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new ut(this._transaction,this._coll,t).create(e)},t}(ct),ht=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},pt=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},dt=function(){function e(e){this._db=e,this._request=new _t.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return ht(this,void 0,void 0,(function(){var e;return pt(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 lt(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return ht(this,void 0,void 0,(function(){var e,t;return pt(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 ht(this,void 0,void 0,(function(){var t,n;return pt(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 yt(){return ht(this,void 0,void 0,(function(){var e;return pt(this,(function(t){switch(t.label){case 0:return[4,(e=new dt(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function gt(e,t){return void 0===t&&(t=3),ht(this,void 0,void 0,(function(){var n,r,o,i,s=this;return pt(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new dt(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 ht(s,void 0,void 0,(function(){return pt(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:return t.sent(),[3,4];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===rt.code?[4,gt.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 _t=function(){function e(e){this.config=e,this.Geo=i,this.serverDate=oe,this.command=Xe,this.RegExp=tt,this.startTransaction=yt,this.runTransaction=gt,this.logicCommand=de,this.updateCommand=le,this.queryCommand=ve}return e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new ze(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",n)},e}(),vt=function(){return(vt=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}).apply(this,arguments)};var mt={name:"database",entity:{database:function(e){var t=this.platform,n=t.adapter,r=t.runtime;return _t.reqClass=this.request.constructor,_t.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},_t.runtime=r,this.wsClientClass&&(_t.wsClass=n.wsClass,_t.wsClientClass=this.wsClientClass),_t.ws||(_t.ws=null),new _t(vt(vt({},this.config),e))}}};try{cloudbase.registerComponent(mt)}catch(e){}function bt(e){try{e.registerComponent(mt)}catch(e){console.warn(e)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"registerRealtime",(function(){return q}));var r=n(14),o=n.n(r),i=n(15),s=n.n(i),a=n(16),u=n.n(a);function c(e){return void 0===e&&(e=""),(e?e+"_":"")+ +new Date+"_"+Math.random()}var f,l,h=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}})},p=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}})},d=(f=function(e,t){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}f(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),y=function(e){function t(t){var n=e.call(this,"Watch Error "+JSON.stringify(t.msgData)+" (requestid: "+t.requestId+")")||this;return n.isRealtimeErrorMessageError=!0,n.payload=t,n}return d(t,e),t}(Error),g=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},_=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 d(t,e),t}(Error),v=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 d(t,e),t}(Error),m=function(e){function t(t){var n=e.call(this,t.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: "+this.errCode+" "+(b[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e}}}),n.errCode=t.errCode||"UNKNOWN_ERROR",n.errMsg=t.errMsg,n}return d(t,e),Object.defineProperty(t.prototype,"message",{get:function(){return"errCode: "+this.errCode+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),t}(Error),b={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"},w=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},E=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},S=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},O=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};!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"}(l||(l={}));var A=function(){function e(e){var t=this;this.watchStatus=l.INITING,this._login=function(e,n){return E(t,void 0,void 0,(function(){var t;return S(this,(function(r){switch(r.label){case 0:return this.watchStatus=l.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 E(t,void 0,void 0,(function(){var t,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(t,r){return E(n,void 0,void 0,(function(){var n,o,i,s,a,u,f,h,d,y;return S(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];case 1:return n=g.sent().envId,this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=l.INITING,o={watchId:this.watchId,requestId:c(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=g.sent(),s=i.msgData,a=s.events,u=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:u-1,currentDocs:[]},a.length>0){for(f=0,h=a;f<h.length;f++)h[f].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,d=new p({id:u,docChanges:[],docs:[],type:"init"}),this.listener.onChange(d),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=l.ACTIVE,this._availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return y=g.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._initWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch "+(t?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(e){return E(t,void 0,void 0,(function(){var t,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(t,r){return E(n,void 0,void 0,(function(){var n,o,i,s;return S(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=l.REBUILDING,o={watchId:this.watchId,requestId:c(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=l.ACTIVE,this._availableRetries.REBUILD_WATCH=2,t(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._rebuildWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch "+(t?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(e,n){return E(t,void 0,void 0,(function(){var t,r,o,i=this;return S(this,(function(s){return t="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new m({errCode:t?b.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:b.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),n.reject(e)},o=function(e){i.useRetryTicket(n.operationName)?t?(i._initWatchPromise=void 0,n.resolve(i.initWatch(e))):(i._rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(e))):r()},this.handleCommonError(e,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){return E(i,void 0,void 0,(function(){var e,t=this;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),e=function(){return E(t,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];case 1:return r.sent(),[3,7];case 2:return[4,w(100)];case 3:return r.sent(),this.watchStatus!==l.PAUSED?[3,4]:(n.reject(new v(n.operationName+" cancelled due to pause after unknownError")),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return E(t,void 0,void 0,(function(){var e,t,n;return S(this,(function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==l.ACTIVE)return this.watchStatus=l.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=l.CLOSING,t={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=l.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new m({errCode:b.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 E(t,void 0,void 0,(function(){var e,t,n;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==l.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:c(),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(),g(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 m({errCode:b.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--,this.scheduleSendACK()):this.closeWithError(new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(g(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);case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":default:return void t.onNotRetryableError(e)}}else{if(function(e){return"timeout"===e.type}(e))return void t.onTimeoutError(e);if(function(e){return"cancelled"===e.type}(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_"+ +new Date+"_"+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 h({close:this.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 l.PAUSED:if("ERROR"!==e.msgType)return;break;case l.LOGGINGIN:case l.INITING:case l.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case l.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case l.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 "+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 "+this.getWaitExpectedTimeoutLength()));break;case"ERROR":this.closeWithError(new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:e.msgData.code+" - "+e.msgData.message}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg "+e.msgType+": ",e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){this.watchStatus=l.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,this.sessionInfo&&this.sessionInfo.queryID||""),console.log("[realtime] client closed ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.pause=function(){this.watchStatus=l.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.resume=function(){return E(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:this.watchStatus=l.RESUMING,console.log("[realtime] client resuming with "+(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH")+" ("+this.collectionName+" "+this.query+") ("+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 ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed ("+this.collectionName+" "+this.query+") ("+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]--,console.log("[realtime] "+e+" use a retry ticket, now only "+this._availableRetries[e]+" retry left"),!0)},e.prototype.handleServerEvents=function(e){return E(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this._handleServerEvents(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._handleServerEvents=function(e){return E(this,void 0,void 0,(function(){var t,n,r,i,a,c,f,l,h,d,y,g;return S(this,(function(_){switch(_.label){case 0:if(t=e.requestId,n=e.msgData.events,r=e.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(I)}catch(e){return this.closeWithError(new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}c=O(i.currentDocs),f=!1,l=function(n,l){var d,y,g,_,v,w,E,A,I,N,T;return S(this,(function(S){switch(S.label){case 0:return d=a[n],i.currentEventId>=d.id?(!a[n-1]||d.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur "+i.currentEventId+" but got "+d.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 "+t+")"),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==d.id-1)return[3,2];switch(d.dataType){case"update":if(!d.doc)switch(d.queueType){case"update":case"dequeue":if(y=c.find((function(e){return e._id===d.docId}))){if(w=u()(y),d.updatedFields)for(v in d.updatedFields)o()(w,v,d.updatedFields[v]);if(d.removedFields)for(g=0,_=d.removedFields;g<_.length;g++)v=_[g],s()(w,v);d.doc=w}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw E=new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '+e.requestId+")"}),h.closeWithError(E),E}break;case"replace":if(!d.doc)throw E=new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '+e.requestId+")"}),h.closeWithError(E),E;break;case"remove":(w=c.find((function(e){return e._id===d.docId})))?d.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!d.doc)switch(d.queueType){case"dequeue":(w=c.find((function(e){return e._id===d.docId})))?d.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw E=new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '+e.requestId+")"}),h.closeWithError(E),E}}switch(d.queueType){case"init":f?c.push(d.doc):(f=!0,c=[d.doc]);break;case"enqueue":c.push(d.doc);break;case"dequeue":(A=c.findIndex((function(e){return e._id===d.docId})))>-1?c.splice(A,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":(A=c.findIndex((function(e){return e._id===d.docId})))>-1?c[A]=d.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===l-1||a[n+1]&&a[n+1].id!==d.id)&&(I=O(c),N=a.slice(0,n+1).filter((function(e){return e.id===d.id})),h.sessionInfo.currentEventId=d.id,h.sessionInfo.currentDocs=c,T=new p({id:d.id,docChanges:N,docs:I,msgType:r}),h.listener.onChange(T)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur "+h.sessionInfo.currentEventId+" but got "+d.id),[4,h.rebuildWatch()];case 3:return S.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,d=0,y=a.length,_.label=1;case 1:return d<y?[5,l(d,y)]:[3,4];case 2:if("object"==typeof(g=_.sent()))return[2,g.value];_.label=3;case 3:return d++,[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 I(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}var N,T={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"}};!function(e){e[e.NormalClosure=1e3]="NormalClosure",e[e.GoingAway=1001]="GoingAway",e[e.ProtocolError=1002]="ProtocolError",e[e.UnsupportedData=1003]="UnsupportedData",e[e.NoStatusReceived=1005]="NoStatusReceived",e[e.AbnormalClosure=1006]="AbnormalClosure",e[e.InvalidFramePayloadData=1007]="InvalidFramePayloadData",e[e.PolicyViolation=1008]="PolicyViolation",e[e.MessageTooBig=1009]="MessageTooBig",e[e.MissingExtension=1010]="MissingExtension",e[e.InternalError=1011]="InternalError",e[e.ServiceRestart=1012]="ServiceRestart",e[e.TryAgainLater=1013]="TryAgainLater",e[e.BadGateway=1014]="BadGateway",e[e.TLSHandshake=1015]="TLSHandshake",e[e.ReconnectWebSocket=3e3]="ReconnectWebSocket",e[e.NoRealtimeListeners=3001]="NoRealtimeListeners",e[e.HeartbeatPingError=3002]="HeartbeatPingError",e[e.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",e[e.NoAuthentication=3050]="NoAuthentication"}(N||(N={}));var R=function(e,t){var n=T[e],r=n?n.name+", code "+e+", reason "+(t||n.description):"code "+e;return new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},B=null,D="web";function P(){return D}var L=function(){return(L=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}).apply(this,arguments)},U=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},x=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},C=1,j=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 U(t,void 0,void 0,(function(){var t=this;return x(this,(function(n){return[2,new Promise((function(n,r){return U(t,void 0,void 0,(function(){var t,o,i,s,a,u,c,f=this;return x(this,(function(l){switch(l.label){case 0:o=!1,i=!1,s=function(e){o=!0,t&&clearTimeout(t),n(e)},a=function(e){i=!0,t&&clearTimeout(t),r(e)},e.timeout&&(t=setTimeout((function(){return U(f,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,w(0)];case 1:e.sent(),o&&i||a(new _("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),l.label=1;case 1:return l.trys.push([1,8,,9]),this._wsInitPromise?[4,this._wsInitPromise]:[3,3];case 2:l.sent(),l.label=3;case 3:if(!this._ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(this._ws.readyState!==C)return a(new Error("ws readyState invalid: "+this._ws.readyState+", can not send message")),[2];e.waitResponse&&this._wsResponseWait.set(e.msg.requestId,{resolve:s,reject:a,skipOnMessage:e.skipOnMessage}),l.label=4;case 4:return l.trys.push([4,6,,7]),[4,this._ws.send(JSON.stringify(e.msg))];case 5:return l.sent(),e.waitResponse||s(),[3,7];case 6:return(u=l.sent())&&(a(u),e.waitResponse&&this._wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return c=l.sent(),a(c),[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),U(t,void 0,void 0,(function(){var t=this;return x(this,(function(r){switch(r.label){case 0:if(e&&this._reconnectState)return[2];if(e&&(this._reconnectState=!0),this._wsInitPromise)return[2,this._wsInitPromise];e&&this.pauseClients(),this.close(N.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,o){return U(t,void 0,void 0,(function(){var t,i,s=this;return x(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=a.sent(),[4,new Promise((function(e){var n=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=B;s._ws=r?new r(n):new WebSocket(n),e()}))];case 2:return a.sent(),this._ws.connect?[4,this._ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),e&&(this.resumeClients(),this._reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(!0,this._wsInitPromise=void 0,[4,w(this._reconnectInterval)]):[3,9];case 7:a.sent(),e&&(this._reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(e,n-1)),[3,10];case 9:o(i),e&&this.closeAllClients(new m({errCode:b.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.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 m({errCode:b.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 N.ReconnectWebSocket:case N.NoRealtimeListeners:break;case N.HeartbeatPingError:case N.HeartbeatPongTimeoutError:case N.NormalClosure:case N.AbnormalClosure:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(R(e.code));break;case N.NoAuthentication:t.closeAllClients(R(e.code,e.reason));break;default:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(R(e.code))}},t._ws.onmessage=function(e){var n,r=e.data;t.heartbeat();try{n=JSON.parse(r)}catch(e){throw new Error("[realtime] onMessage parse res.data error: "+e)}if("ERROR"===n.msgType){var o=null;t._virtualWSClient.forEach((function(e){e.watchId===n.watchId&&(o=e)})),o&&o.listener.onError(n)}var i=t._wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new y(n)):i.resolve(n)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t._wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&t._watchIdClientMap.get(n.watchId);if(s)s.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId "+n.watchId+": ",n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(s=t._queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,u=Array.from(t._watchIdClientMap.entries());a<u.length;a++){u[a][1].onMessage(n);break}}}else if(t._lastPingSendTS){var c=Date.now()-t._lastPingSendTS;if(c>1e4)return void console.warn("[realtime] untrusted rtt observed: "+c);t._rttObserved.length>=3&&t._rttObserved.splice(0,t._rttObserved.length-3+1),t._rttObserved.push(c)}},t.heartbeat()}))},this.isWSConnected=function(){return Boolean(t._ws&&t._ws.readyState===C)},this.onceWSConnected=function(){return U(t,void 0,void 0,(function(){var e=this;return x(this,(function(t){return this.isWSConnected()?[2]:this._wsInitPromise?[2,this._wsInitPromise]:[2,new Promise((function(t,n){e._wsReadySubsribers.push({resolve:t,reject:n})}))]}))}))},this.webLogin=function(e,n){return U(t,void 0,void 0,(function(){var t,r,o,i,s,a,u,f,l=this;return x(this,(function(h){switch(h.label){case 0:if(!n)if(e){if(t=this._logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(t.loggingInPromise)return[2,t.loggingInPromise]}}else if(null==(r=this._logins.get(""))?void 0:r.loggingInPromise)return[2,r.loggingInPromise];o=new Promise((function(e,t){return U(l,void 0,void 0,(function(){var n,r,o,i,s;return x(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=a.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:c(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:P(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(i=a.sent()).msgData.code?t(new Error(i.msgData.code+" "+i.msgData.message)):e({envId:n.envId}),[3,4];case 3:return s=a.sent(),t(s),[3,4];case 4:return[2]}}))}))})),i=e&&this._logins.get(e),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this._logins.set(e||"",i)),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,o];case 2:if(a=h.sent(),(u=e&&this._logins.get(e))&&u===i&&u.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(u){if(u.loggedIn&&u.loginResult)return[2,u.loginResult];if(u.loggingInPromise)return[2,u.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return U(t,void 0,void 0,(function(){var e,t,n,r,o,i,s;return x(this,(function(a){switch(a.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:P()})]);case 1:if((t=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: "+t.code);if(t.data)return n=t.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,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 U(t,void 0,void 0,(function(){var e;return x(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:c(),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(N.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,T[e].name),this._ws=void 0)},e.prototype.watch=function(e){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var t=new A(L(L({},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(){return U(t,void 0,void 0,(function(){var e=this;return x(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this._ws&&this._ws.readyState===C?(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++,e.heartbeat(!0)):e.initWebSocketConnection(!0)}),this._context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this._pingFailed<2?(this._pingFailed++,this.heartbeat()):this.close(N.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this._context.appConfig.realtimePingInterval)},e}(),M={target:"database",entity:function(){var e,t=this.platform,n=t.adapter,r=t.runtime;e=n.wsClass,B=e,function(e){D=e}(r)}},k={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=j}};try{cloudbase.registerComponent(k),cloudbase.registerHook(M)}catch(e){}function q(e){try{e.registerComponent(k),e.registerHook(M)}catch(e){console.warn(e)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"getBaseEndPoint",(function(){return A.b})),n.d(t,"cloudbase",(function(){return ee}));var r,o=n(0),i=n(3),s=(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)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=function(){return(a=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}).apply(this,arguments)},u=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},c=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};var f=function(e){function t(t){void 0===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 s(t,e),t.prototype.post=function(e){var t=this;return new Promise((function(n,r){var o=e.url,s=e.data,a=e.headers,u=wx.request({url:Object(i.formatUrl)("https:",o),data:s,timeout:t._timeout,method:"POST",header:a,success:function(e){n(e)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg)){console.warn(t._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t.prototype.upload=function(e){var t=this,n=this;return new Promise((function(r){return u(t,void 0,void 0,(function(){var t,o,i,s,u,f;return c(this,(function(c){return t=e.url,o=e.file,i=e.data,s=e.headers,u=e.onUploadProgress,f=wx.uploadFile({url:t,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(t.statusCode=parseInt(i.success_action_status,10)),r(t)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{f.abort()}catch(e){}}}}),u&&f.onProgressUpdate((function(e){u(e)})),[2]}))}))}))},t.prototype.download=function(e){var t=this,n=this;return new Promise((function(r,o){var s=e.url,a=e.headers,u=wx.downloadFile({url:Object(i.formatUrl)("https:",s),header:a,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?r({statusCode:200,tempFilePath:e.tempFilePath}):r(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t}(i.AbstractSDKRequest),l={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},h=function(e,t){void 0===t&&(t={});var n=wx.connectSocket(a({url:e},t));return{set onopen(e){n.onOpen(e)},set onmessage(e){n.onMessage(e)},set onclose(e){n.onClose(e)},set onerror(e){n.onError(e)},send:function(e){return n.send({data:e})},close:function(e,t){return n.close({code:e,reason:t})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var p={genAdapter:function(){return{root:{},reqClass:f,wsClass:h,localStorage:l,primaryStorage:i.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:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0},runtime:"wx_mp"},d=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},y=o.constants.ERRORS,g={};function _(e,t){var n=t.name,r=t.namespace,o=t.entity,i=t.injectEvents,s=t.IIFE,a=void 0!==s&&s;if(g[n]||r&&e[r])throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(e)}if(g[n]=t,r?e.prototype[r]=o:function e(t,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:return new Date(n.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return n}for(var r in n)n.hasOwnProperty(r)&&(t[r]=e(t[r],n[r]));return t}(e.prototype,o),i){var u=i.bus,c=i.events;if(!u||!c||0===c.length)return;var f=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[n]?e.prototype.events[n].events=d(e.prototype.events[n].events,c):e.prototype.events[n]={bus:u,events:c},e.prototype.fire=function(e,t){for(var n in f(e,t),this.events){var r=this.events[n],o=r.bus;if(r.events.includes(e)){o.fire(e,t);break}}}}}var v={},m=function(){return(m=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}).apply(this,arguments)},b=o.cache.CloudbaseCache,w={},E={};function S(e){var t=e.env,n=e.platformInfo,r={userInfoKey:"user_info_"+t};w[t]=w[t]||new b(m(m({},e),{keys:r,platformInfo:n})),E[t]=E[t]||new b(m(m({},e),{keys:r,platformInfo:n,persistence:"local"}))}function O(e){return E[e]}var A=n(1),I=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}).apply(this,arguments)},N=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},T=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},R=o.constants.ERRORS,B=o.utils.genSeqId,D=o.utils.isFormData,P=o.utils.formatUrl,L=o.utils.createSign,U=o.adapters.RUNTIME,x=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function C(e,t,n){var r=e[t];e[t]=function(t){var o={},i={};n.forEach((function(n){var r=n.call(e,t),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=t.data;return s&&function(){if(D(s))for(var e in o)s.append(e,o[e]);else t.data=I(I({},s),o)}(),t.headers=I(I({},t.headers||{}),i),r.call(e,t)}}function j(){var e=B();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+Object(A.e)(),"x-seqid":e}}}var M=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new v.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e.throw||!1,this._localCache=O(this.config.env),C(this._reqClass,"post",[j]),C(this._reqClass,"upload",[j]),C(this._reqClass,"download",[j])}return e.prototype.post=function(e){return N(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.post(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.upload=function(e){return N(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.upload(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.download=function(e){return N(this,void 0,void 0,(function(){return T(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.download(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getBaseEndPoint=function(){return Object(A.b)()},e.prototype.getOauthAccessTokenV2=function(e){return N(this,void 0,void 0,(function(){var t,n;return T(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){return N(this,void 0,void 0,(function(){var r,o,i,s,a,u,c,f,l,h,p,d,y,g,_,m,b,w,E,S,O,N,R,B,D,C,j;return T(this,(function(T){switch(T.label){case 0:return r="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=I({action:e,dataVersion:A.a,env:this.config.env},t),-1!==x.indexOf(e)?[3,2]:(s=this.config._fromApp,a=s.oauthInstance.oauth2client,u=i,[4,this.getOauthAccessTokenV2(a)]);case 1:u.access_token=T.sent().accessToken,T.label=2;case 2:if("storage.uploadFile"===e){for(f in c=new FormData)c.hasOwnProperty(f)&&void 0!==c[f]&&c.append(f,i[f]);o="multipart/form-data"}else for(f in o="application/json;charset=UTF-8",c={},i)void 0!==i[f]&&(c[f]=i[f]);return l={headers:{"content-type":o}},(null==n?void 0:n.onUploadProgress)&&(l.onUploadProgress=n.onUploadProgress),this.config.region&&(l.headers["X-TCB-Region"]=this.config.region),(h=this._localCache.getStore(r))&&(l.headers["X-TCB-Trace"]=h),v.runtime!==U.WEB&&(p=this.config,d=p.appSign,y=p.appSecret,g=Date.now(),_=y.appAccessKey,m=y.appAccessKeyId,b=L({data:{},timestamp:g,appAccessKeyId:m,appSign:d},_),l.headers["X-TCB-App-Source"]="timestamp="+g+";appAccessKeyId="+m+";appSign="+d+";sign="+b),w=t.parse,E=t.inQuery,S=t.search,O={env:this.config.env},w&&(O.parse=!0),E&&(O=I(I({},E),O)),N=Object(A.c)(),R=N.BASE_URL,B=N.PROTOCOL,D=P(B,R,O),S&&(D+=S),[4,this.post(I({url:D,data:c},l))];case 3:if(C=T.sent(),(j=C.header&&C.header["x-tcb-trace"])&&this._localCache.setStore(r,j),200!==Number(C.status)&&200!==Number(C.statusCode)||!C.data)throw new Error("network request error");return[2,C]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t={}),N(this,void 0,void 0,(function(){var n;return T(this,(function(r){switch(r.label){case 0:return[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 1:if((n=r.sent()).data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:R.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},e}(),k={};var q=function(){return(q=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}).apply(this,arguments)},F=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},W=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Y=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},$=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},H=o.adapters.useAdapters,V=o.adapters.useDefaultAdapter,G=o.adapters.RUNTIME,J=o.constants.ERRORS,K=o.constants.COMMUNITY_SITE_URL,z=o.utils.printWarn,X=o.helpers.catchErrorsDecorator,Q={timeout:15e3,persistence:"local"},Z={},ee=new(function(){function e(e){this._config=e||this._config,this.authInstance=null,this.oauthInstance=null}return Object.defineProperty(e.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return v},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return e=this._config.env,w[e];var e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return O(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this._config.env,k[e];var e},enumerable:!1,configurable:!0}),e.prototype.init=function(t){if(!t.env)throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"env must not be specified"}));if(v.adapter||this._useDefaultAdapter(),this.requestClient=new v.adapter.reqClass({timeout:t.timeout||5e3,timeoutMsg:"["+Object(A.d)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+t.timeout/1e3+"s"}),v.runtime!==G.WEB){if(!t.appSecret)throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"invalid appSecret"}));var n=v.adapter.getAppSign?v.adapter.getAppSign():"";if(t.appSign&&n&&t.appSign!==n)throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(t.appSign=n),!t.appSign)throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=q(q({},Q),t),this._config.timeout=this._formatTimeout(this._config.timeout);var r=this._config,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,u=r.appSecret,c=r.appSign,f=r.oauthClient;S({env:o,persistence:i,debug:s,platformInfo:this.platform}),Object(A.g)(o,t.region||"");var l=new e(this._config);return function(e){k[e.env]=new M(I(I({},e),{throw:!0}))}({env:o,region:t.region||"",timeout:a,appSecret:u,appSign:c,oauthClient:f,_fromApp:l}),l.requestClient=this.requestClient,l},e.prototype.updateConfig=function(e){var t=e.persistence,n=e.debug;this._config.persistence=t,this._config.debug=n,S({env:this._config.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.registerExtension=function(e){Z[e.name]=e},e.prototype.invokeExtension=function(e,t){return Y(this,void 0,void 0,(function(){var n;return $(this,(function(r){switch(r.label){case 0:if(!(n=Z[e]))throw new Error(JSON.stringify({code:J.INVALID_PARAMS,msg:"extension:"+e+" must be registered before invoke"}));return[4,n.invoke(t,this)];case 1:return[2,r.sent()]}}))}))},e.prototype.useAdapters=function(e){var t=H(e)||{},n=t.adapter,r=t.runtime;n&&(v.adapter=n),r&&(v.runtime=r)},e.prototype.registerHook=function(t){!function(e,t){var n=t.entity,r=t.target;if(!e.prototype.hasOwnProperty(r))throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=e.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not a function which is the only type supports hook"}));e.prototype[r]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.call.apply(n,d([this],e)),o.call.apply(o,d([this],e))}}(e,t)},e.prototype.registerComponent=function(t){_(e,t)},e.prototype.registerVersion=function(e){Object(A.i)(e)},e.prototype.registerSdkName=function(e){Object(A.h)(e)},e.prototype.registerEndPoint=function(e,t){Object(A.f)(e,t)},e.prototype._useDefaultAdapter=function(){var e=V(),t=e.adapter,n=e.runtime;v.adapter=t,v.runtime=n},e.prototype._formatTimeout=function(e){switch(!0){case e>6e5:return z(J.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case e<100:return z(J.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},F([X({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+K]}),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",e)],e.prototype,"init",null),F([X({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+K]}),W("design:type",Function),W("design:paramtypes",[String,Object]),W("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}());ee.useAdapters(p);t.default=ee}])}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/js-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "cloudbase javascript sdk",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"license": "ISC",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@cloudbase/analytics": "^2.0.0-alpha.0",
|
|
49
|
-
"@cloudbase/app": "^2.0.0-alpha.
|
|
49
|
+
"@cloudbase/app": "^2.0.0-alpha.1",
|
|
50
50
|
"@cloudbase/auth": "^2.0.0-alpha.0",
|
|
51
51
|
"@cloudbase/database": "0.9.18-next",
|
|
52
52
|
"@cloudbase/functions": "^2.0.0-alpha.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"not dead",
|
|
89
89
|
"chrome 53"
|
|
90
90
|
],
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "4568e598d198896703ac0e204b3211c14bc79861"
|
|
92
92
|
}
|