@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,10 @@
|
|
|
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=13)}([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(7));t.constants=s;var a=i(n(17));t.adapters=a;var u=i(n(24));t.cache=u;var c=i(n(25));t.events=c;var f=i(n(4));t.utils=f;var l=i(n(26));t.helpers=l},function(e,t,n){"use strict";(function(e,r){n.d(t,"a",(function(){return Se}));var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function s(e,t){return e(t={exports:{}},t.exports),t.exports}for(var a=function(e){var t=g(e),n=t[0],r=t[1];return 3*(n+r)/4-r},u=function(e){var t,n,r=g(e),o=r[0],i=r[1],s=new h(function(e,t,n){return 3*(t+n)/4-n}(0,o,i)),a=0,u=i>0?o-4:o;for(n=0;n<u;n+=4)t=l[e.charCodeAt(n)]<<18|l[e.charCodeAt(n+1)]<<12|l[e.charCodeAt(n+2)]<<6|l[e.charCodeAt(n+3)],s[a++]=t>>16&255,s[a++]=t>>8&255,s[a++]=255&t;2===i&&(t=l[e.charCodeAt(n)]<<2|l[e.charCodeAt(n+1)]>>4,s[a++]=255&t);1===i&&(t=l[e.charCodeAt(n)]<<10|l[e.charCodeAt(n+1)]<<4|l[e.charCodeAt(n+2)]>>2,s[a++]=t>>8&255,s[a++]=255&t);return s},c=function(e){for(var t,n=e.length,r=n%3,o=[],i=0,s=n-r;i<s;i+=16383)o.push(_(e,i,i+16383>s?s:i+16383));1===r?(t=e[n-1],o.push(f[t>>2]+f[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(f[t>>10]+f[t>>4&63]+f[t<<2&63]+"="));return o.join("")},f=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,y=p.length;d<y;++d)f[d]=p[d],l[p.charCodeAt(d)]=d;function g(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function _(e,t,n){for(var r,o,i=[],s=t;s<n;s+=3)r=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),i.push(f[(o=r)>>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63;var m={byteLength:a,toByteArray:u,fromByteArray:c},v=function(e,t,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,f=-7,l=n?o-1:0,h=n?-1:1,p=e[t+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=c}return(p?-1:1)*s*Math.pow(2,i-r)},b=function(e,t,n,r,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[n+p]=255&s,p+=d,s/=256,c-=8);e[n+p-d]|=128*y},w=s((function(e,t){var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=o,t.SlowBuffer=function(e){+e!=e&&(e=0);return o.alloc(+e)},t.INSPECT_MAX_BYTES=50;function r(e){if(e>2147483647)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return a(e)}return i(e,t,n)}function i(e,t,n){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|l(e,t),i=r(n),s=i.write(e,t);s!==n&&(i=i.slice(0,s));return i}(e,t);if(ArrayBuffer.isView(e))return u(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(e));if(q(e,ArrayBuffer)||e&&q(e.buffer,ArrayBuffer))return c(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(q(e,SharedArrayBuffer)||e&&q(e.buffer,SharedArrayBuffer)))return c(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return o.from(i,t,n);var s=function(e){if(o.isBuffer(e)){var t=0|f(e.length),n=r(t);return 0===n.length||e.copy(n,0,0,t),n}if(void 0!==e.length)return"number"!=typeof e.length||F(e.length)?r(0):u(e);if("Buffer"===e.type&&Array.isArray(e.data))return u(e.data)}(e);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(e))}function s(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function a(e){return s(e),r(e<0?0:0|f(e))}function u(e){for(var t=e.length<0?0:0|f(e.length),n=r(t),o=0;o<t;o+=1)n[o]=255&e[o];return n}function c(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n),Object.setPrototypeOf(r,o.prototype),r}function f(e){if(e>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|e}function l(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||q(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(e));var n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return M(e).length;default:if(i)return r?-1:j(e).length;t=(""+t).toLowerCase(),i=!0}}function h(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return B(this,t,n);case"utf8":case"utf-8":return I(this,t,n);case"ascii":return N(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return O(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function p(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function d(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),F(n=+n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=o.from(t,r)),o.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,o){var i,s=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=n;i<a;i++)if(c(e,i)===c(t,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){l=!1;break}if(l)return i}return-1}function g(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(F(a))return s;e[n+s]=a}return s}function _(e,t,n,r){return k(j(t,e.length-n),e,n,r)}function w(e,t,n,r){return k(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function E(e,t,n,r){return w(e,t,n,r)}function S(e,t,n,r){return k(M(t),e,n,r)}function A(e,t,n,r){return k(function(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function O(e,t,n){return 0===t&&n===e.length?m.fromByteArray(e):m.fromByteArray(e.slice(t,n))}function I(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),o+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.kMaxLength=2147483647,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,n){return i(e,t,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,n){return function(e,t,n){return s(e),e<=0?r(e):void 0!==t?"string"==typeof n?r(e).fill(t,n):r(e).fill(t):r(e)}(e,t,n)},o.allocUnsafe=function(e){return a(e)},o.allocUnsafeSlow=function(e){return a(e)},o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(q(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),q(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=o.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(q(s,Uint8Array)&&(s=o.from(s)),!o.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},o.byteLength=l,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)p(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)p(this,t,t+3),p(this,t+1,t+2);return this},o.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)p(this,t,t+7),p(this,t+1,t+6),p(this,t+2,t+5),p(this,t+3,t+4);return this},o.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?I(this,0,e):h.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(e,t,n,r,i){if(q(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(e));if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),u=Math.min(s,a),c=this.slice(r,i),f=e.slice(t,n),l=0;l<u;++l)if(c[l]!==f[l]){s=c[l],a=f[l];break}return s<a?-1:a<s?1:0},o.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},o.prototype.indexOf=function(e,t,n){return d(this,e,t,n,!0)},o.prototype.lastIndexOf=function(e,t,n){return d(this,e,t,n,!1)},o.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return g(this,e,t,n);case"utf8":case"utf-8":return _(this,e,t,n);case"ascii":return w(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function N(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function T(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function B(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=W[e[i]];return o}function R(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function D(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,n,r,i,s){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function L(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(e,t,n,r,o){return t=+t,n>>>=0,o||L(e,0,n,4),b(e,t,n,r,23,4),n+4}function x(e,t,n,r,o){return t=+t,n>>>=0,o||L(e,0,n,8),b(e,t,n,r,52,8),n+8}o.prototype.slice=function(e,t){var n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e);var r=this.subarray(e,t);return Object.setPrototypeOf(r,o.prototype),r},o.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||D(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},o.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||D(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},o.prototype.readUInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||D(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},o.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||D(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},o.prototype.readInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||D(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){e>>>=0,t||D(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||D(e,4,this.length),v(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||D(e,4,this.length),v(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||D(e,8,this.length),v(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||D(e,8,this.length),v(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t>>>=0,n>>>=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},o.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t>>>=0,n>>>=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},o.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return x(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return x(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,r){if(!o.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var s=i-1;s>=0;--s)e[s+t]=this[s+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return i},o.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var i=e.charCodeAt(0);("utf8"===r&&i<128||"latin1"===r)&&(e=i)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var a=o.isBuffer(e)?e:o.from(e,r),u=a.length;if(0===u)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-t;++s)this[s+t]=a[s%u]}return this};var C=/[^+/0-9A-Za-z-_]/g;function j(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function M(e){return m.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(C,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function k(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function q(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function F(e){return e!=e}var W=function(){for(var e=new Array(256),t=0;t<16;++t)for(var n=16*t,r=0;r<16;++r)e[n+r]="0123456789abcdef"[t]+"0123456789abcdef"[r];return e}()})),E=(w.Buffer,w.SlowBuffer,w.INSPECT_MAX_BYTES,w.kMaxLength,{}),S="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},A=/%[sdj%]/g;function O(e){if(!M(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(T(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,i=String(e).replace(A,(function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n<o;s=r[++n])C(s)||!F(s)?i+=" "+s:i+=" "+T(s);return i}var I,N={};function T(e,t){var n={seen:[],stylize:R};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),x(t)?n.showHidden=t:t&&V(n,t),k(n.showHidden)&&(n.showHidden=!1),k(n.depth)&&(n.depth=2),k(n.colors)&&(n.colors=!1),k(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=B),D(n,e,n.depth)}function B(e,t){var n=T.styles[t];return n?"["+T.colors[n][0]+"m"+e+"["+T.colors[n][1]+"m":e}function R(e,t){return e}function D(e,t,n){if(e.customInspect&&t&&$(t.inspect)&&t.inspect!==T&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return M(r)||(r=D(e,r,n)),r}var o=function(e,t){if(k(t))return e.stylize("undefined","undefined");if(M(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(j(t))return e.stylize(""+t,"number");if(x(t))return e.stylize(""+t,"boolean");if(C(t))return e.stylize("null","null")}(e,t);if(o)return o;var i=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(i);if(e.showHidden&&(i=Object.getOwnPropertyNames(t)),Y(t)&&(i.indexOf("message")>=0||i.indexOf("description")>=0))return P(t);if(0===i.length){if($(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(q(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(W(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Y(t))return P(t)}var u,c="",f=!1,l=["{","}"];(U(t)&&(f=!0,l=["[","]"]),$(t))&&(c=" [Function"+(t.name?": "+t.name:"")+"]");return q(t)&&(c=" "+RegExp.prototype.toString.call(t)),W(t)&&(c=" "+Date.prototype.toUTCString.call(t)),Y(t)&&(c=" "+P(t)),0!==i.length||f&&0!=t.length?n<0?q(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=f?function(e,t,n,r,o){for(var i=[],s=0,a=t.length;s<a;++s)z(t,String(s))?i.push(L(e,t,n,r,String(s),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(L(e,t,n,r,o,!0))})),i}(e,t,n,s,i):i.map((function(r){return L(e,t,n,s,r,f)})),e.seen.pop(),function(e,t,n){if(e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(u,c,l)):l[0]+c+l[1]}function P(e){return"["+Error.prototype.toString.call(e)+"]"}function L(e,t,n,r,o,i){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),z(r,o)||(s="["+o+"]"),a||(e.seen.indexOf(u.value)<0?(a=C(n)?D(e,u.value,null):D(e,u.value,n-1)).indexOf("\n")>-1&&(a=i?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),k(s)){if(i&&o.match(/^\d+$/))return a;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function U(e){return Array.isArray(e)}function x(e){return"boolean"==typeof e}function C(e){return null===e}function j(e){return"number"==typeof e}function M(e){return"string"==typeof e}function k(e){return void 0===e}function q(e){return F(e)&&"[object RegExp]"===K(e)}function F(e){return"object"===babelHelpers.typeof(e)&&null!==e}function W(e){return F(e)&&"[object Date]"===K(e)}function Y(e){return F(e)&&("[object Error]"===K(e)||e instanceof Error)}function $(e){return"function"==typeof e}function K(e){return Object.prototype.toString.call(e)}function G(e){return e<10?"0"+e.toString(10):e.toString(10)}T.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},T.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var H=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function J(){var e=new Date,t=[G(e.getHours()),G(e.getMinutes()),G(e.getSeconds())].join(":");return[e.getDate(),H[e.getMonth()],t].join(" ")}function V(e,t){if(!t||!F(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function z(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var X={inherits:S,_extend:V,log:function(){console.log("%s - %s",J(),O.apply(null,arguments))},isBuffer:function(e){return r.isBuffer(e)},isPrimitive:function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===babelHelpers.typeof(e)||void 0===e},isFunction:$,isError:Y,isDate:W,isObject:F,isRegExp:q,isUndefined:k,isSymbol:function(e){return"symbol"===babelHelpers.typeof(e)},isString:M,isNumber:j,isNullOrUndefined:function(e){return null==e},isNull:C,isBoolean:x,isArray:U,inspect:T,deprecate:function t(n,r){if(k(e.process))return function(){return t(n,r).apply(this,arguments)};var o=!1;return function(){return o||(console.error(r),o=!0),n.apply(this,arguments)}},format:O,debuglog:function(e){if(k(I)&&(I=""),e=e.toUpperCase(),!N[e])if(new RegExp("\\b"+e+"\\b","i").test(I)){N[e]=function(){var t=O.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else N[e]=function(){};return N[e]}},Z=s((function(e,t){function n(e){const t=w.Buffer.alloc(e);for(let n=0;n<e;++n)t[n]=Math.floor(256*Math.random());return t}if(Object.defineProperty(t,"__esModule",{value:!0}),t.deprecate=t.isObjectLike=t.isDate=t.isBuffer=t.haveBuffer=t.isBigUInt64Array=t.isBigInt64Array=t.isUint8Array=t.randomBytes=t.normalizedFunctionString=void 0,t.normalizedFunctionString=function(e){return e.toString().replace("function(","function (")},t.randomBytes=n,"undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues)t.randomBytes=e=>window.crypto.getRandomValues(w.Buffer.alloc(e));else{try{t.randomBytes=E.randomBytes}catch(e){}null==t.randomBytes&&(t.randomBytes=n)}function r(e){return"object"==typeof e&&null!==e}t.isUint8Array=function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},t.isBigInt64Array=function(e){return"[object BigInt64Array]"===Object.prototype.toString.call(e)},t.isBigUInt64Array=function(e){return"[object BigUint64Array]"===Object.prototype.toString.call(e)},t.haveBuffer=function(){return void 0!==o&&void 0!==o.Buffer},t.isBuffer=function(e){var t;return"object"==typeof e&&"Buffer"===(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)},t.isDate=function(e){return r(e)&&"[object Date]"===Object.prototype.toString.call(e)},t.isObjectLike=r,t.deprecate=function(e,t){if("undefined"==typeof window||"undefined"==typeof self)return X.deprecate(e,t);let n=!1;return function(...r){return n||(console.warn(t),n=!0),e.apply(this,...r)}}}));i(Z);Z.deprecate,Z.isObjectLike,Z.isDate,Z.isBuffer,Z.haveBuffer,Z.isBigUInt64Array,Z.isBigInt64Array,Z.isUint8Array,Z.randomBytes,Z.normalizedFunctionString;var Q=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ensureBuffer=void 0,t.ensureBuffer=function(e){if(Z.isBuffer(e))return e;if(ArrayBuffer.isView(e))return w.Buffer.from(e.buffer);if(e instanceof ArrayBuffer)return w.Buffer.from(e);throw new TypeError("Must use either Buffer or TypedArray")}}));i(Q);Q.ensureBuffer;var ee=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.parseUUID=void 0;const n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;t.parseUUID=function(e){if("string"!=typeof e)throw new TypeError("Invalid type for UUID, expected string but got "+typeof e);if(!n.test(e))throw new TypeError("Invalid format for UUID: "+e);let t;const r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r}}));i(ee);ee.parseUUID;var te=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Binary=void 0;class n{constructor(e,t){if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new TypeError("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=t?t:n.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=w.Buffer.alloc(n.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=w.Buffer.from(e,"binary"):Array.isArray(e)?this.buffer=w.Buffer.from(e):this.buffer=Q.ensureBuffer(e),this.position=this.buffer.byteLength)}put(e){if("string"==typeof e&&1!==e.length)throw new TypeError("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new TypeError("only accepts single character Uint8Array or Array");let t;if(t="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0],t<0||t>255)throw new TypeError("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=t;else{const e=w.Buffer.alloc(n.BUFFER_SIZE+this.buffer.length);this.buffer.copy(e,0,0,this.buffer.length),this.buffer=e,this.buffer[this.position++]=t}}write(e,t){if(t="number"==typeof t?t:this.position,this.buffer.length<t+e.length){const t=w.Buffer.alloc(this.buffer.length+e.length);this.buffer.copy(t,0,0,this.buffer.length),this.buffer=t}ArrayBuffer.isView(e)?(this.buffer.set(Q.ensureBuffer(e),t),this.position=t+e.byteLength>this.position?t+e.length:this.position):"string"==typeof e&&(this.buffer.write(e,t,e.length,"binary"),this.position=t+e.length>this.position?t+e.length:this.position)}read(e,t){return t=t&&t>0?t:this.position,this.buffer.slice(e,e+t)}value(e){return(e=!!e)&&this.buffer.length===this.position?this.buffer:e?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)}length(){return this.position}toJSON(){return this.buffer.toString("base64")}toString(e){return this.buffer.toString(e)}toExtendedJSON(e){e=e||{};const t=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===n.length?"0"+n:n}:{$binary:{base64:t,subType:1===n.length?"0"+n:n}}}static fromExtendedJSON(e,t){let r,o;if(t=t||{},"$binary"in e?t.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,r=w.Buffer.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=w.Buffer.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=w.Buffer.from(ee.parseUUID(e.$uuid))),!r)throw new TypeError("Unexpected Binary Extended JSON format "+JSON.stringify(e));return new n(r,o)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Binary("${this.value(!0).toString("hex")}", ${this.sub_type})`}}t.Binary=n,n.BSON_BINARY_SUBTYPE_DEFAULT=0,n.BUFFER_SIZE=256,n.SUBTYPE_DEFAULT=0,n.SUBTYPE_FUNCTION=1,n.SUBTYPE_BYTE_ARRAY=2,n.SUBTYPE_UUID_OLD=3,n.SUBTYPE_UUID=4,n.SUBTYPE_MD5=5,n.SUBTYPE_USER_DEFINED=128,Object.defineProperty(n.prototype,"_bsontype",{value:"Binary"})}));i(te);te.Binary;var ne=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Code=void 0;class n{constructor(e,t){this.code=e,this.scope=t}toJSON(){return{code:this.code,scope:this.scope}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(e){return new n(e.$code,e.$scope)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){const e=this.toJSON();return`Code("${e.code}"${e.scope?", "+JSON.stringify(e.scope):""})`}}t.Code=n,Object.defineProperty(n.prototype,"_bsontype",{value:"Code"})}));i(ne);ne.Code;var re=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.DBRef=t.isDBRefLike=void 0,t.isDBRefLike=function(e){return Z.isObjectLike(e)&&null!=e.$id&&null!=e.$ref};class n{constructor(e,t,n,r){const o=e.split(".");2===o.length&&(n=o.shift(),e=o.shift()),this.collection=e,this.oid=t,this.db=n,this.fields=r||{}}get namespace(){return this.collection}set namespace(e){this.collection=e}toJSON(){const e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e}toExtendedJSON(e){e=e||{};let t={$ref:this.collection,$id:this.oid};return e.legacy||(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields)),t}static fromExtendedJSON(e){const t=Object.assign({},e);return delete t.$ref,delete t.$id,delete t.$db,new n(e.$ref,e.$id,e.$db,t)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){const e=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return`DBRef("${this.namespace}", "${e}"${this.db?`, "${this.db}"`:""})`}}t.DBRef=n,Object.defineProperty(n.prototype,"_bsontype",{value:"DBRef"})}));i(re);re.DBRef,re.isDBRefLike;var oe=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Long=void 0;let n=void 0;try{n=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}const r={},o={};class i{constructor(e=0,t=0,n){this.low=0|e,this.high=0|t,this.unsigned=!!n,Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}static fromBits(e,t,n){return new i(e,t,n)}static fromInt(e,t){let n,s,a;return t?(a=0<=(e>>>=0)&&e<256)&&(s=o[e],s)?s:(n=i.fromBits(e,(0|e)<0?-1:0,!0),a&&(o[e]=n),n):(a=-128<=(e|=0)&&e<128)&&(s=r[e],s)?s:(n=i.fromBits(e,e<0?-1:0,!1),a&&(r[e]=n),n)}static fromNumber(e,t){if(isNaN(e))return t?i.UZERO:i.ZERO;if(t){if(e<0)return i.UZERO;if(e>=0x10000000000000000)return i.MAX_UNSIGNED_VALUE}else{if(e<=-0x8000000000000000)return i.MIN_VALUE;if(e+1>=0x8000000000000000)return i.MAX_VALUE}return e<0?i.fromNumber(-e,t).neg():i.fromBits(e%4294967296|0,e/4294967296|0,t)}static fromBigInt(e,t){return i.fromString(e.toString(),t)}static fromString(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return i.ZERO;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");let r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return i.fromString(e.substring(1),t,n).neg();const o=i.fromNumber(Math.pow(n,8));let s=i.ZERO;for(let t=0;t<e.length;t+=8){const r=Math.min(8,e.length-t),a=parseInt(e.substring(t,t+r),n);if(r<8){const e=i.fromNumber(Math.pow(n,r));s=s.mul(e).add(i.fromNumber(a))}else s=s.mul(o),s=s.add(i.fromNumber(a))}return s.unsigned=t,s}static fromBytes(e,t,n){return n?i.fromBytesLE(e,t):i.fromBytesBE(e,t)}static fromBytesLE(e,t){return new i(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)}static fromBytesBE(e,t){return new i(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}static isLong(e){return Z.isObjectLike(e)&&!0===e.__isLong__}static fromValue(e,t){return"number"==typeof e?i.fromNumber(e,t):"string"==typeof e?i.fromString(e,t):i.fromBits(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}add(e){i.isLong(e)||(e=i.fromValue(e));const t=this.high>>>16,n=65535&this.high,r=this.low>>>16,o=65535&this.low,s=e.high>>>16,a=65535&e.high,u=e.low>>>16;let c=0,f=0,l=0,h=0;return h+=o+(65535&e.low),l+=h>>>16,h&=65535,l+=r+u,f+=l>>>16,l&=65535,f+=n+a,c+=f>>>16,f&=65535,c+=t+s,c&=65535,i.fromBits(l<<16|h,c<<16|f,this.unsigned)}and(e){return i.isLong(e)||(e=i.fromValue(e)),i.fromBits(this.low&e.low,this.high&e.high,this.unsigned)}compare(e){if(i.isLong(e)||(e=i.fromValue(e)),this.eq(e))return 0;const t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1}comp(e){return this.compare(e)}divide(e){if(i.isLong(e)||(e=i.fromValue(e)),e.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;const t=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,e.low,e.high);return i.fromBits(t,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?i.UZERO:i.ZERO;let t,r,o;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return i.UZERO;if(e.gt(this.shru(1)))return i.UONE;o=i.UZERO}else{if(this.eq(i.MIN_VALUE)){if(e.eq(i.ONE)||e.eq(i.NEG_ONE))return i.MIN_VALUE;if(e.eq(i.MIN_VALUE))return i.ONE;return t=this.shr(1).div(e).shl(1),t.eq(i.ZERO)?e.isNegative()?i.ONE:i.NEG_ONE:(r=this.sub(e.mul(t)),o=t.add(r.div(e)),o)}if(e.eq(i.MIN_VALUE))return this.unsigned?i.UZERO:i.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();o=i.ZERO}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));const n=Math.ceil(Math.log(t)/Math.LN2),s=n<=48?1:Math.pow(2,n-48);let a=i.fromNumber(t),u=a.mul(e);for(;u.isNegative()||u.gt(r);)t-=s,a=i.fromNumber(t,this.unsigned),u=a.mul(e);a.isZero()&&(a=i.ONE),o=o.add(a),r=r.sub(u)}return o}div(e){return this.divide(e)}equals(e){return i.isLong(e)||(e=i.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)}eq(e){return this.equals(e)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(i.MIN_VALUE)?64:this.neg().getNumBitsAbs();const e=0!==this.high?this.high:this.low;let t;for(t=31;t>0&&0==(e&1<<t);t--);return 0!==this.high?t+33:t+1}greaterThan(e){return this.comp(e)>0}gt(e){return this.greaterThan(e)}greaterThanOrEqual(e){return this.comp(e)>=0}gte(e){return this.greaterThanOrEqual(e)}ge(e){return this.greaterThanOrEqual(e)}isEven(){return 0==(1&this.low)}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return 1==(1&this.low)}isPositive(){return this.unsigned||this.high>=0}isZero(){return 0===this.high&&0===this.low}lessThan(e){return this.comp(e)<0}lt(e){return this.lessThan(e)}lessThanOrEqual(e){return this.comp(e)<=0}lte(e){return this.lessThanOrEqual(e)}modulo(e){if(i.isLong(e)||(e=i.fromValue(e)),n){const t=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,e.low,e.high);return i.fromBits(t,n.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))}mod(e){return this.modulo(e)}rem(e){return this.modulo(e)}multiply(e){if(this.isZero())return i.ZERO;if(i.isLong(e)||(e=i.fromValue(e)),n){const t=n.mul(this.low,this.high,e.low,e.high);return i.fromBits(t,n.get_high(),this.unsigned)}if(e.isZero())return i.ZERO;if(this.eq(i.MIN_VALUE))return e.isOdd()?i.MIN_VALUE:i.ZERO;if(e.eq(i.MIN_VALUE))return this.isOdd()?i.MIN_VALUE:i.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(i.TWO_PWR_24)&&e.lt(i.TWO_PWR_24))return i.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);const t=this.high>>>16,r=65535&this.high,o=this.low>>>16,s=65535&this.low,a=e.high>>>16,u=65535&e.high,c=e.low>>>16,f=65535&e.low;let l=0,h=0,p=0,d=0;return d+=s*f,p+=d>>>16,d&=65535,p+=o*f,h+=p>>>16,p&=65535,p+=s*c,h+=p>>>16,p&=65535,h+=r*f,l+=h>>>16,h&=65535,h+=o*c,l+=h>>>16,h&=65535,h+=s*u,l+=h>>>16,h&=65535,l+=t*f+r*c+o*u+s*a,l&=65535,i.fromBits(p<<16|d,l<<16|h,this.unsigned)}mul(e){return this.multiply(e)}negate(){return!this.unsigned&&this.eq(i.MIN_VALUE)?i.MIN_VALUE:this.not().add(i.ONE)}neg(){return this.negate()}not(){return i.fromBits(~this.low,~this.high,this.unsigned)}notEquals(e){return!this.equals(e)}neq(e){return this.notEquals(e)}ne(e){return this.notEquals(e)}or(e){return i.isLong(e)||(e=i.fromValue(e)),i.fromBits(this.low|e.low,this.high|e.high,this.unsigned)}shiftLeft(e){return i.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?i.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):i.fromBits(0,this.low<<e-32,this.unsigned)}shl(e){return this.shiftLeft(e)}shiftRight(e){return i.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?i.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):i.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)}shr(e){return this.shiftRight(e)}shiftRightUnsigned(e){if(i.isLong(e)&&(e=e.toInt()),0===(e&=63))return this;{const t=this.high;if(e<32){const n=this.low;return i.fromBits(n>>>e|t<<32-e,t>>>e,this.unsigned)}return 32===e?i.fromBits(t,0,this.unsigned):i.fromBits(t>>>e-32,0,this.unsigned)}}shr_u(e){return this.shiftRightUnsigned(e)}shru(e){return this.shiftRightUnsigned(e)}subtract(e){return i.isLong(e)||(e=i.fromValue(e)),this.add(e.neg())}sub(e){return this.subtract(e)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(e){return e?this.toBytesLE():this.toBytesBE()}toBytesLE(){const e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]}toBytesBE(){const e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]}toSigned(){return this.unsigned?i.fromBits(this.low,this.high,!1):this}toString(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(i.MIN_VALUE)){const t=i.fromNumber(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}const t=i.fromNumber(Math.pow(e,6),this.unsigned);let n=this,r="";for(;;){const o=n.div(t);let i=(n.sub(o.mul(t)).toInt()>>>0).toString(e);if(n=o,n.isZero())return i+r;for(;i.length<6;)i="0"+i;r=""+i+r}}toUnsigned(){return this.unsigned?this:i.fromBits(this.low,this.high,!0)}xor(e){return i.isLong(e)||(e=i.fromValue(e)),i.fromBits(this.low^e.low,this.high^e.high,this.unsigned)}eqz(){return this.isZero()}le(e){return this.lessThanOrEqual(e)}toExtendedJSON(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(e,t){const n=i.fromString(e.$numberLong);return t&&t.relaxed?n.toNumber():n}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Long("${this.toString()}")`}}t.Long=i,i.TWO_PWR_24=i.fromInt(1<<24),i.MAX_UNSIGNED_VALUE=i.fromBits(-1,-1,!0),i.ZERO=i.fromInt(0),i.UZERO=i.fromInt(0,!0),i.ONE=i.fromInt(1),i.UONE=i.fromInt(1,!0),i.NEG_ONE=i.fromInt(-1),i.MAX_VALUE=i.fromBits(-1,2147483647,!1),i.MIN_VALUE=i.fromBits(0,-2147483648,!1),Object.defineProperty(i.prototype,"__isLong__",{value:!0}),Object.defineProperty(i.prototype,"_bsontype",{value:"Long"})}));i(oe);oe.Long;var ie=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Decimal128=void 0;const n=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,r=/^(\+|-)?(Infinity|inf)$/i,o=/^(\+|-)?NaN$/i,i=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),s=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),a=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),u=/^([-+])?(\d+)?$/;function c(e){return!isNaN(parseInt(e,10))}function f(e){const t=oe.Long.fromNumber(1e9);let n=oe.Long.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:n};for(let r=0;r<=3;r++)n=n.shiftLeft(32),n=n.add(new oe.Long(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function l(e,t){throw new TypeError(`"${e}" is not a valid Decimal128 string - ${t}`)}class h{constructor(e){this.bytes=e}static fromString(e){let t=!1,f=!1,p=!1,d=0,y=0,g=0,_=0,m=0;const v=[0];let b=0,E=0,S=0,A=0,O=0,I=0,N=new oe.Long(0,0),T=new oe.Long(0,0),B=0,R=0;if(e.length>=7e3)throw new TypeError(e+" not a valid Decimal128 string");const D=e.match(n),P=e.match(r),L=e.match(o);if(!D&&!P&&!L||0===e.length)throw new TypeError(e+" not a valid Decimal128 string");if(D){const t=D[2],n=D[4],r=D[5],o=D[6];n&&void 0===o&&l(e,"missing exponent power"),n&&void 0===t&&l(e,"missing exponent base"),void 0===n&&(r||o)&&l(e,"missing e before exponent")}if("+"!==e[R]&&"-"!==e[R]||(t="-"===e[R++]),!c(e[R])&&"."!==e[R]){if("i"===e[R]||"I"===e[R])return new h(w.Buffer.from(t?s:a));if("N"===e[R])return new h(w.Buffer.from(i))}for(;c(e[R])||"."===e[R];)"."!==e[R]?(b<34&&("0"!==e[R]||p)&&(p||(m=y),p=!0,v[E++]=parseInt(e[R],10),b+=1),p&&(g+=1),f&&(_+=1),y+=1,R+=1):(f&&l(e,"contains multiple periods"),f=!0,R+=1);if(f&&!y)throw new TypeError(e+" not a valid Decimal128 string");if("e"===e[R]||"E"===e[R]){const t=e.substr(++R).match(u);if(!t||!t[2])return new h(w.Buffer.from(i));O=parseInt(t[0],10),R+=t[0].length}if(e[R])return new h(w.Buffer.from(i));if(S=0,b){if(A=b-1,d=g,1!==d)for(;"0"===e[m+d-1];)d-=1}else S=0,A=0,v[0]=0,g=1,b=1,d=0;for(O<=_&&_-O>16384?O=-6176:O-=_;O>6111;){if(A+=1,A-S>34){if(v.join("").match(/^0+$/)){O=6111;break}l(e,"overflow")}O-=1}for(;O<-6176||b<g;){if(0===A&&d<b){O=-6176,d=0;break}if(b<g?g-=1:A-=1,O<6111)O+=1;else{if(v.join("").match(/^0+$/)){O=6111;break}l(e,"overflow")}}if(A-S+1<d){let n=y;f&&(m+=1,n+=1),t&&(m+=1,n+=1);const r=parseInt(e[m+A+1],10);let o=0;if(r>=5&&(o=1,5===r))for(o=v[A]%2==1?1:0,I=m+A+2;I<n;I++)if(parseInt(e[I],10)){o=1;break}if(o){let e=A;for(;e>=0;e--)if(++v[e]>9&&(v[e]=0,0===e)){if(!(O<6111))return new h(w.Buffer.from(t?s:a));O+=1,v[e]=1}}}if(N=oe.Long.fromNumber(0),T=oe.Long.fromNumber(0),0===d)N=oe.Long.fromNumber(0),T=oe.Long.fromNumber(0);else if(A-S<17){let e=S;for(T=oe.Long.fromNumber(v[e++]),N=new oe.Long(0,0);e<=A;e++)T=T.multiply(oe.Long.fromNumber(10)),T=T.add(oe.Long.fromNumber(v[e]))}else{let e=S;for(N=oe.Long.fromNumber(v[e++]);e<=A-17;e++)N=N.multiply(oe.Long.fromNumber(10)),N=N.add(oe.Long.fromNumber(v[e]));for(T=oe.Long.fromNumber(v[e++]);e<=A;e++)T=T.multiply(oe.Long.fromNumber(10)),T=T.add(oe.Long.fromNumber(v[e]))}const U=function(e,t){if(!e&&!t)return{high:oe.Long.fromNumber(0),low:oe.Long.fromNumber(0)};const n=e.shiftRightUnsigned(32),r=new oe.Long(e.getLowBits(),0),o=t.shiftRightUnsigned(32),i=new oe.Long(t.getLowBits(),0);let s=n.multiply(o),a=n.multiply(i);const u=r.multiply(o);let c=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new oe.Long(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),s=s.add(a.shiftRightUnsigned(32)),c=a.shiftLeft(32).add(new oe.Long(c.getLowBits(),0)),{high:s,low:c}}(N,oe.Long.fromString("100000000000000000"));U.low=U.low.add(T),function(e,t){const n=e.high>>>0,r=t.high>>>0;if(n<r)return!0;if(n===r){if(e.low>>>0<t.low>>>0)return!0}return!1}(U.low,T)&&(U.high=U.high.add(oe.Long.fromNumber(1))),B=O+6176;const x={low:oe.Long.fromNumber(0),high:oe.Long.fromNumber(0)};U.high.shiftRightUnsigned(49).and(oe.Long.fromNumber(1)).equals(oe.Long.fromNumber(1))?(x.high=x.high.or(oe.Long.fromNumber(3).shiftLeft(61)),x.high=x.high.or(oe.Long.fromNumber(B).and(oe.Long.fromNumber(16383).shiftLeft(47))),x.high=x.high.or(U.high.and(oe.Long.fromNumber(0x7fffffffffff)))):(x.high=x.high.or(oe.Long.fromNumber(16383&B).shiftLeft(49)),x.high=x.high.or(U.high.and(oe.Long.fromNumber(562949953421311)))),x.low=U.low,t&&(x.high=x.high.or(oe.Long.fromString("9223372036854775808")));const C=w.Buffer.alloc(16);return R=0,C[R++]=255&x.low.low,C[R++]=x.low.low>>8&255,C[R++]=x.low.low>>16&255,C[R++]=x.low.low>>24&255,C[R++]=255&x.low.high,C[R++]=x.low.high>>8&255,C[R++]=x.low.high>>16&255,C[R++]=x.low.high>>24&255,C[R++]=255&x.high.low,C[R++]=x.high.low>>8&255,C[R++]=x.high.low>>16&255,C[R++]=x.high.low>>24&255,C[R++]=255&x.high.high,C[R++]=x.high.high>>8&255,C[R++]=x.high.high>>16&255,C[R++]=x.high.high>>24&255,new h(C)}toString(){let e,t=0;const n=new Array(36);for(let e=0;e<n.length;e++)n[e]=0;let r,o,i,s=0,a=!1,u={parts:[0,0,0,0]};const c=[];s=0;const l=this.bytes,h=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,p=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,d=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,y=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24;s=0;({low:new oe.Long(h,p),high:new oe.Long(d,y)}).high.lessThan(oe.Long.ZERO)&&c.push("-");const g=y>>26&31;if(g>>3==3){if(30===g)return c.join("")+"Infinity";if(31===g)return"NaN";e=y>>15&16383,r=8+(y>>14&1)}else r=y>>14&7,e=y>>17&16383;const _=e-6176;if(u.parts[0]=(16383&y)+((15&r)<<14),u.parts[1]=d,u.parts[2]=p,u.parts[3]=h,0===u.parts[0]&&0===u.parts[1]&&0===u.parts[2]&&0===u.parts[3])a=!0;else for(i=3;i>=0;i--){let e=0;const t=f(u);if(u=t.quotient,e=t.rem.low,e)for(o=8;o>=0;o--)n[9*i+o]=e%10,e=Math.floor(e/10)}if(a)t=1,n[s]=0;else for(t=36;!n[s];)t-=1,s+=1;const m=t-1+_;if(m>=34||m<=-7||_>0){if(t>34)return c.push("0"),_>0?c.push("E+"+_):_<0&&c.push("E"+_),c.join("");c.push(""+n[s++]),t-=1,t&&c.push(".");for(let e=0;e<t;e++)c.push(""+n[s++]);c.push("E"),m>0?c.push("+"+m):c.push(""+m)}else if(_>=0)for(let e=0;e<t;e++)c.push(""+n[s++]);else{let e=t+_;if(e>0)for(let t=0;t<e;t++)c.push(""+n[s++]);else c.push("0");for(c.push(".");e++<0;)c.push("0");for(let r=0;r<t-Math.max(e-1,0);r++)c.push(""+n[s++])}return c.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(e){return h.fromString(e.$numberDecimal)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Decimal128("${this.toString()}")`}}t.Decimal128=h,Object.defineProperty(h.prototype,"_bsontype",{value:"Decimal128"})}));i(ie);ie.Decimal128;var se=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Double=void 0;class n{constructor(e){e instanceof Number&&(e=e.valueOf()),this.value=+e}valueOf(){return this.value}toJSON(){return this.value}toExtendedJSON(e){if(e&&(e.legacy||e.relaxed&&isFinite(this.value)))return this.value;if(Object.is(Math.sign(this.value),-0))return{$numberDouble:"-"+this.value.toFixed(1)};let t;return Number.isInteger(this.value)?(t=this.value.toFixed(1),t.length>=13&&(t=this.value.toExponential(13).toUpperCase())):t=this.value.toString(),{$numberDouble:t}}static fromExtendedJSON(e,t){const r=parseFloat(e.$numberDouble);return t&&t.relaxed?r:new n(r)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Double(${this.toExtendedJSON().$numberDouble})`}}t.Double=n,Object.defineProperty(n.prototype,"_bsontype",{value:"Double"})}));i(se);se.Double;var ae=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Int32=void 0;class n{constructor(e){e instanceof Number&&(e=e.valueOf()),this.value=+e}valueOf(){return this.value}toJSON(){return this.value}toExtendedJSON(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(e,t){return t&&t.relaxed?parseInt(e.$numberInt,10):new n(e.$numberInt)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Int32(${this.valueOf()})`}}t.Int32=n,Object.defineProperty(n.prototype,"_bsontype",{value:"Int32"})}));i(ae);ae.Int32;var ue=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MaxKey=void 0;class n{toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new n}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return"MaxKey()"}}t.MaxKey=n,Object.defineProperty(n.prototype,"_bsontype",{value:"MaxKey"})}));i(ue);ue.MaxKey;var ce=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MinKey=void 0;class n{toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new n}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return"MinKey()"}}t.MinKey=n,Object.defineProperty(n.prototype,"_bsontype",{value:"MinKey"})}));i(ce);ce.MinKey;var fe=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ObjectId=void 0;const n=Z.randomBytes(5),r=new RegExp("^[0-9a-fA-F]{24}$"),o=[];for(let e=0;e<256;e++)o[e]=(e<=15?"0":"")+e.toString(16);const i=[];let s=0;for(;s<10;)i[48+s]=s++;for(;s<16;)i[55+s]=i[87+s]=s++;const a=Symbol("id");class u{constructor(e){if(e instanceof u&&(this[a]=e.id,this.__id=e.__id),"object"==typeof e&&e&&"id"in e&&("toHexString"in e&&"function"==typeof e.toHexString?this[a]=w.Buffer.from(e.toHexString(),"hex"):this[a]="string"==typeof e.id?w.Buffer.from(e.id):e.id),null!=e&&"number"!=typeof e||(this[a]=u.generate("number"==typeof e?e:void 0),u.cacheHexString&&(this.__id=this.id.toString("hex"))),ArrayBuffer.isView(e)&&12===e.byteLength&&(this[a]=Q.ensureBuffer(e)),"string"==typeof e)if(12===e.length){const t=w.Buffer.from(e);12===t.byteLength&&(this[a]=t)}else{if(24!==e.length||!r.test(e))throw new TypeError("Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters");this[a]=w.Buffer.from(e,"hex")}u.cacheHexString&&(this.__id=this.id.toString("hex"))}get id(){return this[a]}set id(e){this[a]=e,u.cacheHexString&&(this.__id=e.toString("hex"))}get generationTime(){return this.id.readInt32BE(0)}set generationTime(e){this.id.writeUInt32BE(e,0)}toHexString(){if(u.cacheHexString&&this.__id)return this.__id;const e=this.id.toString("hex");return u.cacheHexString&&!this.__id&&(this.__id=e),e}static getInc(){return u.index=(u.index+1)%16777215}static generate(e){"number"!=typeof e&&(e=~~(Date.now()/1e3));const t=u.getInc(),r=w.Buffer.alloc(12);return r.writeUInt32BE(e,0),r[4]=n[0],r[5]=n[1],r[6]=n[2],r[7]=n[3],r[8]=n[4],r[11]=255&t,r[10]=t>>8&255,r[9]=t>>16&255,r}toString(e){return e?this.id.toString(e):this.toHexString()}toJSON(){return this.toHexString()}equals(e){return null!=e&&(e instanceof u?this.toString()===e.toString():"string"==typeof e&&u.isValid(e)&&12===e.length&&this.id instanceof w.Buffer?e===this.id.toString("binary"):"string"==typeof e&&u.isValid(e)&&24===e.length?e.toLowerCase()===this.toHexString():"string"==typeof e&&u.isValid(e)&&12===e.length?w.Buffer.from(e).equals(this.id):"object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString&&e.toHexString()===this.toHexString())}getTimestamp(){const e=new Date,t=this.id.readUInt32BE(0);return e.setTime(1e3*Math.floor(t)),e}static createPk(){return new u}static createFromTime(e){const t=w.Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0]);return t.writeUInt32BE(e,0),new u(t)}static createFromHexString(e){if(void 0===e||null!=e&&24!==e.length)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new u(w.Buffer.from(e,"hex"))}static isValid(e){return null!=e&&("number"==typeof e||("string"==typeof e?12===e.length||24===e.length&&r.test(e):e instanceof u||(e instanceof w.Buffer&&12===e.length||"object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString&&("string"==typeof e.id?12===e.id.length:24===e.toHexString().length&&r.test(e.id.toString("hex"))))))}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(e){return new u(e.$oid)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`ObjectId("${this.toHexString()}")`}}t.ObjectId=u,u.index=~~(16777215*Math.random()),Object.defineProperty(u.prototype,"generate",{value:Z.deprecate(e=>u.generate(e),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(u.prototype,"getInc",{value:Z.deprecate(()=>u.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(u.prototype,"get_inc",{value:Z.deprecate(()=>u.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(u,"get_inc",{value:Z.deprecate(()=>u.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(u.prototype,"_bsontype",{value:"ObjectID"})}));i(fe);fe.ObjectId;var le=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSONRegExp=void 0;class n{constructor(e,t){this.pattern=e,this.options=null!=t?t:"",this.options.split("").sort().join("");for(let e=0;e<this.options.length;e++)if("i"!==this.options[e]&&"m"!==this.options[e]&&"x"!==this.options[e]&&"l"!==this.options[e]&&"s"!==this.options[e]&&"u"!==this.options[e])throw new Error(`The regular expression option [${this.options[e]}] is not supported`)}static parseOptions(e){return e?e.split("").sort().join(""):""}toExtendedJSON(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(e){if("$regex"in e){if("string"==typeof e.$regex)return new n(e.$regex,n.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new n(e.$regularExpression.pattern,n.parseOptions(e.$regularExpression.options));throw new TypeError("Unexpected BSONRegExp EJSON object form: "+JSON.stringify(e))}}t.BSONRegExp=n,Object.defineProperty(n.prototype,"_bsontype",{value:"BSONRegExp"})}));i(le);le.BSONRegExp;var he=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSONSymbol=void 0;class n{constructor(e){this.value=e}valueOf(){return this.value}toString(){return this.value}inspect(){return`BSONSymbol("${this.value}")`}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(e){return new n(e.$symbol)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}}t.BSONSymbol=n,Object.defineProperty(n.prototype,"_bsontype",{value:"Symbol"})}));i(he);he.BSONSymbol;var pe=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Timestamp=t.LongWithoutOverridesClass=void 0,t.LongWithoutOverridesClass=oe.Long;class n extends t.LongWithoutOverridesClass{constructor(e,t){oe.Long.isLong(e)?super(e.low,e.high,!0):super(e,t,!0),Object.defineProperty(this,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1})}toJSON(){return{$timestamp:this.toString()}}static fromInt(e){return new n(oe.Long.fromInt(e,!0))}static fromNumber(e){return new n(oe.Long.fromNumber(e,!0))}static fromBits(e,t){return new n(e,t)}static fromString(e,t){return new n(oe.Long.fromString(e,!0,t))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(e){return new n(e.$timestamp.i,e.$timestamp.t)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Timestamp(${this.getLowBits().toString()}, ${this.getHighBits().toString()})`}}t.Timestamp=n,n.MAX_VALUE=oe.Long.MAX_UNSIGNED_VALUE}));i(pe);pe.Timestamp,pe.LongWithoutOverridesClass;var de=s((function(e,t){function n(e){return Z.isObjectLike(e)&&Reflect.has(e,"_bsontype")&&"string"==typeof e._bsontype}Object.defineProperty(t,"__esModule",{value:!0}),t.EJSON=t.isBSONType=void 0,t.isBSONType=n;const r={$oid:fe.ObjectId,$binary:te.Binary,$uuid:te.Binary,$symbol:he.BSONSymbol,$numberInt:ae.Int32,$numberDecimal:ie.Decimal128,$numberDouble:se.Double,$numberLong:oe.Long,$minKey:ce.MinKey,$maxKey:ue.MaxKey,$regex:le.BSONRegExp,$regularExpression:le.BSONRegExp,$timestamp:pe.Timestamp};function o(e){const t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function i(e,t){if(Array.isArray(e))return function(e,t){return e.map(e=>i(e,t))}(e,t);if(void 0===e)return null;if(e instanceof Date){const n=e.getTime(),r=n>-1&&n<2534023188e5;return t.legacy?t.relaxed&&r?{$date:e.getTime()}:{$date:o(e)}:t.relaxed&&r?{$date:o(e)}:{$date:{$numberLong:e.getTime().toString()}}}if("number"==typeof e&&!t.relaxed){if(Math.floor(e)===e){const t=e>=-0x8000000000000000&&e<=0x8000000000000000;if(e>=-2147483648&&e<=2147483647)return{$numberInt:e.toString()};if(t)return{$numberLong:e.toString()}}return{$numberDouble:e.toString()}}if(e instanceof RegExp){let n=e.flags;if(void 0===n){const t=e.toString().match(/[gimuy]*$/);t&&(n=t[0])}return new le.BSONRegExp(e.source,n).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new Error("not an object instance");const r=e._bsontype;if(void 0===r){const n={};for(const r in e)n[r]=i(e[r],t);return n}if(n(e)){let n=e;if("function"!=typeof n.toExtendedJSON){const t=s[e._bsontype];if(!t)throw new TypeError("Unrecognized or invalid _bsontype: "+e._bsontype);n=t(n)}return"Code"===r&&n.scope?n=new ne.Code(n.code,i(n.scope,t)):"DBRef"===r&&n.oid&&(n=new re.DBRef(n.collection,i(n.oid,t),n.db,n.fields)),n.toExtendedJSON(t)}throw new Error("_bsontype must be a string, but was: "+typeof r)}(e,t):e}const s={Binary:e=>new te.Binary(e.value(),e.sub_type),Code:e=>new ne.Code(e.code,e.scope),DBRef:e=>new re.DBRef(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new ie.Decimal128(e.bytes),Double:e=>new se.Double(e.value),Int32:e=>new ae.Int32(e.value),Long:e=>oe.Long.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_),MaxKey:()=>new ue.MaxKey,MinKey:()=>new ce.MinKey,ObjectID:e=>new fe.ObjectId(e),ObjectId:e=>new fe.ObjectId(e),BSONRegExp:e=>new le.BSONRegExp(e.pattern,e.options),Symbol:e=>new he.BSONSymbol(e.value),Timestamp:e=>pe.Timestamp.fromBits(e.low,e.high)};!function(e){function t(e,t){const n=Object.assign({},{relaxed:!0,legacy:!1},t);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(e,(e,t)=>function e(t,n={}){if("number"==typeof t){if(n.relaxed||n.legacy)return t;if(Math.floor(t)===t){if(t>=-2147483648&&t<=2147483647)return new ae.Int32(t);if(t>=-0x8000000000000000&&t<=0x8000000000000000)return oe.Long.fromNumber(t)}return new se.Double(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;const o=Object.keys(t).filter(e=>e.startsWith("$")&&null!=t[e]);for(let e=0;e<o.length;e++){const i=r[o[e]];if(i)return i.fromExtendedJSON(t,n)}if(null!=t.$date){const e=t.$date,r=new Date;return n.legacy?"number"==typeof e?r.setTime(e):"string"==typeof e&&r.setTime(Date.parse(e)):"string"==typeof e?r.setTime(Date.parse(e)):oe.Long.isLong(e)?r.setTime(e.toNumber()):"number"==typeof e&&n.relaxed&&r.setTime(e),r}if(null!=t.$code){const n=Object.assign({},t);return t.$scope&&(n.$scope=e(t.$scope)),ne.Code.fromExtendedJSON(t)}if(null!=t.$ref||null!=t.$dbPointer){const e=t.$ref?t:t.$dbPointer;if(e instanceof re.DBRef)return e;const n=Object.keys(e).filter(e=>e.startsWith("$"));let r=!0;if(n.forEach(e=>{-1===["$ref","$id","$db"].indexOf(e)&&(r=!1)}),r)return re.DBRef.fromExtendedJSON(e)}return t}(t,n))}function n(e,t,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==t||"object"!=typeof t||Array.isArray(t)||(r=t,t=void 0,n=0);const o=i(e,r=Object.assign({},{relaxed:!0,legacy:!1},r));return JSON.stringify(o,t,n)}e.parse=t,e.stringify=n,e.serialize=function(e,t){return t=t||{},JSON.parse(n(e,t))},e.deserialize=function(e,n){return n=n||{},t(JSON.stringify(e),n)}}(t.EJSON||(t.EJSON={}))}));i(de);de.EJSON,de.isBSONType;var ye=s((function(e,t){let n;Object.defineProperty(t,"__esModule",{value:!0}),t.Map=void 0,t.Map=n;const r=function(e){return e&&e.Math==Math&&e};const i=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof o&&o)||Function("return this")();Object.prototype.hasOwnProperty.call(i,"Map")?t.Map=n=i.Map:t.Map=n=class{constructor(e=[]){this._keys=[],this._values={};for(let t=0;t<e.length;t++){if(null==e[t])continue;const n=e[t],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}clear(){this._keys=[],this._values={}}delete(e){const t=this._values[e];return null!=t&&(delete this._values[e],this._keys.splice(t.i,1),!0)}entries(){let e=0;return{next:()=>{const t=this._keys[e++];return{value:void 0!==t?[t,this._values[t].v]:void 0,done:void 0===t}}}}forEach(e,t){t=t||this;for(let n=0;n<this._keys.length;n++){const r=this._keys[n];e.call(t,this._values[r].v,r,t)}}get(e){return this._values[e]?this._values[e].v:void 0}has(e){return null!=this._values[e]}keys(){let e=0;return{next:()=>{const t=this._keys[e++];return{value:void 0!==t?t:void 0,done:void 0===t}}}}set(e,t){return this._values[e]?(this._values[e].v=t,this):(this._keys.push(e),this._values[e]={v:t,i:this._keys.length-1},this)}values(){let e=0;return{next:()=>{const t=this._keys[e++];return{value:void 0!==t?this._values[t].v:void 0,done:void 0===t}}}}get size(){return this._keys.length}}}));i(ye);ye.Map;var ge=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSON_BINARY_SUBTYPE_USER_DEFINED=t.BSON_BINARY_SUBTYPE_MD5=t.BSON_BINARY_SUBTYPE_UUID_NEW=t.BSON_BINARY_SUBTYPE_UUID=t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=t.BSON_BINARY_SUBTYPE_FUNCTION=t.BSON_BINARY_SUBTYPE_DEFAULT=t.BSON_DATA_MAX_KEY=t.BSON_DATA_MIN_KEY=t.BSON_DATA_DECIMAL128=t.BSON_DATA_LONG=t.BSON_DATA_TIMESTAMP=t.BSON_DATA_INT=t.BSON_DATA_CODE_W_SCOPE=t.BSON_DATA_SYMBOL=t.BSON_DATA_CODE=t.BSON_DATA_DBPOINTER=t.BSON_DATA_REGEXP=t.BSON_DATA_NULL=t.BSON_DATA_DATE=t.BSON_DATA_BOOLEAN=t.BSON_DATA_OID=t.BSON_DATA_UNDEFINED=t.BSON_DATA_BINARY=t.BSON_DATA_ARRAY=t.BSON_DATA_OBJECT=t.BSON_DATA_STRING=t.BSON_DATA_NUMBER=t.JS_INT_MIN=t.JS_INT_MAX=t.BSON_INT64_MIN=t.BSON_INT64_MAX=t.BSON_INT32_MIN=t.BSON_INT32_MAX=void 0,t.BSON_INT32_MAX=2147483647,t.BSON_INT32_MIN=-2147483648,t.BSON_INT64_MAX=Math.pow(2,63)-1,t.BSON_INT64_MIN=-Math.pow(2,63),t.JS_INT_MAX=Math.pow(2,53),t.JS_INT_MIN=-Math.pow(2,53),t.BSON_DATA_NUMBER=1,t.BSON_DATA_STRING=2,t.BSON_DATA_OBJECT=3,t.BSON_DATA_ARRAY=4,t.BSON_DATA_BINARY=5,t.BSON_DATA_UNDEFINED=6,t.BSON_DATA_OID=7,t.BSON_DATA_BOOLEAN=8,t.BSON_DATA_DATE=9,t.BSON_DATA_NULL=10,t.BSON_DATA_REGEXP=11,t.BSON_DATA_DBPOINTER=12,t.BSON_DATA_CODE=13,t.BSON_DATA_SYMBOL=14,t.BSON_DATA_CODE_W_SCOPE=15,t.BSON_DATA_INT=16,t.BSON_DATA_TIMESTAMP=17,t.BSON_DATA_LONG=18,t.BSON_DATA_DECIMAL128=19,t.BSON_DATA_MIN_KEY=255,t.BSON_DATA_MAX_KEY=127,t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BSON_BINARY_SUBTYPE_FUNCTION=1,t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,t.BSON_BINARY_SUBTYPE_UUID=3,t.BSON_BINARY_SUBTYPE_UUID_NEW=4,t.BSON_BINARY_SUBTYPE_MD5=5,t.BSON_BINARY_SUBTYPE_USER_DEFINED=128}));i(ge);ge.BSON_BINARY_SUBTYPE_USER_DEFINED,ge.BSON_BINARY_SUBTYPE_MD5,ge.BSON_BINARY_SUBTYPE_UUID_NEW,ge.BSON_BINARY_SUBTYPE_UUID,ge.BSON_BINARY_SUBTYPE_BYTE_ARRAY,ge.BSON_BINARY_SUBTYPE_FUNCTION,ge.BSON_BINARY_SUBTYPE_DEFAULT,ge.BSON_DATA_MAX_KEY,ge.BSON_DATA_MIN_KEY,ge.BSON_DATA_DECIMAL128,ge.BSON_DATA_LONG,ge.BSON_DATA_TIMESTAMP,ge.BSON_DATA_INT,ge.BSON_DATA_CODE_W_SCOPE,ge.BSON_DATA_SYMBOL,ge.BSON_DATA_CODE,ge.BSON_DATA_DBPOINTER,ge.BSON_DATA_REGEXP,ge.BSON_DATA_NULL,ge.BSON_DATA_DATE,ge.BSON_DATA_BOOLEAN,ge.BSON_DATA_OID,ge.BSON_DATA_UNDEFINED,ge.BSON_DATA_BINARY,ge.BSON_DATA_ARRAY,ge.BSON_DATA_OBJECT,ge.BSON_DATA_STRING,ge.BSON_DATA_NUMBER,ge.JS_INT_MIN,ge.JS_INT_MAX,ge.BSON_INT64_MIN,ge.BSON_INT64_MAX,ge.BSON_INT32_MIN,ge.BSON_INT32_MAX;var _e=s((function(e,t){function n(e,t,n){let o=5;if(Array.isArray(e))for(let i=0;i<e.length;i++)o+=r(i.toString(),e[i],t,!0,n);else{e.toBSON&&(e=e.toBSON());for(const i in e)o+=r(i,e[i],t,!1,n)}return o}function r(e,t,r=!1,o=!1,i=!1){switch(t&&t.toBSON&&(t=t.toBSON()),typeof t){case"string":return 1+w.Buffer.byteLength(e,"utf8")+1+4+w.Buffer.byteLength(t,"utf8")+1;case"number":return Math.floor(t)===t&&t>=ge.JS_INT_MIN&&t<=ge.JS_INT_MAX&&t>=ge.BSON_INT32_MIN&&t<=ge.BSON_INT32_MAX?(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+5:(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+9;case"undefined":return o||!i?(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1:0;case"boolean":return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+2;case"object":if(null==t||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1;if("ObjectId"===t._bsontype||"ObjectID"===t._bsontype)return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+13;if(t instanceof Date||Z.isDate(t))return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+9;if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer)return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+6+t.byteLength;if("Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+9;if("Decimal128"===t._bsontype)return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+17;if("Code"===t._bsontype)return null!=t.scope&&Object.keys(t.scope).length>0?(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1+4+4+w.Buffer.byteLength(t.code.toString(),"utf8")+1+n(t.scope,r,i):(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1+4+w.Buffer.byteLength(t.code.toString(),"utf8")+1;if("Binary"===t._bsontype)return t.sub_type===te.Binary.SUBTYPE_BYTE_ARRAY?(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1+4):(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1);if("Symbol"===t._bsontype)return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+w.Buffer.byteLength(t.value,"utf8")+4+1+1;if("DBRef"===t._bsontype){const o=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return null!=t.db&&(o.$db=t.db),(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1+n(o,r,i)}return t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)?(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1+w.Buffer.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:"BSONRegExp"===t._bsontype?(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1+w.Buffer.byteLength(t.pattern,"utf8")+1+w.Buffer.byteLength(t.options,"utf8")+1:(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+n(t,r,i)+1;case"function":if(t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)||"[object RegExp]"===String.call(t))return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1+w.Buffer.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1;if(r&&null!=t.scope&&Object.keys(t.scope).length>0)return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1+4+4+w.Buffer.byteLength(Z.normalizedFunctionString(t),"utf8")+1+n(t.scope,r,i);if(r)return(null!=e?w.Buffer.byteLength(e,"utf8")+1:0)+1+4+w.Buffer.byteLength(Z.normalizedFunctionString(t),"utf8")+1}return 0}Object.defineProperty(t,"__esModule",{value:!0}),t.calculateObjectSize=void 0,t.calculateObjectSize=n}));i(_e);_e.calculateObjectSize;var me=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateUtf8=void 0;t.validateUtf8=function(e,t,n){let r=0;for(let o=t;o<n;o+=1){const t=e[o];if(r){if(128!=(192&t))return!1;r-=1}else if(128&t)if(192==(224&t))r=1;else if(224==(240&t))r=2;else{if(240!=(248&t))return!1;r=3}}return!r}}));i(me);me.validateUtf8;var ve=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deserialize=void 0;const n=oe.Long.fromNumber(ge.JS_INT_MAX),r=oe.Long.fromNumber(ge.JS_INT_MIN),o={};function i(e,t,a,u=!1){const c=null!=a.evalFunctions&&a.evalFunctions,f=null!=a.cacheFunctions&&a.cacheFunctions,l=null==a.fieldsAsRaw?null:a.fieldsAsRaw,h=null!=a.raw&&a.raw,p="boolean"==typeof a.bsonRegExp&&a.bsonRegExp,d=null!=a.promoteBuffers&&a.promoteBuffers,y=null==a.promoteLongs||a.promoteLongs,g=null==a.promoteValues||a.promoteValues,_=t;if(e.length<5)throw new Error("corrupt bson message < 5 bytes long");const m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<5||m>e.length)throw new Error("corrupt bson message");const v=u?[]:{};let b=0;for(;;){const _=e[t++];if(0===_)break;let m=t;for(;0!==e[m]&&m<e.length;)m++;if(m>=e.byteLength)throw new Error("Bad BSON Document: illegal CString");const E=u?b++:e.toString("utf8",t,m);if(t=m+1,_===ge.BSON_DATA_STRING){const n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(n<=0||n>e.length-t||0!==e[t+n-1])throw new Error("bad string length in bson");if(!me.validateUtf8(e,t,t+n-1))throw new Error("Invalid UTF-8 string in BSON document");const r=e.toString("utf8",t,t+n-1);v[E]=r,t+=n}else if(_===ge.BSON_DATA_OID){const n=w.Buffer.alloc(12);e.copy(n,0,t,t+12),v[E]=new fe.ObjectId(n),t+=12}else if(_===ge.BSON_DATA_INT&&!1===g)v[E]=new ae.Int32(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(_===ge.BSON_DATA_INT)v[E]=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(_===ge.BSON_DATA_NUMBER&&!1===g)v[E]=new se.Double(e.readDoubleLE(t)),t+=8;else if(_===ge.BSON_DATA_NUMBER)v[E]=e.readDoubleLE(t),t+=8;else if(_===ge.BSON_DATA_DATE){const n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;v[E]=new Date(new oe.Long(n,r).toNumber())}else if(_===ge.BSON_DATA_BOOLEAN){if(0!==e[t]&&1!==e[t])throw new Error("illegal boolean type value");v[E]=1===e[t++]}else if(_===ge.BSON_DATA_OBJECT){const n=t,r=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(r<=0||r>e.length-t)throw new Error("bad embedded document length in bson");v[E]=h?e.slice(t,t+r):i(e,n,a,!1),t+=r}else if(_===ge.BSON_DATA_ARRAY){const n=t,r=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;let o=a;const s=t+r;if(l&&l[E]){o={};for(const e in a)o[e]=a[e];o.raw=!0}if(v[E]=i(e,n,o,!0),0!==e[(t+=r)-1])throw new Error("invalid array terminator byte");if(t!==s)throw new Error("corrupted array bson")}else if(_===ge.BSON_DATA_UNDEFINED)v[E]=void 0;else if(_===ge.BSON_DATA_NULL)v[E]=null;else if(_===ge.BSON_DATA_LONG){const o=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,i=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,s=new oe.Long(o,i);v[E]=y&&!0===g&&s.lessThanOrEqual(n)&&s.greaterThanOrEqual(r)?s.toNumber():s}else if(_===ge.BSON_DATA_DECIMAL128){const n=w.Buffer.alloc(16);e.copy(n,0,t,t+16),t+=16;const r=new ie.Decimal128(n);"toObject"in r&&"function"==typeof r.toObject?v[E]=r.toObject():v[E]=r}else if(_===ge.BSON_DATA_BINARY){let n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;const r=n,o=e[t++];if(n<0)throw new Error("Negative binary type element size found");if(n>e.byteLength)throw new Error("Binary type size larger than document size");if(null!=e.slice){if(o===te.Binary.SUBTYPE_BYTE_ARRAY){if(n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,n<0)throw new Error("Negative binary type element size found for subtype 0x02");if(n>r-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(n<r-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}v[E]=d&&g?e.slice(t,t+n):new te.Binary(e.slice(t,t+n),o)}else{const i=w.Buffer.alloc(n);if(o===te.Binary.SUBTYPE_BYTE_ARRAY){if(n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,n<0)throw new Error("Negative binary type element size found for subtype 0x02");if(n>r-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(n<r-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}for(m=0;m<n;m++)i[m]=e[t+m];v[E]=d&&g?i:new te.Binary(i,o)}t+=n}else if(_===ge.BSON_DATA_REGEXP&&!1===p){for(m=t;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");const n=e.toString("utf8",t,m);for(m=t=m+1;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");const r=e.toString("utf8",t,m);t=m+1;const o=new Array(r.length);for(m=0;m<r.length;m++)switch(r[m]){case"m":o[m]="m";break;case"s":o[m]="g";break;case"i":o[m]="i"}v[E]=new RegExp(n,o.join(""))}else if(_===ge.BSON_DATA_REGEXP&&!0===p){for(m=t;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");const n=e.toString("utf8",t,m);for(m=t=m+1;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");const r=e.toString("utf8",t,m);t=m+1,v[E]=new le.BSONRegExp(n,r)}else if(_===ge.BSON_DATA_SYMBOL){const n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(n<=0||n>e.length-t||0!==e[t+n-1])throw new Error("bad string length in bson");const r=e.toString("utf8",t,t+n-1);v[E]=g?r:new he.BSONSymbol(r),t+=n}else if(_===ge.BSON_DATA_TIMESTAMP){const n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;v[E]=new pe.Timestamp(n,r)}else if(_===ge.BSON_DATA_MIN_KEY)v[E]=new ce.MinKey;else if(_===ge.BSON_DATA_MAX_KEY)v[E]=new ue.MaxKey;else if(_===ge.BSON_DATA_CODE){const n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(n<=0||n>e.length-t||0!==e[t+n-1])throw new Error("bad string length in bson");const r=e.toString("utf8",t,t+n-1);v[E]=c?f?s(r,o,v):s(r):new ne.Code(r),t+=n}else if(_===ge.BSON_DATA_CODE_W_SCOPE){const n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(n<13)throw new Error("code_w_scope total size shorter minimum expected length");const r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(r<=0||r>e.length-t||0!==e[t+r-1])throw new Error("bad string length in bson");const u=e.toString("utf8",t,t+r-1),l=t+=r,h=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,p=i(e,l,a,!1);if(t+=h,n<8+h+r)throw new Error("code_w_scope total size is too short, truncating scope");if(n>8+h+r)throw new Error("code_w_scope total size is too long, clips outer document");c?(v[E]=f?s(u,o,v):s(u),v[E].scope=p):v[E]=new ne.Code(u,p)}else{if(_!==ge.BSON_DATA_DBPOINTER)throw new Error("Detected unknown BSON type "+_.toString(16)+' for fieldname "'+E+'"');{const n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(n<=0||n>e.length-t||0!==e[t+n-1])throw new Error("bad string length in bson");if(!me.validateUtf8(e,t,t+n-1))throw new Error("Invalid UTF-8 string in BSON document");const r=e.toString("utf8",t,t+n-1);t+=n;const o=w.Buffer.alloc(12);e.copy(o,0,t,t+12);const i=new fe.ObjectId(o);t+=12,v[E]=new re.DBRef(r,i)}}}if(m!==t-_){if(u)throw new Error("corrupt array bson");throw new Error("corrupt object bson")}const E=Object.keys(v).filter(e=>e.startsWith("$"));let S=!0;if(E.forEach(e=>{-1===["$ref","$id","$db"].indexOf(e)&&(S=!1)}),!S)return v;if(re.isDBRefLike(v)){const e=Object.assign({},v);return delete e.$ref,delete e.$id,delete e.$db,new re.DBRef(v.$ref,v.$id,v.$db,e)}return v}function s(e,t,n){return t?(null==t[e]&&(t[e]=new Function(e)),t[e].bind(n)):new Function(e)}t.deserialize=function(e,t,n){const r=(t=null==t?{}:t)&&t.index?t.index:0,o=e[r]|e[r+1]<<8|e[r+2]<<16|e[r+3]<<24;if(o<5)throw new Error("bson size must be >= 5, is "+o);if(t.allowObjectSmallerThanBufferSize&&e.length<o)throw new Error(`buffer length ${e.length} must be >= bson size ${o}`);if(!t.allowObjectSmallerThanBufferSize&&e.length!==o)throw new Error(`buffer length ${e.length} must === bson size ${o}`);if(o+r>e.byteLength)throw new Error(`(bson size ${o} + options.index ${r} must be <= buffer length ${e.byteLength})`);if(0!==e[r+o-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return i(e,r,t,n)}}));i(ve);ve.deserialize;var be=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.writeIEEE754=t.readIEEE754=void 0,t.readIEEE754=function(e,t,n,r,o){let i,s;const a="big"===n,u=8*o-r-1,c=(1<<u)-1,f=c>>1;let l=-7,h=a?0:o-1;const p=a?1:-1;let d=e[t+h];for(h+=p,i=d&(1<<-l)-1,d>>=-l,l+=u;l>0;i=256*i+e[t+h],h+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=p,l-=8);if(0===i)i=1-f;else{if(i===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),i-=f}return(d?-1:1)*s*Math.pow(2,i-r)},t.writeIEEE754=function(e,t,n,r,o,i){let s,a,u;const c="big"===r;let f=8*i-o-1;const l=(1<<f)-1,h=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0;let d=c?i-1:0;const y=c?-1:1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?p/u:p*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*u-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0)),isNaN(t)&&(a=0);o>=8;)e[n+d]=255&a,d+=y,a/=256,o-=8;for(s=s<<o|a,isNaN(t)&&(s+=8),f+=o;f>0;)e[n+d]=255&s,d+=y,s/=256,f-=8;e[n+d-y]|=128*g}}));i(be);be.writeIEEE754,be.readIEEE754;var we=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeInto=void 0;const n=/\x00/,r=new Set(["$db","$ref","$id","$clusterTime"]);function o(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function i(e,t,n,r,o){e[r++]=ge.BSON_DATA_STRING;const i=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8");e[(r=r+i+1)-1]=0;const s=e.write(n,r+4,void 0,"utf8");return e[r+3]=s+1>>24&255,e[r+2]=s+1>>16&255,e[r+1]=s+1>>8&255,e[r]=s+1&255,r=r+4+s,e[r++]=0,r}function s(e,t,n,r,o){if(Number.isInteger(n)&&n>=ge.BSON_INT32_MIN&&n<=ge.BSON_INT32_MAX){e[r++]=ge.BSON_DATA_INT;r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,e[r++]=255&n,e[r++]=n>>8&255,e[r++]=n>>16&255,e[r++]=n>>24&255}else{e[r++]=ge.BSON_DATA_NUMBER;r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,be.writeIEEE754(e,n,r,"little",52,8),r+=8}return r}function a(e,t,n,r,o){e[r++]=ge.BSON_DATA_NULL;return r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,r}function u(e,t,n,r,o){e[r++]=ge.BSON_DATA_BOOLEAN;return r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,e[r++]=n?1:0,r}function c(e,t,n,r,o){e[r++]=ge.BSON_DATA_DATE;r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;const i=oe.Long.fromNumber(n.getTime()),s=i.getLowBits(),a=i.getHighBits();return e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=255&a,e[r++]=a>>8&255,e[r++]=a>>16&255,e[r++]=a>>24&255,r}function f(e,t,r,o,i){e[o++]=ge.BSON_DATA_REGEXP;if(o+=i?e.write(t,o,void 0,"ascii"):e.write(t,o,void 0,"utf8"),e[o++]=0,r.source&&null!=r.source.match(n))throw Error("value "+r.source+" must not contain null bytes");return o+=e.write(r.source,o,void 0,"utf8"),e[o++]=0,r.ignoreCase&&(e[o++]=105),r.global&&(e[o++]=115),r.multiline&&(e[o++]=109),e[o++]=0,o}function l(e,t,r,o,i){e[o++]=ge.BSON_DATA_REGEXP;if(o+=i?e.write(t,o,void 0,"ascii"):e.write(t,o,void 0,"utf8"),e[o++]=0,null!=r.pattern.match(n))throw Error("pattern "+r.pattern+" must not contain null bytes");return o+=e.write(r.pattern,o,void 0,"utf8"),e[o++]=0,o+=e.write(r.options.split("").sort().join(""),o,void 0,"utf8"),e[o++]=0,o}function h(e,t,n,r,o){null===n?e[r++]=ge.BSON_DATA_NULL:"MinKey"===n._bsontype?e[r++]=ge.BSON_DATA_MIN_KEY:e[r++]=ge.BSON_DATA_MAX_KEY;return r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,r}function p(e,t,n,r,o){e[r++]=ge.BSON_DATA_OID;if(r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,"string"==typeof n.id)e.write(n.id,r,void 0,"binary");else{if(!n.id||!n.id.copy)throw new TypeError("object ["+JSON.stringify(n)+"] is not a valid ObjectId");n.id.copy(e,r,0,12)}return r+12}function d(e,t,n,r,o){e[r++]=ge.BSON_DATA_BINARY;r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;const i=n.length;return e[r++]=255&i,e[r++]=i>>8&255,e[r++]=i>>16&255,e[r++]=i>>24&255,e[r++]=ge.BSON_BINARY_SUBTYPE_DEFAULT,e.set(Q.ensureBuffer(n),r),r+=i}function y(e,t,n,r,o=!1,i=0,s=!1,a=!0,u=!1,c=[]){for(let e=0;e<c.length;e++)if(c[e]===n)throw new Error("cyclic dependency detected");c.push(n),e[r++]=Array.isArray(n)?ge.BSON_DATA_ARRAY:ge.BSON_DATA_OBJECT;r+=u?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;const f=O(e,n,o,r,i+1,s,a,c);return c.pop(),f}function g(e,t,n,r,o){e[r++]=ge.BSON_DATA_DECIMAL128;return r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,n.bytes.copy(e,r,0,16),r+16}function _(e,t,n,r,o){e[r++]="Long"===n._bsontype?ge.BSON_DATA_LONG:ge.BSON_DATA_TIMESTAMP;r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;const i=n.getLowBits(),s=n.getHighBits();return e[r++]=255&i,e[r++]=i>>8&255,e[r++]=i>>16&255,e[r++]=i>>24&255,e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,r}function m(e,t,n,r,o){n=n.valueOf(),e[r++]=ge.BSON_DATA_INT;return r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,e[r++]=255&n,e[r++]=n>>8&255,e[r++]=n>>16&255,e[r++]=n>>24&255,r}function v(e,t,n,r,o){e[r++]=ge.BSON_DATA_NUMBER;return r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,be.writeIEEE754(e,n.value,r,"little",52,8),r+=8}function b(e,t,n,r,o=!1,i=0,s){e[r++]=ge.BSON_DATA_CODE;r+=s?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;const a=Z.normalizedFunctionString(n),u=e.write(a,r+4,void 0,"utf8")+1;return e[r]=255&u,e[r+1]=u>>8&255,e[r+2]=u>>16&255,e[r+3]=u>>24&255,r=r+4+u-1,e[r++]=0,r}function w(e,t,n,r,o=!1,i=0,s=!1,a=!0,u=!1){if(n.scope&&"object"==typeof n.scope){e[r++]=ge.BSON_DATA_CODE_W_SCOPE;r+=u?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;let c=r;const f="string"==typeof n.code?n.code:n.code.toString();r+=4;const l=e.write(f,r+4,void 0,"utf8")+1;e[r]=255&l,e[r+1]=l>>8&255,e[r+2]=l>>16&255,e[r+3]=l>>24&255,e[r+4+l-1]=0,r=r+l+4;const h=O(e,n.scope,o,r,i+1,s,a);r=h-1;const p=h-c;e[c++]=255&p,e[c++]=p>>8&255,e[c++]=p>>16&255,e[c++]=p>>24&255,e[r++]=0}else{e[r++]=ge.BSON_DATA_CODE;r+=u?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;const o=n.code.toString(),i=e.write(o,r+4,void 0,"utf8")+1;e[r]=255&i,e[r+1]=i>>8&255,e[r+2]=i>>16&255,e[r+3]=i>>24&255,r=r+4+i-1,e[r++]=0}return r}function E(e,t,n,r,o){e[r++]=ge.BSON_DATA_BINARY;r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;const i=n.value(!0);let s=n.position;return n.sub_type===te.Binary.SUBTYPE_BYTE_ARRAY&&(s+=4),e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=n.sub_type,n.sub_type===te.Binary.SUBTYPE_BYTE_ARRAY&&(s-=4,e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255),e.set(i,r),r+=n.position}function S(e,t,n,r,o){e[r++]=ge.BSON_DATA_SYMBOL;r+=o?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;const i=e.write(n.value,r+4,void 0,"utf8")+1;return e[r]=255&i,e[r+1]=i>>8&255,e[r+2]=i>>16&255,e[r+3]=i>>24&255,r=r+4+i-1,e[r++]=0,r}function A(e,t,n,r,o,i,s){e[r++]=ge.BSON_DATA_OBJECT;r+=s?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;let a=r,u={$ref:n.collection||n.namespace,$id:n.oid};null!=n.db&&(u.$db=n.db),u=Object.assign(u,n.fields);const c=O(e,u,!1,r,o+1,i),f=c-a;return e[a++]=255&f,e[a++]=f>>8&255,e[a++]=f>>16&255,e[a++]=f>>24&255,c}function O(e,t,O=!1,I=0,N=0,T=!1,B=!0,R=[]){I=I||0,(R=R||[]).push(t);let D=I+4;if(Array.isArray(t))for(let n=0;n<t.length;n++){const r=""+n;let I=t[n];if(I&&I.toBSON){if("function"!=typeof I.toBSON)throw new TypeError("toBSON is not a function");I=I.toBSON()}if("string"==typeof I)D=i(e,r,I,D,!0);else if("number"==typeof I)D=s(e,r,I,D,!0);else{if("bigint"==typeof I)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"==typeof I)D=u(e,r,I,D,!0);else if(I instanceof Date||Z.isDate(I))D=c(e,r,I,D,!0);else if(void 0===I)D=a(e,r,0,D,!0);else if(null===I)D=a(e,r,0,D,!0);else if("ObjectId"===I._bsontype||"ObjectID"===I._bsontype)D=p(e,r,I,D,!0);else if(Z.isBuffer(I)||Z.isUint8Array(I))D=d(e,r,I,D,!0);else if(I instanceof RegExp||o(I))D=f(e,r,I,D,!0);else if("object"==typeof I&&null==I._bsontype)D=y(e,r,I,D,O,N,T,B,!0,R);else if("object"==typeof I&&de.isBSONType(I)&&"Decimal128"===I._bsontype)D=g(e,r,I,D,!0);else if("Long"===I._bsontype||"Timestamp"===I._bsontype)D=_(e,r,I,D,!0);else if("Double"===I._bsontype)D=v(e,r,I,D,!0);else if("function"==typeof I&&T)D=b(e,r,I,D,O,N,!0);else if("Code"===I._bsontype)D=w(e,r,I,D,O,N,T,B,!0);else if("Binary"===I._bsontype)D=E(e,r,I,D,!0);else if("Symbol"===I._bsontype)D=S(e,r,I,D,!0);else if("DBRef"===I._bsontype)D=A(e,r,I,D,N,T,!0);else if("BSONRegExp"===I._bsontype)D=l(e,r,I,D,!0);else if("Int32"===I._bsontype)D=m(e,r,I,D,!0);else if("MinKey"===I._bsontype||"MaxKey"===I._bsontype)D=h(e,r,I,D,!0);else if(void 0!==I._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+I._bsontype)}}else if(t instanceof ye.Map){const I=t.entries();let P=!1;for(;!P;){const t=I.next();if(P=!!t.done,P)continue;const L=t.value[0],U=t.value[1],x=typeof U;if("string"==typeof L&&!r.has(L)){if(null!=L.match(n))throw Error("key "+L+" must not contain null bytes");if(O){if("$"===L[0])throw Error("key "+L+" must not start with '$'");if(~L.indexOf("."))throw Error("key "+L+" must not contain '.'")}}if("string"===x)D=i(e,L,U,D);else if("number"===x)D=s(e,L,U,D);else{if("bigint"===x||Z.isBigInt64Array(U)||Z.isBigUInt64Array(U))throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===x)D=u(e,L,U,D);else if(U instanceof Date||Z.isDate(U))D=c(e,L,U,D);else if(null===U||void 0===U&&!1===B)D=a(e,L,0,D);else if("ObjectId"===U._bsontype||"ObjectID"===U._bsontype)D=p(e,L,U,D);else if(Z.isBuffer(U)||Z.isUint8Array(U))D=d(e,L,U,D);else if(U instanceof RegExp||o(U))D=f(e,L,U,D);else if("object"===x&&null==U._bsontype)D=y(e,L,U,D,O,N,T,B,!1,R);else if("object"===x&&"Decimal128"===U._bsontype)D=g(e,L,U,D);else if("Long"===U._bsontype||"Timestamp"===U._bsontype)D=_(e,L,U,D);else if("Double"===U._bsontype)D=v(e,L,U,D);else if("Code"===U._bsontype)D=w(e,L,U,D,O,N,T,B);else if("function"==typeof U&&T)D=b(e,L,U,D,O,N,T);else if("Binary"===U._bsontype)D=E(e,L,U,D);else if("Symbol"===U._bsontype)D=S(e,L,U,D);else if("DBRef"===U._bsontype)D=A(e,L,U,D,N,T);else if("BSONRegExp"===U._bsontype)D=l(e,L,U,D);else if("Int32"===U._bsontype)D=m(e,L,U,D);else if("MinKey"===U._bsontype||"MaxKey"===U._bsontype)D=h(e,L,U,D);else if(void 0!==U._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+U._bsontype)}}}else{if(t.toBSON){if("function"!=typeof t.toBSON)throw new TypeError("toBSON is not a function");if(null!=(t=t.toBSON())&&"object"!=typeof t)throw new TypeError("toBSON function did not return an object")}for(const I in t){let P=t[I];if(P&&P.toBSON){if("function"!=typeof P.toBSON)throw new TypeError("toBSON is not a function");P=P.toBSON()}const L=typeof P;if("string"==typeof I&&!r.has(I)){if(null!=I.match(n))throw Error("key "+I+" must not contain null bytes");if(O){if("$"===I[0])throw Error("key "+I+" must not start with '$'");if(~I.indexOf("."))throw Error("key "+I+" must not contain '.'")}}if("string"===L)D=i(e,I,P,D);else if("number"===L)D=s(e,I,P,D);else{if("bigint"===L)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===L)D=u(e,I,P,D);else if(P instanceof Date||Z.isDate(P))D=c(e,I,P,D);else if(void 0===P)!1===B&&(D=a(e,I,0,D));else if(null===P)D=a(e,I,0,D);else if("ObjectId"===P._bsontype||"ObjectID"===P._bsontype)D=p(e,I,P,D);else if(Z.isBuffer(P)||Z.isUint8Array(P))D=d(e,I,P,D);else if(P instanceof RegExp||o(P))D=f(e,I,P,D);else if("object"===L&&null==P._bsontype)D=y(e,I,P,D,O,N,T,B,!1,R);else if("object"===L&&"Decimal128"===P._bsontype)D=g(e,I,P,D);else if("Long"===P._bsontype||"Timestamp"===P._bsontype)D=_(e,I,P,D);else if("Double"===P._bsontype)D=v(e,I,P,D);else if("Code"===P._bsontype)D=w(e,I,P,D,O,N,T,B);else if("function"==typeof P&&T)D=b(e,I,P,D,O,N,T);else if("Binary"===P._bsontype)D=E(e,I,P,D);else if("Symbol"===P._bsontype)D=S(e,I,P,D);else if("DBRef"===P._bsontype)D=A(e,I,P,D,N,T);else if("BSONRegExp"===P._bsontype)D=l(e,I,P,D);else if("Int32"===P._bsontype)D=m(e,I,P,D);else if("MinKey"===P._bsontype||"MaxKey"===P._bsontype)D=h(e,I,P,D);else if(void 0!==P._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+P._bsontype)}}}R.pop(),e[D++]=0;const P=D-I;return e[I++]=255&P,e[I++]=P>>8&255,e[I++]=P>>16&255,e[I++]=P>>24&255,D}t.serializeInto=O}));i(we);we.serializeInto;var Ee=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeStream=t.calculateObjectSize=t.deserialize=t.serializeWithBufferAndIndex=t.serialize=t.setInternalBufferSize=t.ObjectID=t.Decimal128=t.BSONRegExp=t.MaxKey=t.MinKey=t.Int32=t.Double=t.Timestamp=t.Long=t.ObjectId=t.Binary=t.DBRef=t.BSONSymbol=t.Map=t.Code=t.LongWithoutOverridesClass=t.EJSON=t.BSON_INT64_MIN=t.BSON_INT64_MAX=t.BSON_INT32_MIN=t.BSON_INT32_MAX=t.BSON_DATA_UNDEFINED=t.BSON_DATA_TIMESTAMP=t.BSON_DATA_SYMBOL=t.BSON_DATA_STRING=t.BSON_DATA_REGEXP=t.BSON_DATA_OID=t.BSON_DATA_OBJECT=t.BSON_DATA_NUMBER=t.BSON_DATA_NULL=t.BSON_DATA_MIN_KEY=t.BSON_DATA_MAX_KEY=t.BSON_DATA_LONG=t.BSON_DATA_INT=t.BSON_DATA_DECIMAL128=t.BSON_DATA_DBPOINTER=t.BSON_DATA_DATE=t.BSON_DATA_CODE_W_SCOPE=t.BSON_DATA_CODE=t.BSON_DATA_BOOLEAN=t.BSON_DATA_BINARY=t.BSON_DATA_ARRAY=t.BSON_BINARY_SUBTYPE_UUID_NEW=t.BSON_BINARY_SUBTYPE_UUID=t.BSON_BINARY_SUBTYPE_USER_DEFINED=t.BSON_BINARY_SUBTYPE_MD5=t.BSON_BINARY_SUBTYPE_FUNCTION=t.BSON_BINARY_SUBTYPE_DEFAULT=t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=void 0,Object.defineProperty(t,"Binary",{enumerable:!0,get:function(){return te.Binary}}),Object.defineProperty(t,"Code",{enumerable:!0,get:function(){return ne.Code}}),Object.defineProperty(t,"DBRef",{enumerable:!0,get:function(){return re.DBRef}}),Object.defineProperty(t,"Decimal128",{enumerable:!0,get:function(){return ie.Decimal128}}),Object.defineProperty(t,"Double",{enumerable:!0,get:function(){return se.Double}}),Object.defineProperty(t,"Int32",{enumerable:!0,get:function(){return ae.Int32}}),Object.defineProperty(t,"Long",{enumerable:!0,get:function(){return oe.Long}}),Object.defineProperty(t,"Map",{enumerable:!0,get:function(){return ye.Map}}),Object.defineProperty(t,"MaxKey",{enumerable:!0,get:function(){return ue.MaxKey}}),Object.defineProperty(t,"MinKey",{enumerable:!0,get:function(){return ce.MinKey}}),Object.defineProperty(t,"ObjectId",{enumerable:!0,get:function(){return fe.ObjectId}}),Object.defineProperty(t,"ObjectID",{enumerable:!0,get:function(){return fe.ObjectId}}),Object.defineProperty(t,"BSONRegExp",{enumerable:!0,get:function(){return le.BSONRegExp}}),Object.defineProperty(t,"BSONSymbol",{enumerable:!0,get:function(){return he.BSONSymbol}}),Object.defineProperty(t,"Timestamp",{enumerable:!0,get:function(){return pe.Timestamp}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_BYTE_ARRAY",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_BYTE_ARRAY}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_DEFAULT",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_DEFAULT}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_FUNCTION",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_FUNCTION}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_MD5",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_MD5}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_USER_DEFINED",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_USER_DEFINED}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_UUID",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_UUID}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_UUID_NEW",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_UUID_NEW}}),Object.defineProperty(t,"BSON_DATA_ARRAY",{enumerable:!0,get:function(){return ge.BSON_DATA_ARRAY}}),Object.defineProperty(t,"BSON_DATA_BINARY",{enumerable:!0,get:function(){return ge.BSON_DATA_BINARY}}),Object.defineProperty(t,"BSON_DATA_BOOLEAN",{enumerable:!0,get:function(){return ge.BSON_DATA_BOOLEAN}}),Object.defineProperty(t,"BSON_DATA_CODE",{enumerable:!0,get:function(){return ge.BSON_DATA_CODE}}),Object.defineProperty(t,"BSON_DATA_CODE_W_SCOPE",{enumerable:!0,get:function(){return ge.BSON_DATA_CODE_W_SCOPE}}),Object.defineProperty(t,"BSON_DATA_DATE",{enumerable:!0,get:function(){return ge.BSON_DATA_DATE}}),Object.defineProperty(t,"BSON_DATA_DBPOINTER",{enumerable:!0,get:function(){return ge.BSON_DATA_DBPOINTER}}),Object.defineProperty(t,"BSON_DATA_DECIMAL128",{enumerable:!0,get:function(){return ge.BSON_DATA_DECIMAL128}}),Object.defineProperty(t,"BSON_DATA_INT",{enumerable:!0,get:function(){return ge.BSON_DATA_INT}}),Object.defineProperty(t,"BSON_DATA_LONG",{enumerable:!0,get:function(){return ge.BSON_DATA_LONG}}),Object.defineProperty(t,"BSON_DATA_MAX_KEY",{enumerable:!0,get:function(){return ge.BSON_DATA_MAX_KEY}}),Object.defineProperty(t,"BSON_DATA_MIN_KEY",{enumerable:!0,get:function(){return ge.BSON_DATA_MIN_KEY}}),Object.defineProperty(t,"BSON_DATA_NULL",{enumerable:!0,get:function(){return ge.BSON_DATA_NULL}}),Object.defineProperty(t,"BSON_DATA_NUMBER",{enumerable:!0,get:function(){return ge.BSON_DATA_NUMBER}}),Object.defineProperty(t,"BSON_DATA_OBJECT",{enumerable:!0,get:function(){return ge.BSON_DATA_OBJECT}}),Object.defineProperty(t,"BSON_DATA_OID",{enumerable:!0,get:function(){return ge.BSON_DATA_OID}}),Object.defineProperty(t,"BSON_DATA_REGEXP",{enumerable:!0,get:function(){return ge.BSON_DATA_REGEXP}}),Object.defineProperty(t,"BSON_DATA_STRING",{enumerable:!0,get:function(){return ge.BSON_DATA_STRING}}),Object.defineProperty(t,"BSON_DATA_SYMBOL",{enumerable:!0,get:function(){return ge.BSON_DATA_SYMBOL}}),Object.defineProperty(t,"BSON_DATA_TIMESTAMP",{enumerable:!0,get:function(){return ge.BSON_DATA_TIMESTAMP}}),Object.defineProperty(t,"BSON_DATA_UNDEFINED",{enumerable:!0,get:function(){return ge.BSON_DATA_UNDEFINED}}),Object.defineProperty(t,"BSON_INT32_MAX",{enumerable:!0,get:function(){return ge.BSON_INT32_MAX}}),Object.defineProperty(t,"BSON_INT32_MIN",{enumerable:!0,get:function(){return ge.BSON_INT32_MIN}}),Object.defineProperty(t,"BSON_INT64_MAX",{enumerable:!0,get:function(){return ge.BSON_INT64_MAX}}),Object.defineProperty(t,"BSON_INT64_MIN",{enumerable:!0,get:function(){return ge.BSON_INT64_MIN}});var n=de;Object.defineProperty(t,"EJSON",{enumerable:!0,get:function(){return n.EJSON}});var r=pe;Object.defineProperty(t,"LongWithoutOverridesClass",{enumerable:!0,get:function(){return r.LongWithoutOverridesClass}});let o=w.Buffer.alloc(17825792);function i(e){o.length<e&&(o=w.Buffer.alloc(e))}function s(e,t={}){const n="boolean"==typeof t.checkKeys&&t.checkKeys,r="boolean"==typeof t.serializeFunctions&&t.serializeFunctions,i="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined,s="number"==typeof t.minInternalBufferSize?t.minInternalBufferSize:17825792;o.length<s&&(o=w.Buffer.alloc(s));const a=we.serializeInto(o,e,n,0,0,r,i,[]),u=w.Buffer.alloc(a);return o.copy(u,0,0,u.length),u}function a(e,t,n={}){const r="boolean"==typeof n.checkKeys&&n.checkKeys,i="boolean"==typeof n.serializeFunctions&&n.serializeFunctions,s="boolean"!=typeof n.ignoreUndefined||n.ignoreUndefined,a="number"==typeof n.index?n.index:0,u=we.serializeInto(o,e,r,0,0,i,s);return o.copy(t,a,0,u),a+u-1}function u(e,t={}){return ve.deserialize(Q.ensureBuffer(e),t)}function c(e,t={}){const n="boolean"==typeof(t=t||{}).serializeFunctions&&t.serializeFunctions,r="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined;return _e.calculateObjectSize(e,n,r)}function f(e,t,n,r,o,i){const s=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},i),a=Q.ensureBuffer(e);let u=t;for(let e=0;e<n;e++){const t=a[u]|a[u+1]<<8|a[u+2]<<16|a[u+3]<<24;s.index=u,r[o+e]=ve.deserialize(a,s),u+=t}return u}t.setInternalBufferSize=i,t.serialize=s,t.serializeWithBufferAndIndex=a,t.deserialize=u,t.calculateObjectSize=c,t.deserializeStream=f;const l={Binary:te.Binary,Code:ne.Code,DBRef:re.DBRef,Decimal128:ie.Decimal128,Double:se.Double,Int32:ae.Int32,Long:oe.Long,Map:ye.Map,MaxKey:ue.MaxKey,MinKey:ce.MinKey,ObjectId:fe.ObjectId,ObjectID:fe.ObjectId,BSONRegExp:le.BSONRegExp,BSONSymbol:he.BSONSymbol,Timestamp:pe.Timestamp,EJSON:de.EJSON,setInternalBufferSize:i,serialize:s,serializeWithBufferAndIndex:a,deserialize:u,calculateObjectSize:c,deserializeStream:f};t.default=l})),Se=(i(Ee),Ee.deserializeStream,Ee.calculateObjectSize,Ee.deserialize,Ee.serializeWithBufferAndIndex,Ee.serialize,Ee.setInternalBufferSize,Ee.ObjectID,Ee.Decimal128,Ee.BSONRegExp,Ee.MaxKey,Ee.MinKey,Ee.Int32,Ee.Double,Ee.Timestamp,Ee.Long,Ee.ObjectId,Ee.Binary,Ee.DBRef,Ee.BSONSymbol,Ee.Map,Ee.Code,Ee.LongWithoutOverridesClass,Ee.EJSON);Ee.BSON_INT64_MIN,Ee.BSON_INT64_MAX,Ee.BSON_INT32_MIN,Ee.BSON_INT32_MAX,Ee.BSON_DATA_UNDEFINED,Ee.BSON_DATA_TIMESTAMP,Ee.BSON_DATA_SYMBOL,Ee.BSON_DATA_STRING,Ee.BSON_DATA_REGEXP,Ee.BSON_DATA_OID,Ee.BSON_DATA_OBJECT,Ee.BSON_DATA_NUMBER,Ee.BSON_DATA_NULL,Ee.BSON_DATA_MIN_KEY,Ee.BSON_DATA_MAX_KEY,Ee.BSON_DATA_LONG,Ee.BSON_DATA_INT,Ee.BSON_DATA_DECIMAL128,Ee.BSON_DATA_DBPOINTER,Ee.BSON_DATA_DATE,Ee.BSON_DATA_CODE_W_SCOPE,Ee.BSON_DATA_CODE,Ee.BSON_DATA_BOOLEAN,Ee.BSON_DATA_BINARY,Ee.BSON_DATA_ARRAY,Ee.BSON_BINARY_SUBTYPE_UUID_NEW,Ee.BSON_BINARY_SUBTYPE_UUID,Ee.BSON_BINARY_SUBTYPE_USER_DEFINED,Ee.BSON_BINARY_SUBTYPE_MD5,Ee.BSON_BINARY_SUBTYPE_FUNCTION,Ee.BSON_BINARY_SUBTYPE_DEFAULT,Ee.BSON_BINARY_SUBTYPE_BYTE_ARRAY}).call(this,n(6),n(32).Buffer)},function(e,t,n){"use strict";(function(e){n.d(t,"i",(function(){return u})),n.d(t,"e",(function(){return c})),n.d(t,"h",(function(){return f})),n.d(t,"d",(function(){return l})),n.d(t,"a",(function(){return p})),n.d(t,"f",(function(){return g})),n.d(t,"g",(function(){return _})),n.d(t,"c",(function(){return m})),n.d(t,"b",(function(){return h}));var r=n(0),o=r.constants.setSdkName,i=r.constants.setProtocol,s="",a="@cloudbase/js-sdk";function u(e){s=e}function c(){return s}function f(e){a=e,o(e)}function l(){return a}var h,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 _(e,t,n){g(t?"//"+e+"."+t+".tcb-api.tencentcloudapi.com/web":"//"+e+".ap-shanghai.tcb-api.tencentcloudapi.com/web",n)}function m(){return{BASE_URL:y,PROTOCOL:d}}!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.CUSTOM="CUSTOM",e.NULL="NULL"}(h||(h={}))}).call(this,n(9))},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.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(19)),i=r(n(22)),s=r(n(23)),a=n(7);function u(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=u(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"})))+"."+u(s.default.parse(JSON.stringify(e)));return n+"."+u(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("["+a.getSdkName()+"]["+e+"]:"+t)},t.printError=function(e,t){console.error({code:e,msg:"["+a.getSdkName()+"]["+e+"]:"+t})},t.printInfo=function(e,t){console.log("["+a.getSdkName()+"]["+e+"]:"+t)},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"["+a.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,a=void 0!==s&&s,u=e.collapsed;void 0!==u&&u?console.groupCollapsed(t,r):console.group(t,r);for(var c=0,f=i;c<f.length;c++){var l=f[c],h=l.type,p=l.body;switch(h){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}a&&console.trace("stack trace:"),console.groupEnd()},t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,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||u).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 a=o(4294967296*(n||e.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,t)}}),a=r.enc={},u=a.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)}},c=a.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=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},l=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,a=o/(4*i),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,c=e.min(4*u,o);if(u){for(var f=0;f<u;f+=i)this._doProcessBlock(r,f);var l=r.splice(0,u);n.sigBytes-=c}return new s.init(l,c)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),h=(o.Hasher=l.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.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 h.HMAC.init(e,n).finalize(t)}}}),r.algo={});return r}(Math),r)},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){"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(8),t),o(n(16),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 a(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 u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&p())}function p(){if(!f){var e=a(h);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l<t;)u&&u[l].run();l=-1,t=c.length}u=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];c.push(new d(e,t)),1!==c.length||f||a(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){(function(t){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,o=/^\./,i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,u=/^(?:0|[1-9]\d*)$/,c="object"==typeof t&&t&&t.Object===Object&&t,f="object"==typeof self&&self&&self.Object===Object&&self,l=c||f||Function("return this")();var h,p=Array.prototype,d=Function.prototype,y=Object.prototype,g=l["__core-js_shared__"],_=(h=/[^.]+$/.exec(g&&g.keys&&g.keys.IE_PROTO||""))?"Symbol(src)_1."+h:"",m=d.toString,v=y.hasOwnProperty,b=y.toString,w=RegExp("^"+m.call(v).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),E=l.Symbol,S=p.splice,A=C(l,"Map"),O=C(Object,"create"),I=E?E.prototype:void 0,N=I?I.toString:void 0;function T(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 B(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 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 D(e,t,n){var r=e[t];v.call(e,t)&&F(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function P(e,t){for(var n=e.length;n--;)if(F(e[n][0],t))return n;return-1}function L(e){return!(!Y(e)||(t=e,_&&_ in t))&&(function(e){var t=Y(e)?b.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)?w:a).test(function(e){if(null!=e){try{return m.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}function U(e,t,o,i){if(!Y(e))return e;for(var s=-1,a=(t=function(e,t){if(W(e))return!1;var o=typeof e;if("number"==o||"symbol"==o||"boolean"==o||null==e||$(e))return!0;return r.test(e)||!n.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:function(e){return W(e)?e:M(e)}(t)).length,u=a-1,c=e;null!=c&&++s<a;){var f=k(t[s]),l=o;if(s!=u){var h=c[f];void 0===(l=i?i(h,f,c):void 0)&&(l=Y(h)?h:j(t[s+1])?[]:{})}D(c,f,l),c=c[f]}return e}function x(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function C(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return L(n)?n:void 0}function j(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||u.test(e))&&e>-1&&e%1==0&&e<t}T.prototype.clear=function(){this.__data__=O?O(null):{}},T.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},T.prototype.get=function(e){var t=this.__data__;if(O){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return v.call(t,e)?t[e]:void 0},T.prototype.has=function(e){var t=this.__data__;return O?void 0!==t[e]:v.call(t,e)},T.prototype.set=function(e,t){return this.__data__[e]=O&&void 0===t?"__lodash_hash_undefined__":t,this},B.prototype.clear=function(){this.__data__=[]},B.prototype.delete=function(e){var t=this.__data__,n=P(t,e);return!(n<0)&&(n==t.length-1?t.pop():S.call(t,n,1),!0)},B.prototype.get=function(e){var t=this.__data__,n=P(t,e);return n<0?void 0:t[n][1]},B.prototype.has=function(e){return P(this.__data__,e)>-1},B.prototype.set=function(e,t){var n=this.__data__,r=P(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},R.prototype.clear=function(){this.__data__={hash:new T,map:new(A||B),string:new T}},R.prototype.delete=function(e){return x(this,e).delete(e)},R.prototype.get=function(e){return x(this,e).get(e)},R.prototype.has=function(e){return x(this,e).has(e)},R.prototype.set=function(e,t){return x(this,e).set(e,t),this};var M=q((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if($(e))return N?N.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return o.test(e)&&n.push(""),e.replace(i,(function(e,t,r,o){n.push(r?o.replace(s,"$1"):t||e)})),n}));function k(e){if("string"==typeof e||$(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function q(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(q.Cache||R),n}function F(e,t){return e===t||e!=e&&t!=t}q.Cache=R;var W=Array.isArray;function Y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function $(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==b.call(e)}e.exports=function(e,t,n){return null==e?e:U(e,t,n)}}).call(this,n(6))},function(e,t,n){(function(t){var n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/,o=/^\./,i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,u="object"==typeof t&&t&&t.Object===Object&&t,c="object"==typeof self&&self&&self.Object===Object&&self,f=u||c||Function("return this")();var l,h=Array.prototype,p=Function.prototype,d=Object.prototype,y=f["__core-js_shared__"],g=(l=/[^.]+$/.exec(y&&y.keys&&y.keys.IE_PROTO||""))?"Symbol(src)_1."+l:"",_=p.toString,m=d.hasOwnProperty,v=d.toString,b=RegExp("^"+_.call(m).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),w=f.Symbol,E=h.splice,S=x(f,"Map"),A=x(Object,"create"),O=w?w.prototype:void 0,I=O?O.toString:void 0;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 T(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 B(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 R(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function D(e){return!(!F(e)||(t=e,g&&g in t))&&(function(e){var t=F(e)?v.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)?b:a).test(function(e){if(null!=e){try{return _.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}function P(e,t){e=function(e,t){return 1==t.length?e:function(e,t){for(var n=0,r=(t=C(t,e)?[t]:L(t)).length;null!=e&&n<r;)e=e[M(t[n++])];return n&&n==r?e:void 0}(e,function(e,t,n){var r=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=e[r+t];return i}(t,0,-1))}(e,t=C(t,e)?[t]:L(t));var n,r,o=M((r=(n=t)?n.length:0)?n[r-1]:void 0);return!(null!=e&&m.call(e,o))||delete e[o]}function L(e){return q(e)?e:j(e)}function U(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function x(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return D(n)?n:void 0}function C(e,t){if(q(e))return!1;var o=typeof e;return!("number"!=o&&"symbol"!=o&&"boolean"!=o&&null!=e&&!W(e))||(r.test(e)||!n.test(e)||null!=t&&e in Object(t))}N.prototype.clear=function(){this.__data__=A?A(null):{}},N.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},N.prototype.get=function(e){var t=this.__data__;if(A){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return m.call(t,e)?t[e]:void 0},N.prototype.has=function(e){var t=this.__data__;return A?void 0!==t[e]:m.call(t,e)},N.prototype.set=function(e,t){return this.__data__[e]=A&&void 0===t?"__lodash_hash_undefined__":t,this},T.prototype.clear=function(){this.__data__=[]},T.prototype.delete=function(e){var t=this.__data__,n=R(t,e);return!(n<0)&&(n==t.length-1?t.pop():E.call(t,n,1),!0)},T.prototype.get=function(e){var t=this.__data__,n=R(t,e);return n<0?void 0:t[n][1]},T.prototype.has=function(e){return R(this.__data__,e)>-1},T.prototype.set=function(e,t){var n=this.__data__,r=R(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},B.prototype.clear=function(){this.__data__={hash:new N,map:new(S||T),string:new N}},B.prototype.delete=function(e){return U(this,e).delete(e)},B.prototype.get=function(e){return U(this,e).get(e)},B.prototype.has=function(e){return U(this,e).has(e)},B.prototype.set=function(e,t){return U(this,e).set(e,t),this};var j=k((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(W(e))return I?I.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return o.test(e)&&n.push(""),e.replace(i,(function(e,t,r,o){n.push(r?o.replace(s,"$1"):t||e)})),n}));function M(e){if("string"==typeof e||W(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,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(k.Cache||B),n}k.Cache=B;var q=Array.isArray;function F(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function W(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==v.call(e)}e.exports=function(e,t){return null==e||P(e,t)}}).call(this,n(6))},function(e,t,n){(function(e,n){var r="[object Arguments]",o="[object Function]",i="[object GeneratorFunction]",s="[object Map]",a="[object Set]",u=/\w*$/,c=/^\[object .+?Constructor\]$/,f=/^(?:0|[1-9]\d*)$/,l={};l[r]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[s]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[o]=l["[object WeakMap]"]=!1;var h="object"==typeof e&&e&&e.Object===Object&&e,p="object"==typeof self&&self&&self.Object===Object&&self,d=h||p||Function("return this")(),y=t&&!t.nodeType&&t,g=y&&"object"==typeof n&&n&&!n.nodeType&&n,_=g&&g.exports===y;function m(e,t){return e.set(t[0],t[1]),e}function v(e,t){return e.add(t),e}function b(e,t,n,r){var o=-1,i=e?e.length:0;for(r&&i&&(n=e[++o]);++o<i;)n=t(n,e[o],o,e);return n}function w(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function E(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function S(e,t){return function(n){return e(t(n))}}function A(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var O,I=Array.prototype,N=Function.prototype,T=Object.prototype,B=d["__core-js_shared__"],R=(O=/[^.]+$/.exec(B&&B.keys&&B.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"",D=N.toString,P=T.hasOwnProperty,L=T.toString,U=RegExp("^"+D.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),x=_?d.Buffer:void 0,C=d.Symbol,j=d.Uint8Array,M=S(Object.getPrototypeOf,Object),k=Object.create,q=T.propertyIsEnumerable,F=I.splice,W=Object.getOwnPropertySymbols,Y=x?x.isBuffer:void 0,$=S(Object.keys,Object),K=ge(d,"DataView"),G=ge(d,"Map"),H=ge(d,"Promise"),J=ge(d,"Set"),V=ge(d,"WeakMap"),z=ge(Object,"create"),X=we(K),Z=we(G),Q=we(H),ee=we(J),te=we(V),ne=C?C.prototype:void 0,re=ne?ne.valueOf:void 0;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 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 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 ie(e)}function ue(e,t){var n=Se(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Ae(e)}(e)&&P.call(e,"callee")&&(!q.call(e,"callee")||L.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):[],o=n.length,i=!!o;for(var s in e)!t&&!P.call(e,s)||i&&("length"==s||ve(s,o))||n.push(s);return n}function ce(e,t,n){var r=e[t];P.call(e,t)&&Ee(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function fe(e,t){for(var n=e.length;n--;)if(Ee(e[n][0],t))return n;return-1}function le(e,t,n,c,f,h,p){var d;if(c&&(d=h?c(e,f,h,p):c(e)),void 0!==d)return d;if(!Ne(e))return e;var y=Se(e);if(y){if(d=function(e){var t=e.length,n=e.constructor(t);t&&"string"==typeof e[0]&&P.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,d)}else{var g=me(e),_=g==o||g==i;if(Oe(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]"==g||g==r||_&&!h){if(w(e))return h?e:{};if(d=function(e){return"function"!=typeof e.constructor||be(e)?{}:(t=M(e),Ne(t)?k(t):{});var t}(_?{}:e),!t)return function(e,t){return de(e,_e(e),t)}(e,function(e,t){return e&&de(t,Te(t),e)}(d,e))}else{if(!l[g])return h?e:{};d=function(e,t,n,r){var o=e.constructor;switch(t){case"[object ArrayBuffer]":return pe(e);case"[object Boolean]":case"[object Date]":return new o(+e);case"[object DataView]":return function(e,t){var n=t?pe(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?pe(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,r);case s:return function(e,t,n){return b(t?n(E(e),!0):E(e),m,new e.constructor)}(e,r,n);case"[object Number]":case"[object String]":return new o(e);case"[object RegExp]":return function(e){var t=new e.constructor(e.source,u.exec(e));return t.lastIndex=e.lastIndex,t}(e);case a:return function(e,t,n){return b(t?n(A(e),!0):A(e),v,new e.constructor)}(e,r,n);case"[object Symbol]":return i=e,re?Object(re.call(i)):{}}var i}(e,g,le,t)}}p||(p=new ae);var S=p.get(e);if(S)return S;if(p.set(e,d),!y)var O=n?function(e){return function(e,t,n){var r=t(e);return Se(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Te,_e)}(e):Te(e);return function(e,t){for(var n=-1,r=e?e.length:0;++n<r&&!1!==t(e[n],n,e););}(O||e,(function(r,o){O&&(r=e[o=r]),ce(d,o,le(r,t,n,c,o,e,p))})),d}function he(e){return!(!Ne(e)||(t=e,R&&R in t))&&(Ie(e)||w(e)?U:c).test(we(e));var t}function pe(e){var t=new e.constructor(e.byteLength);return new j(t).set(new j(e)),t}function de(e,t,n,r){n||(n={});for(var o=-1,i=t.length;++o<i;){var s=t[o],a=r?r(n[s],e[s],s,n,e):void 0;ce(n,s,void 0===a?e[s]:a)}return n}function ye(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function ge(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return he(n)?n:void 0}oe.prototype.clear=function(){this.__data__=z?z(null):{}},oe.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},oe.prototype.get=function(e){var t=this.__data__;if(z){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return P.call(t,e)?t[e]:void 0},oe.prototype.has=function(e){var t=this.__data__;return z?void 0!==t[e]:P.call(t,e)},oe.prototype.set=function(e,t){return this.__data__[e]=z&&void 0===t?"__lodash_hash_undefined__":t,this},ie.prototype.clear=function(){this.__data__=[]},ie.prototype.delete=function(e){var t=this.__data__,n=fe(t,e);return!(n<0)&&(n==t.length-1?t.pop():F.call(t,n,1),!0)},ie.prototype.get=function(e){var t=this.__data__,n=fe(t,e);return n<0?void 0:t[n][1]},ie.prototype.has=function(e){return fe(this.__data__,e)>-1},ie.prototype.set=function(e,t){var n=this.__data__,r=fe(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},se.prototype.clear=function(){this.__data__={hash:new oe,map:new(G||ie),string:new oe}},se.prototype.delete=function(e){return ye(this,e).delete(e)},se.prototype.get=function(e){return ye(this,e).get(e)},se.prototype.has=function(e){return ye(this,e).has(e)},se.prototype.set=function(e,t){return ye(this,e).set(e,t),this},ae.prototype.clear=function(){this.__data__=new ie},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 ie){var r=n.__data__;if(!G||r.length<199)return r.push([e,t]),this;n=this.__data__=new se(r)}return n.set(e,t),this};var _e=W?S(W,Object):function(){return[]},me=function(e){return L.call(e)};function ve(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||f.test(e))&&e>-1&&e%1==0&&e<t}function be(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||T)}function we(e){if(null!=e){try{return D.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ee(e,t){return e===t||e!=e&&t!=t}(K&&"[object DataView]"!=me(new K(new ArrayBuffer(1)))||G&&me(new G)!=s||H&&"[object Promise]"!=me(H.resolve())||J&&me(new J)!=a||V&&"[object WeakMap]"!=me(new V))&&(me=function(e){var t=L.call(e),n="[object Object]"==t?e.constructor:void 0,r=n?we(n):void 0;if(r)switch(r){case X:return"[object DataView]";case Z:return s;case Q:return"[object Promise]";case ee:return a;case te:return"[object WeakMap]"}return t});var Se=Array.isArray;function Ae(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}(e.length)&&!Ie(e)}var Oe=Y||function(){return!1};function Ie(e){var t=Ne(e)?L.call(e):"";return t==o||t==i}function Ne(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Te(e){return Ae(e)?ue(e):function(e){if(!be(e))return $(e);var t=[];for(var n in Object(e))P.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}n.exports=function(e){return le(e,!0,!0)}}).call(this,n(6),n(30)(e))},function(e,t,n){n(14),e.exports=n(15)},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 a(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof l?t:l,i=Object.create(o.prototype),s=new S(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 O()}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var a=b(s,n);if(a){if(a===f)continue;return a}}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 u=c(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(e,n,s),i}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function l(){}function h(){}function p(){}var d={};d[o]=function(){return this};var y=Object.getPrototypeOf,g=y&&y(y(A([])));g&&g!==t&&n.call(g,o)&&(d=g);var _=p.prototype=l.prototype=Object.create(d);function m(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function v(e,t){var r;this._invoke=function(o,i){function s(){return new t((function(r,s){!function r(o,i,s,a){var u=c(e[o],e,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,a)}),(function(e){r("throw",e,s,a)})):t.resolve(l).then((function(e){f.value=e,s(f)}),(function(e){return r("throw",e,s,a)}))}a(u.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=c(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 E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function A(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:O}}function O(){return{value:void 0,done:!0}}return h.prototype=_.constructor=p,p.constructor=h,h.displayName=a(p,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,a(e,s,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},m(v.prototype),v.prototype[i]=function(){return this},e.AsyncIterator=v,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var s=new v(u(t,n,r,o),i);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},m(_),a(_,s,"Generator"),_[o]=function(){return this},_.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=A,S.prototype={constructor:S,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(E),!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 a=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)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),E(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;E(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:A(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(40)),a=n(39),u=n(28),c=n(29),f=n(38),l=n(31),h=n(37),p=i(n(36)).version;s.default.registerVersion(p);try{a.registerAuth(s.default),u.registerFunctions(s.default),c.registerStorage(s.default),h.registerDatabase(s.default),f.registerRealtime(s.default),l.registerAnalytics(s.default)}catch(e){}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,a=i(n(18)),u=n(4);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(s=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e){for(var t=0,n=u.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:a.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{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=n(3),c=n(4),f=n(8),l=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 a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype._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,a=e.url,u=e.headers,l=void 0===u?{}:u,h=e.data,p=e.responseType,d=e.withCredentials,y=e.body,g=e.onUploadProgress,_=c.formatUrl(f.getProtocol(),a,"get"===r?h:{}),m=new XMLHttpRequest;for(var v in m.open(r,_),p&&(m.responseType=p),l)m.setRequestHeader(v,l[v]);g&&m.upload.addEventListener("progress",g),m.onreadystatechange=function(){var e={};if(4===m.readyState){var t=m.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=m.status;try{e.data="blob"===p?m.response:JSON.parse(m.responseText)}catch(t){e.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(e)}},t&&n._timeout&&(i=setTimeout((function(){console.warn(n._timeoutMsg),m.abort()}),n._timeout)),s=c.isFormData(h)?h:"application/x-www-form-urlencoded"===l["content-type"]?c.toQueryString(h):y||(h?JSON.stringify(h):void 0),d&&(m.withCredentials=!0),m.send(s)}))},t}(u.AbstractSDKRequest);t.WebRequest=l,t.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}}},function(e,t,n){var r;e.exports=(r=n(5),n(20),n(21),r.HmacSHA256)},function(e,t,n){var r;e.exports=(r=n(5),function(e){var t=r,n=t.lib,o=n.WordArray,i=n.Hasher,s=t.algo,a=[],u=[];!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&&(a[o]=n(e.pow(r,.5))),u[o]=n(e.pow(r,1/3)),o++),r++}();var c=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],a=n[4],f=n[5],l=n[6],h=n[7],p=0;p<64;p++){if(p<16)c[p]=0|e[t+p];else{var d=c[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=c[p-2],_=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;c[p]=y+c[p-7]+_+c[p-16]}var m=r&o^r&i^o&i,v=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&l)+u[p]+c[p];h=l,l=f,f=a,a=s+b|0,s=i,i=o,o=r,r=b+(v+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]+a|0,n[5]=n[5]+f|0,n[6]=n[6]+l|0,n[7]=n[7]+h|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(5),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(),a=o.words,u=i.words,c=0;c<n;c++)a[c]^=1549556828,u[c]^=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(5),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,a=0;a<4&&i+.75*a<n;a++)o.push(r.charAt(s>>>6*(3-a)&63));var u=r.charAt(64);if(u)for(;o.length%4;)o.push(u);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 a=e.indexOf(s);-1!==a&&(t=a)}return function(e,t,n){for(var r=[],i=0,s=0;s<t;s++)if(s%4){var a=n[e.charCodeAt(s-1)]<<s%4*2,u=n[e.charCodeAt(s)]>>>6-s%4*2;r[i>>>2]|=(a|u)<<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(5),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{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=n(3),u=n(4),c=n(7),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}(a.AbstractStorage);function l(e,t){switch(e){case"local":return t.localStorage?t.localStorage:(u.printWarn(c.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:(u.printWarn(c.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new f(t.root));default:return t.localStorage?t.localStorage:(u.printWarn(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(t.root))}}var h=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,a=void 0===s?[]:s;this._platformInfo=r,this._alwaysLocalKeys=a,this._storage||(this._persistence=r.adapter.primaryStorage||t,this._storage=l(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=l(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);u.isUndefined(i)||u.isNull(i)||(n.setItem(o,i),this._storage.removeItem(o))}}this._storage=n}}else u.printWarn(c.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,a,c,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=l(e,this._platformInfo.adapter),r=[],this.keys)r.push(o);i=0,s.label=1;case 1:return i<r.length?(a=r[i],c=this.keys[a],t&&this._alwaysLocalKeys.includes(a)?[3,4]:[4,this._storage.getItem(c)]):[3,5];case 2:return f=s.sent(),u.isUndefined(f)||u.isNull(f)?[3,4]:(n.setItem(c,f),[4,this._storage.removeItem(c)]);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:c.ERRORS.OPERATION_FAIL,msg:"["+c.getSdkName()+"]["+c.ERRORS.OPERATION_FAIL+"]setStore failed",info:e}))}}else u.printWarn(c.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:""}u.printWarn(c.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):u.printWarn(c.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=h}).call(this,n(9))},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,a=i.length;s<a;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(4);var a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return o(t,e),t}(a);t.IErrorEvent=u;var c=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,u))return console.error(e.error),this;var n=s.isString(e)?new a(e,t||{}):e,r=n.name;if(this._listens(r)){n.target=this;for(var o=0,c=this._listeners[r]?i(this._listeners[r]):[];o<c.length;o++){c[o].call(this,n)}}return this},e.prototype._listens=function(e){return this._listeners[e]&&this._listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var f=new c;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(27),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{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=n(4),s=n(7),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/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"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]\\s*\\(.*\\)$"),f=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp(n+"\\.descriptor.value\\s*\\[as\\s"+r+"\\]"),l=s.findIndex((function(e){return u.test(e)}));if(-1!==l){var h=s.filter((function(e,t){return t>l}));h.unshift(s[l].replace(f,n+"."+r).replace(c,o)),(i=new Error).stack=(a?"@debugger":"Error")+"\n"+h.join("\n")}return i}t.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,a=e.customInfo,l=void 0===a?{}:a,h=e.title,p=e.messages,d=void 0===p?[]:p;return function(e,t,a){if(s.IS_DEBUG_MODE){var p=l.className||e.constructor.name,y=l.methodName||t,g=a.value,_=function(e){var t="",n=e.stack.split("\n"),r=n.findIndex((function(e){return u.test(e)}));if(-1!==r){var o=c.exec(n[r+1]||"");t=o?o[0]:""}return t}(new Error);a.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:_});try{return g.apply(this,e)}catch(e){var r=e,o=e.message,s={title:h||p+"."+y+" failed",content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var a=JSON.parse(o);s.subtitle=o,a.code&&(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,a,u;return o(this,(function(o){switch(o.label){case 0:t=f({err:new Error,className:p,methodName:y,sourceLink:_}),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,a={title:h||p+"."+y+" failed",content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(u=JSON.parse(s),a.subtitle=u,u.code&&(r=t||n,a.content=d.map((function(e){return{type:"info",body:e}})))),i.printGroupLog(a),r;case 4:return[2]}}))}))}}}}},function(e,t,n){"use strict";n.r(t),n.d(t,"registerFunctions",(function(){return d}));var r=n(0),o=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},i=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},a=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},u=r.constants.getSdkName,c=r.constants.ERRORS,f=r.constants.COMMUNITY_SITE_URL,l=r.utils.execCallback,h=r.helpers.catchErrorsDecorator,p={name:"functions",entity:{callFunction:(new(function(){function e(){}return e.prototype.callFunction=function(e,t){return s(this,void 0,void 0,(function(){var n,r,o,i,s,f,h,p,d,y,g,_;return a(this,(function(a){switch(a.label){case 0:if(n=e.name,r=e.data,o=e.query,i=e.parse,s=e.search,!n)throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[functions.callFunction] invalid function name"}));try{f=r?JSON.stringify(r):""}catch(e){throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[functions.callFunction] invalid data"}))}h="functions.invokeFunction",p={inQuery:o,parse:i,search:s,function_name:n,request_data:f},d=this.request,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,d.send(h,p)];case 2:if((y=a.sent()).code)return[2,l(t,null,y)];if(g=y.data.response_data,i)return[2,l(t,null,{result:g,requestId:y.requestId})];try{return g=JSON.parse(y.data.response_data),[2,l(t,null,{result:g,requestId:y.requestId})]}catch(e){l(t,new Error("["+u()+"]["+c.INVALID_PARAMS+"][functions.callFunction] response data must be json"))}return[3,4];case 3:return _=a.sent(),l(t,_),[3,4];case 4:return[2]}}))}))},o([h({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],e.prototype,"callFunction",null),e}())).callFunction}};try{cloudbase.registerComponent(p)}catch(e){}function d(e){try{e.registerComponent(p)}catch(e){console.warn(e)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"registerStorage",(function(){return m}));var r=n(0),o=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},i=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},a=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},u=r.constants.getSdkName,c=r.constants.ERRORS,f=r.constants.COMMUNITY_SITE_URL,l=r.utils.isArray,h=r.utils.isString,p=r.utils.isPalinObject,d=r.utils.execCallback,y=r.helpers.catchErrorsDecorator,g=new(function(){function e(){}return e.prototype.uploadFile=function(e,t){return s(this,void 0,void 0,(function(){var n,r,o,i,s,f,l,p,y,g,_,m,v,b;return a(this,(function(a){switch(a.label){case 0:if(n=e.cloudPath,r=e.filePath,o=e.onUploadProgress,!h(n)||!r)throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[storage.uploadFile] invalid params"}));return"storage.getUploadMetadata",[4,(i=this.request).send("storage.getUploadMetadata",{path:n})];case 1:return s=a.sent(),f=s.data,l=f.url,p=f.authorization,y=f.token,g=f.fileId,_=f.cosFileId,m=s.requestId,v={key:n,signature:p,"x-cos-meta-fileid":_,success_action_status:"201","x-cos-security-token":y},[4,i.upload({url:l,data:v,file:r,name:n,onUploadProgress:o})];case 2:return 201===(b=a.sent()).statusCode?[2,d(t,null,{fileID:g,requestId:m})]:[2,d(t,new Error("["+u()+"]["+c.OPERATION_FAIL+"][storage]:"+b.data))]}}))}))},e.prototype.getUploadMetadata=function(e,t){return s(this,void 0,void 0,(function(){var n,r,o,i,s;return a(this,(function(a){switch(a.label){case 0:if(n=e.cloudPath,!h(n))throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[storage.getUploadMetadata] invalid cloudPath"}));r=this.request,o="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.send(o,{path:n})];case 2:return i=a.sent(),[2,d(t,null,i)];case 3:return s=a.sent(),[2,d(t,s)];case 4:return[2]}}))}))},e.prototype.deleteFile=function(e,t){return s(this,void 0,void 0,(function(){var n,r,o,i,s,u;return a(this,(function(a){switch(a.label){case 0:if(!(n=e.fileList)||!l(n)||0===n.length)throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[storage.deleteFile] fileList must not be empty"}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!h(i))throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[storage.deleteFile] fileID must be string"}));return"storage.batchDeleteFile",[4,this.request.send("storage.batchDeleteFile",{fileid_list:n})];case 1:return(s=a.sent()).code?[2,d(t,null,s)]:(u={fileList:s.data.delete_list,requestId:s.requestId},[2,d(t,null,u)])}}))}))},e.prototype.getTempFileURL=function(e,t){return s(this,void 0,void 0,(function(){var n,r,o,i,s,u;return a(this,(function(a){switch(a.label){case 0:if(!(n=e.fileList)||!l(n)||0===n.length)throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[storage.getTempFileURL] fileList must not be empty"}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],p(s)){if(!s.hasOwnProperty("fileID")||!s.hasOwnProperty("maxAge"))throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[storage.getTempFileURL] file info must include fileID and maxAge"}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!h(s))throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[storage.getTempFileURL] invalid fileList"}));r.push({fileid:s})}return"storage.batchGetDownloadUrl",[4,this.request.send("storage.batchGetDownloadUrl",{file_list:r})];case 1:return(u=a.sent()).code?[2,d(t,null,u)]:[2,d(t,null,{fileList:u.data.download_list,requestId:u.requestId})]}}))}))},e.prototype.downloadFile=function(e,t){return s(this,void 0,void 0,(function(){var n,r,o,i,s,u;return a(this,(function(a){switch(a.label){case 0:if(n=e.fileID,!h(n))throw new Error(JSON.stringify({code:c.INVALID_PARAMS,msg:"[storage.getTempFileURL] fileID must be string"}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}]})];case 1:return r=a.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,d(t,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return u=a.sent(),[2,d(t,null,u)]}}))}))},o([y({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],e.prototype,"uploadFile",null),o([y({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],e.prototype,"getUploadMetadata",null),o([y({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],e.prototype,"deleteFile",null),o([y({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],e.prototype,"getTempFileURL",null),o([y({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+f]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],e.prototype,"downloadFile",null),e}()),_={name:"storage",entity:{uploadFile:g.uploadFile,deleteFile:g.deleteFile,getTempFileURL:g.getTempFileURL,downloadFile:g.downloadFile,getUploadMetadata:g.getUploadMetadata}};try{cloudbase.registerComponent(_)}catch(e){}function m(e){try{e.registerComponent(_)}catch(e){console.warn(e)}}},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,"registerAnalytics",(function(){return p}));var r=n(0),o=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},i=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},a=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},u=r.constants.ERRORS,c=r.constants.COMMUNITY_SITE_URL,f=r.helpers.catchErrorsDecorator,l=["mall"];var h={name:"analytics",entity:{analytics:(new(function(){function e(){}return e.prototype.analytics=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(o){if(!function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))return!1;var t=e.report_data,n=e.report_type;return!1!==l.includes(n)&&("Object"===Object.prototype.toString.call(t).slice(8,-1)&&(!(void 0!==t.action_time&&!Number.isInteger(t.action_time))&&"string"==typeof t.action_type))}(e))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[analytics.analytics] invalid report data"}));return"analytics.report",t=void 0===e.report_data.action_time?Math.floor(Date.now()/1e3):e.report_data.action_time,n={analytics_scene:e.report_type,analytics_data:Object.assign({},e.report_data,{action_time:t})},r={requestData:n},this.request.send("analytics.report",r),[2]}))}))},o([f({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+c]}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],e.prototype,"analytics",null),e}())).analytics}};try{cloudbase.registerComponent(h)}catch(e){}function p(e){try{e.registerComponent(h)}catch(e){console.warn(e)}}},function(e,t,n){"use strict";(function(e){
|
|
2
|
+
/*!
|
|
3
|
+
* The buffer module from node.js, for the browser.
|
|
4
|
+
*
|
|
5
|
+
* @author Feross Aboukhadijeh <http://feross.org>
|
|
6
|
+
* @license MIT
|
|
7
|
+
*/
|
|
8
|
+
var r=n(33),o=n(34),i=n(35);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,t,n)}function c(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(t,n),o=(e=a(e,r)).write(t,n);o!==r&&(e=e.slice(0,o));return e}(e,t,n):function(e,t){if(u.isBuffer(t)){var n=0|p(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):h(e,t);if("Buffer"===t.type&&i(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(f(t),e=a(e,t<0?0:0|p(t)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|p(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return F(e).length;default:if(r)return q(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return B(this,t,n);case"utf8":case"utf-8":return I(this,t,n);case"ascii":return N(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return O(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:m(e,t,n,r,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):m(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,r,o){var i,s=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=n;i<a;i++)if(c(e,i)===c(t,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===u)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){for(var l=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){l=!1;break}if(l)return i}return-1}function v(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function b(e,t,n,r){return W(q(t,e.length-n),e,n,r)}function w(e,t,n,r){return W(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function E(e,t,n,r){return w(e,t,n,r)}function S(e,t,n,r){return W(F(t),e,n,r)}function A(e,t,n,r){return W(function(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function O(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function I(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,u,c=e[o],f=null,l=c>239?4:c>223?3:c>191?2:1;if(o+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(f=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),o+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,n){return c(null,e,t,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,n){return function(e,t,n,r){return f(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},u.allocUnsafe=function(e){return l(null,e)},u.allocUnsafeSlow=function(e){return l(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=u.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?I(this,0,e):y.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,n,r,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(r,o),f=e.slice(t,n),l=0;l<a;++l)if(c[l]!==f[l]){i=c[l],s=f[l];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return _(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return _(this,e,t,n,!1)},u.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return v(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return w(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function N(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function T(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function B(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=k(e[i]);return o}function R(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function D(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,n,r,o,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function L(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function U(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function x(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function C(e,t,n,r,i){return i||x(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function j(e,t,n,r,i){return i||x(e,0,n,8),o.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=u.prototype;else{var o=t-e;n=new u(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},u.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},u.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},u.prototype.readUInt8=function(e,t){return t||D(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||D(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||D(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||D(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){t||D(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(e,t){return t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||D(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||D(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||D(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||D(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},u.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):U(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):U(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):U(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):U(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,n){return C(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return C(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},u.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=u.isBuffer(e)?e:q(new u(e,r).toString()),a=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%a]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function k(e){return e<16?"0"+e.toString(16):e.toString(16)}function q(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function F(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function W(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this,n(6))},function(e,t,n){"use strict";t.byteLength=function(e){var t=c(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=c(e),s=r[0],a=r[1],u=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),f=0,l=a>0?s-4:s;for(n=0;n<l;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,u[f++]=255&t);1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t);return u},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],s=0,a=n-o;s<a;s+=16383)i.push(f(e,s,s+16383>a?a:s+16383));1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return i.join("")};for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function f(e,t,n){for(var o,i,s=[],a=t;a<n;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){
|
|
9
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
10
|
+
t.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,f=-7,l=n?o-1:0,h=n?-1:1,p=e[t+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+e[t+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=c}return(p?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,o,i){var s,a,u,c=8*i-o-1,f=(1<<c)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[n+p]=255&s,p+=d,s/=256,c-=8);e[n+p-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e){e.exports=JSON.parse('{"version":"1.4.1-alpha.0"}')},function(e,t,n){"use strict";n.r(t),n.d(t,"registerDatabase",(function(){return bt}));var r,o,i={};n.r(i),n.d(i,"Point",(function(){return ce})),n.d(i,"LineString",(function(){return J})),n.d(i,"Polygon",(function(){return z})),n.d(i,"MultiPoint",(function(){return Z})),n.d(i,"MultiLineString",(function(){return ee})),n.d(i,"MultiPolygon",(function(){return ne})),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a="Number",u="Object",c="Array",f="GeoPoint",l="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",d="GeoMultiLineString",y="GeoMultiPolygon",g="Date",_="ServerDate",m="BsonDate",v=["desc","asc"],b=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={}));var w;(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte";!function(e){e.WHERE="WHERE",e.DOC="DOC"}(w||(w={}));var E,S=(E=function(e,t){return(E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}E(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),A=[],O={},I=function(e){function t(t,n){if(n!==O)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return S(t,e),t.for=function(e){for(var n=0,r=A.length;n<r;n++)if(A[n].target===e)return A[n].instance;var o=new t(e,O);return A.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),N=I,T=N.for("UNSET_FIELD_NAME"),B=N.for("UPDATE_COMMAND"),R=N.for("QUERY_COMMAND"),D=N.for("LOGIC_COMMAND"),P=N.for("GEO_POINT"),L=N.for("SYMBOL_GEO_LINE_STRING"),U=N.for("SYMBOL_GEO_POLYGON"),x=N.for("SYMBOL_GEO_MULTI_POINT"),C=N.for("SYMBOL_GEO_MULTI_LINE_STRING"),j=N.for("SYMBOL_GEO_MULTI_POLYGON"),M=N.for("SERVER_DATE"),k=N.for("REGEXP"),q=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},F=function(e){return"object"===q(e)},W=function(e){return"number"===q(e)},Y=function(e){return Array.isArray(e)},$=function(e){return"date"===q(e)},K=function(e){return"regexp"===q(e)},G=function(e){return e&&e._internalType instanceof I},H=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},J=function(){function e(e){if(!Y(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof ce))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("LineString"!==e.type||!Y(e.coordinates))return!1;try{for(var r=H(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],n=e.points[e.points.length-1];if(t.latitude===n.latitude&&t.longitude===n.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),e}(),V=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(){function e(e){if(!Y(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof J))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]");if(!J.isClosed(e))throw new Error("LineString "+e.points.map((function(e){return e.toReadableString()}))+" is not a closed cycle")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,o;if("Polygon"!==e.type||!Y(e.coordinates))return!1;try{for(var i=V(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var u=(r=void 0,V(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),e}(),X=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Z=function(){function e(e){if(!Y(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof ce))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("MultiPoint"!==e.type||!Y(e.coordinates))return!1;try{for(var r=X(e.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!W(i[0])||!W(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return x},enumerable:!0,configurable:!0}),e}(),Q=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ee=function(){function e(e){if(!Y(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof J))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,o;if("MultiLineString"!==e.type||!Y(e.coordinates))return!1;try{for(var i=Q(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(r=void 0,Q(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!W(f[0])||!W(f[1]))return!1}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return C},enumerable:!0,configurable:!0}),e}(),te=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ne=function(){function e(e){var t,n;if(!Y(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof e);if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=te(e),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof z))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof i+"[]")}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))}},e.validate=function(e){var t,n,r,o,i,s;if("MultiPolygon"!==e.type||!Y(e.coordinates))return!1;try{for(var a=te(e.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var f=(r=void 0,te(c)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,te(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!W(y[0])||!W(y[1]))return!1}}catch(e){i={error:e}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),e}(),re=function(){function e(e){var t=(void 0===e?{}:e).offset,n=void 0===t?0:t;this.offset=n}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return M},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function oe(e){return new re(e)}var ie,se=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},ae=function(){function e(){}return e.formatResDocumentData=function(t){return t.map((function(t){return e.formatField(t)}))},e.formatField=function(t){var n=Object.keys(t),r={};return Array.isArray(t)&&(r=[]),n.forEach((function(n){var o,i=t[n];switch(e.whichType(i)){case f:o=new ce(i.coordinates[0],i.coordinates[1]);break;case l:o=new J(i.coordinates.map((function(e){return new ce(e[0],e[1])})));break;case h:o=new z(i.coordinates.map((function(e){return new J(e.map((function(e){var t=se(e,2),n=t[0],r=t[1];return new ce(n,r)})))})));break;case p:o=new Z(i.coordinates.map((function(e){return new ce(e[0],e[1])})));break;case d:o=new ee(i.coordinates.map((function(e){return new J(e.map((function(e){var t=se(e,2),n=t[0],r=t[1];return new ce(n,r)})))})));break;case y:o=new ne(i.coordinates.map((function(e){return new z(e.map((function(e){return new J(e.map((function(e){var t=se(e,2),n=t[0],r=t[1];return new ce(n,r)})))})))})));break;case g:o=new Date(1e3*i.$timestamp);break;case u:case c:o=e.formatField(i);break;case _:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o})),r},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);if(t===g)return m;if(t===u){if(e instanceof ce)return f;if(e instanceof Date)return g;if(e instanceof re)return _;e.$timestamp?t=g:e.$date?t=_:ce.validate(e)?t=f:J.validate(e)?t=l:z.validate(e)?t=h:Z.validate(e)?t=p:ee.validate(e)?t=d:ne.validate(e)&&(t=y)}return t},e.generateDocId=function(){for(var e="ABCDEFabcdef0123456789",t="",n=0;n<24;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return t},e}(),ue=function(){function e(){}return e.isGeopoint=function(e,t){if(ae.whichType(t)!==a)throw new Error("Geo Point must be number type");var n=Math.abs(t);if("latitude"===e&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+o.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===v.indexOf(e))throw new Error(o.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===b.indexOf(e))throw new Error(o.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(o.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(o.DocIDError);return!0},e}(),ce=function(){function e(e,t){ue.isGeopoint("longitude",e),ue.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},e.validate=function(e){return"Point"===e.type&&Y(e.coordinates)&&ue.isGeopoint("longitude",e.coordinates[0])&&ue.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),e}(),fe=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e};!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(ie||(ie={}));var le=function(){function e(e,t,n){this._internalType=B,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||T}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function he(e){return e&&e instanceof le&&e._internalType===B}var pe;!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(pe||(pe={}));var de=function(){function e(e,t,n){if(this._internalType=D,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||T,this.fieldName!==T)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,o=t.length;r<o;r++){(ye(i=t[r])||ve(i))&&(t[r]=i._setFieldName(this.fieldName))}}else{var i;(ye(i=t)||ve(i))&&(t=i._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var n=this.operands.map((function(n){return n instanceof e?n._setFieldName(t):n}));return new e(this.operator,n,t)},e.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(pe.AND,r,this.fieldName)},e.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(pe.OR,r,this.fieldName)},e}();function ye(e){return e&&e instanceof de&&e._internalType===D}var ge,_e=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(ge||(ge={}));var me=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.operator=t,o._internalType=R,o}return _e(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case ge.IN:case ge.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var n=new t(ge.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(ge.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(ge.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(ge.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(ge.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(ge.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(ge.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(ge.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof ce))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!W(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!W(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var n=new t(ge.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof ne||e.geometry instanceof z))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var n=new t(ge.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof ce||e.geometry instanceof J||e.geometry instanceof z||e.geometry instanceof Z||e.geometry instanceof ee||e.geometry instanceof ne))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var n=new t(ge.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(de);function ve(e){return e&&e instanceof me&&e._internalType===R}function be(e){return ve(e)}var we={};for(var Ee in ge)we[Ee]="$"+Ee;for(var Ee in pe)we[Ee]="$"+Ee;for(var Ee in ie)we[Ee]="$"+Ee;function Se(e){return we[e]||"$"+e}we[ge.NEQ]="$ne",we[ie.REMOVE]="$unset",we[ie.SHIFT]="$pop",we[ie.UNSHIFT]="$push";var Ae=function(){return(Ae=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)},Oe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},Ie=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Oe(arguments[t]));return e};function Ne(e){return function e(t,n){if(!G(t)){if($(t))return{$date:+t};if(K(t))return{$regex:t.source,$options:t.flags};if(Y(t))return t.map((function(t){if(n.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return e(t,Ie(n,[t]))}));if(F(t)){var r=Ae({},t);for(var o in r){if(n.indexOf(r[o])>-1)throw new Error("Cannot convert circular structure to JSON");r[o]=e(r[o],Ie(n,[r[o]]))}return r}return t}switch(t._internalType){case P:return t.toJSON();case M:case k:return t.parse();default:return t.toJSON?t.toJSON():t}}(e,[e])}var Te=function(){return(Te=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Be=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},Re=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Be(arguments[t]));return e};function De(e,t,n,r){var o=Te({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&F(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=De(s,t,Re(n,[i]),Re(r,[s]));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o[i+"."+c]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Pe(e){return De(e,Ue,[],[e])}function Le(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Y(e[r])?e[r].push(t[r]):F(e[r])?F(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is "+q(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+q(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]}function Ue(e){return G(e)||$(e)||K(e)}function xe(e){return Ne(e)}var Ce=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return he(e)?this.encodeUpdateCommand(e):"object"===q(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===T)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case ie.PUSH:case ie.PULL:case ie.PULL_ALL:case ie.POP:case ie.SHIFT:case ie.UNSHIFT:case ie.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,o,i=Se(e.operator);switch(e.operator){case ie.REMOVE:return(t={})[i]=((n={})[e.fieldName]="",n),t;default:return(r={})[i]=((o={})[e.fieldName]=e.operands[0],o),r}},e.prototype.encodeArrayUpdateCommand=function(e){var t,n,r,o,i,s,a,u,c,f,l=Se(e.operator);switch(e.operator){case ie.PUSH:var h=void 0;return h=Y(e.operands)?{$each:e.operands.map(xe)}:e.operands,(t={})[l]=((n={})[e.fieldName]=h,n),t;case ie.UNSHIFT:h={$each:e.operands.map(xe),$position:0};return(r={})[l]=((o={})[e.fieldName]=h,o),r;case ie.POP:return(i={})[l]=((s={})[e.fieldName]=1,s),i;case ie.SHIFT:return(a={})[l]=((u={})[e.fieldName]=-1,u),a;default:return(c={})[l]=((f={})[e.fieldName]=xe(e.operands),f),c}},e.prototype.encodeUpdateObject=function(e){var t=Pe(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(he(r)){t[n]=r._setFieldName(n),Le(t,this.encodeUpdateCommand(t[n]),n)}else{t[n]=r=xe(r);var o=new le(ie.SET,[r],n);Le(t,this.encodeUpdateCommand(o),n)}}return t},e}(),je={};function Me(e){if(!_t.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return je[t]||(je[t]=new _t.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new _t.reqClass(e.config)}}})),je[t]}var ke=function(){return(ke=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},qe=function(){function e(e,t,n,r){var o=this;void 0===r&&(r={}),this.watch=function(e){return Me(o._db).watch(ke(ke({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=e,this._coll=t,this.id=n,this.request=new _t.reqClass(this._db.config),this.projection=r}return e.prototype.create=function(e,t){t=t||fe();var n={collectionName:this._coll,data:Ne(e)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(e){e.code?t(0,e):t(0,{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||fe(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof le?n=!0:"object"==typeof e[t]&&r(e[t])};if(r(e),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:w.DOC,data:Ne(e),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||fe(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Ce.encode(e),query:n,queryType:w.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||fe();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:w.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||fe();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:w.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n=ae.formatResDocumentData(t.data.list);e(0,{data:n,requestId:t.requestId,total:t.TotalCount,limit:t.Limit,offset:t.Offset})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var n in t)t[n]?t[n]=1:t[n]=0;return new e(this._db,this._coll,this.id,t)},e}(),Fe=function(){function e(){}return e.encode=function(e){return(new We).encodeQuery(e)},e}(),We=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n;return Ue(e)?ye(e)?this.encodeLogicCommand(e):ve(e)?this.encodeQueryCommand(e):((n={})[t]=this.encodeQueryObject(e),n):F(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,n,r,o,i,s,a,u=this;switch(e.operator){case pe.NOR:case pe.AND:case pe.OR:var c=Se(e.operator),f=e.operands.map((function(t){return u.encodeQuery(t,e.fieldName)}));return(t={})[c]=f,t;case pe.NOT:c=Se(e.operator);var l=e.operands[0];if(K(l))return(n={})[e.fieldName]=((r={})[c]=this.encodeRegExp(l),r),n;f=this.encodeQuery(l)[e.fieldName];return(o={})[e.fieldName]=((i={})[c]=f,i),o;default:c=Se(e.operator);if(1===e.operands.length){var h=this.encodeQuery(e.operands[0]);return(s={})[c]=h,s}f=e.operands.map(this.encodeQuery.bind(this));return(a={})[c]=f,a}},e.prototype.encodeQueryCommand=function(e){return be(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,o,i,s,a,u,c;if(e.fieldName===T)throw new Error("Cannot encode a comparison command with unset field name");var f=Se(e.operator);switch(e.operator){case ge.EQ:case ge.NEQ:case ge.LT:case ge.LTE:case ge.GT:case ge.GTE:case ge.ELEM_MATCH:case ge.EXISTS:case ge.SIZE:case ge.MOD:return(t={})[e.fieldName]=((n={})[f]=xe(e.operands[0]),n),t;case ge.IN:case ge.NIN:case ge.ALL:return(r={})[e.fieldName]=((o={})[f]=xe(e.operands),o),r;case ge.GEO_NEAR:var l=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case ge.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case ge.GEO_INTERSECTS:l=e.operands[0];return(a={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(u={})[e.fieldName]=((c={})[f]=xe(e.operands[0]),c),u}},e.prototype.encodeQueryObject=function(e){var t=Pe(e);for(var n in t){var r=t[n];if(ye(r)){t[n]=r._setFieldName(n);var o=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else if(be(r)){t[n]=r._setFieldName(n);o=this.encodeComparisonCommand(t[n]);this.mergeConditionAfterEncode(t,o,n)}else Ue(r)&&(t[n]=xe(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?Y(e[r])?e[r]=e[r].concat(t[r]):F(e[r])?F(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+q(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+q(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),Ye=function(){return(Ye=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},$e=function(){function e(e,t,n,r,o){var i=this;this.watch=function(e){return Me(i._db).watch(Ye(Ye({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new _t.reqClass(this._db.config)}return e.prototype.get=function(e){e=e||fe();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var n={collectionName:this._coll,queryType:w.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),t.length>0&&(n.order=t),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n={data:ae.formatResDocumentData(t.data.list),requestId:t.requestId};t.TotalCount&&(n.total=t.TotalCount),t.Limit&&(n.limit=t.Limit),t.Offset&&(n.offset=t.Offset),e(0,n)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||fe();var t={collectionName:this._coll,queryType:w.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(t),r=n.some((function(e){return void 0!==t[e]}));if(n.length&&!r)throw Error(o.QueryParamValueError);return new e(this._db,this._coll,Fe.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,n){ue.isFieldPath(t),ue.isFieldOrder(n);var r={field:t,direction:n},o=this._fieldOrders.concat(r);return new e(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},e.prototype.limit=function(t){ue.isInteger("limit",t);var n=Ye({},this._queryOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.skip=function(t){ue.isInteger("offset",t);var n=Ye({},this._queryOptions);return n.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.update=function(e,t){if(t=t||fe(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:w.WHERE,multi:!0,merge:!0,upsert:!1,data:Ce.encode(e)};return this._request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var n in t)t[n]?"object"!=typeof t[n]&&(t[n]=1):t[n]=0;var r=Ye({},this._queryOptions);return r.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.remove=function(e){e=e||fe(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var t={collectionName:this._coll,query:Fe.encode(this._fieldFilters),queryType:w.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}(),Ke=n(1),Ge=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},He=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Je=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new _t.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Ge(this,void 0,void 0,(function(){var e;return He(this,(function(t){switch(t.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map(Ke.a.parse)}]:[2,e]}}))}))},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map((function(e){var t,n=e.stageKey,r=e.stageValue;return(t={})[n]=JSON.parse(r),t}))},e.prototype._pipe=function(e,t){return this._stages.push({stageKey:"$"+e,stageValue:JSON.stringify(t)}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",Fe.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),Ve=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ze=function(e){function t(t,n){return e.call(this,t,n)||this}return Ve(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new qe(this._db,this._coll,e)},t.prototype.add=function(e,t){return new qe(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new Je(this._db,this._coll)},t}($e),Xe={eq:function(e){return new me(ge.EQ,[e])},neq:function(e){return new me(ge.NEQ,[e])},lt:function(e){return new me(ge.LT,[e])},lte:function(e){return new me(ge.LTE,[e])},gt:function(e){return new me(ge.GT,[e])},gte:function(e){return new me(ge.GTE,[e])},in:function(e){return new me(ge.IN,e)},nin:function(e){return new me(ge.NIN,e)},all:function(e){return new me(ge.ALL,e)},elemMatch:function(e){return new me(ge.ELEM_MATCH,[e])},exists:function(e){return new me(ge.EXISTS,[e])},size:function(e){return new me(ge.SIZE,[e])},mod:function(e){return new me(ge.MOD,[e])},geoNear:function(e){return new me(ge.GEO_NEAR,[e])},geoWithin:function(e){return new me(ge.GEO_WITHIN,[e])},geoIntersects:function(e){return new me(ge.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.AND,n)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOR,n)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.OR,n)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOT,n)},set:function(e){return new le(ie.SET,[e])},remove:function(){return new le(ie.REMOVE,[])},inc:function(e){return new le(ie.INC,[e])},mul:function(e){return new le(ie.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(F(t[0])&&t[0].hasOwnProperty("each")){var r=t[0];e={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else e=Y(t[0])?t[0]:Array.from(t);return new le(ie.PUSH,e)},pull:function(e){return new le(ie.PULL,e)},pullAll:function(e){return new le(ie.PULL_ALL,e)},pop:function(){return new le(ie.POP,[])},shift:function(){return new le(ie.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new le(ie.UNSHIFT,n)},addToSet:function(e){return new le(ie.ADD_TO_SET,e)},rename:function(e){return new le(ie.RENAME,[e])},bit:function(e){return new le(ie.BIT,[e])},max:function(e){return new le(ie.MAX,[e])},min:function(e){return new le(ie.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===q(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new Je},abs:function(e){return new Ze("abs",e)},add:function(e){return new Ze("add",e)},ceil:function(e){return new Ze("ceil",e)},divide:function(e){return new Ze("divide",e)},exp:function(e){return new Ze("exp",e)},floor:function(e){return new Ze("floor",e)},ln:function(e){return new Ze("ln",e)},log:function(e){return new Ze("log",e)},log10:function(e){return new Ze("log10",e)},mod:function(e){return new Ze("mod",e)},multiply:function(e){return new Ze("multiply",e)},pow:function(e){return new Ze("pow",e)},sqrt:function(e){return new Ze("sqrt",e)},subtract:function(e){return new Ze("subtract",e)},trunc:function(e){return new Ze("trunc",e)},arrayElemAt:function(e){return new Ze("arrayElemAt",e)},arrayToObject:function(e){return new Ze("arrayToObject",e)},concatArrays:function(e){return new Ze("concatArrays",e)},filter:function(e){return new Ze("filter",e)},in:function(e){return new Ze("in",e)},indexOfArray:function(e){return new Ze("indexOfArray",e)},isArray:function(e){return new Ze("isArray",e)},map:function(e){return new Ze("map",e)},range:function(e){return new Ze("range",e)},reduce:function(e){return new Ze("reduce",e)},reverseArray:function(e){return new Ze("reverseArray",e)},size:function(e){return new Ze("size",e)},slice:function(e){return new Ze("slice",e)},zip:function(e){return new Ze("zip",e)},and:function(e){return new Ze("and",e)},not:function(e){return new Ze("not",e)},or:function(e){return new Ze("or",e)},cmp:function(e){return new Ze("cmp",e)},eq:function(e){return new Ze("eq",e)},gt:function(e){return new Ze("gt",e)},gte:function(e){return new Ze("gte",e)},lt:function(e){return new Ze("lt",e)},lte:function(e){return new Ze("lte",e)},neq:function(e){return new Ze("ne",e)},cond:function(e){return new Ze("cond",e)},ifNull:function(e){return new Ze("ifNull",e)},switch:function(e){return new Ze("switch",e)},dateFromParts:function(e){return new Ze("dateFromParts",e)},dateFromString:function(e){return new Ze("dateFromString",e)},dayOfMonth:function(e){return new Ze("dayOfMonth",e)},dayOfWeek:function(e){return new Ze("dayOfWeek",e)},dayOfYear:function(e){return new Ze("dayOfYear",e)},isoDayOfWeek:function(e){return new Ze("isoDayOfWeek",e)},isoWeek:function(e){return new Ze("isoWeek",e)},isoWeekYear:function(e){return new Ze("isoWeekYear",e)},millisecond:function(e){return new Ze("millisecond",e)},minute:function(e){return new Ze("minute",e)},month:function(e){return new Ze("month",e)},second:function(e){return new Ze("second",e)},hour:function(e){return new Ze("hour",e)},week:function(e){return new Ze("week",e)},year:function(e){return new Ze("year",e)},literal:function(e){return new Ze("literal",e)},mergeObjects:function(e){return new Ze("mergeObjects",e)},objectToArray:function(e){return new Ze("objectToArray",e)},allElementsTrue:function(e){return new Ze("allElementsTrue",e)},anyElementTrue:function(e){return new Ze("anyElementTrue",e)},setDifference:function(e){return new Ze("setDifference",e)},setEquals:function(e){return new Ze("setEquals",e)},setIntersection:function(e){return new Ze("setIntersection",e)},setIsSubset:function(e){return new Ze("setIsSubset",e)},setUnion:function(e){return new Ze("setUnion",e)},concat:function(e){return new Ze("concat",e)},dateToString:function(e){return new Ze("dateToString",e)},indexOfBytes:function(e){return new Ze("indexOfBytes",e)},indexOfCP:function(e){return new Ze("indexOfCP",e)},split:function(e){return new Ze("split",e)},strLenBytes:function(e){return new Ze("strLenBytes",e)},strLenCP:function(e){return new Ze("strLenCP",e)},strcasecmp:function(e){return new Ze("strcasecmp",e)},substr:function(e){return new Ze("substr",e)},substrBytes:function(e){return new Ze("substrBytes",e)},substrCP:function(e){return new Ze("substrCP",e)},toLower:function(e){return new Ze("toLower",e)},toUpper:function(e){return new Ze("toUpper",e)},meta:function(e){return new Ze("meta",e)},addToSet:function(e){return new Ze("addToSet",e)},avg:function(e){return new Ze("avg",e)},first:function(e){return new Ze("first",e)},last:function(e){return new Ze("last",e)},max:function(e){return new Ze("max",e)},min:function(e){return new Ze("min",e)},push:function(e){return new Ze("push",e)},stdDevPop:function(e){return new Ze("stdDevPop",e)},stdDevSamp:function(e){return new Ze("stdDevSamp",e)},sum:function(e){return new Ze("sum",e)},let:function(e){return new Ze("let",e)}},project:{slice:function(e){return new Qe("slice",e)},elemMatch:function(e){return new Qe("elemMatch",e)}}},Ze=function(e,t){this["$"+e]=t},Qe=function(e,t){this["$"+e]=t},et=function(){function e(e){var t=e.regexp,n=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=n}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return k},enumerable:!0,configurable:!0}),e}();function tt(e){return new et(e)}var nt={code:"INSERT_DOC_FAIL",message:"insert document failed"},rt={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},ot=function(){return(ot=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},it=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},st=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},at="database.updateDocInTransaction",ut=function(){function e(e,t,n){this._coll=t,this.id=n,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return it(this,void 0,void 0,(function(){var t,n,r,o;return st(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:Ke.a.stringify(Ne(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((n=i.sent()).code)throw n;if(r=Ke.a.parse(n.inserted),1==(o=Ke.a.parse(n.ok))&&1==r)return[2,ot(ot({},n),{ok:o,inserted:r})];throw new Error(nt.message)}}))}))},e.prototype.get=function(){return it(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,{data:"null"!==t.data?ae.formatField(Ke.a.parse(t.data)):Ke.a.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return it(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Ke.a.stringify(Ne(e),{relaxed:!1}),upsert:!0},[4,this._request.send(at,t)];case 1:if((n=r.sent()).code)throw n;return[2,ot(ot({},n),{updated:Ke.a.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},e.prototype.update=function(e){return it(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Ke.a.stringify(Ce.encode(e),{relaxed:!1})},[4,this._request.send(at,t)];case 1:if((n=r.sent()).code)throw n;return[2,ot(ot({},n),{updated:Ke.a.parse(n.updated)})]}}))}))},e.prototype.delete=function(){return it(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,ot(ot({},t),{deleted:Ke.a.parse(t.deleted)})]}}))}))},e}(),ct=function(e,t){this._coll=t,this._transaction=e},ft=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),lt=function(e){function t(t,n){return e.call(this,t,n)||this}return ft(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new ut(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new ut(this._transaction,this._coll,t).create(e)},t}(ct),ht=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},pt=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},dt=function(){function e(e){this._db=e,this._request=new _t.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return ht(this,void 0,void 0,(function(){var e;return pt(this,(function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}}))}))},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new lt(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return ht(this,void 0,void 0,(function(){var e,t;return pt(this,(function(n){switch(n.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=n.sent()).code)throw t;return this.commited=!0,[2,t]}}))}))},e.prototype.rollback=function(e){return ht(this,void 0,void 0,(function(){var t,n;return pt(this,(function(r){switch(r.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=e,[2,n]}}))}))},e}();function yt(){return ht(this,void 0,void 0,(function(){var e;return pt(this,(function(t){switch(t.label){case 0:return[4,(e=new dt(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function gt(e,t){return void 0===t&&(t=3),ht(this,void 0,void 0,(function(){var n,r,o,i,s=this;return pt(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new dt(this)).init()];case 1:return a.sent(),[4,e(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(e){return ht(s,void 0,void 0,(function(){return pt(this,(function(t){switch(t.label){case 0:if(n.aborted||n.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.rollback()];case 2:return t.sent(),[3,4];case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===n.aborted)throw n.abortReason;throw e}}))}))},t<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===rt.code?[4,gt.bind(this)(e,--t)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}}))}))}var _t=function(){function e(e){this.config=e,this.Geo=i,this.serverDate=oe,this.command=Xe,this.RegExp=tt,this.startTransaction=yt,this.runTransaction=gt,this.logicCommand=de,this.updateCommand=le,this.queryCommand=me}return e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new ze(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",n)},e}(),mt=function(){return(mt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var vt={name:"database",entity:{database:function(e){var t=this.platform,n=t.adapter,r=t.runtime;return _t.reqClass=this.request.constructor,_t.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},_t.runtime=r,this.wsClientClass&&(_t.wsClass=n.wsClass,_t.wsClientClass=this.wsClientClass),_t.ws||(_t.ws=null),new _t(mt(mt({},this.config),e))}}};try{cloudbase.registerComponent(vt)}catch(e){}function bt(e){try{e.registerComponent(vt)}catch(e){console.warn(e)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"registerRealtime",(function(){return q}));var r=n(10),o=n.n(r),i=n(11),s=n.n(i),a=n(12),u=n.n(a);function c(e){return void 0===e&&(e=""),(e?e+"_":"")+ +new Date+"_"+Math.random()}var f,l,h=function(e){this.close=e.close,this.onChange=e.onChange,this.onError=e.onError,e.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return e.virtualClient}})},p=function(e){var t,n,r=e.id,o=e.docChanges,i=e.docs,s=e.msgType,a=e.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return t||(t=JSON.parse(JSON.stringify(o))),t},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},d=(f=function(e,t){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}f(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),y=function(e){function t(t){var n=e.call(this,"Watch Error "+JSON.stringify(t.msgData)+" (requestid: "+t.requestId+")")||this;return n.isRealtimeErrorMessageError=!0,n.payload=t,n}return d(t,e),t}(Error),g=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="timeout",t.payload=null,t.generic=!0,t}return d(t,e),t}(Error),m=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="cancelled",t.payload=null,t.generic=!0,t}return d(t,e),t}(Error),v=function(e){function t(t){var n=e.call(this,t.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: "+this.errCode+" "+(b[this.errCode]||"")+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e}}}),n.errCode=t.errCode||"UNKNOWN_ERROR",n.errMsg=t.errMsg,n}return d(t,e),Object.defineProperty(t.prototype,"message",{get:function(){return"errCode: "+this.errCode+" | errMsg: "+this.errMsg},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),t}(Error),b={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"},w=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},E=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},S=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},A=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};!function(e){e.LOGGINGIN="LOGGINGIN",e.INITING="INITING",e.REBUILDING="REBUILDING",e.ACTIVE="ACTIVE",e.ERRORED="ERRORED",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.PAUSED="PAUSED",e.RESUMING="RESUMING"}(l||(l={}));var O=function(){function e(e){var t=this;this.watchStatus=l.INITING,this._login=function(e,n){return E(t,void 0,void 0,(function(){var t;return S(this,(function(r){switch(r.label){case 0:return this.watchStatus=l.LOGGINGIN,[4,this.login(e,n)];case 1:return t=r.sent(),this.envId||(this.envId=t.envId),[2,t]}}))}))},this.initWatch=function(e){return E(t,void 0,void 0,(function(){var t,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(t,r){return E(n,void 0,void 0,(function(){var n,o,i,s,a,u,f,h,d,y;return S(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];case 1:return n=g.sent().envId,this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=l.INITING,o={watchId:this.watchId,requestId:c(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=g.sent(),s=i.msgData,a=s.events,u=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:u-1,currentDocs:[]},a.length>0){for(f=0,h=a;f<h.length;f++)h[f].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,d=new p({id:u,docChanges:[],docs:[],type:"init"}),this.listener.onChange(d),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=l.ACTIVE,this._availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return y=g.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._initWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch "+(t?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(e){return E(t,void 0,void 0,(function(){var t,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(t,r){return E(n,void 0,void 0,(function(){var n,o,i,s;return S(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):[4,this._login(this.envId,e)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=l.REBUILDING,o={watchId:this.watchId,requestId:c(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=l.ACTIVE,this._availableRetries.REBUILD_WATCH=2,t(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._rebuildWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this._rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch "+(t?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(e,n){return E(t,void 0,void 0,(function(){var t,r,o,i=this;return S(this,(function(s){return t="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new v({errCode:t?b.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:b.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),n.reject(e)},o=function(e){i.useRetryTicket(n.operationName)?t?(i._initWatchPromise=void 0,n.resolve(i.initWatch(e))):(i._rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(e))):r()},this.handleCommonError(e,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){return E(i,void 0,void 0,(function(){var e,t=this;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),e=function(){return E(t,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];case 1:return r.sent(),[3,7];case 2:return[4,w(100)];case 3:return r.sent(),this.watchStatus!==l.PAUSED?[3,4]:(n.reject(new m(n.operationName+" cancelled due to pause after unknownError")),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return E(t,void 0,void 0,(function(){var e,t,n;return S(this,(function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==l.ACTIVE)return this.watchStatus=l.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=l.CLOSING,t={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=l.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,e),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){t.clearACKSchedule(),t._ackTimeoutId=setTimeout((function(){t._waitExpectedTimeoutId?t.scheduleSendACK():t.sendACK()}),1e4)},this.clearACKSchedule=function(){t._ackTimeoutId&&clearTimeout(t._ackTimeoutId)},this.sendACK=function(){return E(t,void 0,void 0,(function(){var e,t,n;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==l.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:c(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:e})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(t=r.sent(),g(t))switch((n=t.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this._availableRetries.CHECK_LAST&&this._availableRetries.CHECK_LAST>0?(this._availableRetries.CHECK_LAST--,this.scheduleSendACK()):this.closeWithError(new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(g(e)){switch(e.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void t.onSignError(e);case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":default:return void t.onNotRetryableError(e)}}else{if(function(e){return"timeout"===e.type}(e))return void t.onTimeoutError(e);if(function(e){return"cancelled"===e.type}(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_"+ +new Date+"_"+Math.random(),this.envId=e.envId,this.collectionName=e.collectionName,this.query=e.query,this.limit=e.limit,this.orderBy=e.orderBy,this.send=e.send,this.login=e.login,this.isWSConnected=e.isWSConnected,this.onceWSConnected=e.onceWSConnected,this.getWaitExpectedTimeoutLength=e.getWaitExpectedTimeoutLength,this.onWatchStart=e.onWatchStart,this.onWatchClose=e.onWatchClose,this.debug=e.debug,this._availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new h({close:this.closeWatch,onChange:e.onChange,onError:e.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return e.prototype.onMessage=function(e){var t=this;switch(this.watchStatus){case l.PAUSED:if("ERROR"!==e.msgType)return;break;case l.LOGGINGIN:case l.INITING:case l.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while "+this.watchStatus);case l.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case l.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),e.msgType){case"NEXT_EVENT":console.warn("nextevent "+e.msgData.currEvent+" ignored",e),this.handleServerEvents(e);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<e.msgData.currEvent&&(this.sessionInfo.expectEventId=e.msgData.currEvent,this.clearWaitExpectedEvent(),this._waitExpectedTimeoutId=setTimeout((function(){t.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength "+this.getWaitExpectedTimeoutLength()));break;case"ERROR":this.closeWithError(new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:e.msgData.code+" - "+e.msgData.message}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg "+e.msgType+": ",e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){this.watchStatus=l.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,this.sessionInfo&&this.sessionInfo.queryID||""),console.log("[realtime] client closed ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.pause=function(){this.watchStatus=l.PAUSED,console.log("[realtime] client paused ("+this.collectionName+" "+this.query+") (watchId "+this.watchId+")")},e.prototype.resume=function(){return E(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0:this.watchStatus=l.RESUMING,console.log("[realtime] client resuming with "+(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH")+" ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return t.sent(),console.log("[realtime] client successfully resumed ("+this.collectionName+" "+this.query+") ("+this.watchId+")"),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed ("+this.collectionName+" "+this.query+") ("+this.watchId+")",e),[3,4];case 4:return[2]}}))}))},e.prototype.useRetryTicket=function(e){return!!(this._availableRetries[e]&&this._availableRetries[e]>0)&&(this._availableRetries[e]--,console.log("[realtime] "+e+" use a retry ticket, now only "+this._availableRetries[e]+" retry left"),!0)},e.prototype.handleServerEvents=function(e){return E(this,void 0,void 0,(function(){var t;return S(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this._handleServerEvents(e)];case 1:return n.sent(),this._postHandleServerEventsValidityCheck(e),[3,3];case 2:throw t=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",t),t;case 3:return[2]}}))}))},e.prototype._handleServerEvents=function(e){return E(this,void 0,void 0,(function(){var t,n,r,i,a,c,f,l,h,d,y,g;return S(this,(function(_){switch(_.label){case 0:if(t=e.requestId,n=e.msgData.events,r=e.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(I)}catch(e){return this.closeWithError(new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}c=A(i.currentDocs),f=!1,l=function(n,l){var d,y,g,_,m,w,E,O,I,N,T;return S(this,(function(S){switch(S.label){case 0:return d=a[n],i.currentEventId>=d.id?(!a[n-1]||d.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur "+i.currentEventId+" but got "+d.id):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId "+t+")"),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==d.id-1)return[3,2];switch(d.dataType){case"update":if(!d.doc)switch(d.queueType){case"update":case"dequeue":if(y=c.find((function(e){return e._id===d.docId}))){if(w=u()(y),d.updatedFields)for(m in d.updatedFields)o()(w,m,d.updatedFields[m]);if(d.removedFields)for(g=0,_=d.removedFields;g<_.length;g++)m=_[g],s()(w,m);d.doc=w}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw E=new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '+e.requestId+")"}),h.closeWithError(E),E}break;case"replace":if(!d.doc)throw E=new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '+e.requestId+")"}),h.closeWithError(E),E;break;case"remove":(w=c.find((function(e){return e._id===d.docId})))?d.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!d.doc)switch(d.queueType){case"dequeue":(w=c.find((function(e){return e._id===d.docId})))?d.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw E=new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '+e.requestId+")"}),h.closeWithError(E),E}}switch(d.queueType){case"init":f?c.push(d.doc):(f=!0,c=[d.doc]);break;case"enqueue":c.push(d.doc);break;case"dequeue":(O=c.findIndex((function(e){return e._id===d.docId})))>-1?c.splice(O,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":(O=c.findIndex((function(e){return e._id===d.docId})))>-1?c[O]=d.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===l-1||a[n+1]&&a[n+1].id!==d.id)&&(I=A(c),N=a.slice(0,n+1).filter((function(e){return e.id===d.id})),h.sessionInfo.currentEventId=d.id,h.sessionInfo.currentDocs=c,T=new p({id:d.id,docChanges:N,docs:I,msgType:r}),h.listener.onChange(T)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur "+h.sessionInfo.currentEventId+" but got "+d.id),[4,h.rebuildWatch()];case 3:return S.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,d=0,y=a.length,_.label=1;case 1:return d<y?[5,l(d,y)]:[3,4];case 2:if("object"==typeof(g=_.sent()))return[2,g.value];_.label=3;case 3:return d++,[3,1];case 4:return[2]}}))}))},e.prototype._postHandleServerEventsValidityCheck=function(e){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<e.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},e.prototype.clearWaitExpectedEvent=function(){this._waitExpectedTimeoutId&&(clearTimeout(this._waitExpectedTimeoutId),this._waitExpectedTimeoutId=void 0)},e}();function I(e){var t={id:e.ID,dataType:e.DataType,queueType:e.QueueType,docId:e.DocID,doc:e.Doc&&"{}"!==e.Doc?JSON.parse(e.Doc):void 0};return"update"===e.DataType&&(e.UpdatedFields&&(t.updatedFields=JSON.parse(e.UpdatedFields)),(e.removedFields||e.RemovedFields)&&(t.removedFields=JSON.parse(e.removedFields))),t}var N,T={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}};!function(e){e[e.NormalClosure=1e3]="NormalClosure",e[e.GoingAway=1001]="GoingAway",e[e.ProtocolError=1002]="ProtocolError",e[e.UnsupportedData=1003]="UnsupportedData",e[e.NoStatusReceived=1005]="NoStatusReceived",e[e.AbnormalClosure=1006]="AbnormalClosure",e[e.InvalidFramePayloadData=1007]="InvalidFramePayloadData",e[e.PolicyViolation=1008]="PolicyViolation",e[e.MessageTooBig=1009]="MessageTooBig",e[e.MissingExtension=1010]="MissingExtension",e[e.InternalError=1011]="InternalError",e[e.ServiceRestart=1012]="ServiceRestart",e[e.TryAgainLater=1013]="TryAgainLater",e[e.BadGateway=1014]="BadGateway",e[e.TLSHandshake=1015]="TLSHandshake",e[e.ReconnectWebSocket=3e3]="ReconnectWebSocket",e[e.NoRealtimeListeners=3001]="NoRealtimeListeners",e[e.HeartbeatPingError=3002]="HeartbeatPingError",e[e.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",e[e.NoAuthentication=3050]="NoAuthentication"}(N||(N={}));var B=function(e,t){var n=T[e],r=n?n.name+", code "+e+", reason "+(t||n.description):"code "+e;return new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},R=null,D="web";function P(){return D}var L=function(){return(L=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},U=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},x=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},C=1,j=function(){function e(e){var t=this;this._virtualWSClient=new Set,this._queryIdClientMap=new Map,this._watchIdClientMap=new Map,this._pingFailed=0,this._pongMissed=0,this._logins=new Map,this._wsReadySubsribers=[],this._wsResponseWait=new Map,this._rttObserved=[],this.send=function(e){return U(t,void 0,void 0,(function(){var t=this;return x(this,(function(n){return[2,new Promise((function(n,r){return U(t,void 0,void 0,(function(){var t,o,i,s,a,u,c,f=this;return x(this,(function(l){switch(l.label){case 0:o=!1,i=!1,s=function(e){o=!0,t&&clearTimeout(t),n(e)},a=function(e){i=!0,t&&clearTimeout(t),r(e)},e.timeout&&(t=setTimeout((function(){return U(f,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,w(0)];case 1:e.sent(),o&&i||a(new _("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),l.label=1;case 1:return l.trys.push([1,8,,9]),this._wsInitPromise?[4,this._wsInitPromise]:[3,3];case 2:l.sent(),l.label=3;case 3:if(!this._ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(this._ws.readyState!==C)return a(new Error("ws readyState invalid: "+this._ws.readyState+", can not send message")),[2];e.waitResponse&&this._wsResponseWait.set(e.msg.requestId,{resolve:s,reject:a,skipOnMessage:e.skipOnMessage}),l.label=4;case 4:return l.trys.push([4,6,,7]),[4,this._ws.send(JSON.stringify(e.msg))];case 5:return l.sent(),e.waitResponse||s(),[3,7];case 6:return(u=l.sent())&&(a(u),e.waitResponse&&this._wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return c=l.sent(),a(c),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(e){t._virtualWSClient.forEach((function(t){t.closeWithError(e)}))},this.pauseClients=function(e){(e||t._virtualWSClient).forEach((function(e){e.pause()}))},this.resumeClients=function(e){(e||t._virtualWSClient).forEach((function(e){e.resume()}))},this.initWebSocketConnection=function(e,n){return void 0===n&&(n=t._maxReconnect),U(t,void 0,void 0,(function(){var t=this;return x(this,(function(r){switch(r.label){case 0:if(e&&this._reconnectState)return[2];if(e&&(this._reconnectState=!0),this._wsInitPromise)return[2,this._wsInitPromise];e&&this.pauseClients(),this.close(N.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,o){return U(t,void 0,void 0,(function(){var t,i,s=this;return x(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=a.sent(),[4,new Promise((function(e){var n=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=R;s._ws=r?new r(n):new WebSocket(n),e()}))];case 2:return a.sent(),this._ws.connect?[4,this._ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),e&&(this.resumeClients(),this._reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(!0,this._wsInitPromise=void 0,[4,w(this._reconnectInterval)]):[3,9];case 7:a.sent(),e&&(this._reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(e,n-1)),[3,10];case 9:o(i),e&&this.closeAllClients(new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._wsInitPromise];case 2:return r.sent(),this._wsReadySubsribers.forEach((function(e){return(0,e.resolve)()})),[3,5];case 3:return r.sent(),this._wsReadySubsribers.forEach((function(e){return(0,e.reject)()})),[3,5];case 4:return this._wsInitPromise=void 0,this._wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(e,n){if(!t._ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;t._ws.onopen=function(t){console.warn("[realtime] ws event: open",t),r=!0,e()},t._ws.onerror=function(e){t._logins=new Map,r?(console.error("[realtime] ws event: error",e),t.clearHeartbeat(),t._virtualWSClient.forEach((function(t){return t.closeWithError(new v({errCode:b.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:e}))}))):(console.error("[realtime] ws open failed with ws event: error",e),n(e))},t._ws.onclose=function(e){switch(console.warn("[realtime] ws event: close",e),t._logins=new Map,t.clearHeartbeat(),e.code){case N.ReconnectWebSocket:case N.NoRealtimeListeners:break;case N.HeartbeatPingError:case N.HeartbeatPongTimeoutError:case N.NormalClosure:case N.AbnormalClosure:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(B(e.code));break;case N.NoAuthentication:t.closeAllClients(B(e.code,e.reason));break;default:t._maxReconnect>0?t.initWebSocketConnection(!0,t._maxReconnect):t.closeAllClients(B(e.code))}},t._ws.onmessage=function(e){var n,r=e.data;t.heartbeat();try{n=JSON.parse(r)}catch(e){throw new Error("[realtime] onMessage parse res.data error: "+e)}if("ERROR"===n.msgType){var o=null;t._virtualWSClient.forEach((function(e){e.watchId===n.watchId&&(o=e)})),o&&o.listener.onError(n)}var i=t._wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new y(n)):i.resolve(n)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t._wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&t._watchIdClientMap.get(n.watchId);if(s)s.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId "+n.watchId+": ",n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(s=t._queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,u=Array.from(t._watchIdClientMap.entries());a<u.length;a++){u[a][1].onMessage(n);break}}}else if(t._lastPingSendTS){var c=Date.now()-t._lastPingSendTS;if(c>1e4)return void console.warn("[realtime] untrusted rtt observed: "+c);t._rttObserved.length>=3&&t._rttObserved.splice(0,t._rttObserved.length-3+1),t._rttObserved.push(c)}},t.heartbeat()}))},this.isWSConnected=function(){return Boolean(t._ws&&t._ws.readyState===C)},this.onceWSConnected=function(){return U(t,void 0,void 0,(function(){var e=this;return x(this,(function(t){return this.isWSConnected()?[2]:this._wsInitPromise?[2,this._wsInitPromise]:[2,new Promise((function(t,n){e._wsReadySubsribers.push({resolve:t,reject:n})}))]}))}))},this.webLogin=function(e,n){return U(t,void 0,void 0,(function(){var t,r,o,i,s,a,u,f,l=this;return x(this,(function(h){switch(h.label){case 0:if(!n)if(e){if(t=this._logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(t.loggingInPromise)return[2,t.loggingInPromise]}}else if(null==(r=this._logins.get(""))?void 0:r.loggingInPromise)return[2,r.loggingInPromise];o=new Promise((function(e,t){return U(l,void 0,void 0,(function(){var n,r,o,i,s;return x(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=a.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:c(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:P(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(i=a.sent()).msgData.code?t(new Error(i.msgData.code+" "+i.msgData.message)):e({envId:n.envId}),[3,4];case 3:return s=a.sent(),t(s),[3,4];case 4:return[2]}}))}))})),i=e&&this._logins.get(e),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this._logins.set(e||"",i)),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,o];case 2:if(a=h.sent(),(u=e&&this._logins.get(e))&&u===i&&u.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(u){if(u.loggedIn&&u.loginResult)return[2,u.loginResult];if(u.loggingInPromise)return[2,u.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return U(t,void 0,void 0,(function(){var e,t,n,r,o,i,s;return x(this,(function(a){switch(a.label){case 0:return this._wsSign&&this._wsSign.expiredTs>Date.now()?[2,this._wsSign]:(e=Date.now()+6e4,[4,this._context.appConfig.request.send("auth.wsWebSign",{runtime:P()})]);case 1:if((t=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: "+t.code);if(t.data)return n=t.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,expiredTs:e}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return t._rttObserved.length?t._rttObserved.reduce((function(e,t){return e+t}))/t._rttObserved.length*1.5:5e3},this.ping=function(){return U(t,void 0,void 0,(function(){var e;return x(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:c(),msgType:"PING",msgData:null},[4,this.send({msg:e})];case 1:return t.sent(),[2]}}))}))},this.onWatchStart=function(e,n){t._queryIdClientMap.set(n,e)},this.onWatchClose=function(e,n){n&&t._queryIdClientMap.delete(n),t._watchIdClientMap.delete(e.watchId),t._virtualWSClient.delete(e),t._virtualWSClient.size||t.close(N.NoRealtimeListeners)},this._maxReconnect=e.maxReconnect||5,this._reconnectInterval=e.reconnectInterval||1e4,this._context=e.context}return e.prototype.clearHeartbeat=function(){this._pingTimeoutId&&clearTimeout(this._pingTimeoutId),this._pongTimeoutId&&clearTimeout(this._pongTimeoutId)},e.prototype.close=function(e){this.clearHeartbeat(),this._ws&&(this._ws.close(e,T[e].name),this._ws=void 0)},e.prototype.watch=function(e){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var t=new O(L(L({},e),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this._virtualWSClient.add(t),this._watchIdClientMap.set(t.watchId,t),t.listener},e.prototype.heartbeat=function(e){var t=this;this.clearHeartbeat(),this._pingTimeoutId=setTimeout((function(){return U(t,void 0,void 0,(function(){var e=this;return x(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this._ws&&this._ws.readyState===C?(this._lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return t.sent(),this._pingFailed=0,this._pongTimeoutId=setTimeout((function(){console.error("pong timed out"),e._pongMissed<2?(e._pongMissed++,e.heartbeat(!0)):e.initWebSocketConnection(!0)}),this._context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this._pingFailed<2?(this._pingFailed++,this.heartbeat()):this.close(N.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this._context.appConfig.realtimePingInterval)},e}(),M={target:"database",entity:function(){var e,t=this.platform,n=t.adapter,r=t.runtime;e=n.wsClass,R=e,function(e){D=e}(r)}},k={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=j}};try{cloudbase.registerComponent(k),cloudbase.registerHook(M)}catch(e){}function q(e){try{e.registerComponent(k),e.registerHook(M)}catch(e){console.warn(e)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"LoginState",(function(){return Te})),n.d(t,"Auth",(function(){return Be})),n.d(t,"AuthProvider",(function(){return a})),n.d(t,"EVENTS",(function(){return Re})),n.d(t,"eventBus",(function(){return Ie})),n.d(t,"registerAuth",(function(){return Pe})),n.d(t,"registerProvider",(function(){return Le}));var r,o=n(0),i=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},s=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},a=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request}return e.prototype.checkLocalLoginState=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,o,i;return s(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 Te({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 i(this,void 0,void 0,(function(){var t,n,r,o;return s(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 i(this,void 0,void 0,(function(){var n,r,o;return s(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 i(this,void 0,void 0,(function(){var e;return s(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 i(this,void 0,void 0,(function(){var t;return s(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"}(r||(r={}));var u,c=(u=function(e,t){return(u=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}u(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),f=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},l=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},h=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},p=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},d=o.constants.getSdkName,y=o.constants.ERRORS,g=o.constants.COMMUNITY_SITE_URL,_=o.adapters.RUNTIME,m=o.utils.getQuery,v=o.utils.getHash,b=o.utils.removeParam,w=o.utils.printWarn,E=o.helpers.catchErrorsDecorator,S=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 c(t,e),t.prototype.signIn=function(){return h(this,void 0,void 0,(function(){return p(this,(function(e){return[2,w(y.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]}))}))},t.prototype.signInWithRedirect=function(){return h(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this._redirect()]}))}))},t.prototype.getRedirectResult=function(e){return h(this,void 0,void 0,(function(){var t;return p(this,(function(n){return(t=A())?[2,this._signInWithCode(t,e)]:[2,null]}))}))},t.prototype.getLinkRedirectResult=function(e){return void 0===e&&(e={}),h(this,void 0,void 0,(function(){var t,n,r,o,i,s;return p(this,(function(a){return t=e.withUnionId,n=void 0!==t&&t,(r=A())?(o=this._appid,i=function(e){switch(e){case"snsapi_login":return"WECHAT-OPEN";default:return"WECHAT-PUBLIC"}}(this._scope),s=this._runtime===_.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=b("code",location.href);e=b("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("["+d()+"]["+y.UNKOWN_ERROR+"]"+e)}},t.prototype._signInWithCode=function(e,t){return h(this,void 0,void 0,(function(){var n,o,i,s,a,u,c,f;return p(this,(function(l){switch(l.label){case 0:return n=this._cache.keys,o=n.accessTokenKey,i=n.accessTokenExpireKey,s=n.refreshTokenKey,a=function(e){switch(e){case"snsapi_login":return"WECHAT-OPEN";default:return"WECHAT-PUBLIC"}}(this._scope),[4,this._getRefreshTokenByWXCode(this._appid,a,e,t)];case 1:return u=l.sent(),c=u.refreshToken,[4,this._cache.setStoreAsync(s,c)];case 2:return l.sent(),u.accessToken?[4,this._cache.setStoreAsync(o,u.accessToken)]:[3,4];case 3:l.sent(),l.label=4;case 4:return u.accessTokenExpire?[4,this._cache.setStoreAsync(i,String(u.accessTokenExpire+Date.now()))]:[3,6];case 5:l.sent(),l.label=6;case 6:return Ie.fire(Re.LOGIN_STATE_CHANGED),Ie.fire(Re.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return l.sent(),[4,(f=new Te({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return l.sent(),[2,f]}}))}))},t.prototype._getRefreshTokenByWXCode=function(e,t,n,r){return void 0===r&&(r={}),h(this,void 0,void 0,(function(){var o,i,s,a,u,c;return p(this,(function(f){return o=r.withUnionId,i=void 0!==o&&o,s=r.createUser,a=void 0===s||s,u="snsapi_base"!==this._scope&&(r.syncUserInfo||!1),"auth.signIn",c=this._runtime===_.WX_MP?"1":"0",[2,this._request.send("auth.signIn",{appid:e,loginType:t,hybridMiniapp:c,syncUserInfo:u,loginCredential:n,withUnionId:i,createUser:a}).then((function(e){if(e.code)throw new Error("["+d()+"]["+y.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("["+d()+"]["+y.OPERATION_FAIL+"] action:getJwt not return refreshToken")}))]}))}))},f([E({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+g]}),l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",Promise)],t.prototype,"signInWithRedirect",null),f([E({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+g]}),l("design:type",Function),l("design:paramtypes",[Object]),l("design:returntype",Promise)],t.prototype,"getRedirectResult",null),f([E({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+g]}),l("design:type",Function),l("design:paramtypes",[Object]),l("design:returntype",Promise)],t.prototype,"getLinkRedirectResult",null),t}(a);function A(){return m("code")||v("code")}var O=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)}}(),I=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},N=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},T=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},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:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},R=o.constants.ERRORS,D=o.constants.COMMUNITY_SITE_URL,P=o.utils.throwError,L=o.utils.isString,U=o.events.addEventListener,x=o.helpers.catchErrorsDecorator,C=function(e){function t(t){var n=e.call(this,t)||this;return n._onConverted=n._onConverted.bind(n),U(Re.ANONYMOUS_CONVERTED,n._onConverted),n}return O(t,e),t.prototype.signIn=function(){return T(this,void 0,void 0,(function(){var e,t,n,o,i,s,a;return B(this,(function(u){switch(u.label){case 0:return[4,this._cache.updatePersistenceAsync("local")];case 1:return u.sent(),e=this._cache.keys,t=e.anonymousUuidKey,n=e.refreshTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return o=u.sent(),[4,this._cache.getStoreAsync(n)];case 3:return i=u.sent(),[4,this._request.send("auth.signInAnonymously",{anonymous_uuid:o,refresh_token:i})];case 4:return(s=u.sent()).uuid&&s.refresh_token?[4,this._setAnonymousUUID(s.uuid)]:[3,10];case 5:return u.sent(),[4,this.setRefreshToken(s.refresh_token)];case 6:return u.sent(),[4,this._request.refreshAccessToken()];case 7:return u.sent(),Ie.fire(Re.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.ANONYMOUS,persistence:"local"}),Ie.fire(Re.LOGIN_STATE_CHANGED),[4,(a=new Te({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return u.sent(),[4,a.user.refresh()];case 9:return u.sent(),[2,a];case 10:throw new Error(JSON.stringify({code:R.OPERATION_FAIL,msg:JSON.stringify(s)||"anonymous signIn failed"}))}}))}))},t.prototype.linkAndRetrieveDataWithTicket=function(e){return T(this,void 0,void 0,(function(){var t,n,o,i,s,a,u;return B(this,(function(c){switch(c.label){case 0:return L(e)||P(R.INVALID_PARAMS,"ticket must be a string"),t=this._cache.keys,n=t.anonymousUuidKey,o=t.refreshTokenKey,[4,this._cache.getStoreAsync(n)];case 1:return i=c.sent(),[4,this._cache.getStoreAsync(o)];case 2:return s=c.sent(),[4,this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:i,refresh_token:s,ticket:e})];case 3:return(a=c.sent()).refresh_token?[4,this._clearAnonymousUUID()]:[3,8];case 4:return c.sent(),[4,this.setRefreshToken(a.refresh_token)];case 5:return c.sent(),[4,this._request.refreshAccessToken()];case 6:return c.sent(),Ie.fire(Re.ANONYMOUS_CONVERTED,{env:this._config.env}),Ie.fire(Re.LOGIN_TYPE_CHANGED,{loginType:r.CUSTOM,persistence:"local"}),[4,(u=new Te({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return c.sent(),[2,u];case 8:P(R.OPERATION_FAIL,JSON.stringify(a)||"linkAndRetrieveDataWithTicket failed"),c.label=9;case 9:return[2]}}))}))},t.prototype._setAnonymousUUID=function(e){return T(this,void 0,void 0,(function(){var t,n,o;return B(this,(function(i){switch(i.label){case 0:return t=this._cache.keys,n=t.anonymousUuidKey,o=t.loginTypeKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.setStoreAsync(n,e)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,r.ANONYMOUS)];case 3:return i.sent(),[2]}}))}))},t.prototype._clearAnonymousUUID=function(){return T(this,void 0,void 0,(function(){return B(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 T(this,void 0,void 0,(function(){return B(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]}}))}))},I([x({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),N("design:type",Function),N("design:paramtypes",[]),N("design:returntype",Promise)],t.prototype,"signIn",null),t}(a),j=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)}}(),M=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},k=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},q=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},F=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},W=o.constants.ERRORS,Y=o.constants.COMMUNITY_SITE_URL,$=o.utils.isString,K=o.helpers.catchErrorsDecorator,G=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return j(t,e),t.prototype.signIn=function(e){return q(this,void 0,void 0,(function(){var t,n,o,i,s,a,u;return F(this,(function(c){switch(c.label){case 0:if(!$(e))throw new Error(JSON.stringify({code:W.INVALID_PARAMS,msg:"ticket must be a string"}));return t=this._cache.keys.refreshTokenKey,i=(o=this._request).send,s=["auth.signInWithTicket"],a={ticket:e},[4,this._cache.getStoreAsync(t)];case 1:return[4,i.apply(o,s.concat([(a.refresh_token=c.sent()||"",a)]))];case 2:return(n=c.sent()).refresh_token?[4,this.setRefreshToken(n.refresh_token)]:[3,7];case 3:return c.sent(),[4,this._request.refreshAccessToken()];case 4:return c.sent(),Ie.fire(Re.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.CUSTOM,persistence:this._config.persistence}),Ie.fire(Re.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return c.sent(),[4,(u=new Te({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 6:return c.sent(),[2,u];case 7:throw new Error(JSON.stringify({code:W.OPERATION_FAIL,msg:"custom signIn failed"}))}}))}))},M([K({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Y]}),k("design:type",Function),k("design:paramtypes",[String]),k("design:returntype",Promise)],t.prototype,"signIn",null),t}(a),H=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 a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},V=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{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},X=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Z=o.utils.throwError,Q=o.utils.isString,ee=o.constants.ERRORS,te=o.constants.COMMUNITY_SITE_URL,ne=o.helpers.catchErrorsDecorator,re=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return H(t,e),t.prototype.signIn=function(e,t){return z(this,void 0,void 0,(function(){var n,o,i,s,a;return X(this,(function(u){switch(u.label){case 0:return Q(e)||Z(ee.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 o=u.sent(),i=o.refresh_token,s=o.access_token,a=o.access_token_expire,i?[4,this.setRefreshToken(i)]:[3,8];case 2:return u.sent(),s&&a?[4,this.setAccessToken(s,a)]:[3,4];case 3:return u.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:u.sent(),u.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return u.sent(),Ie.fire(Re.LOGIN_STATE_CHANGED),Ie.fire(Re.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.EMAIL,persistence:this._config.persistence}),[2,new Te({envId:this._config.env,cache:this._cache,request:this._request})];case 8:o.code?Z(ee.OPERATION_FAIL,"Email login fail["+o.code+"] "+o.message):Z(ee.OPERATION_FAIL,"Email login fail"),u.label=9;case 9:return[2]}}))}))},t.prototype.signUp=function(e,t){return z(this,void 0,void 0,(function(){return X(this,(function(n){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})]}))}))},t.prototype.resetPassword=function(e){return z(this,void 0,void 0,(function(){return X(this,(function(t){return[2,this._request.send("auth.sendPasswordResetEmail",{email:e})]}))}))},t.prototype.resetPasswordWithToken=function(e,t){return z(this,void 0,void 0,(function(){return X(this,(function(n){return[2,this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})]}))}))},t.prototype.activate=function(e){return z(this,void 0,void 0,(function(){return X(this,(function(t){return[2,this._request.send("auth.activateEndUserMail",{token:e})]}))}))},J([ne({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),V("design:type",Function),V("design:paramtypes",[String,String]),V("design:returntype",Promise)],t.prototype,"signIn",null),J([ne({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),V("design:type",Function),V("design:paramtypes",[String,String]),V("design:returntype",Promise)],t.prototype,"signUp",null),J([ne({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),V("design:type",Function),V("design:paramtypes",[String]),V("design:returntype",Promise)],t.prototype,"resetPassword",null),J([ne({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),V("design:type",Function),V("design:paramtypes",[String,String]),V("design:returntype",Promise)],t.prototype,"resetPasswordWithToken",null),J([ne({title:"邮箱激活失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+te]}),V("design:type",Function),V("design:paramtypes",[String]),V("design:returntype",Promise)],t.prototype,"activate",null),t}(a),oe=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)}}(),ie=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},se=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ae=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},ue=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},ce=o.utils.printWarn,fe=o.constants.ERRORS,le=o.constants.COMMUNITY_SITE_URL,he=o.helpers.catchErrorsDecorator,pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return oe(t,e),t.prototype.signIn=function(e,t){return ae(this,void 0,void 0,(function(){var n,o,i,s,a,u,c,f,l;return ue(this,(function(h){switch(h.label){case 0:if("string"!=typeof e)throw new Error(JSON.stringify({code:fe.INVALID_PARAMS,msg:"username must be a string"}));return"string"!=typeof t&&(t="",ce(fe.INVALID_PARAMS,"password is empty")),n=this._cache.keys.refreshTokenKey,s=(i=this._request).send,a=["auth.signIn"],u={loginType:r.USERNAME,username:e,password:t},[4,this._cache.getStoreAsync(n)];case 1:return[4,s.apply(i,a.concat([(u.refresh_token=h.sent()||"",u)]))];case 2:return o=h.sent(),c=o.refresh_token,f=o.access_token_expire,l=o.access_token,c?[4,this.setRefreshToken(c)]:[3,9];case 3:return h.sent(),l&&f?[4,this.setAccessToken(l,f)]:[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(),Ie.fire(Re.LOGIN_STATE_CHANGED),Ie.fire(Re.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.USERNAME,persistence:this._config.persistence}),[2,new Te({envId:this._config.env,cache:this._cache,request:this._request})];case 9:throw o.code?new Error(JSON.stringify({code:fe.OPERATION_FAIL,msg:"login by username failed:["+o.code+"] "+o.message})):new Error(JSON.stringify({code:fe.OPERATION_FAIL,msg:"login by username failed"}));case 10:return[2]}}))}))},ie([he({title:"用户名密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录"," 3 - 用户名密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+le]}),se("design:type",Function),se("design:paramtypes",[String,String]),se("design:returntype",Promise)],t.prototype,"signIn",null),t}(a),de=function(){return(de=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)},ye=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},ge=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},_e=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},me=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},ve=o.events.CloudbaseEventEmitter,be=o.adapters.RUNTIME,we=o.utils.printWarn,Ee=o.utils.throwError,Se=o.constants.ERRORS,Ae=o.constants.COMMUNITY_SITE_URL,Oe=o.helpers.catchErrorsDecorator,Ie=new ve,Ne=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 _e(this,void 0,void 0,(function(){return me(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.location={country:this._getLocalUserInfo("country"),province:this._getLocalUserInfo("province"),city:this._getLocalUserInfo("city")},[2]}))}))},e.prototype.checkLocalInfoAsync=function(){return _e(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a,u,c,f,l,h,p,d,y;return me(this,(function(g){switch(g.label){case 0:return e=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return e.uid=g.sent(),t=this,[4,this._getLocalUserInfoAsync("loginType")];case 2:return t.loginType=g.sent(),n=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 3:return n.openid=g.sent(),r=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 4:return r.wxOpenId=g.sent(),o=this,[4,this._getLocalUserInfoAsync("wxPublicId")];case 5:return o.wxPublicId=g.sent(),i=this,[4,this._getLocalUserInfoAsync("wxUnionId")];case 6:return i.unionId=g.sent(),s=this,[4,this._getLocalUserInfoAsync("qqMiniOpenId")];case 7:return s.qqMiniOpenId=g.sent(),a=this,[4,this._getLocalUserInfoAsync("customUserId")];case 8:return a.customUserId=g.sent(),u=this,[4,this._getLocalUserInfoAsync("nickName")];case 9:return u.nickName=g.sent(),c=this,[4,this._getLocalUserInfoAsync("gender")];case 10:return c.gender=g.sent(),f=this,[4,this._getLocalUserInfoAsync("avatarUrl")];case 11:return f.avatarUrl=g.sent(),l=this,[4,this._getLocalUserInfoAsync("email")];case 12:return l.email=g.sent(),h=this,p=Boolean,[4,this._getLocalUserInfoAsync("hasPassword")];case 13:return h.hasPassword=p.apply(void 0,[g.sent()]),d=this,y={},[4,this._getLocalUserInfoAsync("country")];case 14:return y.country=g.sent(),[4,this._getLocalUserInfoAsync("province")];case 15:return y.province=g.sent(),[4,this._getLocalUserInfoAsync("city")];case 16:return d.location=(y.city=g.sent(),y),[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 _e(this,void 0,void 0,(function(){var e,t,n,r,o,i;return me(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 _e(this,void 0,void 0,(function(){var t,n,r,o,i,s,a;return me(this,(function(u){switch(u.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 a=u.sent().data,this._setLocalUserInfo(a),[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&&Ee(Se.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:e})},e.prototype.refresh=function(){return _e(this,void 0,void 0,(function(){var e;return me(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._getLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;return this._cache.getStore(t)[e]},e.prototype._getLocalUserInfoAsync=function(e){return _e(this,void 0,void 0,(function(){var t;return me(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"].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()},ye([Oe({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[String]),ge("design:returntype",Promise)],e.prototype,"linkWithTicket",null),ye([Oe({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[Object]),ge("design:returntype",void 0)],e.prototype,"linkWithRedirect",null),ye([Oe({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[]),ge("design:returntype",Promise)],e.prototype,"getLinkedUidList",null),ye([Oe({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[String]),ge("design:returntype",void 0)],e.prototype,"setPrimaryUid",null),ye([Oe({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[String]),ge("design:returntype",void 0)],e.prototype,"unlink",null),ye([Oe({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[Object]),ge("design:returntype",Promise)],e.prototype,"update",null),ye([Oe({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[String,String]),ge("design:returntype",void 0)],e.prototype,"updatePassword",null),ye([Oe({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[String]),ge("design:returntype",void 0)],e.prototype,"updateEmail",null),ye([Oe({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[String]),ge("design:returntype",void 0)],e.prototype,"updateUsername",null),ye([Oe({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[]),ge("design:returntype",Promise)],e.prototype,"refresh",null),e}(),Te=function(){function e(e){var t=e.envId,n=e.cache,r=e.request;t||Ee(Se.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new Ne({cache:n,request:r})}return e.prototype.checkLocalState=function(){return _e(this,void 0,void 0,(function(){var e,t,n,r,o,i,s;return me(this,(function(a){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 _e(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a;return me(this,(function(u){switch(u.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=u.sent(),[4,this._cache.getStoreAsync(n)];case 2:return i=u.sent(),[4,this._cache.getStoreAsync(r)];case 3:return s=u.sent(),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},a=this,[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 4:return a._loginType=u.sent(),[4,this.user.checkLocalInfoAsync()];case 5:return u.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"isAnonymousAuth",{get:function(){return this.loginType===r.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCustomAuth",{get:function(){return this.loginType===r.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWeixinAuth",{get:function(){return this.loginType===r.WECHAT||this.loginType===r.WECHAT_OPEN||this.loginType===r.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsernameAuth",{get:function(){return this.loginType===r.USERNAME},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._loginType},enumerable:!1,configurable:!0}),e}(),Be=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request,this._runtime=e.runtime||be.WEB,Ie.on(Re.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}we(Se.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 _e(this,void 0,void 0,(function(){var e;return me(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 _e(this,void 0,void 0,(function(){return me(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 _e(this,void 0,void 0,(function(){var e;return me(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 S(de(de({},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 C(de(de({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},e.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new G(de(de({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},e.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new re(de(de({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},e.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new pe(de(de({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},e.prototype.signInWithUsernameAndPassword=function(e,t){return _e(this,void 0,void 0,(function(){return me(this,(function(n){return[2,this.usernameAuthProvider().signIn(e,t)]}))}))},e.prototype.isUsernameRegistered=function(e){return _e(this,void 0,void 0,(function(){var t;return me(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&Ee(Se.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 _e(this,void 0,void 0,(function(){return me(this,(function(n){return[2,this.emailAuthProvider().signIn(e,t)]}))}))},e.prototype.signUpWithEmailAndPassword=function(e,t){return _e(this,void 0,void 0,(function(){return me(this,(function(n){return[2,this.emailAuthProvider().signUp(e,t)]}))}))},e.prototype.sendPasswordResetEmail=function(e){return _e(this,void 0,void 0,(function(){return me(this,(function(t){return[2,this.emailAuthProvider().resetPassword(e)]}))}))},e.prototype.signOut=function(){return _e(this,void 0,void 0,(function(){var e,t,n,o,i,s,a;return me(this,(function(u){switch(u.label){case 0:return[4,this.getLoginType()];case 1:if(u.sent()===r.ANONYMOUS)throw new Error(JSON.stringify({code:Se.INVALID_OPERATION,msg:"anonymous user doesn't support signOut action"}));return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,o=e.accessTokenExpireKey,i="auth.logout",[4,this._cache.getStoreAsync(t)];case 2:return(s=u.sent())?[4,this._request.send(i,{refresh_token:s})]:[2];case 3:return a=u.sent(),this._cache.removeStoreAsync(t),this._cache.removeStoreAsync(n),this._cache.removeStoreAsync(o),Ie.fire(Re.LOGIN_STATE_CHANGED),Ie.fire(Re.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.NULL,persistence:this._config.persistence}),[2,a]}}))}))},e.prototype.onLoginStateChanged=function(e){return _e(this,void 0,void 0,(function(){var t,n=this;return me(this,(function(r){switch(r.label){case 0:return Ie.on(Re.LOGIN_STATE_CHANGED,(function(){return _e(n,void 0,void 0,(function(){var t;return me(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){Ie.on(Re.LOGIN_STATE_EXPIRED,e.bind(this))},e.prototype.onAccessTokenRefreshed=function(e){Ie.on(Re.ACCESS_TOKEN_REFRESHD,e.bind(this))},e.prototype.onAnonymousConverted=function(e){Ie.on(Re.ANONYMOUS_CONVERTED,e.bind(this))},e.prototype.onLoginTypeChanged=function(e){var t=this;Ie.on(Re.LOGIN_TYPE_CHANGED,(function(){return _e(t,void 0,void 0,(function(){var t;return me(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 Te({envId:this._config.env,cache:this._cache,request:this._request});return t.checkLocalState(),t}return null}we(Se.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},e.prototype.getLoginState=function(){return _e(this,void 0,void 0,(function(){var e,t;return me(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 Te({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 _e(this,void 0,void 0,(function(){var e;return me(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,de(de({},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 _e(this,void 0,void 0,(function(){var e,t,n,r;return me(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._onLoginTypeChanged=function(e){return _e(this,void 0,void 0,(function(){var t,n,r;return me(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]}}))}))},ye([Oe({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[]),ge("design:returntype",Promise)],e.prototype,"getCurrenUser",null),ye([Oe({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[String]),ge("design:returntype",Promise)],e.prototype,"isUsernameRegistered",null),ye([Oe({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[]),ge("design:returntype",Promise)],e.prototype,"signOut",null),ye([Oe({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[]),ge("design:returntype",Promise)],e.prototype,"getLoginState",null),ye([Oe({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Ae]}),ge("design:type",Function),ge("design:paramtypes",[]),ge("design:returntype",Promise)],e.prototype,"getUserInfo",null),e}(),Re={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},De={name:"auth",namespace:"auth",injectEvents:{bus:Ie,events:[Re.LOGIN_TYPE_CHANGED,Re.LOGIN_STATE_EXPIRED,Re.LOGIN_STATE_CHANGED,Re.ACCESS_TOKEN_REFRESHD,Re.ANONYMOUS_CONVERTED]},entity:function(e){if(void 0===e&&(e={region:"",persistence:"session"}),this.authInstance)return we(Se.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,a=i.persistence,u=i.debug;return this.authInstance=new Be({env:s,region:e.region,persistence:a,debug:u,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(De)}catch(e){}function Pe(e){try{e.registerComponent(De)}catch(e){console.warn(e)}}function Le(e,t){Be.prototype[e]=function(n){var r="_"+e;return this[r]||(this[r]=new t(de(de({},n),this._config))),this[r]}}},function(e,t,n){"use strict";n.r(t),n.d(t,"cloudbase",(function(){return re}));var r,o=n(0),i=n(3),s=(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=function(){return(a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},u=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},c=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};var f=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return s(t,e),t.prototype.post=function(e){var t=this;return new Promise((function(n,r){var o=e.url,s=e.data,a=e.headers,u=wx.request({url:Object(i.formatUrl)("https:",o),data:s,timeout:t._timeout,method:"POST",header:a,success:function(e){n(e)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg)){console.warn(t._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t.prototype.upload=function(e){var t=this,n=this;return new Promise((function(r){return u(t,void 0,void 0,(function(){var t,o,i,s,u,f;return c(this,(function(c){return t=e.url,o=e.file,i=e.data,s=e.headers,u=e.onUploadProgress,f=wx.uploadFile({url:t,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(t.statusCode=parseInt(i.success_action_status,10)),r(t)},fail:function(e){r(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{f.abort()}catch(e){}}}}),u&&f.onProgressUpdate((function(e){u(e)})),[2]}))}))}))},t.prototype.download=function(e){var t=this,n=this;return new Promise((function(r,o){var s=e.url,a=e.headers,u=wx.downloadFile({url:Object(i.formatUrl)("https:",s),header:a,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?r({statusCode:200,tempFilePath:e.tempFilePath}):r(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg)){console.warn(n._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t}(i.AbstractSDKRequest),l={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},h=function(e,t){void 0===t&&(t={});var n=wx.connectSocket(a({url:e},t));return{set onopen(e){n.onOpen(e)},set onmessage(e){n.onMessage(e)},set onclose(e){n.onClose(e)},set onerror(e){n.onError(e)},send:function(e){return n.send({data:e})},close:function(e,t){return n.close({code:e,reason:t})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var p={genAdapter:function(){return{root:{},reqClass:f,wsClass:h,localStorage:l,primaryStorage:i.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0},runtime:"wx_mp"},d=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},y=o.constants.ERRORS,g={};function _(e,t){var n=t.name,r=t.namespace,o=t.entity,i=t.injectEvents,s=t.IIFE,a=void 0!==s&&s;if(g[n]||r&&e[r])throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"Duplicate component "+n}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(e)}if(g[n]=t,r?e.prototype[r]=o:function e(t,n){if(!(n instanceof Object))return n;switch(n.constructor){case Date:return new Date(n.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return n}for(var r in n)n.hasOwnProperty(r)&&(t[r]=e(t[r],n[r]));return t}(e.prototype,o),i){var u=i.bus,c=i.events;if(!u||!c||0===c.length)return;var f=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[n]?e.prototype.events[n].events=d(e.prototype.events[n].events,c):e.prototype.events[n]={bus:u,events:c},e.prototype.fire=function(e,t){for(var n in f(e,t),this.events){var r=this.events[n],o=r.bus;if(r.events.includes(e)){o.fire(e,t);break}}}}}var m={},v=function(){return(v=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},b=o.cache.CloudbaseCache,w={},E={};function S(e){var t=e.env,n=e.persistence,r=e.platformInfo,o={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(v(v({},e),{keys:o,platformInfo:r,alwaysLocalKeys:["anonymousUuidKey"]})),E[t]=E[t]||new b(v(v({},e),{keys:o,platformInfo:r,persistence:"local"}))}function A(e){return w[e]}function O(e){return E[e]}var I=n(2),N="loginStateExpire",T="refreshAccessToken",B=function(){return(B=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{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},D=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},P=o.constants.ERRORS,L=o.utils.genSeqId,U=o.utils.isFormData,x=o.utils.formatUrl,C=o.utils.createSign,j=o.adapters.RUNTIME,M=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function k(e,t,n){var r=e[t];e[t]=function(t){var o={},i={};n.forEach((function(n){var r=n.call(e,t),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=t.data;return s&&function(){if(U(s))for(var e in o)s.append(e,o[e]);else t.data=B(B({},s),o)}(),t.headers=B(B({},t.headers||{}),i),r.call(e,t)}}function q(){var e=L();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+Object(I.e)(),"x-seqid":e}}}var F=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new m.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e.throw||!1,this._cache=A(this.config.env),this._localCache=O(this.config.env),k(this._reqClass,"post",[q]),k(this._reqClass,"upload",[q]),k(this._reqClass,"download",[q])}return e.prototype.post=function(e){return R(this,void 0,void 0,(function(){return D(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 D(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 D(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 D(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,a,u;return D(this,(function(c){switch(c.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(!c.sent())throw new Error(JSON.stringify({code:P.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=c.sent(),s=Number,[4,this._cache.getStoreAsync(n)];case 3:return i=s.apply(void 0,[c.sent()]),a=!0,(u=this._shouldRefreshAccessTokenHook)?[4,this._shouldRefreshAccessTokenHook(o,i)]:[3,5];case 4:u=!c.sent(),c.label=5;case 5:return u&&(a=!1),o&&i&&!(i<Date.now())||!a?[3,7]:[4,this.refreshAccessToken()];case 6:return[2,c.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,a,u,c,f,l,h,p,d,y,g,_,v,b,w,E,S,A,O,N,T,R,P;return D(this,(function(D){switch(D.label){case 0:return r="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",i=B({action:e,dataVersion:I.a,env:this.config.env},t),-1!==M.indexOf(e)?[3,3]:(s=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(s)]);case 1:return D.sent()?(a=i,[4,this.getAccessToken()]):[3,3];case 2:a.access_token=D.sent().accessToken,D.label=3;case 3:if("storage.uploadFile"===e){for(c in u=new FormData)u.hasOwnProperty(c)&&void 0!==u[c]&&u.append(c,i[c]);o="multipart/form-data"}else for(c in o="application/json;charset=UTF-8",u={},i)void 0!==i[c]&&(u[c]=i[c]);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),(l=this._localCache.getStore(r))&&(f.headers["X-TCB-Trace"]=l),m.runtime!==j.WEB&&(h=this.config,p=h.appSign,d=h.appSecret,y=Date.now(),g=d.appAccessKey,_=d.appAccessKeyId,v=C({data:u,timestamp:y,appAccessKeyId:_,appSign:p},g),f.headers["X-TCB-App-Source"]="timestamp="+y+";appAccessKeyId="+_+";appSign="+p+";sign="+v),b=t.parse,w=t.inQuery,E=t.search,S={env:this.config.env},b&&(S.parse=!0),w&&(S=B(B({},w),S)),A=Object(I.c)(),O=A.BASE_URL,N=A.PROTOCOL,T=x(N,O,S),E&&(T+=E),[4,this.post(B({url:T,data:u},f))];case 4:if(R=D.sent(),(P=R.header&&R.header["x-tcb-trace"])&&this._localCache.setStore(r,P),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 D(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!==M.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:P.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},e.prototype._refreshAccessToken=function(){return R(this,void 0,void 0,(function(){var e,t,n,r,o,i,s,a,u,c,f,l,h;return D(this,(function(p){switch(p.label){case 0:return e=this._cache.keys,t=e.accessTokenKey,n=e.accessTokenExpireKey,r=e.refreshTokenKey,o=e.loginTypeKey,i=e.anonymousUuidKey,[4,this._cache.removeStoreAsync(t)];case 1:return p.sent(),[4,this._cache.removeStoreAsync(n)];case 2:return p.sent(),[4,this._cache.getStoreAsync(r)];case 3:if(!(s=p.sent()))throw new Error(JSON.stringify({code:P.INVALID_OPERATION,msg:"not login"}));return a={refresh_token:s},[4,this.request("auth.fetchAccessTokenWithRefreshToken",a)];case 4:return(u=p.sent()).data.code?"SIGN_PARAM_INVALID"!==(c=u.data.code)&&"REFRESH_TOKEN_EXPIRED"!==c&&"INVALID_REFRESH_TOKEN"!==c?[3,11]:[4,this._cache.getStoreAsync(o)]:[3,12];case 5:return p.sent()===I.b.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===c?[4,this._cache.getStoreAsync(i)]:[3,9];case 6:return f=p.sent(),[4,this._cache.getStoreAsync(r)];case 7:return l=p.sent(),[4,this.send("auth.signInAnonymously",{anonymous_uuid:f,refresh_token:l})];case 8:return h=p.sent(),this._setRefreshToken(h.refresh_token),[2,this._refreshAccessToken()];case 9:return re.fire(N),[4,this._cache.removeStoreAsync(r)];case 10:p.sent(),p.label=11;case 11:throw new Error(JSON.stringify({code:P.NETWORK_ERROR,msg:"refresh access_token failed:"+u.data.code}));case 12:return u.data.access_token?(re.fire(T),[4,this._cache.setStoreAsync(t,u.data.access_token)]):[3,15];case 13:return p.sent(),[4,this._cache.setStoreAsync(n,u.data.access_token_expire+Date.now())];case 14:return p.sent(),[2,{accessToken:u.data.access_token,accessTokenExpire:u.data.access_token_expire}];case 15:return u.data.refresh_token?[4,this._cache.removeStoreAsync(r)]:[3,19];case 16:return p.sent(),[4,this._cache.setStoreAsync(r,u.data.refresh_token)];case 17:return p.sent(),[4,this._refreshAccessToken()];case 18:p.sent(),p.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 D(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}(),W={};var Y=function(){return(Y=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)},$=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},K=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},G=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},H=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},J=o.adapters.useAdapters,V=o.adapters.useDefaultAdapter,z=o.adapters.RUNTIME,X=o.constants.ERRORS,Z=o.constants.COMMUNITY_SITE_URL,Q=o.utils.printWarn,ee=o.helpers.catchErrorsDecorator,te={timeout:15e3,persistence:"session"},ne={},re=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 m},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return A(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return O(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this._config.env,W[e];var e},enumerable:!1,configurable:!0}),e.prototype.init=function(t){if(!t.env)throw new Error(JSON.stringify({code:X.INVALID_PARAMS,msg:"env must not be specified"}));if(m.adapter||this._useDefaultAdapter(),this.requestClient=new m.adapter.reqClass({timeout:t.timeout||5e3,timeoutMsg:"["+Object(I.d)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+t.timeout/1e3+"s"}),m.runtime!==z.WEB){if(!t.appSecret)throw new Error(JSON.stringify({code:X.INVALID_PARAMS,msg:"invalid appSecret"}));var n=m.adapter.getAppSign?m.adapter.getAppSign():"";if(t.appSign&&n&&t.appSign!==n)throw new Error(JSON.stringify({code:X.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(t.appSign=n),!t.appSign)throw new Error(JSON.stringify({code:X.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=Y(Y({},te),t),this._config.timeout=this._formatTimeout(this._config.timeout);var r=this._config,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,u=r.appSecret,c=r.appSign;return S({env:o,persistence:i,debug:s,platformInfo:this.platform}),function(e){W[e.env]=new F(B(B({},e),{throw:!0}))}({env:o,region:t.region||"",timeout:a,appSecret:u,appSign:c}),t.region&&Object(I.g)(o,t.region||""),new e(this._config)},e.prototype.updateConfig=function(e){var t=e.persistence,n=e.debug;this._config.persistence=t,this._config.debug=n,S({env:this._config.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.registerExtension=function(e){ne[e.name]=e},e.prototype.invokeExtension=function(e,t){return G(this,void 0,void 0,(function(){var n;return H(this,(function(r){switch(r.label){case 0:if(!(n=ne[e]))throw new Error(JSON.stringify({code:X.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=J(e)||{},n=t.adapter,r=t.runtime;n&&(m.adapter=n),r&&(m.runtime=r)},e.prototype.registerHook=function(t){!function(e,t){var n=t.entity,r=t.target;if(!e.prototype.hasOwnProperty(r))throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var o=e.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:y.INVALID_OPERATION,msg:"target:"+r+" is not a function which is the only type supports hook"}));e.prototype[r]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.call.apply(n,d([this],e)),o.call.apply(o,d([this],e))}}(e,t)},e.prototype.registerComponent=function(t){_(e,t)},e.prototype.registerVersion=function(e){Object(I.i)(e)},e.prototype.registerSdkName=function(e){Object(I.h)(e)},e.prototype.registerEndPoint=function(e,t){Object(I.f)(e,t)},e.prototype._useDefaultAdapter=function(){var e=V(),t=e.adapter,n=e.runtime;m.adapter=t,m.runtime=n},e.prototype._formatTimeout=function(e){switch(!0){case e>6e5:return Q(X.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),6e5;case e<100:return Q(X.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},$([ee({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Z]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",e)],e.prototype,"init",null),$([ee({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+Z]}),K("design:type",Function),K("design:paramtypes",[String,Object]),K("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}());re.useAdapters(p);t.default=re}])}));
|