@cloudbase/oauth 0.1.1-alpha → 0.1.1-alpha.2
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/Dockerfile +15 -0
- package/README.md +1 -1
- package/_exmaple/assets/scripts/function/function.ts +99 -0
- package/_exmaple/assets/scripts/index.ts +99 -0
- package/_exmaple/assets/scripts/request.ts +11 -0
- package/_exmaple/index.html +15 -0
- package/_exmaple/package.json +33 -0
- package/_exmaple/tsconfig.json +71 -0
- package/_exmaple/typings.d.ts +0 -0
- package/_exmaple/webpack.config.js +42 -0
- package/cdnjs/1.0.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.0/cloudbase.database.js +8 -0
- package/cdnjs/1.0.0/cloudbase.full.js +8 -0
- package/cdnjs/1.0.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.0/cloudbase.js +1 -0
- package/cdnjs/1.0.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.0.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.1/cloudbase.database.js +8 -0
- package/cdnjs/1.0.1/cloudbase.full.js +8 -0
- package/cdnjs/1.0.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.1/cloudbase.js +1 -0
- package/cdnjs/1.0.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.0.2/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.2/cloudbase.database.js +8 -0
- package/cdnjs/1.0.2/cloudbase.full.js +8 -0
- package/cdnjs/1.0.2/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.2/cloudbase.js +1 -0
- package/cdnjs/1.0.2/cloudbase.storage.js +1 -0
- package/cdnjs/1.0.3/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.3/cloudbase.database.js +8 -0
- package/cdnjs/1.0.3/cloudbase.full.js +8 -0
- package/cdnjs/1.0.3/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.3/cloudbase.js +1 -0
- package/cdnjs/1.0.3/cloudbase.storage.js +1 -0
- package/cdnjs/1.0.4/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.4/cloudbase.database.js +8 -0
- package/cdnjs/1.0.4/cloudbase.full.js +8 -0
- package/cdnjs/1.0.4/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.4/cloudbase.js +1 -0
- package/cdnjs/1.0.4/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.0/cloudbase.database.js +8 -0
- package/cdnjs/1.1.0/cloudbase.full.js +8 -0
- package/cdnjs/1.1.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.0/cloudbase.js +1 -0
- package/cdnjs/1.1.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.1/cloudbase.database.js +8 -0
- package/cdnjs/1.1.1/cloudbase.full.js +8 -0
- package/cdnjs/1.1.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.1/cloudbase.js +1 -0
- package/cdnjs/1.1.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.2/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.2/cloudbase.database.js +8 -0
- package/cdnjs/1.1.2/cloudbase.full.js +8 -0
- package/cdnjs/1.1.2/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.2/cloudbase.js +1 -0
- package/cdnjs/1.1.2/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.3/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.3/cloudbase.database.js +8 -0
- package/cdnjs/1.1.3/cloudbase.full.js +8 -0
- package/cdnjs/1.1.3/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.3/cloudbase.js +1 -0
- package/cdnjs/1.1.3/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.4/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.4/cloudbase.database.js +8 -0
- package/cdnjs/1.1.4/cloudbase.full.js +8 -0
- package/cdnjs/1.1.4/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.4/cloudbase.js +1 -0
- package/cdnjs/1.1.4/cloudbase.storage.js +1 -0
- package/cdnjs/1.2.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.2.1/cloudbase.database.js +8 -0
- package/cdnjs/1.2.1/cloudbase.full.js +8 -0
- package/cdnjs/1.2.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.2.1/cloudbase.js +1 -0
- package/cdnjs/1.2.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.2.2/cloudbase.auth.js +1 -0
- package/cdnjs/1.2.2/cloudbase.database.js +8 -0
- package/cdnjs/1.2.2/cloudbase.full.js +8 -0
- package/cdnjs/1.2.2/cloudbase.functions.js +1 -0
- package/cdnjs/1.2.2/cloudbase.js +1 -0
- package/cdnjs/1.2.2/cloudbase.storage.js +1 -0
- package/cdnjs/1.2.3/cloudbase.auth.js +1 -0
- package/cdnjs/1.2.3/cloudbase.database.js +8 -0
- package/cdnjs/1.2.3/cloudbase.full.js +8 -0
- package/cdnjs/1.2.3/cloudbase.functions.js +1 -0
- package/cdnjs/1.2.3/cloudbase.js +1 -0
- package/cdnjs/1.2.3/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.0/cloudbase.database.js +8 -0
- package/cdnjs/1.3.0/cloudbase.full.js +8 -0
- package/cdnjs/1.3.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.0/cloudbase.js +1 -0
- package/cdnjs/1.3.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.1/cloudbase.database.js +8 -0
- package/cdnjs/1.3.1/cloudbase.full.js +8 -0
- package/cdnjs/1.3.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.1/cloudbase.js +1 -0
- package/cdnjs/1.3.1/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.2/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.2/cloudbase.database.js +8 -0
- package/cdnjs/1.3.2/cloudbase.full.js +8 -0
- package/cdnjs/1.3.2/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.2/cloudbase.js +1 -0
- package/cdnjs/1.3.2/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.2/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.3/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.3/cloudbase.database.js +8 -0
- package/cdnjs/1.3.3/cloudbase.full.js +8 -0
- package/cdnjs/1.3.3/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.3/cloudbase.js +1 -0
- package/cdnjs/1.3.3/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.3/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.database.js +8 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.full.js +8 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.5/cloudbase.analytics.js +1 -0
- package/cdnjs/1.3.5/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.5/cloudbase.database.js +10 -0
- package/cdnjs/1.3.5/cloudbase.full.js +10 -0
- package/cdnjs/1.3.5/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.5/cloudbase.js +1 -0
- package/cdnjs/1.3.5/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.5/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.database.js +10 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.full.js +10 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.4.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.4.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.4.0/cloudbase.database.js +10 -0
- package/cdnjs/1.4.0/cloudbase.full.js +10 -0
- package/cdnjs/1.4.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.4.0/cloudbase.js +1 -0
- package/cdnjs/1.4.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.4.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.4.1/cloudbase.analytics.js +1 -0
- package/cdnjs/1.4.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.4.1/cloudbase.database.js +10 -0
- package/cdnjs/1.4.1/cloudbase.full.js +10 -0
- package/cdnjs/1.4.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.4.1/cloudbase.js +1 -0
- package/cdnjs/1.4.1/cloudbase.realtime.js +1 -0
- package/cdnjs/1.4.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.database.js +10 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.full.js +10 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.database.js +10 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.full.js +10 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.5.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.5.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.5.0/cloudbase.database.js +10 -0
- package/cdnjs/1.5.0/cloudbase.full.js +10 -0
- package/cdnjs/1.5.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.5.0/cloudbase.js +1 -0
- package/cdnjs/1.5.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.5.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.5.1/cloudbase.analytics.js +1 -0
- package/cdnjs/1.5.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.5.1/cloudbase.database.js +26 -0
- package/cdnjs/1.5.1/cloudbase.full.js +26 -0
- package/cdnjs/1.5.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.5.1/cloudbase.js +1 -0
- package/cdnjs/1.5.1/cloudbase.realtime.js +1 -0
- package/cdnjs/1.5.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.database.js +10 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.full.js +10 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.database.js +26 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.full.js +26 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.6.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.6.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.6.0/cloudbase.database.js +26 -0
- package/cdnjs/1.6.0/cloudbase.full.js +26 -0
- package/cdnjs/1.6.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.6.0/cloudbase.js +1 -0
- package/cdnjs/1.6.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.6.0/cloudbase.storage.js +1 -0
- package/{CHANGELOG.md → changelog.md} +0 -0
- package/dist/README.md +153 -0
- package/{app → dist/app}/index.d.ts +1 -0
- package/{app → dist/app}/index.js +0 -0
- package/dist/app/index.js.map +1 -0
- package/{app → dist/app}/internal.d.ts +0 -0
- package/{app → dist/app}/internal.js +0 -0
- package/{app → dist/app}/internal.js.map +0 -0
- package/{app → dist/app}/openuri.d.ts +0 -0
- package/{app → dist/app}/openuri.js +2 -1
- package/{app → dist/app}/openuri.js.map +1 -1
- package/{app → dist/app}/request.d.ts +4 -3
- package/{app → dist/app}/request.js +20 -12
- package/dist/app/request.js.map +1 -0
- package/{app → dist/app}/storage.d.ts +0 -0
- package/{app → dist/app}/storage.js +0 -0
- package/{app → dist/app}/storage.js.map +0 -0
- package/{auth → dist/auth}/consts.d.ts +21 -4
- package/{auth → dist/auth}/consts.js +27 -5
- package/dist/auth/consts.js.map +1 -0
- package/{auth → dist/auth}/index.d.ts +83 -34
- package/{auth → dist/auth}/index.js +239 -92
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/models.d.ts +284 -0
- package/{oauthclient → dist/auth}/models.js +1 -0
- package/dist/auth/models.js.map +1 -0
- package/{captcha → dist/captcha}/index.d.ts +0 -0
- package/{captcha → dist/captcha}/index.js +4 -2
- package/dist/captcha/index.js.map +1 -0
- package/dist/changelog.md +30 -0
- package/dist/function/index.d.ts +38 -0
- package/dist/function/index.js +80 -0
- package/dist/function/index.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/{oauthclient → dist/oauthclient}/consts.d.ts +0 -0
- package/{oauthclient → dist/oauthclient}/consts.js +0 -0
- package/{oauthclient → dist/oauthclient}/consts.js.map +0 -0
- package/{oauthclient → dist/oauthclient}/index.d.ts +0 -0
- package/{oauthclient → dist/oauthclient}/index.js +2 -2
- package/dist/oauthclient/index.js.map +1 -0
- package/{oauthclient → dist/oauthclient}/interface.d.ts +4 -0
- package/{oauthclient → dist/oauthclient}/interface.js +0 -0
- package/{oauthclient → dist/oauthclient}/interface.js.map +1 -1
- package/{oauthclient → dist/oauthclient}/models.d.ts +12 -11
- package/{auth → dist/oauthclient}/models.js +0 -0
- package/{oauthclient → dist/oauthclient}/models.js.map +0 -0
- package/{oauthclient → dist/oauthclient}/oauthclient.d.ts +11 -7
- package/{oauthclient → dist/oauthclient}/oauthclient.js +27 -12
- package/dist/oauthclient/oauthclient.js.map +1 -0
- package/dist/package.json +32 -0
- package/{utils/single-promise.d.ts → dist/utils/promise.d.ts} +3 -3
- package/{utils/single-promise.js → dist/utils/promise.js} +6 -6
- package/dist/utils/promise.js.map +1 -0
- package/{utils → dist/utils}/uuid.d.ts +0 -0
- package/{utils → dist/utils}/uuid.js +0 -0
- package/{utils → dist/utils}/uuid.js.map +0 -0
- package/docs/dev.md +71 -0
- package/docs/errlog.md +79 -0
- package/package.json +3 -2
- package/publish.sh +2 -0
- package/src/app/index.ts +83 -0
- package/src/app/internal.ts +26 -0
- package/src/app/openuri.ts +111 -0
- package/src/app/request.ts +66 -0
- package/src/app/storage.ts +58 -0
- package/src/auth/consts.ts +74 -0
- package/src/auth/index.ts +718 -0
- package/src/auth/models.ts +352 -0
- package/src/captcha/index.ts +170 -0
- package/src/function/index.ts +103 -0
- package/src/index.ts +32 -0
- package/src/oauthclient/consts.ts +48 -0
- package/src/oauthclient/index.ts +33 -0
- package/src/oauthclient/interface.ts +34 -0
- package/src/oauthclient/models.ts +50 -0
- package/src/oauthclient/oauthclient.ts +487 -0
- package/src/utils/promise.ts +41 -0
- package/src/utils/uuid.ts +11 -0
- package/test/e2e/cases/custom-login.test.js +122 -0
- package/test/e2e/cases/index.test.js +61 -0
- package/test/e2e/cases/login-state.test.js +89 -0
- package/test/e2e/environment.js +39 -0
- package/test/e2e/global_setup.js +33 -0
- package/test/e2e/global_teardown.js +15 -0
- package/test/e2e/setup.js +37 -0
- package/test/unit/index.test.js +89 -0
- package/test/web/cases/auth/index.js +256 -0
- package/test/web/cases/database/collection.js +173 -0
- package/test/web/cases/database/command.js +754 -0
- package/test/web/cases/database/date.js +122 -0
- package/test/web/cases/database/db.js +20 -0
- package/test/web/cases/database/document.js +160 -0
- package/test/web/cases/database/geo-advanced.js +327 -0
- package/test/web/cases/database/geo.js +105 -0
- package/test/web/cases/database/index.js +315 -0
- package/test/web/cases/database/order.js +83 -0
- package/test/web/cases/database/realtime.js +102 -0
- package/test/web/cases/database/regex.js +140 -0
- package/test/web/cases/ext/index.js +88 -0
- package/test/web/cases/function/index.js +77 -0
- package/test/web/cases/storage/cos.jpeg +0 -0
- package/test/web/cases/storage/index.js +207 -0
- package/test/web/index.html +63 -0
- package/test/web/index.js +109 -0
- package/test/web/util.js +80 -0
- package/tsconfig.json +35 -0
- package/wiki/README.md +75 -0
- package/app/index.js.map +0 -1
- package/app/request.js.map +0 -1
- package/auth/consts.js.map +0 -1
- package/auth/index.js.map +0 -1
- package/auth/models.d.ts +0 -158
- package/auth/models.js.map +0 -1
- package/captcha/index.js.map +0 -1
- package/index.d.ts +0 -8
- package/index.js +0 -17
- package/index.js.map +0 -1
- package/oauthclient/index.js.map +0 -1
- package/oauthclient/oauthclient.js.map +0 -1
- package/utils/single-promise.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_functions",[],e):"object"==typeof exports?exports.cloudbase_functions=e():t.cloudbase_functions=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=6)}([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(11)),i=n(r(14)),s=n(r(15)),a=r(3);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(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+c(s.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("["+a.getSdkName()+"]["+t+"]:"+e)},e.printError=function(t,e){console.error({code:t,msg:"["+a.getSdkName()+"]["+t+"]:"+e})},e.printInfo=function(t,e){console.log("["+a.getSdkName()+"]["+t+"]:"+e)},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"["+a.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,s=t.printTrace,a=void 0!==s&&s,c=t.collapsed;void 0!==c&&c?console.groupCollapsed(e,n):console.group(e,n);for(var u=0,l=i;u<l.length;u++){var f=l[u],p=f.type,d=f.body;switch(p){case"info":console.log(d);break;case"warn":console.warn(d);break;case"error":console.error(d)}}a&&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){"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.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var s=i(r(3));e.constants=s;var a=i(r(9));e.adapters=a;var c=i(r(16));e.cache=c;var u=i(r(18));e.events=u;var l=i(r(0));e.utils=l;var f=i(r(19));e.helpers=f},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)}},s=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 s=r[i>>>2]>>>24-i%4*8&255;e[n+i>>>2]|=s<<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 a=o(4294967296*(r||t.random()));r=987654071*a(),n.push(4294967296*a()|0)}return new s.init(n,e)}}),a=n.enc={},c=a.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 s.init(r,e/2)}},u=a.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 s.init(r,e)}},l=a.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)))}},f=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=l.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,a=o/(4*i),c=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*i,u=t.min(4*c,o);if(c){for(var l=0;l<c;l+=i)this._doProcessBlock(n,l);var f=n.splice(0,c);r.sigBytes-=u}return new s.init(f,u)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),p=(o.Hasher=f.extend({cfg:i.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){f.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}),o(r(4),e),o(r(8),e)},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,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 s})),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(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";Object.defineProperty(e,"__esModule",{value:!0}),e.registerFunctions=void 0;var n=r(7);e.registerFunctions=n.registerFunctions},function(t,e,r){"use strict";r.r(e),r.d(e,"registerFunctions",(function(){return h}));var n=r(1),o=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},i=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(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(s,a)}c((n=n.apply(t,e||[])).next())}))},a=function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,n=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=e.call(t,s)}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,a])}}},c=n.constants.getSdkName,u=n.constants.ERRORS,l=n.constants.COMMUNITY_SITE_URL,f=n.utils.execCallback,p=n.helpers.catchErrorsDecorator,d={name:"functions",entity:{callFunction:(new(function(){function t(){}return t.prototype.callFunction=function(t,e){return s(this,void 0,void 0,(function(){var r,n,o,i,s,l,p,d,h,v,y,g;return a(this,(function(a){switch(a.label){case 0:if(r=t.name,n=t.data,o=t.query,i=t.parse,s=t.search,!r)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[functions.callFunction] invalid function name"}));try{l=n?JSON.stringify(n):""}catch(t){throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[functions.callFunction] invalid data"}))}p="functions.invokeFunction",d={inQuery:o,parse:i,search:s,function_name:r,request_data:l},h=this.request,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,h.send(p,d)];case 2:if((v=a.sent()).code)return[2,f(e,null,v)];if(y=v.data.response_data,i)return[2,f(e,null,{result:y,requestId:v.requestId})];try{return y=JSON.parse(v.data.response_data),[2,f(e,null,{result:y,requestId:v.requestId})]}catch(t){f(e,new Error("["+c()+"]["+u.INVALID_PARAMS+"][functions.callFunction] response data must be json"))}return[3,4];case 3:return g=a.sent(),f(e,g),[3,4];case 4:return[2]}}))}))},o([p({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+l]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"callFunction",null),t}())).callFunction}};try{cloudbase.registerComponent(d)}catch(t){}function h(t){try{t.registerComponent(d)}catch(t){console.warn(t)}}},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 s,a=i(r(10)),c=r(0);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=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,s=n.runtime;if(o())return{adapter:i(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.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)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(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(s,a)}c((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,n=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=e.call(t,s)}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,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=r(5),u=r(0),l=r(4),f=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 s in e)o.append(s,e[s]);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 s(this,void 0,void 0,(function(){var e,r,n,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.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 s.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,s,a=t.url,c=t.headers,f=void 0===c?{}:c,p=t.data,d=t.responseType,h=t.withCredentials,v=t.body,y=t.onUploadProgress,g=u.formatUrl(l.getProtocol(),a,"get"===n?p:{}),_=new XMLHttpRequest;for(var m in _.open(n,g),d&&(_.responseType=d),f)_.setRequestHeader(m,f[m]);y&&_.upload.addEventListener("progress",y),_.onreadystatechange=function(){var t={};if(4===_.readyState){var e=_.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=_.status;try{t.data="blob"===d?_.response:JSON.parse(_.responseText)}catch(e){t.data="blob"===d?_.response:_.responseText}clearTimeout(i),o(t)}},e&&r._timeout&&(i=setTimeout((function(){console.warn(r._timeoutMsg),_.abort()}),r._timeout)),s=u.isFormData(p)?p:"application/x-www-form-urlencoded"===f["content-type"]?u.toQueryString(p):v||(p?JSON.stringify(p):void 0),h&&(_.withCredentials=!0),_.send(s)}))},e}(c.AbstractSDKRequest);e.WebRequest=f,e.genAdapter=function(){return{root:window,reqClass:f,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}}},function(t,e,r){var n;t.exports=(n=r(2),r(12),r(13),n.HmacSHA256)},function(t,e,r){var n;t.exports=(n=r(2),function(t){var e=n,r=e.lib,o=r.WordArray,i=r.Hasher,s=e.algo,a=[],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&&(a[o]=r(t.pow(n,.5))),c[o]=r(t.pow(n,1/3)),o++),n++}();var u=[],l=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],o=r[1],i=r[2],s=r[3],a=r[4],l=r[5],f=r[6],p=r[7],d=0;d<64;d++){if(d<16)u[d]=0|t[e+d];else{var h=u[d-15],v=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,y=u[d-2],g=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[d]=v+u[d-7]+g+u[d-16]}var _=n&o^n&i^o&i,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),b=p+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&f)+c[d]+u[d];p=f,f=l,l=a,a=s+b|0,s=i,i=o,o=n,n=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]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+f|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(l),e.HmacSHA256=i._createHmacHelper(l)}(Math),n.SHA256)},function(t,e,r){var n,o,i,s;t.exports=(n=r(2),i=(o=n).lib.Base,s=o.enc.Utf8,void(o.algo.HMAC=i.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=s.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(),a=o.words,c=i.words,u=0;u<r;u++)a[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(2),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 s=(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,a=0;a<4&&i+.75*a<r;a++)o.push(n.charAt(s>>>6*(3-a)&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 s=r.charAt(64);if(s){var a=t.indexOf(s);-1!==a&&(e=a)}return function(t,e,r){for(var n=[],i=0,s=0;s<e;s++)if(s%4){var a=r[t.charCodeAt(s-1)]<<s%4*2,c=r[t.charCodeAt(s)]>>>6-s%4*2;n[i>>>2]|=(a|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(2),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 s(t){try{c(n.next(t))}catch(t){i(t)}}function a(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(s,a)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,n=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=e.call(t,s)}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,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=r(5),c=r(0),u=r(3),l=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}(a.AbstractStorage);function f(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 l(e.root));case"none":return new l(e.root);case"session":return e.sessionStorage?e.sessionStorage:(c.printWarn(u.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new l(e.root));default:return e.localStorage?e.localStorage:(c.printWarn(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(e.root))}}var p=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,s=t.alwaysLocalKeys,a=void 0===s?[]:s;this._platformInfo=n,this._alwaysLocalKeys=a,this._storage||(this._persistence=n.adapter.primaryStorage||e,this._storage=f(this._persistence,n.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.updatePersistence=function(t){if("async"!==this.mode){if(t!==this._persistence){var e="local"===this._persistence;this._persistence=t;var r=f(t,this._platformInfo.adapter);for(var n in this.keys){var o=this.keys[n];if(!e||!this._alwaysLocalKeys.includes(n)){var i=this._storage.getItem(o);c.isUndefined(i)||c.isNull(i)||(r.setItem(o,i),this._storage.removeItem(o))}}this._storage=r}}else c.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use updatePersistenceAsync insteed")},e.prototype.updatePersistenceAsync=function(t){return i(this,void 0,void 0,(function(){var e,r,n,o,i,a,u,l;return s(this,(function(s){switch(s.label){case 0:if(t===this._persistence)return[2];for(o in e="local"===this._persistence,this._persistence=t,r=f(t,this._platformInfo.adapter),n=[],this.keys)n.push(o);i=0,s.label=1;case 1:return i<n.length?(a=n[i],u=this.keys[a],e&&this._alwaysLocalKeys.includes(a)?[3,4]:[4,this._storage.getItem(u)]):[3,5];case 2:return l=s.sent(),c.isUndefined(l)||c.isNull(l)?[3,4]:(r.setItem(u,l),[4,this._storage.removeItem(u)]);case 3:s.sent(),s.label=4;case 4:return i++,[3,1];case 5:return this._storage=r,[2]}}))}))},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 s(this,(function(o){switch(o.label){case 0:if(!this._storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),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 s(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 s(this,(function(e){switch(e.label){case 0:return[4,this._storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},e}();e.CloudbaseCache=p}).call(this,r(17))},function(t,e){var r,n,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(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:s}catch(t){n=s}}();var c,u=[],l=!1,f=-1;function p(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&d())}function d(){if(!l){var t=a(p);l=!0;for(var e=u.length;e;){for(c=u,u=[];++f<e;)c&&c[f].run();f=-1,e=u.length}c=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===s||!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 h(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 h(t,e)),1!==u.length||l||a(d)},h.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){"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],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=r(0);var a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;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}(a);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(s.isInstanceOf(t,c))return console.error(t.error),this;var r=s.isString(t)?new a(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 l=new u;e.addEventListener=function(t,e){l.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),l.fire(t,e)},e.removeEventListener=function(t,e){l.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(20),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 s(t){try{c(n.next(t))}catch(t){i(t)}}function a(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(s,a)}c((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)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 s.label++,{value:i[1],done:!1};case 5:s.label++,n=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=e.call(t,s)}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,a])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=r(0),s=r(3),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function l(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(r+"\\.descriptor.value\\s*\\[as\\s"+n+"\\]\\s*\\(.*\\)$"),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(r+"\\.descriptor.value\\s*\\[as\\s"+n+"\\]"),f=s.findIndex((function(t){return c.test(t)}));if(-1!==f){var p=s.filter((function(t,e){return e>f}));p.unshift(s[f].replace(l,r+"."+n).replace(u,o)),(i=new Error).stack=(a?"@debugger":"Error")+"\n"+p.join("\n")}return i}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,a=t.customInfo,f=void 0===a?{}:a,p=t.title,d=t.messages,h=void 0===d?[]:d;return function(t,e,a){if(s.IS_DEBUG_MODE){var d=f.className||t.constructor.name,v=f.methodName||e,y=a.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);a.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=l({err:new Error,className:d,methodName:v,sourceLink:g});try{return y.apply(this,t)}catch(t){var n=t,o=t.message,s={title:p||d+"."+v+" failed",content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var a=JSON.parse(o);s.subtitle=o,a.code&&(r.code=a.code,r.message=a.msg,n=r||t,s.content=h.map((function(t){return{type:"info",body:t}})))}throw i.printGroupLog(s),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,s,a,c;return o(this,(function(o){switch(o.label){case 0:e=l({err:new Error,className:d,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,s=r.message,a={title:p||d+"."+v+" failed",content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(c=JSON.parse(s),a.subtitle=c,c.code&&(e.code=c.code,e.message=c.msg,n=e||r,a.content=h.map((function(t){return{type:"info",body:t}})))),i.printGroupLog(a),n;case 4:return[2]}}))}))}}}}}])}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase",[],t):"object"==typeof exports?exports.cloudbase=t():e.cloudbase=t()}("undefined"!=typeof window?window:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var s=i(n(5));t.constants=s;var c=i(n(12));t.adapters=c;var a=i(n(19));t.cache=a;var u=i(n(20));t.events=u;var f=i(n(3));t.utils=f;var h=i(n(21));t.helpers=h},function(e,t,n){"use strict";(function(e){n.d(t,"i",(function(){return a})),n.d(t,"e",(function(){return u})),n.d(t,"h",(function(){return f})),n.d(t,"d",(function(){return h})),n.d(t,"a",(function(){return p})),n.d(t,"f",(function(){return g})),n.d(t,"g",(function(){return v})),n.d(t,"c",(function(){return _})),n.d(t,"b",(function(){return l}));var r=n(0),o=r.constants.setSdkName,i=r.constants.setProtocol,s="",c="@cloudbase/js-sdk";function a(e){s=e}function u(){return s}function f(e){c=e,o(e)}function h(){return c}var l,p="2020-01-10",d="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",y="//tcb-api.tencentcloudapi.com/web";function g(e,t){y=e,t&&(d=t,i(t))}function v(e,t,n){g(t?"//"+e+"."+t+".tcb-api.tencentcloudapi.com/web":"//"+e+".ap-shanghai.tcb-api.tencentcloudapi.com/web",n)}function _(){return{BASE_URL:y,PROTOCOL:d}}!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.CUSTOM="CUSTOM",e.NULL="NULL"}(l||(l={}))}).call(this,n(7))},function(e,t,n){"use strict";var r;n.r(t),n.d(t,"StorageType",(function(){return r})),n.d(t,"AbstractSDKRequest",(function(){return o})),n.d(t,"AbstractStorage",(function(){return i})),n.d(t,"formatUrl",(function(){return s})),function(e){e.local="local",e.none="none",e.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.createSign=t.formatUrl=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(n(14)),i=r(n(17)),s=r(n(18)),c=n(5);function a(e){var t=i.default.stringify(e);return t=(t=(t=t.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t},t.createSign=function(e,t){var n=a(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+a(s.default.parse(JSON.stringify(e)));return n+"."+a(o.default(n,t))},t.toQueryString=function(e){void 0===e&&(e={});var t=[];for(var n in e)t.push(n+"="+encodeURIComponent(e[n]));return t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||window.location.search,r=new RegExp("(^|&)"+e+"=([^&]*)(&|$)"),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]"+e+"=([^&#]*)"));return t?t[1]:""},t.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n=n+"?"+r.join("&")}return n},t.createPromiseCallback=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e},t.execCallback=function(e,t,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(t,n);if(t)throw t;return n},t.printWarn=function(e,t){console.warn("["+c.getSdkName()+"]["+e+"]:"+t)},t.printError=function(e,t){console.error({code:e,msg:"["+c.getSdkName()+"]["+e+"]:"+t})},t.printInfo=function(e,t){console.log("["+c.getSdkName()+"]["+e+"]:"+t)},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"["+c.getSdkName()+"]["+e+"]:"+t}))},t.printGroupLog=function(e){var t=e.title,n=e.subtitle,r=void 0===n?"":n,o=e.content,i=void 0===o?[]:o,s=e.printTrace,c=void 0!==s&&s,a=e.collapsed;void 0!==a&&a?console.groupCollapsed(t,r):console.group(t,r);for(var u=0,f=i;u<f.length;u++){var h=f[u],l=h.type,p=h.body;switch(l){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}c&&console.trace("stack trace:"),console.groupEnd()},t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},t.transformPhone=function(e){return"+86"+e}},function(e,t,n){var r;e.exports=(r=r||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),r={},o=r.lib={},i=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=o.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||a).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i<o;i+=4)t[r+i>>>2]=n[i>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],o=function(t){t=t;var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},i=0;i<t;i+=4){var c=o(4294967296*(n||e.random()));n=987654071*c(),r.push(4294967296*c()|0)}return new s.init(r,t)}}),c=r.enc={},a=c.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=c.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},f=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,c=o/(4*i),a=(c=t?e.ceil(c):e.max((0|c)-this._minBufferSize,0))*i,u=e.min(4*a,o);if(a){for(var f=0;f<a;f+=i)this._doProcessBlock(r,f);var h=r.splice(0,a);n.sigBytes-=u}return new s.init(h,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),l=(o.Hasher=h.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new l.HMAC.init(e,n).finalize(t)}}}),r.algo={});return r}(Math),r)},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(6),t),o(n(11),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var o="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";t.setProtocol=function(e){o=e},t.getProtocol=function(){return o},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,u=[],f=!1,h=-1;function l(){f&&a&&(f=!1,a.length?u=a.concat(u):h=-1,u.length&&p())}function p(){if(!f){var e=c(l);f=!0;for(var t=u.length;t;){for(a=u,u=[];++h<t;)a&&a[h].run();h=-1,t=u.length}a=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function y(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new d(e,t)),1!==u.length||f||c(p)},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=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){n(9),e.exports=n(10)},function(e,t,n){var r=function(e){"use strict";var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function a(e,t,n,r){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),s=new O(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return I()}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var c=b(s,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var a=u(e,t,n);if("normal"===a.type){if(r=n.done?"completed":"suspendedYield",a.arg===f)continue;return{value:a.arg,done:n.done}}"throw"===a.type&&(r="completed",n.method="throw",n.arg=a.arg)}}}(e,n,s),i}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=a;var f={};function h(){}function l(){}function p(){}var d={};d[o]=function(){return this};var y=Object.getPrototypeOf,g=y&&y(y(S([])));g&&g!==t&&n.call(g,o)&&(d=g);var v=p.prototype=h.prototype=Object.create(d);function _(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var r;this._invoke=function(o,i){function s(){return new t((function(r,s){!function r(o,i,s,c){var a=u(e[o],e,i);if("throw"!==a.type){var f=a.arg,h=f.value;return h&&"object"==typeof h&&n.call(h,"__await")?t.resolve(h.__await).then((function(e){r("next",e,s,c)}),(function(e){r("throw",e,s,c)})):t.resolve(h).then((function(e){f.value=e,s(f)}),(function(e){return r("throw",e,s,c)}))}c(a.arg)}(o,i,r,s)}))}return r=r?r.then(s,s):s()}}function b(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,f;var o=r.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return l.prototype=v.constructor=p,p.constructor=l,l.displayName=c(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,c(e,s,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},_(m.prototype),m.prototype[i]=function(){return this},e.AsyncIterator=m,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var s=new m(a(t,n,r,o),i);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},_(v),c(v,s,"Generator"),v[o]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=S,O.prototype={constructor:O,reset:function(e){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(A),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return s.type="throw",s.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),a=n.call(i,"finallyLoc");if(c&&a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;A(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},s=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(n(24)),c=i(n(23)).version;s.default.registerVersion(c);try{window.cloudbase=s.default}catch(e){}t.default=s.default,e.exports=s.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var s,c=i(n(13)),a=n(3);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(s=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e){for(var t=0,n=a.isArray(e)?e:[e];t<n.length;t++){var r=n[t],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},t.useDefaultAdapter=function(){return{adapter:c.genAdapter(),runtime:s.WEB}}},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)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)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var a=n(2),u=n(3),f=n(6),h=function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return o(t,e),t.prototype.get=function(e){return this._request(i(i({},e),{method:"get"}),this._restrictedMethods.includes("get"))},t.prototype.post=function(e){return this._request(i(i({},e),{method:"post"}),this._restrictedMethods.includes("post"))},t.prototype.put=function(e){return this._request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,n=e.file,r=e.name,o=new FormData;for(var s in t)o.append(s,t[s]);return o.append("key",r),o.append("file",n),this._request(i(i({},e),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t,n,r,o;return c(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype._request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,c=e.url,a=e.headers,h=void 0===a?{}:a,l=e.data,p=e.responseType,d=e.withCredentials,y=e.body,g=e.onUploadProgress,v=u.formatUrl(f.getProtocol(),c,"get"===r?l:{}),_=new XMLHttpRequest;for(var m in _.open(r,v),p&&(_.responseType=p),h)_.setRequestHeader(m,h[m]);g&&_.upload.addEventListener("progress",g),_.onreadystatechange=function(){var e={};if(4===_.readyState){var t=_.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach((function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o})),e.header=n,e.statusCode=_.status;try{e.data="blob"===p?_.response:JSON.parse(_.responseText)}catch(t){e.data="blob"===p?_.response:_.responseText}clearTimeout(i),o(e)}},t&&n._timeout&&(i=setTimeout((function(){console.warn(n._timeoutMsg),_.abort()}),n._timeout)),s=u.isFormData(l)?l:"application/x-www-form-urlencoded"===h["content-type"]?u.toQueryString(l):y||(l?JSON.stringify(l):void 0),d&&(_.withCredentials=!0),_.send(s)}))},t}(a.AbstractSDKRequest);t.WebRequest=h,t.genAdapter=function(){return{root:window,reqClass:h,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}}},function(e,t,n){var r;e.exports=(r=n(4),n(15),n(16),r.HmacSHA256)},function(e,t,n){var r;e.exports=(r=n(4),function(e){var t=r,n=t.lib,o=n.WordArray,i=n.Hasher,s=t.algo,c=[],a=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,o=0;o<64;)t(r)&&(o<8&&(c[o]=n(e.pow(r,.5))),a[o]=n(e.pow(r,1/3)),o++),r++}();var u=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(c.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],c=n[4],f=n[5],h=n[6],l=n[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var d=u[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=u[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[p]=y+u[p-7]+v+u[p-16]}var _=r&o^r&i^o&i,m=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&f^~c&h)+a[p]+u[p];l=h,h=f,f=c,c=s+b|0,s=i,i=o,o=r,r=b+(m+_)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+c|0,n[5]=n[5]+f|0,n[6]=n[6]+h|0,n[7]=n[7]+l|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(f),t.HmacSHA256=i._createHmacHelper(f)}(Math),r.SHA256)},function(e,t,n){var r,o,i,s;e.exports=(r=n(4),i=(o=r).lib.Base,s=o.enc.Utf8,void(o.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),c=o.words,a=i.words,u=0;u<n;u++)c[u]^=1549556828,a[u]^=909522486;o.sigBytes=i.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))},function(e,t,n){var r,o,i;e.exports=(i=n(4),o=(r=i).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,r=this._map;e.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,c=0;c<4&&i+.75*c<n;c++)o.push(r.charAt(s>>>6*(3-c)&63));var a=r.charAt(64);if(a)for(;o.length%4;)o.push(a);return o.join("")},parse:function(e){var t=e.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var i=0;i<n.length;i++)r[n.charCodeAt(i)]=i}var s=n.charAt(64);if(s){var c=e.indexOf(s);-1!==c&&(t=c)}return function(e,t,n){for(var r=[],i=0,s=0;s<t;s++)if(s%4){var c=n[e.charCodeAt(s-1)]<<s%4*2,a=n[e.charCodeAt(s)]>>>6-s%4*2;r[i>>>2]|=(c|a)<<24-i%4*8,i++}return o.create(r,i)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)},function(e,t,n){var r;e.exports=(r=n(4),r.enc.Utf8)},function(e,t,n){"use strict";(function(e){var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)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)}),i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var c=n(2),a=n(3),u=n(5),f=function(e){function t(t){var n=e.call(this)||this;return n._root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return o(t,e),t.prototype.setItem=function(e,t){this._root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this._root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this._root.tcbCacheObject[e]},t.prototype.clear=function(){delete this._root.tcbCacheObject},t}(c.AbstractStorage);function h(e,t){switch(e){case"local":return t.localStorage?t.localStorage:(a.printWarn(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(t.root));case"none":return new f(t.root);case"session":return t.sessionStorage?t.sessionStorage:(a.printWarn(u.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new f(t.root));default:return t.localStorage?t.localStorage:(a.printWarn(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(t.root))}}var l=function(){function t(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,i=void 0===o?{}:o,s=e.alwaysLocalKeys,c=void 0===s?[]:s;this._platformInfo=r,this._alwaysLocalKeys=c,this._storage||(this._persistence=r.adapter.primaryStorage||t,this._storage=h(this._persistence,r.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this._storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this._persistence},enumerable:!1,configurable:!0}),t.prototype.updatePersistence=function(e){if("async"!==this.mode){if(e!==this._persistence){var t="local"===this._persistence;this._persistence=e;var n=h(e,this._platformInfo.adapter);for(var r in this.keys){var o=this.keys[r];if(!t||!this._alwaysLocalKeys.includes(r)){var i=this._storage.getItem(o);a.isUndefined(i)||a.isNull(i)||(n.setItem(o,i),this._storage.removeItem(o))}}this._storage=n}}else a.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use updatePersistenceAsync insteed")},t.prototype.updatePersistenceAsync=function(e){return i(this,void 0,void 0,(function(){var t,n,r,o,i,c,u,f;return s(this,(function(s){switch(s.label){case 0:if(e===this._persistence)return[2];for(o in t="local"===this._persistence,this._persistence=e,n=h(e,this._platformInfo.adapter),r=[],this.keys)r.push(o);i=0,s.label=1;case 1:return i<r.length?(c=r[i],u=this.keys[c],t&&this._alwaysLocalKeys.includes(c)?[3,4]:[4,this._storage.getItem(u)]):[3,5];case 2:return f=s.sent(),a.isUndefined(f)||a.isNull(f)?[3,4]:(n.setItem(u,f),[4,this._storage.removeItem(u)]);case 3:s.sent(),s.label=4;case 4:return i++,[3,1];case 5:return this._storage=n,[2]}}))}))},t.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this._storage)try{var r={version:n||"localCachev1",content:t};this._storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"["+u.getSdkName()+"]["+u.ERRORS.OPERATION_FAIL+"]setStore failed",info:e}))}}else a.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(e,t,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:if(!this._storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:t},[4,this._storage.setItem(e,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,n){var r;if("async"!==this.mode){try{if(void 0!==e&&(null===(r=e.env)||void 0===r?void 0:r.tcb_token))return e.env.tcb_token;if(!this._storage)return""}catch(e){return""}n=n||"localCachev1";var o=this._storage.getItem(t);return o&&o.indexOf(n)>=0?JSON.parse(o).content:""}a.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,n){var r;return i(this,void 0,void 0,(function(){var o;return s(this,(function(i){switch(i.label){case 0:try{if(void 0!==e&&(null===(r=e.env)||void 0===r?void 0:r.tcb_token))return[2,e.env.tcb_token];if(!this._storage)return[2,""]}catch(e){return[2,""]}return n=n||"localCachev1",[4,this._storage.getItem(t)];case 1:return(o=i.sent())&&o.indexOf(n)>=0?[2,JSON.parse(o).content]:[2,""]}}))}))},t.prototype.removeStore=function(e){"async"!==this.mode?this._storage.removeItem(e):a.printWarn(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},t}();t.CloudbaseCache=l}).call(this,n(7))},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)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)}),i=this&&this.__spreadArrays||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,c=i.length;s<c;s++,o++)r[o]=i[s];return r};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=n(3);var c=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=c;var a=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return o(t,e),t}(c);t.IErrorEvent=a;var u=function(){function e(){this._listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this._listeners),this},e.prototype.fire=function(e,t){if(s.isInstanceOf(e,a))return console.error(e.error),this;var n=s.isString(e)?new c(e,t||{}):e,r=n.name;if(this._listens(r)){n.target=this;for(var o=0,u=this._listeners[r]?i(this._listeners[r]):[];o<u.length;o++){u[o].call(this,n)}}return this},e.prototype._listens=function(e){return this._listeners[e]&&this._listeners[e].length>0},e}();t.CloudbaseEventEmitter=u;var f=new u;t.addEventListener=function(e,t){f.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),f.fire(e,t)},t.removeEventListener=function(e,t){f.off(e,t)}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(22),t)},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=n(3),s=n(5),c=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(c=-1!==navigator.userAgent.indexOf("Firefox"));var a=c?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function f(e){var t=e.err,n=e.className,r=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),a=c?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),f=c?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),h=s.findIndex((function(e){return a.test(e)}));if(-1!==h){var l=s.filter((function(e,t){return t>h}));l.unshift(s[h].replace(f,n+"."+r).replace(u,o)),(i=new Error).stack=(c?"@debugger":"Error")+"\n"+l.join("\n")}return i}t.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,c=e.customInfo,h=void 0===c?{}:c,l=e.title,p=e.messages,d=void 0===p?[]:p;return function(e,t,c){if(s.IS_DEBUG_MODE){var p=h.className||e.constructor.name,y=h.methodName||t,g=c.value,v=function(e){var t="",n=e.stack.split("\n"),r=n.findIndex((function(e){return a.test(e)}));if(-1!==r){var o=u.exec(n[r+1]||"");t=o?o[0]:""}return t}(new Error);c.value="sync"===n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=f({err:new Error,className:p,methodName:y,sourceLink:v});try{return g.apply(this,e)}catch(e){var r=e,o=e.message,s={title:l||p+"."+y+" failed",content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);s.subtitle=o,c.code&&(n.code=c.code,n.message=c.msg,r=n||e,s.content=d.map((function(e){return{type:"info",body:e}})))}throw i.printGroupLog(s),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,(function(){var t,n,r,s,c,a;return o(this,(function(o){switch(o.label){case 0:t=f({err:new Error,className:p,methodName:y,sourceLink:v}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,g.apply(this,e)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,c={title:l||p+"."+y+" failed",content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(a=JSON.parse(s),c.subtitle=a,a.code&&(t.code=a.code,t.message=a.msg,r=t||n,c.content=d.map((function(e){return{type:"info",body:e}})))),i.printGroupLog(c),r;case 4:return[2]}}))}))}}}}},function(e){e.exports=JSON.parse('{"version":"1.5.3-alpha.0"}')},function(e,t,n){"use strict";n.r(t),n.d(t,"cloudbase",(function(){return Bt}));var r,o=n(0),i=n(2),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)}),c=function(){return(c=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)},a=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},u=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}};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,c=e.headers,a=wx.request({url:Object(i.formatUrl)("https:",o),data:s,timeout:t._timeout,method:"POST",header:c,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{a.abort()}catch(e){}}}})}))},t.prototype.upload=function(e){var t=this,n=this;return new Promise((function(r){return a(t,void 0,void 0,(function(){var t,o,i,s,a,f;return u(this,(function(u){return t=e.url,o=e.file,i=e.data,s=e.headers,a=e.onUploadProgress,f=wx.uploadFile({url:t,filePath:o,name:"file",formData:c({},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){}}}}),a&&f.onProgressUpdate((function(e){a(e)})),[2]}))}))}))},t.prototype.download=function(e){var t=this,n=this;return new Promise((function(r,o){var s=e.url,c=e.headers,a=wx.downloadFile({url:Object(i.formatUrl)("https:",s),header:c,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{a.abort()}catch(e){}}}})}))},t}(i.AbstractSDKRequest),h={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()}},l=function(e,t){void 0===t&&(t={});var n=wx.connectSocket(c({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:l,localStorage:h,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,c=i.length;s<c;s++,o++)r[o]=i[s];return r},y=o.constants.ERRORS,g={};function v(e,t){var n=t.name,r=t.namespace,o=t.entity,i=t.injectEvents,s=t.IIFE,c=void 0!==s&&s;if(g[n]||r&&e[r])throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"Duplicate component "+n}));if(c){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 a=i.bus,u=i.events;if(!a||!u||0===u.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,u):e.prototype.events[n]={bus:a,events:u},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 _={},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={},A={};function O(e){var t=e.env,n=e.persistence,r=e.platformInfo,o={accessTokenKey:"access_token_"+t,accessTokenExpireKey:"access_token_expire_"+t,refreshTokenKey:"refresh_token_"+t,anonymousUuidKey:"anonymous_uuid_"+t,loginTypeKey:"login_type_"+t,userInfoKey:"user_info_"+t};w[t]?w[t].updatePersistence(n):w[t]=new b(m(m({},e),{keys:o,platformInfo:r,alwaysLocalKeys:["anonymousUuidKey"]})),A[t]=A[t]||new b(m(m({},e),{keys:o,platformInfo:r,persistence:"local"}))}function S(e){return w[e]}function I(e){return A[e]}var k=n(1),E="loginStateExpire",P="refreshAccessToken",T=function(){return(T=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)},R=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},N=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},L=o.constants.ERRORS,U=o.utils.genSeqId,x=o.utils.isFormData,C=o.utils.formatUrl,j=o.utils.createSign,M=o.adapters.RUNTIME,q=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function D(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,c=r.headers;Object.assign(o,s),Object.assign(i,c)}));var s=t.data;return s&&function(){if(x(s))for(var e in o)s.append(e,o[e]);else t.data=T(T({},s),o)}(),t.headers=T(T({},t.headers||{}),i),r.call(e,t)}}function W(){var e=U();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+Object(k.e)(),"x-seqid":e}}}var K=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new _.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e.throw||!1,this._cache=S(this.config.env),this._localCache=I(this.config.env),D(this._reqClass,"post",[W]),D(this._reqClass,"upload",[W]),D(this._reqClass,"download",[W])}return e.prototype.post=function(e){return R(this,void 0,void 0,(function(){return N(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 R(this,void 0,void 0,(function(){return N(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 R(this,void 0,void 0,(function(){return N(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.download(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.refreshAccessToken=function(){return R(this,void 0,void 0,(function(){var e,t,n;return N(this,(function(r){switch(r.label){case 0:this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._refreshAccessTokenPromise];case 2:return e=r.sent(),[3,4];case 3:return n=r.sent(),t=n,[3,4];case 4:if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return[2,e]}}))}))},e.prototype.getAccessToken=function(){return R(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,c,a;return N(this,(function(u){switch(u.label){case 0:return e=this._cache.keys,t=e.accessTokenKey,n=e.accessTokenExpireKey,r=e.refreshTokenKey,[4,this._cache.getStoreAsync(r)];case 1:if(!u.sent())throw new Error(JSON.stringify({code:L.OPERATION_FAIL,msg:"refresh token is not exist, your local data might be messed up, please retry after clear localStorage or sessionStorage"}));return[4,this._cache.getStoreAsync(t)];case 2:return o=u.sent(),s=Number,[4,this._cache.getStoreAsync(n)];case 3:return i=s.apply(void 0,[u.sent()]),c=!0,(a=this._shouldRefreshAccessTokenHook)?[4,this._shouldRefreshAccessTokenHook(o,i)]:[3,5];case 4:a=!u.sent(),u.label=5;case 5:return a&&(c=!1),o&&i&&!(i<Date.now())||!c?[3,7]:[4,this.refreshAccessToken()];case 6:return[2,u.sent()];case 7:return[2,{accessToken:o,accessTokenExpire:i}]}}))}))},e.prototype.request=function(e,t,n){return R(this,void 0,void 0,(function(){var r,o,i,s,c,a,u,f,h,l,p,d,y,g,v,m,b,w,A,O,S,I,E,P,R,L;return N(this,(function(N){switch(N.label){case 0:return r="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=T({action:e,dataVersion:k.a,env:this.config.env},t),-1!==q.indexOf(e)?[3,3]:(s=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(s)]);case 1:return N.sent()?(c=i,[4,this.getAccessToken()]):[3,3];case 2:c.access_token=N.sent().accessToken,N.label=3;case 3:if("storage.uploadFile"===e){for(u in a=new FormData)a.hasOwnProperty(u)&&void 0!==a[u]&&a.append(u,i[u]);o="multipart/form-data"}else for(u in o="application/json;charset=UTF-8",a={},i)void 0!==i[u]&&(a[u]=i[u]);return f={headers:{"content-type":o}},(null==n?void 0:n.onUploadProgress)&&(f.onUploadProgress=n.onUploadProgress),this.config.region&&(f.headers["X-TCB-Region"]=this.config.region),(h=this._localCache.getStore(r))&&(f.headers["X-TCB-Trace"]=h),_.runtime!==M.WEB&&(l=this.config,p=l.appSign,d=l.appSecret,y=Date.now(),g=d.appAccessKey,v=d.appAccessKeyId,m=j({data:a,timestamp:y,appAccessKeyId:v,appSign:p},g),f.headers["X-TCB-App-Source"]="timestamp="+y+";appAccessKeyId="+v+";appSign="+p+";sign="+m),b=t.parse,w=t.inQuery,A=t.search,O={env:this.config.env},b&&(O.parse=!0),w&&(O=T(T({},w),O)),S=Object(k.c)(),I=S.BASE_URL,E=S.PROTOCOL,P=C(E,I,O),A&&(P+=A),[4,this.post(T({url:P,data:a},f))];case 4:if(R=N.sent(),(L=R.header&&R.header["x-tcb-trace"])&&this._localCache.setStore(r,L),200!==Number(R.status)&&200!==Number(R.statusCode)||!R.data)throw new Error("network request error");return[2,R]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t={}),R(this,void 0,void 0,(function(){var n;return N(this,(function(r){switch(r.label){case 0:return[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 1:return"ACCESS_TOKEN_EXPIRED"!==(n=r.sent()).data.code||-1!==q.indexOf(e)?[3,4]:[4,this.refreshAccessToken()];case 2:return r.sent(),[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 3:n=r.sent(),r.label=4;case 4:if(n.data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:L.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},e.prototype._refreshAccessToken=function(e){return void 0===e&&(e=1),R(this,void 0,void 0,(function(){var t,n,r,o,i,s,c,a,u,f,h,l,p;return N(this,(function(d){switch(d.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,i=t.loginTypeKey,s=t.anonymousUuidKey,[4,this._cache.removeStoreAsync(n)];case 1:return d.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return d.sent(),[4,this._cache.getStoreAsync(o)];case 3:if(!(c=d.sent()))throw new Error(JSON.stringify({code:L.INVALID_OPERATION,msg:"not login"}));return a={refresh_token:c},[4,this.request("auth.fetchAccessTokenWithRefreshToken",a)];case 4:return(u=d.sent()).data.code?"SIGN_PARAM_INVALID"!==(f=u.data.code)&&"REFRESH_TOKEN_EXPIRED"!==f&&"INVALID_REFRESH_TOKEN"!==f?[3,11]:[4,this._cache.getStoreAsync(i)]:[3,12];case 5:return d.sent()===k.b.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===f?[4,this._cache.getStoreAsync(s)]:[3,9];case 6:return h=d.sent(),[4,this._cache.getStoreAsync(o)];case 7:return l=d.sent(),[4,this.send("auth.signInAnonymously",{anonymous_uuid:h,refresh_token:l})];case 8:if(p=d.sent(),this._setRefreshToken(p.refresh_token),e>=1)return[2,this._refreshAccessToken(--e)];throw new Error(JSON.stringify({code:L.OPERATION_FAIL,message:"重试获取 refresh token 失败"}));case 9:return Bt.fire(E),[4,this._cache.removeStoreAsync(o)];case 10:d.sent(),d.label=11;case 11:throw new Error(JSON.stringify({code:L.NETWORK_ERROR,msg:"refresh access_token failed:"+u.data.code}));case 12:return u.data.access_token?(Bt.fire(P),[4,this._cache.setStoreAsync(n,u.data.access_token)]):[3,15];case 13:return d.sent(),[4,this._cache.setStoreAsync(r,u.data.access_token_expire+Date.now())];case 14:return d.sent(),[2,{accessToken:u.data.access_token,accessTokenExpire:u.data.access_token_expire}];case 15:return u.data.refresh_token?[4,this._cache.removeStoreAsync(o)]:[3,19];case 16:return d.sent(),[4,this._cache.setStoreAsync(o,u.data.refresh_token)];case 17:return d.sent(),[4,this._refreshAccessToken()];case 18:d.sent(),d.label=19;case 19:return[2]}}))}))},e.prototype._setRefreshToken=function(e){return R(this,void 0,void 0,(function(){var t,n,r,o;return N(this,(function(i){switch(i.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,e)];case 3:return i.sent(),[2]}}))}))},e}(),F={};var H,G=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},B=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},V=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request}return e.prototype.checkLocalLoginState=function(){return G(this,void 0,void 0,(function(){var e,t,n,r,o,i;return B(this,(function(s){switch(s.label){case 0:return e=this._cache.keys,t=e.accessTokenKey,n=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(t)];case 1:return r=s.sent(),[4,this._cache.getStoreAsync(n)];case 2:return o=s.sent(),r?o&&o>Date.now()?[4,(i=new Et({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,4]:[3,7];case 3:return s.sent(),[2,i];case 4:return[4,this._cache.removeStoreAsync(t)];case 5:return s.sent(),[4,this._cache.removeStoreAsync(n)];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},e.prototype.setRefreshToken=function(e){return G(this,void 0,void 0,(function(){var t,n,r,o;return B(this,(function(i){switch(i.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=t.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,e)];case 3:return i.sent(),[2]}}))}))},e.prototype.setAccessToken=function(e,t){return G(this,void 0,void 0,(function(){var n,r,o;return B(this,(function(i){switch(i.label){case 0:return n=this._cache.keys,r=n.accessTokenKey,o=n.accessTokenExpireKey,[4,this._cache.setStoreAsync(r,e)];case 1:return i.sent(),[4,this._cache.setStoreAsync(o,t)];case 2:return i.sent(),[2]}}))}))},e.prototype.refreshUserInfo=function(){return G(this,void 0,void 0,(function(){var e;return B(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return e=t.sent().data,[4,this.setLocalUserInfo(e)];case 2:return t.sent(),[2,e]}}))}))},e.prototype.setLocalUserInfo=function(e){return G(this,void 0,void 0,(function(){var t;return B(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._cache.setStoreAsync(t,e)];case 1:return n.sent(),[2]}}))}))},e}();!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL",e.PHONE="PHONE"}(H||(H={}));var Y=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)}}(),J=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 c=e.length-1;c>=0;c--)(o=e[c])&&(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},X=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},z=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},Q=o.constants.getSdkName,Z=o.constants.ERRORS,ee=o.constants.COMMUNITY_SITE_URL,te=o.adapters.RUNTIME,ne=o.utils.getQuery,re=o.utils.getHash,oe=o.utils.removeParam,ie=o.utils.printWarn,se=o.helpers.catchErrorsDecorator,ce=function(e){function t(t,n,r,o){var i=e.call(this,t)||this;return i._runtime=t.runtime,i._appid=n,i._scope=r,i._state=o||"weixin",i}return Y(t,e),t.prototype.signIn=function(){return z(this,void 0,void 0,(function(){return $(this,(function(e){return[2,ie(Z.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]}))}))},t.prototype.signInWithRedirect=function(){return z(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this._redirect()]}))}))},t.prototype.getRedirectResult=function(e){return z(this,void 0,void 0,(function(){var t;return $(this,(function(n){return(t=ae())?[2,this._signInWithCode(t,e)]:[2,null]}))}))},t.prototype.getLinkRedirectResult=function(e){return void 0===e&&(e={}),z(this,void 0,void 0,(function(){var t,n,r,o,i,s;return $(this,(function(c){return t=e.withUnionId,n=void 0!==t&&t,(r=ae())?(o=this._appid,i=function(e){switch(e){case"snsapi_login":return"WECHAT-OPEN";default:return"WECHAT-PUBLIC"}}(this._scope),s=this._runtime===te.WX_MP?"1":"0",[2,this._request.send("auth.linkWithWeixinCode",{payload:{appid:o,loginType:i,code:r,hybridMiniapp:s,withUnionId:n}})]):[2,null]}))}))},t.prototype._redirect=function(){var e=oe("code",location.href);e=oe("state",e),e=encodeURIComponent(e);var t="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this._scope&&(t="//open.weixin.qq.com/connect/qrconnect");try{location.href=t+"?appid="+this._appid+"&redirect_uri="+e+"&response_type=code&scope="+this._scope+"&state="+this._state+"#wechat_redirect"}catch(e){throw new Error("["+Q()+"]["+Z.UNKOWN_ERROR+"]"+e)}},t.prototype._signInWithCode=function(e,t){return z(this,void 0,void 0,(function(){var n,r,o,i,s,c,a,u;return $(this,(function(f){switch(f.label){case 0:return n=this._cache.keys,r=n.accessTokenKey,o=n.accessTokenExpireKey,i=n.refreshTokenKey,s=function(e){switch(e){case"snsapi_login":return"WECHAT-OPEN";default:return"WECHAT-PUBLIC"}}(this._scope),[4,this._getRefreshTokenByWXCode(this._appid,s,e,t)];case 1:return c=f.sent(),a=c.refreshToken,[4,this._cache.setStoreAsync(i,a)];case 2:return f.sent(),c.accessToken?[4,this._cache.setStoreAsync(r,c.accessToken)]:[3,4];case 3:f.sent(),f.label=4;case 4:return c.accessTokenExpire?[4,this._cache.setStoreAsync(o,String(c.accessTokenExpire+Date.now()))]:[3,6];case 5:f.sent(),f.label=6;case 6:return It.fire(Tt.LOGIN_STATE_CHANGED),It.fire(Tt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:H.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return f.sent(),[4,(u=new Et({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return f.sent(),[2,u]}}))}))},t.prototype._getRefreshTokenByWXCode=function(e,t,n,r){return void 0===r&&(r={}),z(this,void 0,void 0,(function(){var o,i,s,c,a,u;return $(this,(function(f){return o=r.withUnionId,i=void 0!==o&&o,s=r.createUser,c=void 0===s||s,a="snsapi_base"!==this._scope&&(r.syncUserInfo||!1),"auth.signIn",u=this._runtime===te.WX_MP?"1":"0",[2,this._request.send("auth.signIn",{appid:e,loginType:t,hybridMiniapp:u,syncUserInfo:a,loginCredential:n,withUnionId:i,createUser:c}).then((function(e){if(e.code)throw new Error("["+Q()+"]["+Z.OPERATION_FAIL+"] failed login via wechat: "+e.code);if(e.refresh_token)return{refreshToken:e.refresh_token,accessToken:e.access_token,accessTokenExpire:e.access_token_expire};throw new Error("["+Q()+"]["+Z.OPERATION_FAIL+"] action:getJwt not return refreshToken")}))]}))}))},J([se({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+ee]}),X("design:type",Function),X("design:paramtypes",[]),X("design:returntype",Promise)],t.prototype,"signInWithRedirect",null),J([se({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+ee]}),X("design:type",Function),X("design:paramtypes",[Object]),X("design:returntype",Promise)],t.prototype,"getRedirectResult",null),J([se({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+ee]}),X("design:type",Function),X("design:paramtypes",[Object]),X("design:returntype",Promise)],t.prototype,"getLinkRedirectResult",null),t}(V);function ae(){return ne("code")||re("code")}var ue=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)}}(),fe=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 c=e.length-1;c>=0;c--)(o=e[c])&&(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},he=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},le=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},pe=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},de=o.constants.ERRORS,ye=o.constants.COMMUNITY_SITE_URL,ge=o.utils.throwError,ve=o.utils.isString,_e=o.events.addEventListener,me=o.helpers.catchErrorsDecorator,be=function(e){function t(t){var n=e.call(this,t)||this;return n._onConverted=n._onConverted.bind(n),_e(Tt.ANONYMOUS_CONVERTED,n._onConverted),n}return ue(t,e),t.prototype.signIn=function(){return le(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return pe(this,(function(c){switch(c.label){case 0:return[4,this._cache.updatePersistenceAsync("local")];case 1:return c.sent(),e=this._cache.keys,t=e.anonymousUuidKey,n=e.refreshTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return r=c.sent(),[4,this._cache.getStoreAsync(n)];case 3:return o=c.sent(),[4,this._request.send("auth.signInAnonymously",{anonymous_uuid:r,refresh_token:o})];case 4:return(i=c.sent()).uuid&&i.refresh_token?[4,this._setAnonymousUUID(i.uuid)]:[3,10];case 5:return c.sent(),[4,this.setRefreshToken(i.refresh_token)];case 6:return c.sent(),[4,this._request.refreshAccessToken()];case 7:return c.sent(),It.fire(Tt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:H.ANONYMOUS,persistence:"local"}),It.fire(Tt.LOGIN_STATE_CHANGED),[4,(s=new Et({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return c.sent(),[4,s.user.refresh()];case 9:return c.sent(),[2,s];case 10:throw new Error(JSON.stringify({code:de.OPERATION_FAIL,msg:JSON.stringify(i)||"anonymous signIn failed"}))}}))}))},t.prototype.linkAndRetrieveDataWithTicket=function(e){return le(this,void 0,void 0,(function(){var t,n,r,o,i,s,c;return pe(this,(function(a){switch(a.label){case 0:return ve(e)||ge(de.INVALID_PARAMS,"ticket must be a string"),t=this._cache.keys,n=t.anonymousUuidKey,r=t.refreshTokenKey,[4,this._cache.getStoreAsync(n)];case 1:return o=a.sent(),[4,this._cache.getStoreAsync(r)];case 2:return i=a.sent(),[4,this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:o,refresh_token:i,ticket:e})];case 3:return(s=a.sent()).refresh_token?[4,this._clearAnonymousUUID()]:[3,8];case 4:return a.sent(),[4,this.setRefreshToken(s.refresh_token)];case 5:return a.sent(),[4,this._request.refreshAccessToken()];case 6:return a.sent(),It.fire(Tt.ANONYMOUS_CONVERTED,{env:this._config.env}),It.fire(Tt.LOGIN_TYPE_CHANGED,{loginType:H.CUSTOM,persistence:"local"}),[4,(c=new Et({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return a.sent(),[2,c];case 8:ge(de.OPERATION_FAIL,JSON.stringify(s)||"linkAndRetrieveDataWithTicket failed"),a.label=9;case 9:return[2]}}))}))},t.prototype._setAnonymousUUID=function(e){return le(this,void 0,void 0,(function(){var t,n,r;return pe(this,(function(o){switch(o.label){case 0:return t=this._cache.keys,n=t.anonymousUuidKey,r=t.loginTypeKey,[4,this._cache.removeStoreAsync(n)];case 1:return o.sent(),[4,this._cache.setStoreAsync(n,e)];case 2:return o.sent(),[4,this._cache.setStoreAsync(r,H.ANONYMOUS)];case 3:return o.sent(),[2]}}))}))},t.prototype._clearAnonymousUUID=function(){return le(this,void 0,void 0,(function(){return pe(this,(function(e){switch(e.label){case 0:return[4,this._cache.removeStoreAsync(this._cache.keys.anonymousUuidKey)];case 1:return e.sent(),[2]}}))}))},t.prototype._onConverted=function(e){return le(this,void 0,void 0,(function(){return pe(this,(function(t){switch(t.label){case 0:return e.data.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(this._config.persistence)];case 1:return t.sent(),[2]}}))}))},fe([me({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+ye]}),he("design:type",Function),he("design:paramtypes",[]),he("design:returntype",Promise)],t.prototype,"signIn",null),t}(V),we=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)}}(),Ae=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 c=e.length-1;c>=0;c--)(o=e[c])&&(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},Oe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Se=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},Ie=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},ke=o.constants.ERRORS,Ee=o.constants.COMMUNITY_SITE_URL,Pe=o.utils.isString,Te=o.helpers.catchErrorsDecorator,Re=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return we(t,e),t.prototype.signIn=function(e){return Se(this,void 0,void 0,(function(){var t,n,r,o,i,s,c;return Ie(this,(function(a){switch(a.label){case 0:if(!Pe(e))throw new Error(JSON.stringify({code:ke.INVALID_PARAMS,msg:"ticket must be a string"}));return t=this._cache.keys.refreshTokenKey,o=(r=this._request).send,i=["auth.signInWithTicket"],s={ticket:e},[4,this._cache.getStoreAsync(t)];case 1:return[4,o.apply(r,i.concat([(s.refresh_token=a.sent()||"",s)]))];case 2:return(n=a.sent()).refresh_token?[4,this.setRefreshToken(n.refresh_token)]:[3,7];case 3:return a.sent(),[4,this._request.refreshAccessToken()];case 4:return a.sent(),It.fire(Tt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:H.CUSTOM,persistence:this._config.persistence}),It.fire(Tt.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return a.sent(),[4,(c=new Et({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 6:return a.sent(),[2,c];case 7:throw new Error(JSON.stringify({code:ke.OPERATION_FAIL,msg:"custom signIn failed"}))}}))}))},Ae([Te({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ee]}),Oe("design:type",Function),Oe("design:paramtypes",[String]),Oe("design:returntype",Promise)],t.prototype,"signIn",null),t}(V),Ne=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)}}(),Le=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 c=e.length-1;c>=0;c--)(o=e[c])&&(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},Ue=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},xe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},Ce=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},je=o.utils.throwError,Me=o.utils.isString,qe=o.constants.ERRORS,De=o.constants.COMMUNITY_SITE_URL,We=o.helpers.catchErrorsDecorator,Ke=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ne(t,e),t.prototype.signIn=function(e,t){return xe(this,void 0,void 0,(function(){var n,r,o,i,s;return Ce(this,(function(c){switch(c.label){case 0:return Me(e)||je(qe.INVALID_PARAMS,"email must be a string"),n=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""})];case 1:return r=c.sent(),o=r.refresh_token,i=r.access_token,s=r.access_token_expire,o?[4,this.setRefreshToken(o)]:[3,8];case 2:return c.sent(),i&&s?[4,this.setAccessToken(i,s)]:[3,4];case 3:return c.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:c.sent(),c.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return c.sent(),It.fire(Tt.LOGIN_STATE_CHANGED),It.fire(Tt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:H.EMAIL,persistence:this._config.persistence}),[2,new Et({envId:this._config.env,cache:this._cache,request:this._request})];case 8:r.code?je(qe.OPERATION_FAIL,"Email login fail["+r.code+"] "+r.message):je(qe.OPERATION_FAIL,"Email login fail"),c.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t){return xe(this,void 0,void 0,(function(){return Ce(this,(function(n){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})]}))}))},t.prototype.resetPassword=function(e){return xe(this,void 0,void 0,(function(){return Ce(this,(function(t){return[2,this._request.send("auth.sendPasswordResetEmail",{email:e})]}))}))},t.prototype.resetPasswordWithToken=function(e,t){return xe(this,void 0,void 0,(function(){return Ce(this,(function(n){return[2,this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})]}))}))},t.prototype.activate=function(e){return xe(this,void 0,void 0,(function(){return Ce(this,(function(t){return[2,this._request.send("auth.activateEndUserMail",{token:e})]}))}))},Le([We({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+De]}),Ue("design:type",Function),Ue("design:paramtypes",[String,String]),Ue("design:returntype",Promise)],t.prototype,"signIn",null),Le([We({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+De]}),Ue("design:type",Function),Ue("design:paramtypes",[String,String]),Ue("design:returntype",Promise)],t.prototype,"signUp",null),Le([We({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+De]}),Ue("design:type",Function),Ue("design:paramtypes",[String]),Ue("design:returntype",Promise)],t.prototype,"resetPassword",null),Le([We({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+De]}),Ue("design:type",Function),Ue("design:paramtypes",[String,String]),Ue("design:returntype",Promise)],t.prototype,"resetPasswordWithToken",null),Le([We({title:"邮箱激活失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+De]}),Ue("design:type",Function),Ue("design:paramtypes",[String]),Ue("design:returntype",Promise)],t.prototype,"activate",null),t}(V),Fe=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)}}(),He=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 c=e.length-1;c>=0;c--)(o=e[c])&&(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},Ge=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Be=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},Ve=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},Ye=o.utils.printWarn,Je=o.constants.ERRORS,Xe=o.constants.COMMUNITY_SITE_URL,ze=o.helpers.catchErrorsDecorator,$e=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Fe(t,e),t.prototype.signIn=function(e,t){return Be(this,void 0,void 0,(function(){var n,r,o,i,s,c,a,u,f;return Ve(this,(function(h){switch(h.label){case 0:if("string"!=typeof e)throw new Error(JSON.stringify({code:Je.INVALID_PARAMS,msg:"username must be a string"}));return"string"!=typeof t&&(t="",Ye(Je.INVALID_PARAMS,"password is empty")),n=this._cache.keys.refreshTokenKey,i=(o=this._request).send,s=["auth.signIn"],c={loginType:H.USERNAME,username:e,password:t},[4,this._cache.getStoreAsync(n)];case 1:return[4,i.apply(o,s.concat([(c.refresh_token=h.sent()||"",c)]))];case 2:return r=h.sent(),a=r.refresh_token,u=r.access_token_expire,f=r.access_token,a?[4,this.setRefreshToken(a)]:[3,9];case 3:return h.sent(),f&&u?[4,this.setAccessToken(f,u)]:[3,5];case 4:return h.sent(),[3,7];case 5:return[4,this._request.refreshAccessToken()];case 6:h.sent(),h.label=7;case 7:return[4,this.refreshUserInfo()];case 8:return h.sent(),It.fire(Tt.LOGIN_STATE_CHANGED),It.fire(Tt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:H.USERNAME,persistence:this._config.persistence}),[2,new Et({envId:this._config.env,cache:this._cache,request:this._request})];case 9:throw r.code?new Error(JSON.stringify({code:Je.OPERATION_FAIL,msg:"login by username failed:["+r.code+"] "+r.message})):new Error(JSON.stringify({code:Je.OPERATION_FAIL,msg:"login by username failed"}));case 10:return[2]}}))}))},He([ze({title:"用户名密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录"," 3 - 用户名密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Xe]}),Ge("design:type",Function),Ge("design:paramtypes",[String,String]),Ge("design:returntype",Promise)],t.prototype,"signIn",null),t}(V),Qe=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,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 c=e.length-1;c>=0;c--)(o=e[c])&&(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},et=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},tt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},nt=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},rt=o.utils.throwError,ot=o.utils.isString,it=o.utils.transformPhone,st=o.constants.ERRORS,ct=o.constants.COMMUNITY_SITE_URL,at=o.helpers.catchErrorsDecorator,ut="SIGNIN",ft="SIGNUP",ht=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Qe(t,e),t.prototype.signIn=function(e){return tt(this,void 0,void 0,(function(){var t,n,r,o,i,s,c,a,u;return nt(this,(function(f){switch(f.label){case 0:return t=e.phoneNumber,n=e.phoneCode,r=e.password,o=e.signMethod,ot(t)||rt(st.INVALID_PARAMS,"phoneNumber must be a string"),ot(n)||ot(r)||rt(st.INVALID_PARAMS,"phoneCode or password must be a string"),o||(o=ut),i=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:H.PHONE,phoneNumber:it(t),phoneCode:n,password:r,refresh_token:this._cache.getStore(i)||"",signMethod:o})];case 1:return s=f.sent(),c=s.refresh_token,a=s.access_token,u=s.access_token_expire,c?[4,this.setRefreshToken(c)]:[3,8];case 2:return f.sent(),a&&u?[4,this.setAccessToken(a,u)]:[3,4];case 3:return f.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:f.sent(),f.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return f.sent(),It.fire(Tt.LOGIN_STATE_CHANGED),It.fire(Tt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:H.PHONE,persistence:this._config.persistence}),[2,new Et({envId:this._config.env,cache:this._cache,request:this._request})];case 8:s.code?rt(st.OPERATION_FAIL,"Phone login fail["+s.code+"] "+s.message):rt(st.OPERATION_FAIL,"Phone login fail"),f.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t,n){return tt(this,void 0,void 0,(function(){return nt(this,(function(r){return[2,this.signIn({phoneNumber:e,phoneCode:t,password:n,signMethod:ft})]}))}))},Ze([at({title:"手机号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().SmsAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录"," 3 - 短信验证码/密码是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+ct]}),et("design:type",Function),et("design:paramtypes",[Object]),et("design:returntype",Promise)],t.prototype,"signIn",null),Ze([at({title:"手机短信注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithPhoneCode() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+ct]}),et("design:type",Function),et("design:paramtypes",[String,String,String]),et("design:returntype",Promise)],t.prototype,"signUp",null),t}(V),lt=function(){return(lt=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)},pt=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 c=e.length-1;c>=0;c--)(o=e[c])&&(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},dt=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},yt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},gt=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},vt=o.events.CloudbaseEventEmitter,_t=o.adapters.RUNTIME,mt=o.utils.printWarn,bt=o.utils.throwError,wt=o.utils.transformPhone,At=o.constants.ERRORS,Ot=o.constants.COMMUNITY_SITE_URL,St=o.helpers.catchErrorsDecorator,It=new vt,kt=function(){function e(e){var t=e.cache,n=e.request;this._cache=t,this._request=n,this._setUserInfo()}return e.prototype.checkLocalInfo=function(){return yt(this,void 0,void 0,(function(){return gt(this,(function(e){return this.uid=this._getLocalUserInfo("uid"),this.loginType=this._getLocalUserInfo("loginType"),this.openid=this._getLocalUserInfo("wxOpenId"),this.wxOpenId=this._getLocalUserInfo("wxOpenId"),this.wxPublicId=this._getLocalUserInfo("wxPublicId"),this.unionId=this._getLocalUserInfo("wxUnionId"),this.qqMiniOpenId=this._getLocalUserInfo("qqMiniOpenId"),this.customUserId=this._getLocalUserInfo("customUserId"),this.nickName=this._getLocalUserInfo("nickName"),this.gender=this._getLocalUserInfo("gender"),this.avatarUrl=this._getLocalUserInfo("avatarUrl"),this.email=this._getLocalUserInfo("email"),this.hasPassword=Boolean(this._getLocalUserInfo("hasPassword")),this.phone=this._getLocalUserInfo("phone"),this.location={country:this._getLocalUserInfo("country"),province:this._getLocalUserInfo("province"),city:this._getLocalUserInfo("city")},[2]}))}))},e.prototype.checkLocalInfoAsync=function(){return yt(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,c,a,u,f,h,l,p,d,y,g;return gt(this,(function(v){switch(v.label){case 0:return e=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return e.uid=v.sent(),t=this,[4,this._getLocalUserInfoAsync("loginType")];case 2:return t.loginType=v.sent(),n=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 3:return n.openid=v.sent(),r=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 4:return r.wxOpenId=v.sent(),o=this,[4,this._getLocalUserInfoAsync("wxPublicId")];case 5:return o.wxPublicId=v.sent(),i=this,[4,this._getLocalUserInfoAsync("wxUnionId")];case 6:return i.unionId=v.sent(),s=this,[4,this._getLocalUserInfoAsync("qqMiniOpenId")];case 7:return s.qqMiniOpenId=v.sent(),c=this,[4,this._getLocalUserInfoAsync("customUserId")];case 8:return c.customUserId=v.sent(),a=this,[4,this._getLocalUserInfoAsync("nickName")];case 9:return a.nickName=v.sent(),u=this,[4,this._getLocalUserInfoAsync("gender")];case 10:return u.gender=v.sent(),f=this,[4,this._getLocalUserInfoAsync("avatarUrl")];case 11:return f.avatarUrl=v.sent(),h=this,[4,this._getLocalUserInfoAsync("email")];case 12:return h.email=v.sent(),l=this,p=Boolean,[4,this._getLocalUserInfoAsync("hasPassword")];case 13:return l.hasPassword=p.apply(void 0,[v.sent()]),d=this,[4,this._getLocalUserInfoAsync("phone")];case 14:return d.phone=v.sent(),y=this,g={},[4,this._getLocalUserInfoAsync("country")];case 15:return g.country=v.sent(),[4,this._getLocalUserInfoAsync("province")];case 16:return g.province=v.sent(),[4,this._getLocalUserInfoAsync("city")];case 17:return y.location=(g.city=v.sent(),g),[2]}}))}))},e.prototype.linkWithTicket=function(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})},e.prototype.linkWithRedirect=function(e){e.signInWithRedirect()},e.prototype.getLinkedUidList=function(){return yt(this,void 0,void 0,(function(){var e,t,n,r,o,i;return gt(this,(function(s){switch(s.label){case 0:return[4,this._request.send("auth.getLinkedUidList",{})];case 1:for(e=s.sent().data,t=!1,n=e.users,r=0,o=n;r<o.length;r++)if((i=o[r]).wxOpenId&&i.wxPublicId){t=!0;break}return[2,{users:n,hasPrimaryUid:t}]}}))}))},e.prototype.setPrimaryUid=function(e){return this._request.send("auth.setPrimaryUid",{uid:e})},e.prototype.unlink=function(e){return this._request.send("auth.unlink",{platform:e})},e.prototype.update=function(e){return yt(this,void 0,void 0,(function(){var t,n,r,o,i,s,c;return gt(this,(function(a){switch(a.label){case 0:return t=e.nickName,n=e.gender,r=e.avatarUrl,o=e.province,i=e.country,s=e.city,[4,this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:r,province:o,country:i,city:s})];case 1:return c=a.sent().data,this._setLocalUserInfo(c),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})},e.prototype.updateEmail=function(e){return this._request.send("auth.updateEmail",{newEmail:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&bt(At.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:e})},e.prototype.refresh=function(){return yt(this,void 0,void 0,(function(){var e;return gt(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return e=t.sent().data,this._setLocalUserInfo(e),[2,e]}}))}))},e.prototype.linkWithPhoneNumber=function(e,t){return yt(this,void 0,void 0,(function(){return gt(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:wt(e),phoneCode:t})]}))}))},e.prototype.updatePhoneNumber=function(e,t){return yt(this,void 0,void 0,(function(){return gt(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:wt(e),phoneCode:t})]}))}))},e.prototype._getLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;return this._cache.getStore(t)[e]},e.prototype._getLocalUserInfoAsync=function(e){return yt(this,void 0,void 0,(function(){var t;return gt(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._cache.getStoreAsync(t)];case 1:return[2,n.sent()[e]]}}))}))},e.prototype._setUserInfo=function(){var e=this,t=this._cache.keys.userInfoKey,n=this._cache.getStore(t);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl","phone"].forEach((function(t){e[t]=n[t]})),this.location={country:n.country,province:n.province,city:n.city}},e.prototype._setLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;this._cache.setStore(t,e),this._setUserInfo()},pt([St({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",Promise)],e.prototype,"linkWithTicket",null),pt([St({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",void 0)],e.prototype,"linkWithRedirect",null),pt([St({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],e.prototype,"getLinkedUidList",null),pt([St({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",void 0)],e.prototype,"setPrimaryUid",null),pt([St({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",void 0)],e.prototype,"unlink",null),pt([St({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],e.prototype,"update",null),pt([St({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String,String]),dt("design:returntype",void 0)],e.prototype,"updatePassword",null),pt([St({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",void 0)],e.prototype,"updateEmail",null),pt([St({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",void 0)],e.prototype,"updateUsername",null),pt([St({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],e.prototype,"refresh",null),pt([St({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().linkWithPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String,String]),dt("design:returntype",Promise)],e.prototype,"linkWithPhoneNumber",null),pt([St({title:"更新手机号失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String,String]),dt("design:returntype",Promise)],e.prototype,"updatePhoneNumber",null),e}(),Et=function(){function e(e){var t=e.envId,n=e.cache,r=e.request;t||bt(At.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new kt({cache:n,request:r})}return e.prototype.checkLocalState=function(){return yt(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return gt(this,(function(c){return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=this._cache.getStore(t),i=this._cache.getStore(n),s=this._cache.getStore(r),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},this._loginType=this._cache.getStore(this._cache.keys.loginTypeKey),this.user.checkLocalInfo(),[2]}))}))},e.prototype.checkLocalStateAsync=function(){return yt(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,c;return gt(this,(function(a){switch(a.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(t)];case 1:return o=a.sent(),[4,this._cache.getStoreAsync(n)];case 2:return i=a.sent(),[4,this._cache.getStoreAsync(r)];case 3:return s=a.sent(),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},c=this,[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 4:return c._loginType=a.sent(),[4,this.user.checkLocalInfoAsync()];case 5:return a.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"isAnonymousAuth",{get:function(){return this.loginType===H.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCustomAuth",{get:function(){return this.loginType===H.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWeixinAuth",{get:function(){return this.loginType===H.WECHAT||this.loginType===H.WECHAT_OPEN||this.loginType===H.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsernameAuth",{get:function(){return this.loginType===H.USERNAME},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._loginType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPhoneAuth",{get:function(){return this.loginType===H.PHONE},enumerable:!1,configurable:!0}),e}(),Pt=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request,this._runtime=e.runtime||_t.WEB,It.on(Tt.LOGIN_TYPE_CHANGED,this._onLoginTypeChanged.bind(this))}return Object.defineProperty(e.prototype,"currentUser",{get:function(){if("async"!==this._cache.mode){var e=this.hasLoginState();return e&&e.user||null}mt(At.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrenUser insteed")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._cache.getStore(this._cache.keys.loginTypeKey)},enumerable:!1,configurable:!0}),e.prototype.getCurrenUser=function(){return yt(this,void 0,void 0,(function(){var e;return gt(this,(function(t){switch(t.label){case 0:return[4,this.getLoginState()];case 1:return(e=t.sent())?[4,e.user.checkLocalInfoAsync()]:[3,3];case 2:return t.sent(),[2,e.user||null];case 3:return[2,null]}}))}))},e.prototype.getLoginType=function(){return yt(this,void 0,void 0,(function(){return gt(this,(function(e){switch(e.label){case 0:return[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAccessToken=function(){return yt(this,void 0,void 0,(function(){var e;return gt(this,(function(t){switch(t.label){case 0:return e={},[4,this._request.getAccessToken()];case 1:return[2,(e.accessToken=t.sent().accessToken,e.env=this._config.env,e)]}}))}))},e.prototype.weixinAuthProvider=function(e){var t=e.appid,n=e.scope,r=e.state;return this._weixinAuthProvider||(this._weixinAuthProvider=new ce(lt(lt({},this._config),{cache:this._cache,request:this._request,runtime:this._runtime}),t,n,r)),this._weixinAuthProvider},e.prototype.anonymousAuthProvider=function(){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new be(lt(lt({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},e.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new Re(lt(lt({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},e.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new Ke(lt(lt({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},e.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new $e(lt(lt({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},e.prototype.phoneAuthProvider=function(){return this._phoneAuthProvider||(this._phoneAuthProvider=new ht(lt(lt({},this._config),{cache:this._cache,request:this._request}))),this._phoneAuthProvider},e.prototype.signInWithUsernameAndPassword=function(e,t){return yt(this,void 0,void 0,(function(){return gt(this,(function(n){return[2,this.usernameAuthProvider().signIn(e,t)]}))}))},e.prototype.isUsernameRegistered=function(e){return yt(this,void 0,void 0,(function(){var t;return gt(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&bt(At.INVALID_PARAMS,"username must be a string"),[4,this._request.send("auth.isUsernameRegistered",{username:e})];case 1:return[2,null==(t=n.sent().data)?void 0:t.isRegistered]}}))}))},e.prototype.signInWithEmailAndPassword=function(e,t){return yt(this,void 0,void 0,(function(){return gt(this,(function(n){return[2,this.emailAuthProvider().signIn(e,t)]}))}))},e.prototype.signUpWithEmailAndPassword=function(e,t){return yt(this,void 0,void 0,(function(){return gt(this,(function(n){return[2,this.emailAuthProvider().signUp(e,t)]}))}))},e.prototype.sendPasswordResetEmail=function(e){return yt(this,void 0,void 0,(function(){return gt(this,(function(t){return[2,this.emailAuthProvider().resetPassword(e)]}))}))},e.prototype.signOut=function(){return yt(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return gt(this,(function(c){switch(c.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,o="auth.logout",[4,this._cache.getStoreAsync(t)];case 1:return(i=c.sent())?[4,this._request.send(o,{refresh_token:i})]:[2];case 2:return s=c.sent(),this._cache.removeStoreAsync(t),this._cache.removeStoreAsync(n),this._cache.removeStoreAsync(r),It.fire(Tt.LOGIN_STATE_CHANGED),It.fire(Tt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:H.NULL,persistence:this._config.persistence}),[2,s]}}))}))},e.prototype.onLoginStateChanged=function(e){return yt(this,void 0,void 0,(function(){var t,n=this;return gt(this,(function(r){switch(r.label){case 0:return It.on(Tt.LOGIN_STATE_CHANGED,(function(){return yt(n,void 0,void 0,(function(){var t;return gt(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))})),[4,this.getLoginState()];case 1:return t=r.sent(),e.call(this,t),[2]}}))}))},e.prototype.onLoginStateExpired=function(e){It.on(Tt.LOGIN_STATE_EXPIRED,e.bind(this))},e.prototype.onAccessTokenRefreshed=function(e){It.on(Tt.ACCESS_TOKEN_REFRESHD,e.bind(this))},e.prototype.onAnonymousConverted=function(e){It.on(Tt.ANONYMOUS_CONVERTED,e.bind(this))},e.prototype.onLoginTypeChanged=function(e){var t=this;It.on(Tt.LOGIN_TYPE_CHANGED,(function(){return yt(t,void 0,void 0,(function(){var t;return gt(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))}))},e.prototype.hasLoginState=function(){if("async"!==this._cache.mode){var e=this._cache.keys.refreshTokenKey;if(this._cache.getStore(e)){var t=new Et({envId:this._config.env,cache:this._cache,request:this._request});return t.checkLocalState(),t}return null}mt(At.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},e.prototype.getLoginState=function(){return yt(this,void 0,void 0,(function(){var e,t;return gt(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(e)];case 1:return n.sent()?[4,(t=new Et({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,3];case 2:return n.sent(),[2,t];case 3:return[2,null]}}))}))},e.prototype.shouldRefreshAccessToken=function(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)},e.prototype.getUserInfo=function(){return yt(this,void 0,void 0,(function(){var e;return gt(this,(function(t){switch(t.label){case 0:return"auth.getUserInfo",[4,this._request.send("auth.getUserInfo",{})];case 1:return(e=t.sent()).code?[2,e]:[2,lt(lt({},e.data),{requestId:e.seqId})]}}))}))},e.prototype.getAuthHeader=function(){var e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=this._cache.getStore(t);return{"x-cloudbase-credentials":this._cache.getStore(n)+"/@@/"+r}},e.prototype.getAuthHeaderAsync=function(){return yt(this,void 0,void 0,(function(){var e,t,n,r;return gt(this,(function(o){switch(o.label){case 0:return[4,this._request.refreshAccessToken()];case 1:return o.sent(),e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return r=o.sent(),[4,this._cache.getStoreAsync(n)];case 3:return[2,{"x-cloudbase-credentials":o.sent()+"/@@/"+r}]}}))}))},e.prototype.sendPhoneCode=function(e){return yt(this,void 0,void 0,(function(){return gt(this,(function(t){switch(t.label){case 0:return[4,this._request.send("auth.sendPhoneCode",{phoneNumber:wt(e)})];case 1:return[2,"Ok"===t.sent().data.SendStatus]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,n){return yt(this,void 0,void 0,(function(){return gt(this,(function(r){return[2,this.phoneAuthProvider().signUp(e,t,n)]}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return yt(this,void 0,void 0,(function(){return gt(this,(function(t){return[2,this.phoneAuthProvider().signIn(e)]}))}))},e.prototype._onLoginTypeChanged=function(e){return yt(this,void 0,void 0,(function(){var t,n,r;return gt(this,(function(o){switch(o.label){case 0:return t=e.data,n=t.loginType,r=t.persistence,t.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(r)];case 1:return o.sent(),[4,this._cache.setStoreAsync(this._cache.keys.loginTypeKey,n)];case 2:return o.sent(),[2]}}))}))},pt([St({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],e.prototype,"getCurrenUser",null),pt([St({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",Promise)],e.prototype,"isUsernameRegistered",null),pt([St({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],e.prototype,"signOut",null),pt([St({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],e.prototype,"getLoginState",null),pt([St({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],e.prototype,"getUserInfo",null),pt([St({title:"发送短信验证码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ot]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",Promise)],e.prototype,"sendPhoneCode",null),e}(),Tt={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},Rt={name:"auth",namespace:"auth",injectEvents:{bus:It,events:[Tt.LOGIN_TYPE_CHANGED,Tt.LOGIN_STATE_EXPIRED,Tt.LOGIN_STATE_CHANGED,Tt.ACCESS_TOKEN_REFRESHD,Tt.ANONYMOUS_CONVERTED]},entity:function(e){if(void 0===e&&(e={region:"",persistence:"session"}),this.authInstance)return mt(At.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var t=this.platform,n=t.adapter,r=t.runtime,o=e.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,c=i.persistence,a=i.debug;return this.authInstance=new Pt({env:s,region:e.region,persistence:c,debug:a,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(Rt)}catch(e){}var Nt=function(){return(Nt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Lt=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 c=e.length-1;c>=0;c--)(o=e[c])&&(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},Ut=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},xt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((r=r.apply(e,t||[])).next())}))},Ct=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},jt=o.adapters.useAdapters,Mt=o.adapters.useDefaultAdapter,qt=o.adapters.RUNTIME,Dt=o.constants.ERRORS,Wt=o.constants.COMMUNITY_SITE_URL,Kt=o.utils.printWarn,Ft=o.helpers.catchErrorsDecorator,Ht={timeout:15e3,persistence:"session"},Gt={},Bt=new(function(){function e(e){this._config=e||this._config,this.authInstance=null}return Object.defineProperty(e.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return _},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return S(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return I(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this._config.env,F[e];var e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eventBus",{get:function(){return It},enumerable:!1,configurable:!0}),e.prototype.init=function(t){if(!t.env)throw new Error(JSON.stringify({code:Dt.INVALID_PARAMS,msg:"env must not be specified"}));if(_.adapter||this._useDefaultAdapter(),this.requestClient=new _.adapter.reqClass({timeout:t.timeout||5e3,timeoutMsg:"["+Object(k.d)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+t.timeout/1e3+"s"}),_.runtime!==qt.WEB){if(!t.appSecret)throw new Error(JSON.stringify({code:Dt.INVALID_PARAMS,msg:"invalid appSecret"}));var n=_.adapter.getAppSign?_.adapter.getAppSign():"";if(t.appSign&&n&&t.appSign!==n)throw new Error(JSON.stringify({code:Dt.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(t.appSign=n),!t.appSign)throw new Error(JSON.stringify({code:Dt.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=Nt(Nt({},Ht),t),this._config.timeout=this._formatTimeout(this._config.timeout);var r=this._config,o=r.env,i=r.persistence,s=r.debug,c=r.timeout,a=r.appSecret,u=r.appSign;O({env:o,persistence:i,debug:s,platformInfo:this.platform}),function(e){F[e.env]=new K(T(T({},e),{throw:!0}))}({env:o,region:t.region||"",timeout:c,appSecret:a,appSign:u}),t.region&&Object(k.g)(o,t.region||"");var f=new e(this._config);return f.requestClient=this.requestClient,f},e.prototype.updateConfig=function(e){var t=e.persistence,n=e.debug;this._config.persistence=t,this._config.debug=n,O({env:this._config.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.registerExtension=function(e){Gt[e.name]=e},e.prototype.invokeExtension=function(e,t){return xt(this,void 0,void 0,(function(){var n;return Ct(this,(function(r){switch(r.label){case 0:if(!(n=Gt[e]))throw new Error(JSON.stringify({code:Dt.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=jt(e)||{},n=t.adapter,r=t.runtime;n&&(_.adapter=n),r&&(_.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){v(e,t)},e.prototype.registerVersion=function(e){Object(k.i)(e)},e.prototype.registerSdkName=function(e){Object(k.h)(e)},e.prototype.registerEndPoint=function(e,t){Object(k.f)(e,t)},e.prototype._useDefaultAdapter=function(){var e=Mt(),t=e.adapter,n=e.runtime;_.adapter=t,_.runtime=n},e.prototype._formatTimeout=function(e){switch(!0){case e>6e5:return Kt(Dt.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case e<100:return Kt(Dt.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},Lt([Ft({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Wt]}),Ut("design:type",Function),Ut("design:paramtypes",[Object]),Ut("design:returntype",e)],e.prototype,"init",null),Lt([Ft({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Wt]}),Ut("design:type",Function),Ut("design:paramtypes",[String,Object]),Ut("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}());Bt.useAdapters(p);t.default=Bt}])}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_realtime",[],t):"object"==typeof exports?exports.cloudbase_realtime=t():e.cloudbase_realtime=t()}("undefined"!=typeof window?window:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,i=/^\./,o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,c=/^(?:0|[1-9]\d*)$/,u="object"==typeof t&&t&&t.Object===Object&&t,l="object"==typeof self&&self&&self.Object===Object&&self,h=u||l||Function("return this")();var d,f=Array.prototype,_=Function.prototype,p=Object.prototype,v=h["__core-js_shared__"],E=(d=/[^.]+$/.exec(v&&v.keys&&v.keys.IE_PROTO||""))?"Symbol(src)_1."+d:"",g=_.toString,y=p.hasOwnProperty,I=p.toString,m=RegExp("^"+g.call(y).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),b=h.Symbol,w=f.splice,S=M(h,"Map"),T=M(Object,"create"),A=b?b.prototype:void 0,R=A?A.toString:void 0;function C(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function D(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function N(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function O(e,t,n){var r=e[t];y.call(e,t)&&H(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function L(e,t){for(var n=e.length;n--;)if(H(e[n][0],t))return n;return-1}function W(e){return!(!F(e)||(t=e,E&&E in t))&&(function(e){var t=F(e)?I.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?m:a).test(function(e){if(null!=e){try{return g.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}function j(e,t,i,o){if(!F(e))return e;for(var s=-1,a=(t=function(e,t){if(q(e))return!1;var i=typeof e;if("number"==i||"symbol"==i||"boolean"==i||null==e||U(e))return!0;return r.test(e)||!n.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:function(e){return q(e)?e:k(e)}(t)).length,c=a-1,u=e;null!=u&&++s<a;){var l=K(t[s]),h=i;if(s!=c){var d=u[l];void 0===(h=o?o(d,l,u):void 0)&&(h=F(d)?d:x(t[s+1])?[]:{})}O(u,l,h),u=u[l]}return e}function P(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function M(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return W(n)?n:void 0}function x(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||c.test(e))&&e>-1&&e%1==0&&e<t}C.prototype.clear=function(){this.__data__=T?T(null):{}},C.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},C.prototype.get=function(e){var t=this.__data__;if(T){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return y.call(t,e)?t[e]:void 0},C.prototype.has=function(e){var t=this.__data__;return T?void 0!==t[e]:y.call(t,e)},C.prototype.set=function(e,t){return this.__data__[e]=T&&void 0===t?"__lodash_hash_undefined__":t,this},D.prototype.clear=function(){this.__data__=[]},D.prototype.delete=function(e){var t=this.__data__,n=L(t,e);return!(n<0)&&(n==t.length-1?t.pop():w.call(t,n,1),!0)},D.prototype.get=function(e){var t=this.__data__,n=L(t,e);return n<0?void 0:t[n][1]},D.prototype.has=function(e){return L(this.__data__,e)>-1},D.prototype.set=function(e,t){var n=this.__data__,r=L(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},N.prototype.clear=function(){this.__data__={hash:new C,map:new(S||D),string:new C}},N.prototype.delete=function(e){return P(this,e).delete(e)},N.prototype.get=function(e){return P(this,e).get(e)},N.prototype.has=function(e){return P(this,e).has(e)},N.prototype.set=function(e,t){return P(this,e).set(e,t),this};var k=B((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(U(e))return R?R.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return i.test(e)&&n.push(""),e.replace(o,(function(e,t,r,i){n.push(r?i.replace(s,"$1"):t||e)})),n}));function K(e){if("string"==typeof e||U(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function B(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(B.Cache||N),n}function H(e,t){return e===t||e!=e&&t!=t}B.Cache=N;var q=Array.isArray;function F(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function U(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==I.call(e)}e.exports=function(e,t,n){return null==e?e:j(e,t,n)}}).call(this,n(0))},function(e,t,n){(function(t){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,i=/^\./,o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,c="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,l=c||u||Function("return this")();var h,d=Array.prototype,f=Function.prototype,_=Object.prototype,p=l["__core-js_shared__"],v=(h=/[^.]+$/.exec(p&&p.keys&&p.keys.IE_PROTO||""))?"Symbol(src)_1."+h:"",E=f.toString,g=_.hasOwnProperty,y=_.toString,I=RegExp("^"+E.call(g).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),m=l.Symbol,b=d.splice,w=P(l,"Map"),S=P(Object,"create"),T=m?m.prototype:void 0,A=T?T.toString:void 0;function R(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function C(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function D(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function N(e,t){for(var n,r,i=e.length;i--;)if((n=e[i][0])===(r=t)||n!=n&&r!=r)return i;return-1}function O(e){return!(!H(e)||(t=e,v&&v in t))&&(function(e){var t=H(e)?y.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?I:a).test(function(e){if(null!=e){try{return E.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}function L(e,t){e=function(e,t){return 1==t.length?e:function(e,t){for(var n=0,r=(t=M(t,e)?[t]:W(t)).length;null!=e&&n<r;)e=e[k(t[n++])];return n&&n==r?e:void 0}(e,function(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r<i;)o[r]=e[r+t];return o}(t,0,-1))}(e,t=M(t,e)?[t]:W(t));var n,r,i=k((r=(n=t)?n.length:0)?n[r-1]:void 0);return!(null!=e&&g.call(e,i))||delete e[i]}function W(e){return B(e)?e:x(e)}function j(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function P(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return O(n)?n:void 0}function M(e,t){if(B(e))return!1;var i=typeof e;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=e&&!q(e))||(r.test(e)||!n.test(e)||null!=t&&e in Object(t))}R.prototype.clear=function(){this.__data__=S?S(null):{}},R.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},R.prototype.get=function(e){var t=this.__data__;if(S){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return g.call(t,e)?t[e]:void 0},R.prototype.has=function(e){var t=this.__data__;return S?void 0!==t[e]:g.call(t,e)},R.prototype.set=function(e,t){return this.__data__[e]=S&&void 0===t?"__lodash_hash_undefined__":t,this},C.prototype.clear=function(){this.__data__=[]},C.prototype.delete=function(e){var t=this.__data__,n=N(t,e);return!(n<0)&&(n==t.length-1?t.pop():b.call(t,n,1),!0)},C.prototype.get=function(e){var t=this.__data__,n=N(t,e);return n<0?void 0:t[n][1]},C.prototype.has=function(e){return N(this.__data__,e)>-1},C.prototype.set=function(e,t){var n=this.__data__,r=N(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},D.prototype.clear=function(){this.__data__={hash:new R,map:new(w||C),string:new R}},D.prototype.delete=function(e){return j(this,e).delete(e)},D.prototype.get=function(e){return j(this,e).get(e)},D.prototype.has=function(e){return j(this,e).has(e)},D.prototype.set=function(e,t){return j(this,e).set(e,t),this};var x=K((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(q(e))return A?A.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return i.test(e)&&n.push(""),e.replace(o,(function(e,t,r,i){n.push(r?i.replace(s,"$1"):t||e)})),n}));function k(e){if("string"==typeof e||q(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function K(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(K.Cache||D),n}K.Cache=D;var B=Array.isArray;function H(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function q(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==y.call(e)}e.exports=function(e,t){return null==e||L(e,t)}}).call(this,n(0))},function(e,t,n){(function(e,n){var r="[object Arguments]",i="[object Function]",o="[object GeneratorFunction]",s="[object Map]",a="[object Set]",c=/\w*$/,u=/^\[object .+?Constructor\]$/,l=/^(?:0|[1-9]\d*)$/,h={};h[r]=h["[object Array]"]=h["[object ArrayBuffer]"]=h["[object DataView]"]=h["[object Boolean]"]=h["[object Date]"]=h["[object Float32Array]"]=h["[object Float64Array]"]=h["[object Int8Array]"]=h["[object Int16Array]"]=h["[object Int32Array]"]=h[s]=h["[object Number]"]=h["[object Object]"]=h["[object RegExp]"]=h[a]=h["[object String]"]=h["[object Symbol]"]=h["[object Uint8Array]"]=h["[object Uint8ClampedArray]"]=h["[object Uint16Array]"]=h["[object Uint32Array]"]=!0,h["[object Error]"]=h[i]=h["[object WeakMap]"]=!1;var d="object"==typeof e&&e&&e.Object===Object&&e,f="object"==typeof self&&self&&self.Object===Object&&self,_=d||f||Function("return this")(),p=t&&!t.nodeType&&t,v=p&&"object"==typeof n&&n&&!n.nodeType&&n,E=v&&v.exports===p;function g(e,t){return e.set(t[0],t[1]),e}function y(e,t){return e.add(t),e}function I(e,t,n,r){var i=-1,o=e?e.length:0;for(r&&o&&(n=e[++i]);++i<o;)n=t(n,e[i],i,e);return n}function m(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function b(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function w(e,t){return function(n){return e(t(n))}}function S(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var T,A=Array.prototype,R=Function.prototype,C=Object.prototype,D=_["__core-js_shared__"],N=(T=/[^.]+$/.exec(D&&D.keys&&D.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"",O=R.toString,L=C.hasOwnProperty,W=C.toString,j=RegExp("^"+O.call(L).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),P=E?_.Buffer:void 0,M=_.Symbol,x=_.Uint8Array,k=w(Object.getPrototypeOf,Object),K=Object.create,B=C.propertyIsEnumerable,H=A.splice,q=Object.getOwnPropertySymbols,F=P?P.isBuffer:void 0,U=w(Object.keys,Object),G=ve(_,"DataView"),V=ve(_,"Map"),$=ve(_,"Promise"),J=ve(_,"Set"),X=ve(_,"WeakMap"),Y=ve(Object,"create"),z=me(G),Q=me(V),Z=me($),ee=me(J),te=me(X),ne=M?M.prototype:void 0,re=ne?ne.valueOf:void 0;function ie(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function oe(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function se(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ae(e){this.__data__=new oe(e)}function ce(e,t){var n=we(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Se(e)}(e)&&L.call(e,"callee")&&(!B.call(e,"callee")||W.call(e)==r)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],i=n.length,o=!!i;for(var s in e)!t&&!L.call(e,s)||o&&("length"==s||ye(s,i))||n.push(s);return n}function ue(e,t,n){var r=e[t];L.call(e,t)&&be(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function le(e,t){for(var n=e.length;n--;)if(be(e[n][0],t))return n;return-1}function he(e,t,n,u,l,d,f){var _;if(u&&(_=d?u(e,l,d,f):u(e)),void 0!==_)return _;if(!Re(e))return e;var p=we(e);if(p){if(_=function(e){var t=e.length,n=e.constructor(t);t&&"string"==typeof e[0]&&L.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!t)return function(e,t){var n=-1,r=e.length;t||(t=Array(r));for(;++n<r;)t[n]=e[n];return t}(e,_)}else{var v=ge(e),E=v==i||v==o;if(Te(e))return function(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}(e,t);if("[object Object]"==v||v==r||E&&!d){if(m(e))return d?e:{};if(_=function(e){return"function"!=typeof e.constructor||Ie(e)?{}:(t=k(e),Re(t)?K(t):{});var t}(E?{}:e),!t)return function(e,t){return _e(e,Ee(e),t)}(e,function(e,t){return e&&_e(t,Ce(t),e)}(_,e))}else{if(!h[v])return d?e:{};_=function(e,t,n,r){var i=e.constructor;switch(t){case"[object ArrayBuffer]":return fe(e);case"[object Boolean]":case"[object Date]":return new i(+e);case"[object DataView]":return function(e,t){var n=t?fe(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e,t){var n=t?fe(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,r);case s:return function(e,t,n){return I(t?n(b(e),!0):b(e),g,new e.constructor)}(e,r,n);case"[object Number]":case"[object String]":return new i(e);case"[object RegExp]":return function(e){var t=new e.constructor(e.source,c.exec(e));return t.lastIndex=e.lastIndex,t}(e);case a:return function(e,t,n){return I(t?n(S(e),!0):S(e),y,new e.constructor)}(e,r,n);case"[object Symbol]":return o=e,re?Object(re.call(o)):{}}var o}(e,v,he,t)}}f||(f=new ae);var w=f.get(e);if(w)return w;if(f.set(e,_),!p)var T=n?function(e){return function(e,t,n){var r=t(e);return we(e)?r:function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}(r,n(e))}(e,Ce,Ee)}(e):Ce(e);return function(e,t){for(var n=-1,r=e?e.length:0;++n<r&&!1!==t(e[n],n,e););}(T||e,(function(r,i){T&&(r=e[i=r]),ue(_,i,he(r,t,n,u,i,e,f))})),_}function de(e){return!(!Re(e)||(t=e,N&&N in t))&&(Ae(e)||m(e)?j:u).test(me(e));var t}function fe(e){var t=new e.constructor(e.byteLength);return new x(t).set(new x(e)),t}function _e(e,t,n,r){n||(n={});for(var i=-1,o=t.length;++i<o;){var s=t[i],a=r?r(n[s],e[s],s,n,e):void 0;ue(n,s,void 0===a?e[s]:a)}return n}function pe(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function ve(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return de(n)?n:void 0}ie.prototype.clear=function(){this.__data__=Y?Y(null):{}},ie.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ie.prototype.get=function(e){var t=this.__data__;if(Y){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return L.call(t,e)?t[e]:void 0},ie.prototype.has=function(e){var t=this.__data__;return Y?void 0!==t[e]:L.call(t,e)},ie.prototype.set=function(e,t){return this.__data__[e]=Y&&void 0===t?"__lodash_hash_undefined__":t,this},oe.prototype.clear=function(){this.__data__=[]},oe.prototype.delete=function(e){var t=this.__data__,n=le(t,e);return!(n<0)&&(n==t.length-1?t.pop():H.call(t,n,1),!0)},oe.prototype.get=function(e){var t=this.__data__,n=le(t,e);return n<0?void 0:t[n][1]},oe.prototype.has=function(e){return le(this.__data__,e)>-1},oe.prototype.set=function(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},se.prototype.clear=function(){this.__data__={hash:new ie,map:new(V||oe),string:new ie}},se.prototype.delete=function(e){return pe(this,e).delete(e)},se.prototype.get=function(e){return pe(this,e).get(e)},se.prototype.has=function(e){return pe(this,e).has(e)},se.prototype.set=function(e,t){return pe(this,e).set(e,t),this},ae.prototype.clear=function(){this.__data__=new oe},ae.prototype.delete=function(e){return this.__data__.delete(e)},ae.prototype.get=function(e){return this.__data__.get(e)},ae.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.set=function(e,t){var n=this.__data__;if(n instanceof oe){var r=n.__data__;if(!V||r.length<199)return r.push([e,t]),this;n=this.__data__=new se(r)}return n.set(e,t),this};var Ee=q?w(q,Object):function(){return[]},ge=function(e){return W.call(e)};function ye(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||l.test(e))&&e>-1&&e%1==0&&e<t}function Ie(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||C)}function me(e){if(null!=e){try{return O.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function be(e,t){return e===t||e!=e&&t!=t}(G&&"[object DataView]"!=ge(new G(new ArrayBuffer(1)))||V&&ge(new V)!=s||$&&"[object Promise]"!=ge($.resolve())||J&&ge(new J)!=a||X&&"[object WeakMap]"!=ge(new X))&&(ge=function(e){var t=W.call(e),n="[object Object]"==t?e.constructor:void 0,r=n?me(n):void 0;if(r)switch(r){case z:return"[object DataView]";case Q:return s;case Z:return"[object Promise]";case ee:return a;case te:return"[object WeakMap]"}return t});var we=Array.isArray;function Se(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}(e.length)&&!Ae(e)}var Te=F||function(){return!1};function Ae(e){var t=Re(e)?W.call(e):"";return t==i||t==o}function Re(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ce(e){return Se(e)?ce(e):function(e){if(!Ie(e))return U(e);var t=[];for(var n in Object(e))L.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}n.exports=function(e){return he(e,!0,!0)}}).call(this,n(0),n(5)(e))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerRealtime=void 0;var r=n(6);t.registerRealtime=r.registerRealtime},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";n.r(t),n.d(t,"registerRealtime",(function(){return B}));var r=n(1),i=n.n(r),o=n(2),s=n.n(o),a=n(3),c=n.n(a);function u(e){return void 0===e&&(e=""),(e?e+"_":"")+ +new Date+"_"+Math.random()}var l,h,d=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}})},f=function(e){var t,n,r=e.id,i=e.docChanges,o=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(i))),t},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(o))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},_=(l=function(e,t){return(l=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}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),p=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 _(t,e),t}(Error),v=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},E=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 _(t,e),t}(Error),g=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 _(t,e),t}(Error),y=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+" "+(I[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e}}}),n.errCode=t.errCode||"UNKNOWN_ERROR",n.errMsg=t.errMsg,n}return _(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),I={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"},m=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},b=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},w=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},S=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[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"}(h||(h={}));var T=function(){function e(e){var t=this;this.watchStatus=h.INITING,this._login=function(e,n){return b(t,void 0,void 0,(function(){var t;return w(this,(function(r){switch(r.label){case 0:return this.watchStatus=h.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 b(t,void 0,void 0,(function(){var t,n=this;return w(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(t,r){return b(n,void 0,void 0,(function(){var n,i,o,s,a,c,l,d,_,p;return w(this,(function(v){switch(v.label){case 0:return v.trys.push([0,3,,4]),this.watchStatus===h.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];case 1:return n=v.sent().envId,this.watchStatus===h.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=h.INITING,i={watchId:this.watchId,requestId:u(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:i,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(o=v.sent(),s=o.msgData,a=s.events,c=s.currEvent,this.sessionInfo={queryID:o.msgData.queryID,currentEventId:c-1,currentDocs:[]},a.length>0){for(l=0,d=a;l<d.length;l++)d[l].ID=c;this.handleServerEvents(o)}else this.sessionInfo.currentEventId=c,_=new f({id:c,docChanges:[],docs:[],type:"init"}),this.listener.onChange(_),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=h.ACTIVE,this._availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return p=v.sent(),this.handleWatchEstablishmentError(p,{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 b(t,void 0,void 0,(function(){var t,n=this;return w(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(t,r){return b(n,void 0,void 0,(function(){var n,i,o,s;return w(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===h.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===h.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=h.REBUILDING,i={watchId:this.watchId,requestId:u(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:i,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return o=a.sent(),this.handleServerEvents(o),this.watchStatus=h.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 b(t,void 0,void 0,(function(){var t,r,i,o=this;return w(this,(function(s){return t="INIT_WATCH"===n.operationName,r=function(){o.closeWithError(new y({errCode:t?I.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:I.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),n.reject(e)},i=function(e){o.useRetryTicket(n.operationName)?t?(o._initWatchPromise=void 0,n.resolve(o.initWatch(e))):(o._rebuildWatchPromise=void 0,n.resolve(o.rebuildWatch(e))):r()},this.handleCommonError(e,{onSignError:function(){return i(!0)},onTimeoutError:function(){return i(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){return b(o,void 0,void 0,(function(){var e,t=this;return w(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),e=function(){return b(t,void 0,void 0,(function(){return w(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),i(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];case 1:return r.sent(),[3,7];case 2:return[4,m(100)];case 3:return r.sent(),this.watchStatus!==h.PAUSED?[3,4]:(n.reject(new g(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:i(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),i(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return b(t,void 0,void 0,(function(){var e,t,n;return w(this,(function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==h.ACTIVE)return this.watchStatus=h.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=h.CLOSING,t={watchId:this.watchId,requestId:u(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=h.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new y({errCode:I.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 b(t,void 0,void 0,(function(){var e,t,n;return w(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==h.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:u(),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(),v(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 y({errCode:I.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 y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(v(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 d({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 h.PAUSED:if("ERROR"!==e.msgType)return;break;case h.LOGGINGIN:case h.INITING:case h.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case h.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case h.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 y({errCode:I.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=h.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=h.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.resume=function(){return b(this,void 0,void 0,(function(){var e;return w(this,(function(t){switch(t.label){case 0:this.watchStatus=h.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 b(this,void 0,void 0,(function(){var t;return w(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 b(this,void 0,void 0,(function(){var t,n,r,o,a,u,l,h,d,_,p,v;return w(this,(function(E){switch(E.label){case 0:if(t=e.requestId,n=e.msgData.events,r=e.msgType,!n.length||!this.sessionInfo)return[2];o=this.sessionInfo;try{a=n.map(A)}catch(e){return this.closeWithError(new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}u=S(o.currentDocs),l=!1,h=function(n,h){var _,p,v,E,g,m,b,T,A,R,C;return w(this,(function(w){switch(w.label){case 0:return _=a[n],o.currentEventId>=_.id?(!a[n-1]||_.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur "+o.currentEventId+" but got "+_.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(o.currentEventId!==_.id-1)return[3,2];switch(_.dataType){case"update":if(!_.doc)switch(_.queueType){case"update":case"dequeue":if(p=u.find((function(e){return e._id===_.docId}))){if(m=c()(p),_.updatedFields)for(g in _.updatedFields)i()(m,g,_.updatedFields[g]);if(_.removedFields)for(v=0,E=_.removedFields;v<E.length;v++)g=E[v],s()(m,g);_.doc=m}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw b=new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '+e.requestId+")"}),d.closeWithError(b),b}break;case"replace":if(!_.doc)throw b=new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '+e.requestId+")"}),d.closeWithError(b),b;break;case"remove":(m=u.find((function(e){return e._id===_.docId})))?_.doc=m:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!_.doc)switch(_.queueType){case"dequeue":(m=u.find((function(e){return e._id===_.docId})))?_.doc=m:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw b=new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '+e.requestId+")"}),d.closeWithError(b),b}}switch(_.queueType){case"init":l?u.push(_.doc):(l=!0,u=[_.doc]);break;case"enqueue":u.push(_.doc);break;case"dequeue":(T=u.findIndex((function(e){return e._id===_.docId})))>-1?u.splice(T,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":(T=u.findIndex((function(e){return e._id===_.docId})))>-1?u[T]=_.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===h-1||a[n+1]&&a[n+1].id!==_.id)&&(A=S(u),R=a.slice(0,n+1).filter((function(e){return e.id===_.id})),d.sessionInfo.currentEventId=_.id,d.sessionInfo.currentDocs=u,C=new f({id:_.id,docChanges:R,docs:A,msgType:r}),d.listener.onChange(C)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur "+d.sessionInfo.currentEventId+" but got "+_.id),[4,d.rebuildWatch()];case 3:return w.sent(),[2,{value:void 0}];case 4:return[2]}}))},d=this,_=0,p=a.length,E.label=1;case 1:return _<p?[5,h(_,p)]:[3,4];case 2:if("object"==typeof(v=E.sent()))return[2,v.value];E.label=3;case 3:return _++,[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 A(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 R,C={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"}(R||(R={}));var D=function(e,t){var n=C[e],r=n?n.name+", code "+e+", reason "+(t||n.description):"code "+e;return new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},N=null,O="web";function L(){return O}var W=function(){return(W=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},j=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},P=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},M=1,x=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 j(t,void 0,void 0,(function(){var t=this;return P(this,(function(n){return[2,new Promise((function(n,r){return j(t,void 0,void 0,(function(){var t,i,o,s,a,c,u,l=this;return P(this,(function(h){switch(h.label){case 0:i=!1,o=!1,s=function(e){i=!0,t&&clearTimeout(t),n(e)},a=function(e){o=!0,t&&clearTimeout(t),r(e)},e.timeout&&(t=setTimeout((function(){return j(l,void 0,void 0,(function(){return P(this,(function(e){switch(e.label){case 0:return i&&o?[3,2]:[4,m(0)];case 1:e.sent(),i&&o||a(new E("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),h.label=1;case 1:return h.trys.push([1,8,,9]),this._wsInitPromise?[4,this._wsInitPromise]:[3,3];case 2:h.sent(),h.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!==M)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}),h.label=4;case 4:return h.trys.push([4,6,,7]),[4,this._ws.send(JSON.stringify(e.msg))];case 5:return h.sent(),e.waitResponse||s(),[3,7];case 6:return(c=h.sent())&&(a(c),e.waitResponse&&this._wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return u=h.sent(),a(u),[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),j(t,void 0,void 0,(function(){var t=this;return P(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(R.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,i){return j(t,void 0,void 0,(function(){var t,o,s=this;return P(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=N;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 o=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",o),n>0?(!0,this._wsInitPromise=void 0,[4,m(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:i(o),e&&this.closeAllClients(new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:o})),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 y({errCode:I.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 R.ReconnectWebSocket:case R.NoRealtimeListeners:break;case R.HeartbeatPingError:case R.HeartbeatPongTimeoutError:case R.NormalClosure:case R.AbnormalClosure:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(D(e.code));break;case R.NoAuthentication:t.closeAllClients(D(e.code,e.reason));break;default:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(D(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 i=null;t._virtualWSClient.forEach((function(e){e.watchId===n.watchId&&(i=e)})),i&&i.listener.onError(n)}var o=t._wsResponseWait.get(n.requestId);if(o){try{"ERROR"===n.msgType?o.reject(new p(n)):o.resolve(n)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t._wsResponseWait.delete(n.requestId)}if(o.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,c=Array.from(t._watchIdClientMap.entries());a<c.length;a++){c[a][1].onMessage(n);break}}}else if(t._lastPingSendTS){var u=Date.now()-t._lastPingSendTS;if(u>1e4)return void console.warn("[realtime] untrusted rtt observed: "+u);t._rttObserved.length>=3&&t._rttObserved.splice(0,t._rttObserved.length-3+1),t._rttObserved.push(u)}},t.heartbeat()}))},this.isWSConnected=function(){return Boolean(t._ws&&t._ws.readyState===M)},this.onceWSConnected=function(){return j(t,void 0,void 0,(function(){var e=this;return P(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 j(t,void 0,void 0,(function(){var t,r,i,o,s,a,c,l,h=this;return P(this,(function(d){switch(d.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];i=new Promise((function(e,t){return j(h,void 0,void 0,(function(){var n,r,i,o,s;return P(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:""},i={watchId:void 0,requestId:u(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:L(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:i,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(o=a.sent()).msgData.code?t(new Error(o.msgData.code+" "+o.msgData.message)):e({envId:n.envId}),[3,4];case 3:return s=a.sent(),t(s),[3,4];case 4:return[2]}}))}))})),o=e&&this._logins.get(e),s=Date.now(),o?(o.loggedIn=!1,o.loggingInPromise=i,o.loginStartTS=s):(o={loggedIn:!1,loggingInPromise:i,loginStartTS:s},this._logins.set(e||"",o)),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,i];case 2:if(a=d.sent(),(c=e&&this._logins.get(e))&&c===o&&c.loginStartTS===s)return o.loggedIn=!0,o.loggingInPromise=void 0,o.loginStartTS=void 0,o.loginResult=a,[2,a];if(c){if(c.loggedIn&&c.loginResult)return[2,c.loginResult];if(c.loggingInPromise)return[2,c.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw l=d.sent(),o.loggedIn=!1,o.loggingInPromise=void 0,o.loginStartTS=void 0,o.loginResult=void 0,l;case 4:return[2]}}))}))},this.getWsSign=function(){return j(t,void 0,void 0,(function(){var e,t,n,r,i,o,s;return P(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:L()})]);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,i=n.wsUrl,o=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:i,secretVersion:o,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 j(t,void 0,void 0,(function(){var e;return P(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:u(),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(R.NoRealtimeListeners)},this._maxReconnect=e.maxReconnect||5,this._reconnectInterval=e.reconnectInterval||1e4,this._context=e.context}return e.prototype.clearHeartbeat=function(){this._pingTimeoutId&&clearTimeout(this._pingTimeoutId),this._pongTimeoutId&&clearTimeout(this._pongTimeoutId)},e.prototype.close=function(e){this.clearHeartbeat(),this._ws&&(this._ws.close(e,C[e].name),this._ws=void 0)},e.prototype.watch=function(e){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var t=new T(W(W({},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 j(t,void 0,void 0,(function(){var e=this;return P(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this._ws&&this._ws.readyState===M?(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(R.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this._context.appConfig.realtimePingInterval)},e}(),k={target:"database",entity:function(){var e,t=this.platform,n=t.adapter,r=t.runtime;e=n.wsClass,N=e,function(e){O=e}(r)}},K={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=x}};try{cloudbase.registerComponent(K),cloudbase.registerHook(k)}catch(e){}function B(e){try{e.registerComponent(K),e.registerHook(k)}catch(e){console.warn(e)}}}])}));
|