@jolibox/sdk 1.1.19-beta.6 → 1.1.19

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.
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "files": {
3
- "packages/sdk/.rush/temp/shrinkwrap-deps.json": "14c542a2304268048706c23eda6c4ee8676b3227",
3
+ "packages/sdk/.rush/temp/shrinkwrap-deps.json": "954affd2a5e9a53a0ca1c48e32a486f5bd1621be",
4
4
  "packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
5
5
  "packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/sdk/esbuild.config.js": "1725a85515499085a7c9799b834c6f632073401c",
7
- "packages/sdk/package.json": "f22a1233f9b4d265efd06953528bf67facaebbd3",
7
+ "packages/sdk/package.json": "6058bf98353553417815247a96ea5bfb397778f6",
8
8
  "packages/sdk/src/__tests__/index.test.ts": "f22e0c0741297803ac3ec016b1dcc166cd2248bd",
9
9
  "packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
10
10
  "packages/sdk/src/api/can-i-use.ts": "4fd7efe21419d39e535584d7ab8e6a3c4e186877",
11
11
  "packages/sdk/src/api/get-system-info.ts": "c73be9f62c7055093effadaf6c48c54d6f383542",
12
12
  "packages/sdk/src/api/index.ts": "d293bd3fe6099bc7c3f79be12cf86f07c55a8d3e",
13
13
  "packages/sdk/src/api/login.ts": "747c923c87175b467c17e303a14210bf0ab7a1cb",
14
- "packages/sdk/src/api/on-custom-event.ts": "5001a430fef95b1198245511489badcdc47c2acc",
14
+ "packages/sdk/src/api/on-custom-event.ts": "0e51f100cd8edb962e7a31fcccc811f36fe8de2b",
15
15
  "packages/sdk/src/api/request.ts": "117baeceb72bd1602a01f3e1fe586faaea48d155",
16
16
  "packages/sdk/src/events.ts": "124aa9c3dbfa2477ba4d365d63446fae6b542f1f",
17
- "packages/sdk/src/index.ts": "e23e305dff4ad41e08dbde21f03ec694dd1b71b6",
17
+ "packages/sdk/src/index.ts": "ca10da46e311902c8a161a3869595d01a47e30e1",
18
18
  "packages/sdk/src/loader/__tests__/version.test.ts": "338ca817bfcb672d1065d6f32872b57bc43951b5",
19
19
  "packages/sdk/src/loader/h5.ts": "1565cba2f78e9ca854cd25682c6f3ac90c19ba34",
20
20
  "packages/sdk/src/loader/index.ts": "336b16295c341ce53d13adc9a04da857b6150e80",
@@ -2,11 +2,15 @@
2
2
  "../../packages/sdk": "../../packages/sdk:0JN5V6/nCY3HNOl5cHknpXXlfqGk48XB8ocf5TGVuLw=:",
3
3
  "/@ampproject/remapping/2.3.0": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==",
4
4
  "/@babel/code-frame/7.26.2": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==",
5
+ "/@babel/code-frame/7.27.1": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==",
5
6
  "/@babel/compat-data/7.26.5": "sha512-XvcZi1KWf88RVbF9wn8MN6tYFloU5qX8KjuF3E1PVBmJ9eypXfs4GRiJwLuTZL0iSnJUKn1BFPa5BPZZJyFzPg==",
7
+ "/@babel/compat-data/7.27.1": "sha512-Q+E+rd/yBzNQhXkG+zQnF58e4zoZfBedaxwzPmicKsiK3nt8iJYrSrDbjwFFDGC4f+rPafqRaPH6TsDoSvMf7A==",
6
8
  "/@babel/core/7.23.3": "sha512-Jg+msLuNuCJDyBvFv5+OKOUjWMZgd85bKjbICd3zWrKAo+bJ49HJufi7CQE0q0uR8NGyO6xkCACScNqyjHSZew==",
7
9
  "/@babel/generator/7.26.5": "sha512-2caSP6fN9I7HOe6nqhtft7V4g7/V/gfDsC3Ag4W7kEzzvRGKqiv0pu0HogPiZ3KaVSoNDhUws6IJjDjpfmYIXw==",
10
+ "/@babel/generator/7.27.1": "sha512-UnJfnIpc/+JO0/+KRVQNGU+y5taA5vCbwN8+azkX6beii/ZF+enZJSOKo11ZSzGJjlNfJHfQtmQT8H+9TXPG2w==",
8
11
  "/@babel/helper-annotate-as-pure/7.25.9": "sha512-gv7320KBUFJz1RnylIg5WWYPRXKZ884AGkYpgpWW02TH66Dl+HaC1t1CKd0z3R4b6hdYEcmrNZHUmfCP+1u3/g==",
9
12
  "/@babel/helper-compilation-targets/7.26.5": "sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA==",
13
+ "/@babel/helper-compilation-targets/7.27.1": "sha512-2YaDd/Rd9E598B5+WIc8wJPmWETiiJXFYVE60oX8FDohv7rAUU3CQj+A1MgeEmcsk2+dQuEjIe/GDvig0SqL4g==",
10
14
  "/@babel/helper-create-class-features-plugin/7.25.9_@babel+core@7.23.3": "sha512-UTZQMvt0d/rSz6KI+qdu7GQze5TIajwTS++GUozlw8VBJDEOAqSXwm1WvmYEZwqdqSGQshRocPDqrt4HBZB3fQ==",
11
15
  "/@babel/helper-create-regexp-features-plugin/7.26.3_@babel+core@7.23.3": "sha512-G7ZRb40uUgdKOQqPLjfD12ZmGA54PzqDFUv2BKImnC9QIfGhIHKvVML0oN8IUiDq4iRqpq74ABpvOaerfWdong==",
12
16
  "/@babel/helper-define-polyfill-provider/0.4.4_@babel+core@7.23.3": "sha512-QcJMILQCu2jm5TFPGA3lCpJJTeEP+mqeXooG/NZbg/h5FTFi6V0+99ahlRsW8/kRLyb24LZVCCiclDedhLKcBA==",
@@ -14,18 +18,24 @@
14
18
  "/@babel/helper-define-polyfill-provider/0.6.3_@babel+core@7.23.3": "sha512-HK7Bi+Hj6H+VTHA3ZvBis7V/6hu9QuTrnMXNybfUf2iiuU/N97I8VjB+KbhFF8Rld/Lx5MzoCwPCpPjfK+n8Cg==",
15
19
  "/@babel/helper-member-expression-to-functions/7.25.9": "sha512-wbfdZ9w5vk0C0oyHqAJbc62+vet5prjj01jjJ8sKn3j9h3MQQlflEdXYvuqRWjHnM12coDEqiC1IRCi0U/EKwQ==",
16
20
  "/@babel/helper-module-imports/7.25.9": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==",
21
+ "/@babel/helper-module-imports/7.27.1": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==",
17
22
  "/@babel/helper-module-transforms/7.26.0_@babel+core@7.23.3": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==",
23
+ "/@babel/helper-module-transforms/7.27.1_@babel+core@7.23.3": "sha512-9yHn519/8KvTU5BjTVEEeIM3w9/2yXNKoD82JifINImhpKkARMJKPP59kLo+BafpdN5zgNeIcS4jsGDmd3l58g==",
18
24
  "/@babel/helper-optimise-call-expression/7.25.9": "sha512-FIpuNaz5ow8VyrYcnXQTDRGvV6tTjkNtCK/RYNDXGSLlUD6cBuQTSw43CShGxjvfBTfcUA/r6UhUCbtYqkhcuQ==",
19
25
  "/@babel/helper-plugin-utils/7.26.5": "sha512-RS+jZcRdZdRFzMyr+wcsaqOmld1/EqTghfaBGQQd/WnRdzdlvSZ//kF7U8VQTxf1ynZ4cjUcYgjVGx13ewNPMg==",
20
26
  "/@babel/helper-remap-async-to-generator/7.25.9_@babel+core@7.23.3": "sha512-IZtukuUeBbhgOcaW2s06OXTzVNJR0ybm4W5xC1opWFFJMZbwRj5LCk+ByYH7WdZPZTt8KnFwA8pvjN2yqcPlgw==",
21
27
  "/@babel/helper-replace-supers/7.26.5_@babel+core@7.23.3": "sha512-bJ6iIVdYX1YooY2X7w1q6VITt+LnUILtNk7zT78ykuwStx8BauCzxvFqFaHjOpW1bVnSUM1PN1f0p5P21wHxvg==",
22
28
  "/@babel/helper-skip-transparent-expression-wrappers/7.25.9": "sha512-K4Du3BFa3gvyhzgPcntrkDgZzQaq6uozzcpGbOO1OEJaI+EJdqWIMTLgFgQf6lrfiDFo5FU+BxKepI9RmZqahA==",
23
29
  "/@babel/helper-string-parser/7.25.9": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==",
30
+ "/@babel/helper-string-parser/7.27.1": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
24
31
  "/@babel/helper-validator-identifier/7.25.9": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==",
32
+ "/@babel/helper-validator-identifier/7.27.1": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
25
33
  "/@babel/helper-validator-option/7.25.9": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==",
34
+ "/@babel/helper-validator-option/7.27.1": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==",
26
35
  "/@babel/helper-wrap-function/7.25.9": "sha512-ETzz9UTjQSTmw39GboatdymDq4XIQbR8ySgVrylRhPOFpsd+JrKHIuF0de7GCWmem+T4uC5z7EZguod7Wj4A4g==",
27
- "/@babel/helpers/7.26.7": "sha512-8NHiL98vsi0mbPQmYAGWwfcFaOy4j2HY49fXJCfuDcdE7fMIsH9a7GdaeXpIBsbT7307WU8KCMp5pUVDNL4f9A==",
36
+ "/@babel/helpers/7.27.1": "sha512-FCvFTm0sWV8Fxhpp2McP5/W53GPllQ9QeQ7SiqGWjMf/LVG07lFa5+pgK05IRhVwtvafT22KF+ZSnM9I545CvQ==",
28
37
  "/@babel/parser/7.26.7": "sha512-kEvgGGgEjRUutvdVvZhbn/BxVt+5VSpwXz1j3WYXQbXDo8KzFOPNG2GQbdAiNq8g6wn1yKk7C/qrke03a84V+w==",
38
+ "/@babel/parser/7.27.1": "sha512-I0dZ3ZpCrJ1c04OqlNsQcKiZlsrXf/kkE4FXzID9rIOYICsAbA8mMDzhW/luRNAHdCNt7os/u8wenklZDlUVUQ==",
29
39
  "/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/7.25.9_@babel+core@7.23.3": "sha512-2qUwwfAFpJLZqxd02YW9btUCZHl+RFvdDkNfZwaIJrvB8Tesjsk8pEQkTvGwZXLqXUx/2oyY3ySRhm6HOXuCug==",
30
40
  "/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/7.25.9_@babel+core@7.23.3": "sha512-6xWgLZTJXwilVjlnV7ospI3xi+sl8lN8rXXbBD6vYn3UYDlGsag8wrZkKcSI8G6KgqKP7vNFaDgeDnfAABq61g==",
31
41
  "/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/7.25.9_@babel+core@7.23.3": "sha512-aLnMXYPnzwwqhYSCyXfKkIkYgJ8zv9RK+roo9DkTXz38ynIhd9XCbN08s3MGvqL2MYGVUGdRQLL/JqBIeJhJBg==",
@@ -104,8 +114,11 @@
104
114
  "/@babel/preset-typescript/7.23.3_@babel+core@7.23.3": "sha512-17oIGVlqz6CchO9RFYn5U6ZpWRZIngayYCtrPRSgANSwC2V1Jb+iP74nVxzzXJte8b8BYxrL1yY96xfhTBrNNQ==",
105
115
  "/@babel/runtime/7.22.10": "sha512-21t/fkKLMZI4pqP2wlmsQAWnYW1PDyKyyUV4vCi+B25ydmdaYTKXPwCj0BzSUnZf4seIiYvSA3jcZ3gdsMFkLQ==",
106
116
  "/@babel/template/7.25.9": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==",
117
+ "/@babel/template/7.27.1": "sha512-Fyo3ghWMqkHHpHQCoBs2VnYjR4iWFFjguTDEqA5WgZDOrFesVjMhMM2FSqTKSoUSDO1VQtavj8NFpdRBEvJTtg==",
107
118
  "/@babel/traverse/7.26.7": "sha512-1x1sgeyRLC3r5fQOM0/xtQKsYjyxmFjaOrLJNtZ81inNjyJHGIolTULPiSc/2qe1/qfpFLisLQYFnnZl7QoedA==",
119
+ "/@babel/traverse/7.27.1": "sha512-ZCYtZciz1IWJB4U61UPu4KEaqyfj+r5T1Q5mqPo+IBpcG9kHv30Z0aD8LXPgC1trYa6rK0orRyAhqUgk4MjmEg==",
108
120
  "/@babel/types/7.26.7": "sha512-t8kDRGrKXyp6+tjUh7hw2RLyclsW4TRoRvRHtSyAX9Bb5ldlFh+90YAYY6awRXrlB4G5G2izNeGySpATlFzmOg==",
121
+ "/@babel/types/7.27.1": "sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q==",
109
122
  "/@esbuild/aix-ppc64/0.24.2": "sha512-thpVCb/rhxE/BnMLQ7GReQLLN8q9qbHmI55F4489/ByVg2aQaQ6kbcLb6FHkocZzQhxc4gx0sCk0tJkKBFzDhA==",
110
123
  "/@esbuild/android-arm/0.24.2": "sha512-tmwl4hJkCfNHwFB3nBa8z1Uy3ypZpxqxfTQOcHX+xRByyYgunVbZ9MzUUfb0RxaHIMnbHagwAxuTL+tnNM+1/Q==",
111
124
  "/@esbuild/android-arm64/0.24.2": "sha512-cNLgeqCqV8WxfcTIOeL4OAtSmL8JjcN6m09XIgro1Wi7cF4t/THaWEa7eL5CMoMBdjoHOTh/vwTO/o2TRXIyzg==",
@@ -1,4 +1,6 @@
1
1
  import { HostEventParamsMap } from '@jolibox/types';
2
- type CustomEventType = 'onI18nChanged';
2
+ type CustomEventType = 'onI18nChanged' | 'onBackPress';
3
3
  export declare const onCustomEvent: <T extends CustomEventType>(event: T, callback: HostEventParamsMap[T]) => void;
4
+ export declare const offCustomEvent: <T extends CustomEventType>(event: T, callback: HostEventParamsMap[T]) => void;
5
+ export declare const onceCustomEvent: <T extends CustomEventType>(event: T, callback: HostEventParamsMap[T]) => void;
4
6
  export {};
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var D=Object.defineProperty,ct=Object.defineProperties,lt=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertyNames,ge=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))Ee.call(t,r)&&_e(e,r,t[r]);if(ge)for(var r of ge(t))ut.call(t,r)&&_e(e,r,t[r]);return e},U=(e,t)=>ct(e,mt(t));var pt=(e,t)=>{for(var r in t)D(e,r,{get:t[r],enumerable:!0})},ft=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of dt(t))!Ee.call(e,o)&&o!==r&&D(e,o,{get:()=>t[o],enumerable:!(n=lt(t,o))||n.enumerable});return e};var ht=e=>ft(D({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var gr={};pt(gr,{JoliboxSDK:()=>H});module.exports=ht(gr);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var Y=Object.defineProperty,gt=Object.defineProperties,_t=Object.getOwnPropertyDescriptor,Et=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertySymbols,yt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vt=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&Se(e,r,t[r]);if(ye)for(var r of ye(t))St.call(t,r)&&Se(e,r,t[r]);return e},bt=(e,t)=>gt(e,Et(t)),xt=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},be=(e,t,r,n)=>{for(var o=n>1?void 0:n?_t(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Y(t,r,o),o},Rt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function wt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Z(e){return typeof e=="string"}function xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function It(e){return typeof e=="undefined"}function Tt(e){return It(e)||e===null}function Lt(e){return typeof e=="function"}function Re(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Dt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Dt||{}),ee=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},we=class extends ee{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ie=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function v(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var At={log:v("log"),warn:v("warn"),info:v("info"),error:v("error"),debug:v("debug")};Object.assign(globalThis,{logger:At});var W=Symbol.for("Jolibox.canIUseMap"),Ut={};globalThis[W]||(globalThis[W]=Ut);var Te={get config(){return globalThis[W]}};function te(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),Ot=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Ot||{}),ve=["name","params"],kt=["name","type","location","target","extra","timestamp","userId"],Pt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ct(e){let t=e.location?k(e.location,ve):null,r=e.target?k(e.target,ve):null;return k(bt(vt({},e),{location:t,target:r}),kt)}function Le(e){let t=e.events.map(n=>Ct(n)),r=k(e.device,Pt);return[e.protocolVersion,t,r,e.project]}var Kt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function oe(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}oe();var Mt=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Nt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",jt="device_id",Jt="advertising_id",De=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Kt()),window.__joliboxLocalStorage__.getItem(e)),Ft=()=>new URLSearchParams(window.location.search).get("deviceId")||De(jt),Bt=()=>De(Jt),Vt=e=>e.charAt(0).toUpperCase()+e.slice(1),$t=()=>{var e;let t=new URLSearchParams(window.location.search);return Vt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ae=e=>{if(Mt())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Nt(),n=navigator.language,o=Ft(),s=Bt();return`${t} (${$t()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},z=class q{constructor(t){this.element=t,this.next=q.Undefined,this.prev=q.Undefined}};z.Undefined=new z(void 0);var d=z,Ht=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Gt=0,b=class{constructor(e){this.value=e,this.id=Gt++}},x=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof b&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new b(t);return this._listeners?this._listeners instanceof b?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,E,fe;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let he=this._listeners.indexOf(c);he>=0&&(this._listeners.splice(he,1),this._size--,this._size===0&&((fe=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||fe.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},se=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Ht,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}},Q={};xt(Q,{None:()=>Wt,filter:()=>qt,once:()=>Ue,toPromise:()=>zt});var Wt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function zt(e){return new Promise(t=>Ue(e)(t))}function Ue(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function qt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var G=Symbol.for("Jolibox.hostEmitter"),Qt=()=>{let e=new se;return globalThis[G]||(globalThis[G]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[G]},C=Qt();function Xt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Yt(e[n],t[n])}function Yt(e,t){if(Z(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Lt(t)){try{if(e instanceof t)return}catch(r){}if(!Tt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var P=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Xt(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};P=be([Re],P);var X=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new P,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=wt(3e4)),this._starActivation}executeCommand(e,...t){return Rt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Q.toPromise(Q.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};X=be([Re],X);var Oe=Symbol.for("Jolibox.commands");function Zt(){return typeof globalThis!="undefined"?globalThis[Oe]:void 0}function er(e){typeof globalThis!="undefined"&&(globalThis[Oe]=e)}function h(){let e=Zt();if(e)return e;let t=new P,r=new X,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return er(n),n}var K=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function tr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function rr(){return{platform:1e3,os:"h5",appVersion:"1.1.19-beta.6",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.19-beta.6",extra:{}}}var ke={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},nr=()=>{var t;let e=(t=ke[window.location.host])!=null?t:ke.default;return K?e.test:e.prod},or=nr(),Ce=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Pe;(Pe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ce);var sr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},ir=sr(),ar=e=>m(void 0,null,function*(){try{let r=`${or}/report`,n=Ae("1.1.19-beta.6"),o=ir,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Ce(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:tr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=rr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Le(o);yield ar(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>C.emit("onDocumentReady",w.startTime));var cr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=cr(),Ke=h(),ie=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof ee?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},ae=ie;window.addEventListener("unhandledrejection",ie.bind(void 0));window.addEventListener("error",ie.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ce=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},I=e=>parseInt(ce(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ce(e),{major:a,minor:l,patch:i,prerelease:c}=ce(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Me=h(),M=(e,t)=>{Me.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},S=(e,t,r)=>{Me.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Je="jolibox-sdk-loadermeta",je,L=JSON.parse((je=window.__joliboxLocalStorage__.getItem(Je))!=null?je:"{}"),le=Date.now(),Ne=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function lr(){return m(this,null,function*(){let t=`${K?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=U(A({},L),{timestamp:le});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=U(A({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=U(A({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Je,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Fe=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=L;i&&c&&!Ne(le,c)&&I(i)==t&&T(i,r)>=0&&(n=me(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Ie(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();M("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),S("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ne(le,u)&&I(c)==t&&T(c,r)>=0&&(o=de(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{S("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),lr()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Be=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){ae(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();M("jsSdkBegin",{t:o}),w.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),S("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),S("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),ae(new R(`module load failed ${o}`))}}};var mr="1.1.19-beta.6",N=mr,Ge=I(N),We=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),dr=We?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,ue="https://jsdelivr.jolibox.com",Ve=window.document.currentScript;Ve&&(ue=new URL(Ve.src).origin);var me=e=>`${ue}/npm/@jolibox/bootstrap@${e}/dist/index.js`,de=e=>`${ue}/npm/@jolibox/implement@${e}/dist/index.js`,ur=e=>/^\d+\.\d+\.\d+$/.test(e),ze=ur(N)?Ge:N,$e=me(ze),He=de(ze);function pr(){We?Be(dr,{bootstrapUrl:$e,implementUrl:He})():Fe({bootstrapUrl:$e,implementUrl:He,currentMajorVersion:Ge,currentVersion:N})()}pr();var qe=h();function Qe(){return qe.excuteCommandSync("API.getSystemInfoSync")}function Xe(){return qe.excuteCommandSync("API.env")}function Ye(e,t){var r;return(r=Te.config[e])==null?void 0:r[t]}function Ze(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var tt="1.1.19-beta.6";function _(e){var l,i;let r=(i=(l=Xe().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=Ye(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||te(tt,a,"<")?!1:o.length===0?!0:et(s,o)||et(s.properties,o)}function et(e,t){if(!e)return!1;let r=Ze(e,t);return r?xe(r)?!0:Z(r)?te(tt,r,">="):!1:!1}var rt=h();function nt(){return m(this,null,function*(){return _("login")?yield rt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ot(){return m(this,null,function*(){return _("checkSession")?yield rt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var fr=h();function st(e){return m(this,null,function*(){return _("request")?yield fr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var it=(e,t)=>{C.on(e,t)};var pe=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},at=window.JoliboxRuntime||pe;var p=class{constructor(){this.commands=h();this._emitter=new se}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var hr="LifecycleSDK.onReady",j=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(hr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var J=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var F=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var B=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var V=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var $=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.19-beta.6";this.runtime=new at;this.ads=new F;this.lifecycle=new j;this.storage=new J;this.keyboard=new B;this.task=new V;this.router=new $;this.getSystemInfoSync=Qe.bind(this);this.canIUse=_.bind(this);this.login=nt.bind(this);this.checkSession=ot.bind(this);this.request=st.bind(this);this.on=it.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var H=g;window.JoliboxSDK=H;
1
+ "use strict";var U=Object.defineProperty,ut=Object.defineProperties,pt=Object.getOwnPropertyDescriptor,ft=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var ve=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var ye=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,O=(e,t)=>{for(var r in t||(t={}))ve.call(t,r)&&ye(e,r,t[r]);if(_e)for(var r of _e(t))gt.call(t,r)&&ye(e,r,t[r]);return e},P=(e,t)=>ut(e,ft(t));var Et=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},_t=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ht(t))!ve.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=pt(t,o))||n.enumerable});return e};var yt=e=>_t(U({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var vr={};Et(vr,{JoliboxSDK:()=>z});module.exports=yt(vr);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var te=Object.defineProperty,vt=Object.defineProperties,St=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))Rt.call(t,r)&&be(e,r,t[r]);return e},It=(e,t)=>vt(e,bt(t)),Tt=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},Re=(e,t,r,n)=>{for(var o=n>1?void 0:n?St(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&te(t,r,o),o},Lt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Dt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function At(e){return typeof e=="undefined"}function Ut(e){return At(e)||e===null}function Ot(e){return typeof e=="function"}function Ie(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Pt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Pt||{}),M=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Te=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},I=class extends Te{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var N=class extends M{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ct={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Ct});var Q=Symbol.for("Jolibox.canIUseMap"),kt={};globalThis[Q]||(globalThis[Q]=kt);var De={get config(){return globalThis[Q]}};function ne(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),Kt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Kt||{}),xe=["name","params"],Mt=["name","type","location","target","extra","timestamp","userId"],Nt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function jt(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(It(wt({},e),{location:t,target:r}),Mt)}function Ae(e){let t=e.events.map(n=>jt(n)),r=k(e.device,Nt);return[e.protocolVersion,t,r,e.project]}var Jt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ie(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ie();var Ft=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),C={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Bt=()=>C.isiOS?"iOS":C.isAndroid?"Android":C.isMac?"Mac":C.isFacebook?"Facebook":"PC",Vt="device_id",$t="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Jt()),window.__joliboxLocalStorage__.getItem(e)),Ht=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue(Vt),Gt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue($t),Wt=e=>e.charAt(0).toUpperCase()+e.slice(1),zt=()=>{var e;let t=new URLSearchParams(window.location.search);return Wt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Oe=e=>{if(Ft())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Bt(),n=navigator.language,o=Ht(),s=Gt();return`${t} (${zt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},X=class Y{constructor(t){this.element=t,this.next=Y.Undefined,this.prev=Y.Undefined}};X.Undefined=new X(void 0);var d=X,qt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Qt=0,R=class{constructor(e){this.value=e,this.id=Qt++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof R&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new R(t);return this._listeners?this._listeners instanceof R?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,_,ge;if(!this._disposed){if(this._listeners instanceof R)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let Ee=this._listeners.indexOf(c);Ee>=0&&(this._listeners.splice(Ee,1),this._size--,this._size===0&&((ge=(_=this.options)==null?void 0:_.onDidRemoveLastListener)==null||ge.call(_)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof R?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ae=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new qt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Z={};Tt(Z,{None:()=>Xt,filter:()=>Zt,once:()=>Pe,toPromise:()=>Yt});var Xt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Yt(e){return new Promise(t=>Pe(e)(t))}function Pe(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function Zt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var q=Symbol.for("Jolibox.hostEmitter"),er=()=>{let e=new ae;return globalThis[q]||(globalThis[q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[q]},v=er();function tr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)rr(e[n],t[n])}function rr(e,t){if(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ot(t)){try{if(e instanceof t)return}catch(r){}if(!Ut(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return tr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};K=Re([Ie],K);var ee=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Dt(3e4)),this._starActivation}executeCommand(e,...t){return Lt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Z.toPromise(Z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};ee=Re([Ie],ee);var Ce=Symbol.for("Jolibox.commands");function nr(){return typeof globalThis!="undefined"?globalThis[Ce]:void 0}function or(e){typeof globalThis!="undefined"&&(globalThis[Ce]=e)}function h(){let e=nr();if(e)return e;let t=new K,r=new ee,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return or(n),n}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function sr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function ir(){return{platform:1e3,os:"h5",appVersion:"1.1.19",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.19",extra:{}}}var ke={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},ar=()=>{var t;let e=(t=ke[window.location.host])!=null?t:ke.default;return j?e.test:e.prod},cr=ar(),Me=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ke;(Ke=AbortSignal.timeout)!=null||(AbortSignal.timeout=Me);var lr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},mr=lr(),dr=e=>m(void 0,null,function*(){try{let r=`${cr}/report`,n=Oe("1.1.19"),o=mr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Me(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:sr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=ir(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Ae(o);yield dr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var ur=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=ur(),Ne=h(),ce=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof M?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},y=ce;window.addEventListener("unhandledrejection",ce.bind(void 0));window.addEventListener("error",ce.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ne.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var le=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(le(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=le(e),{major:a,minor:l,patch:i,prerelease:c}=le(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var je=h(),J=(e,t)=>{je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Be="jolibox-sdk-loadermeta",Fe,A=JSON.parse((Fe=window.__joliboxLocalStorage__.getItem(Be))!=null?Fe:"{}"),me=Date.now(),Je=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function pr(){return m(this,null,function*(){let t=`${j?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=P(O({},A),{timestamp:me});if(o){let{bootstrap_version:a}=A;a&&D(a,o)>=0||(s=P(O({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=A;a&&D(a,n)>=0||(s=P(O({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Be,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ve=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=A;i&&c&&!Je(me,c)&&L(i)==t&&D(i,r)>=0&&(n=de(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Le(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();J("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let _=document.createElement("script");_.type="text/javascript",_.innerHTML=c,document.head.appendChild(_),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=A;c&&u&&!Je(me,u)&&L(c)==t&&D(c,r)>=0&&(o=ue(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),pr()}catch(i){let c=new I(`module evaluate error: ${i}`);S({err:`${c}`})}}};var $e=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){y(new I(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new I(`module load failed ${o}`))}}};var fr="1.1.19",F=fr,ze=L(F),qe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),hr=qe?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,pe="https://jsdelivr.jolibox.com",He=window.document.currentScript;He&&(pe=new URL(He.src).origin);var de=e=>`${pe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ue=e=>`${pe}/npm/@jolibox/implement@${e}/dist/index.js`,gr=e=>/^\d+\.\d+\.\d+$/.test(e),Qe=gr(F)?ze:F,Ge=de(Qe),We=ue(Qe);function Er(){qe?$e(hr,{bootstrapUrl:Ge,implementUrl:We})():Ve({bootstrapUrl:Ge,implementUrl:We,currentMajorVersion:ze,currentVersion:F})()}Er();var Xe=h();function Ye(){return Xe.excuteCommandSync("API.getSystemInfoSync")}function Ze(){return Xe.excuteCommandSync("API.env")}function et(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function tt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var nt="1.1.19";function E(e){var l,i;let r=(i=(l=Ze().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=et(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||ne(nt,a,"<")?!1:o.length===0?!0:rt(s,o)||rt(s.properties,o)}function rt(e,t){if(!e)return!1;let r=tt(e,t);return r?we(r)?!0:re(r)?ne(nt,r,">="):!1:!1}var ot=h();function st(){return m(this,null,function*(){return E("login")?yield ot.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function it(){return m(this,null,function*(){return E("checkSession")?yield ot.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var _r=h();function at(e){return m(this,null,function*(){return E("request")?yield _r.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],ct=(e,t)=>{fe.includes(e)||y(new N(`[onCustomEvent] Unsupported event: ${e}`,2e3)),v.on(e,t)},lt=(e,t)=>{fe.includes(e)||y(new N(`[offCustomEvent] Unsupported event: ${e}`,2e3)),v.off(e,t)},mt=(e,t)=>{fe.includes(e)||y(new N(`[onceCustomEvent] Unsupported event: ${e}`,2e3)),v.once(e,t)};var he=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},dt=window.JoliboxRuntime||he;var p=class{constructor(){this.commands=h();this._emitter=new ae}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var yr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(yr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var H=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var G=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.19";this.runtime=new dt;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.getSystemInfoSync=Ye.bind(this);this.canIUse=E.bind(this);this.login=st.bind(this);this.checkSession=it.bind(this);this.request=at.bind(this);this.on=ct.bind(this);this.off=lt.bind(this);this.once=mt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var z=g;window.JoliboxSDK=z;
package/dist/index.d.ts CHANGED
@@ -47,7 +47,9 @@ export declare class JoliboxSDK {
47
47
  login: typeof login;
48
48
  checkSession: typeof checkSession;
49
49
  request: typeof request;
50
- on: <T extends "onI18nChanged">(event: T, callback: import("@jolibox/types").HostEventParamsMap[T]) => void;
50
+ on: <T extends "onI18nChanged" | "onBackPress">(event: T, callback: import("@jolibox/types").HostEventParamsMap[T]) => void;
51
+ off: <T extends "onI18nChanged" | "onBackPress">(event: T, callback: import("@jolibox/types").HostEventParamsMap[T]) => void;
52
+ once: <T extends "onI18nChanged" | "onBackPress">(event: T, callback: import("@jolibox/types").HostEventParamsMap[T]) => void;
51
53
  constructor();
52
54
  static getInstance(): JoliboxSDK;
53
55
  }
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var it=Object.defineProperty,at=Object.defineProperties;var ct=Object.getOwnPropertyDescriptors;var he=Object.getOwnPropertySymbols;var lt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var ge=(e,t,r)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))lt.call(t,r)&&ge(e,r,t[r]);if(he)for(var r of he(t))mt.call(t,r)&&ge(e,r,t[r]);return e},A=(e,t)=>at(e,ct(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var Q=Object.defineProperty,dt=Object.defineProperties,ut=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,ft=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,Ee=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gt=(e,t)=>{for(var r in t||(t={}))ft.call(t,r)&&Ee(e,r,t[r]);if(_e)for(var r of _e(t))ht.call(t,r)&&Ee(e,r,t[r]);return e},_t=(e,t)=>dt(e,pt(t)),Et=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},Se=(e,t,r,n)=>{for(var o=n>1?void 0:n?ut(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Q(t,r,o),o},yt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function St(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function vt(e){return typeof e=="undefined"}function bt(e){return vt(e)||e===null}function xt(e){return typeof e=="function"}function be(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Rt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Rt||{}),Y=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},xe=class extends Y{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Re=class extends xe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends xe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function v(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var wt={log:v("log"),warn:v("warn"),info:v("info"),error:v("error"),debug:v("debug")};Object.assign(globalThis,{logger:wt});var H=Symbol.for("Jolibox.canIUseMap"),It={};globalThis[H]||(globalThis[H]=It);var we={get config(){return globalThis[H]}};function Z(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ee=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ee||{}),te=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(te||{}),Tt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Tt||{}),ye=["name","params"],Lt=["name","type","location","target","extra","timestamp","userId"],Dt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function At(e){let t=e.location?O(e.location,ye):null,r=e.target?O(e.target,ye):null;return O(_t(gt({},e),{location:t,target:r}),Lt)}function Ie(e){let t=e.events.map(n=>At(n)),r=O(e.device,Dt);return[e.protocolVersion,t,r,e.project]}var Ut=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function re(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}re();var Ot=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),U={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},kt=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Pt="device_id",Ct="advertising_id",Te=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ut()),window.__joliboxLocalStorage__.getItem(e)),Kt=()=>new URLSearchParams(window.location.search).get("deviceId")||Te(Pt),Mt=()=>Te(Ct),Nt=e=>e.charAt(0).toUpperCase()+e.slice(1),jt=()=>{var e;let t=new URLSearchParams(window.location.search);return Nt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Le=e=>{if(Ot())return window.navigator.userAgent;let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Kt(),s=Mt();return`${t} (${jt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},G=class W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.Undefined}};G.Undefined=new G(void 0);var d=G,Jt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Ft=0,b=class{constructor(e){this.value=e,this.id=Ft++}},x=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof b&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new b(t);return this._listeners?this._listeners instanceof b?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,E,pe;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let fe=this._listeners.indexOf(c);fe>=0&&(this._listeners.splice(fe,1),this._size--,this._size===0&&((pe=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||pe.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ne=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Jt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}},z={};Et(z,{None:()=>Bt,filter:()=>$t,once:()=>De,toPromise:()=>Vt});var Bt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Vt(e){return new Promise(t=>De(e)(t))}function De(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function $t(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var $=Symbol.for("Jolibox.hostEmitter"),Ht=()=>{let e=new ne;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Ht();function Gt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Wt(e[n],t[n])}function Wt(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(xt(t)){try{if(e instanceof t)return}catch(r){}if(!bt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Gt(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};k=Se([be],k);var q=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=St(3e4)),this._starActivation}executeCommand(e,...t){return yt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),z.toPromise(z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};q=Se([be],q);var Ae=Symbol.for("Jolibox.commands");function zt(){return typeof globalThis!="undefined"?globalThis[Ae]:void 0}function qt(e){typeof globalThis!="undefined"&&(globalThis[Ae]=e)}function h(){let e=zt();if(e)return e;let t=new k,r=new q,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return qt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Qt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Xt(){return{platform:1e3,os:"h5",appVersion:"1.1.19-beta.6",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.19-beta.6",extra:{}}}var Ue={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Yt=()=>{var t;let e=(t=Ue[window.location.host])!=null?t:Ue.default;return C?e.test:e.prod},Zt=Yt(),ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Oe;(Oe=AbortSignal.timeout)!=null||(AbortSignal.timeout=ke);var er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},tr=er(),rr=e=>m(void 0,null,function*(){try{let r=`${Zt}/report`,n=Le("1.1.19-beta.6"),o=tr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ee.ErrorTrace,location:Qt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Xt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:te.WebSDK},s=Ie(o);yield rr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",w.startTime));var nr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=nr(),Pe=h(),oe=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof Y?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},se=oe;window.addEventListener("unhandledrejection",oe.bind(void 0));window.addEventListener("error",oe.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ie=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},I=e=>parseInt(ie(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ie(e),{major:a,minor:l,patch:i,prerelease:c}=ie(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Ce=h(),K=(e,t)=>{Ce.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},S=(e,t,r)=>{Ce.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};re();var Ne="jolibox-sdk-loadermeta",Me,L=JSON.parse((Me=window.__joliboxLocalStorage__.getItem(Ne))!=null?Me:"{}"),ae=Date.now(),Ke=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function or(){return m(this,null,function*(){let t=`${C?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=A(D({},L),{timestamp:ae});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ne,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var je=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=L;i&&c&&!Ke(ae,c)&&I(i)==t&&T(i,r)>=0&&(n=ce(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Re(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),S("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ke(ae,u)&&I(c)==t&&T(c,r)>=0&&(o=le(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{S("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),or()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){se(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),w.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),S("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),S("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),se(new R(`module load failed ${o}`))}}};var sr="1.1.19-beta.6",M=sr,$e=I(M),He=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),ir=He?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,me="https://jsdelivr.jolibox.com",Fe=window.document.currentScript;Fe&&(me=new URL(Fe.src).origin);var ce=e=>`${me}/npm/@jolibox/bootstrap@${e}/dist/index.js`,le=e=>`${me}/npm/@jolibox/implement@${e}/dist/index.js`,ar=e=>/^\d+\.\d+\.\d+$/.test(e),Ge=ar(M)?$e:M,Be=ce(Ge),Ve=le(Ge);function cr(){He?Je(ir,{bootstrapUrl:Be,implementUrl:Ve})():je({bootstrapUrl:Be,implementUrl:Ve,currentMajorVersion:$e,currentVersion:M})()}cr();var We=h();function ze(){return We.excuteCommandSync("API.getSystemInfoSync")}function qe(){return We.excuteCommandSync("API.env")}function Qe(e,t){var r;return(r=we.config[e])==null?void 0:r[t]}function Xe(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Ze="1.1.19-beta.6";function _(e){var l,i;let r=(i=(l=qe().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=Qe(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Z(Ze,a,"<")?!1:o.length===0?!0:Ye(s,o)||Ye(s.properties,o)}function Ye(e,t){if(!e)return!1;let r=Xe(e,t);return r?ve(r)?!0:X(r)?Z(Ze,r,">="):!1:!1}var et=h();function tt(){return m(this,null,function*(){return _("login")?yield et.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function rt(){return m(this,null,function*(){return _("checkSession")?yield et.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var lr=h();function nt(e){return m(this,null,function*(){return _("request")?yield lr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ot=(e,t)=>{P.on(e,t)};var de=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},st=window.JoliboxRuntime||de;var p=class{constructor(){this.commands=h();this._emitter=new ne}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var mr="LifecycleSDK.onReady",N=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(mr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var j=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var V=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.19-beta.6";this.runtime=new st;this.ads=new J;this.lifecycle=new N;this.storage=new j;this.keyboard=new F;this.task=new B;this.router=new V;this.getSystemInfoSync=ze.bind(this);this.canIUse=_.bind(this);this.login=tt.bind(this);this.checkSession=rt.bind(this);this.request=nt.bind(this);this.on=ot.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var ue=g;window.JoliboxSDK=ue;export{ue as JoliboxSDK};
1
+ var mt=Object.defineProperty,dt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Ee=Object.getOwnPropertySymbols;var pt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))pt.call(t,r)&&_e(e,r,t[r]);if(Ee)for(var r of Ee(t))ft.call(t,r)&&_e(e,r,t[r]);return e},O=(e,t)=>dt(e,ut(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var Z=Object.defineProperty,ht=Object.defineProperties,gt=Object.getOwnPropertyDescriptor,Et=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable,ve=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vt=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&ve(e,r,t[r]);if(ye)for(var r of ye(t))yt.call(t,r)&&ve(e,r,t[r]);return e},St=(e,t)=>ht(e,Et(t)),bt=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},be=(e,t,r,n)=>{for(var o=n>1?void 0:n?gt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Z(t,r,o),o},xt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Rt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function wt(e){return typeof e=="undefined"}function It(e){return wt(e)||e===null}function Tt(e){return typeof e=="function"}function Re(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Lt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Lt||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},we=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ie=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},I=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Dt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Dt});var z=Symbol.for("Jolibox.canIUseMap"),At={};globalThis[z]||(globalThis[z]=At);var Te={get config(){return globalThis[z]}};function te(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),Ut=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Ut||{}),Se=["name","params"],Ot=["name","type","location","target","extra","timestamp","userId"],Pt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ct(e){let t=e.location?C(e.location,Se):null,r=e.target?C(e.target,Se):null;return C(St(vt({},e),{location:t,target:r}),Ot)}function Le(e){let t=e.events.map(n=>Ct(n)),r=C(e.device,Pt);return[e.protocolVersion,t,r,e.project]}var kt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function oe(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}oe();var Kt=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),P={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Mt=()=>P.isiOS?"iOS":P.isAndroid?"Android":P.isMac?"Mac":P.isFacebook?"Facebook":"PC",Nt="device_id",jt="advertising_id",De=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,kt()),window.__joliboxLocalStorage__.getItem(e)),Jt=()=>new URLSearchParams(window.location.search).get("deviceId")||De(Nt),Ft=()=>new URLSearchParams(window.location.search).get("advertisingId")||De(jt),Bt=e=>e.charAt(0).toUpperCase()+e.slice(1),Vt=()=>{var e;let t=new URLSearchParams(window.location.search);return Bt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ae=e=>{if(Kt())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Mt(),n=navigator.language,o=Jt(),s=Ft();return`${t} (${Vt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},q=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};q.Undefined=new q(void 0);var d=q,$t=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Ht=0,R=class{constructor(e){this.value=e,this.id=Ht++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof R&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new R(t);return this._listeners?this._listeners instanceof R?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,_,he;if(!this._disposed){if(this._listeners instanceof R)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let ge=this._listeners.indexOf(c);ge>=0&&(this._listeners.splice(ge,1),this._size--,this._size===0&&((he=(_=this.options)==null?void 0:_.onDidRemoveLastListener)==null||he.call(_)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof R?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},se=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new $t,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},X={};bt(X,{None:()=>Gt,filter:()=>zt,once:()=>Ue,toPromise:()=>Wt});var Gt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Wt(e){return new Promise(t=>Ue(e)(t))}function Ue(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function zt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),qt=()=>{let e=new se;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=qt();function Qt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Xt(e[n],t[n])}function Xt(e,t){if(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Tt(t)){try{if(e instanceof t)return}catch(r){}if(!It(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Qt(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};k=be([Re],k);var Y=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Rt(3e4)),this._starActivation}executeCommand(e,...t){return xt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Y=be([Re],Y);var Oe=Symbol.for("Jolibox.commands");function Yt(){return typeof globalThis!="undefined"?globalThis[Oe]:void 0}function Zt(e){typeof globalThis!="undefined"&&(globalThis[Oe]=e)}function h(){let e=Yt();if(e)return e;let t=new k,r=new Y,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Zt(n),n}var N=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function er(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function tr(){return{platform:1e3,os:"h5",appVersion:"1.1.19",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.19",extra:{}}}var Pe={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},rr=()=>{var t;let e=(t=Pe[window.location.host])!=null?t:Pe.default;return N?e.test:e.prod},nr=rr(),ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ce;(Ce=AbortSignal.timeout)!=null||(AbortSignal.timeout=ke);var or=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},sr=or(),ir=e=>m(void 0,null,function*(){try{let r=`${nr}/report`,n=Ae("1.1.19"),o=sr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:er(),target:null,extra:e,timestamp:Date.now(),userId:null},r=tr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Le(o);yield ir(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var ar=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=ar(),Ke=h(),ie=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},y=ie;window.addEventListener("unhandledrejection",ie.bind(void 0));window.addEventListener("error",ie.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var ae=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(ae(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ae(e),{major:a,minor:l,patch:i,prerelease:c}=ae(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Me=h(),j=(e,t)=>{Me.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Me.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Je="jolibox-sdk-loadermeta",je,A=JSON.parse((je=window.__joliboxLocalStorage__.getItem(Je))!=null?je:"{}"),ce=Date.now(),Ne=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function cr(){return m(this,null,function*(){let t=`${N?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=O(U({},A),{timestamp:ce});if(o){let{bootstrap_version:a}=A;a&&D(a,o)>=0||(s=O(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=A;a&&D(a,n)>=0||(s=O(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Je,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Fe=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=A;i&&c&&!Ne(ce,c)&&L(i)==t&&D(i,r)>=0&&(n=le(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Ie(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let _=document.createElement("script");_.type="text/javascript",_.innerHTML=c,document.head.appendChild(_),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=A;c&&u&&!Ne(ce,u)&&L(c)==t&&D(c,r)>=0&&(o=me(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),cr()}catch(i){let c=new I(`module evaluate error: ${i}`);S({err:`${c}`})}}};var Be=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){y(new I(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new I(`module load failed ${o}`))}}};var lr="1.1.19",J=lr,Ge=L(J),We=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),mr=We?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,de="https://jsdelivr.jolibox.com",Ve=window.document.currentScript;Ve&&(de=new URL(Ve.src).origin);var le=e=>`${de}/npm/@jolibox/bootstrap@${e}/dist/index.js`,me=e=>`${de}/npm/@jolibox/implement@${e}/dist/index.js`,dr=e=>/^\d+\.\d+\.\d+$/.test(e),ze=dr(J)?Ge:J,$e=le(ze),He=me(ze);function ur(){We?Be(mr,{bootstrapUrl:$e,implementUrl:He})():Fe({bootstrapUrl:$e,implementUrl:He,currentMajorVersion:Ge,currentVersion:J})()}ur();var qe=h();function Qe(){return qe.excuteCommandSync("API.getSystemInfoSync")}function Xe(){return qe.excuteCommandSync("API.env")}function Ye(e,t){var r;return(r=Te.config[e])==null?void 0:r[t]}function Ze(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var tt="1.1.19";function E(e){var l,i;let r=(i=(l=Xe().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=Ye(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||te(tt,a,"<")?!1:o.length===0?!0:et(s,o)||et(s.properties,o)}function et(e,t){if(!e)return!1;let r=Ze(e,t);return r?xe(r)?!0:ee(r)?te(tt,r,">="):!1:!1}var rt=h();function nt(){return m(this,null,function*(){return E("login")?yield rt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ot(){return m(this,null,function*(){return E("checkSession")?yield rt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var pr=h();function st(e){return m(this,null,function*(){return E("request")?yield pr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ue=["onI18nChanged","onBackPress"],it=(e,t)=>{ue.includes(e)||y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3)),v.on(e,t)},at=(e,t)=>{ue.includes(e)||y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3)),v.off(e,t)},ct=(e,t)=>{ue.includes(e)||y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3)),v.once(e,t)};var pe=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},lt=window.JoliboxRuntime||pe;var p=class{constructor(){this.commands=h();this._emitter=new se}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var fr="LifecycleSDK.onReady",F=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(fr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var B=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var $=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var H=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var G=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.19";this.runtime=new lt;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new H;this.router=new G;this.getSystemInfoSync=Qe.bind(this);this.canIUse=E.bind(this);this.login=nt.bind(this);this.checkSession=ot.bind(this);this.request=st.bind(this);this.on=it.bind(this);this.off=at.bind(this);this.once=ct.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var fe=g;window.JoliboxSDK=fe;export{fe as JoliboxSDK};
@@ -1 +1 @@
1
- "use strict";(()=>{var it=Object.defineProperty,at=Object.defineProperties;var ct=Object.getOwnPropertyDescriptors;var he=Object.getOwnPropertySymbols;var lt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var ge=(e,t,r)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,D=(e,t)=>{for(var r in t||(t={}))lt.call(t,r)&&ge(e,r,t[r]);if(he)for(var r of he(t))mt.call(t,r)&&ge(e,r,t[r]);return e},A=(e,t)=>at(e,ct(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var Q=Object.defineProperty,dt=Object.defineProperties,ut=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,ft=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,Ee=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gt=(e,t)=>{for(var r in t||(t={}))ft.call(t,r)&&Ee(e,r,t[r]);if(_e)for(var r of _e(t))ht.call(t,r)&&Ee(e,r,t[r]);return e},_t=(e,t)=>dt(e,pt(t)),Et=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},Se=(e,t,r,n)=>{for(var o=n>1?void 0:n?ut(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Q(t,r,o),o},yt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function St(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function X(e){return typeof e=="string"}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function vt(e){return typeof e=="undefined"}function bt(e){return vt(e)||e===null}function xt(e){return typeof e=="function"}function be(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Rt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Rt||{}),Y=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},xe=class extends Y{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Re=class extends xe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},R=class extends xe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};function v(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var wt={log:v("log"),warn:v("warn"),info:v("info"),error:v("error"),debug:v("debug")};Object.assign(globalThis,{logger:wt});var H=Symbol.for("Jolibox.canIUseMap"),It={};globalThis[H]||(globalThis[H]=It);var we={get config(){return globalThis[H]}};function Z(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var ee=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ee||{}),te=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(te||{}),Tt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Tt||{}),ye=["name","params"],Lt=["name","type","location","target","extra","timestamp","userId"],Dt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function O(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function At(e){let t=e.location?O(e.location,ye):null,r=e.target?O(e.target,ye):null;return O(_t(gt({},e),{location:t,target:r}),Lt)}function Ie(e){let t=e.events.map(n=>At(n)),r=O(e.device,Dt);return[e.protocolVersion,t,r,e.project]}var Ut=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function re(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}re();var Ot=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),U={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},kt=()=>U.isiOS?"iOS":U.isAndroid?"Android":U.isMac?"Mac":U.isFacebook?"Facebook":"PC",Pt="device_id",Ct="advertising_id",Te=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Ut()),window.__joliboxLocalStorage__.getItem(e)),Kt=()=>new URLSearchParams(window.location.search).get("deviceId")||Te(Pt),Mt=()=>Te(Ct),Nt=e=>e.charAt(0).toUpperCase()+e.slice(1),jt=()=>{var e;let t=new URLSearchParams(window.location.search);return Nt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Le=e=>{if(Ot())return window.navigator.userAgent;let t="JoliboxWebSDK",r=kt(),n=navigator.language,o=Kt(),s=Mt();return`${t} (${jt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},G=class W{constructor(t){this.element=t,this.next=W.Undefined,this.prev=W.Undefined}};G.Undefined=new G(void 0);var d=G,Jt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Ft=0,b=class{constructor(e){this.value=e,this.id=Ft++}},x=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof b&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new b(t);return this._listeners?this._listeners instanceof b?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,E,pe;if(!this._disposed){if(this._listeners instanceof b)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let fe=this._listeners.indexOf(c);fe>=0&&(this._listeners.splice(fe,1),this._size--,this._size===0&&((pe=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||pe.call(E)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof b?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ne=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t){var r;let n=(r=this.listeners.get(e))!=null?r:new x,o=l=>t(...l.args),s=n.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:s}),this.listeners.set(e,n);let a=this.cachedEventQueue.get(e);if(a)for(let l of a)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Jt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}},z={};Et(z,{None:()=>Bt,filter:()=>$t,once:()=>De,toPromise:()=>Vt});var Bt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Vt(e){return new Promise(t=>De(e)(t))}function De(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function $t(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new x(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var $=Symbol.for("Jolibox.hostEmitter"),Ht=()=>{let e=new ne;return globalThis[$]||(globalThis[$]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e)}),globalThis[$]},P=Ht();function Gt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Wt(e[n],t[n])}function Wt(e,t){if(X(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(xt(t)){try{if(e instanceof t)return}catch(r){}if(!bt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new x,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Gt(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};k=Se([be],k);var q=class{constructor(){this._onWillExecuteCommand=new x,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new x,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=St(3e4)),this._starActivation}executeCommand(e,...t){return yt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),z.toPromise(z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};q=Se([be],q);var Ae=Symbol.for("Jolibox.commands");function zt(){return typeof globalThis!="undefined"?globalThis[Ae]:void 0}function qt(e){typeof globalThis!="undefined"&&(globalThis[Ae]=e)}function h(){let e=zt();if(e)return e;let t=new k,r=new q,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return qt(n),n}var C=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function Qt(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function Xt(){return{platform:1e3,os:"h5",appVersion:"1.1.19-beta.6",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.19-beta.6",extra:{}}}var Ue={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},Yt=()=>{var t;let e=(t=Ue[window.location.host])!=null?t:Ue.default;return C?e.test:e.prod},Zt=Yt(),ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Oe;(Oe=AbortSignal.timeout)!=null||(AbortSignal.timeout=ke);var er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},tr=er(),rr=e=>m(void 0,null,function*(){try{let r=`${Zt}/report`,n=Le("1.1.19-beta.6"),o=tr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function y(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ee.ErrorTrace,location:Qt(),target:null,extra:e,timestamp:Date.now(),userId:null},r=Xt(),o={protocolVersion:"1.0.0",events:[t],device:r,project:te.WebSDK},s=Ie(o);yield rr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>P.emit("onDocumentReady",w.startTime));var nr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},w=nr(),Pe=h(),oe=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof Y?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),y({err:JSON.stringify(t)})})},se=oe;window.addEventListener("unhandledrejection",oe.bind(void 0));window.addEventListener("error",oe.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Pe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{y({err:JSON.stringify(s)})})};var ie=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},I=e=>parseInt(ie(e).major,10),T=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ie(e),{major:a,minor:l,patch:i,prerelease:c}=ie(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Ce=h(),K=(e,t)=>{Ce.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},S=(e,t,r)=>{Ce.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};re();var Ne="jolibox-sdk-loadermeta",Me,L=JSON.parse((Me=window.__joliboxLocalStorage__.getItem(Ne))!=null?Me:"{}"),ae=Date.now(),Ke=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function or(){return m(this,null,function*(){let t=`${C?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=A(D({},L),{timestamp:ae});if(o){let{bootstrap_version:a}=L;a&&T(a,o)>=0||(s=A(D({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=L;a&&T(a,n)>=0||(s=A(D({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ne,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var je=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=L;i&&c&&!Ke(ae,c)&&I(i)==t&&T(i,r)>=0&&(n=ce(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Re(`Bootstrap module faile to fetch ${u}`);y({err:`${f}`})}}function a(){var f;let i=Date.now();K("jsSdkBegin",{t:i}),w.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=c,document.head.appendChild(E),S("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=L;c&&u&&!Ke(ae,u)&&I(c)==t&&T(c,r)>=0&&(o=le(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{S("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),or()}catch(i){let c=new R(`module evaluate error: ${i}`);y({err:`${c}`})}}};var Je=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){se(new R(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();K("jsSdkBegin",{t:o}),w.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),S("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),S("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),se(new R(`module load failed ${o}`))}}};var sr="1.1.19-beta.6",M=sr,$e=I(M),He=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),ir=He?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,me="https://jsdelivr.jolibox.com",Fe=window.document.currentScript;Fe&&(me=new URL(Fe.src).origin);var ce=e=>`${me}/npm/@jolibox/bootstrap@${e}/dist/index.js`,le=e=>`${me}/npm/@jolibox/implement@${e}/dist/index.js`,ar=e=>/^\d+\.\d+\.\d+$/.test(e),Ge=ar(M)?$e:M,Be=ce(Ge),Ve=le(Ge);function cr(){He?Je(ir,{bootstrapUrl:Be,implementUrl:Ve})():je({bootstrapUrl:Be,implementUrl:Ve,currentMajorVersion:$e,currentVersion:M})()}cr();var We=h();function ze(){return We.excuteCommandSync("API.getSystemInfoSync")}function qe(){return We.excuteCommandSync("API.env")}function Qe(e,t){var r;return(r=we.config[e])==null?void 0:r[t]}function Xe(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var Ze="1.1.19-beta.6";function _(e){var l,i;let r=(i=(l=qe().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=Qe(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||Z(Ze,a,"<")?!1:o.length===0?!0:Ye(s,o)||Ye(s.properties,o)}function Ye(e,t){if(!e)return!1;let r=Xe(e,t);return r?ve(r)?!0:X(r)?Z(Ze,r,">="):!1:!1}var et=h();function tt(){return m(this,null,function*(){return _("login")?yield et.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function rt(){return m(this,null,function*(){return _("checkSession")?yield et.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var lr=h();function nt(e){return m(this,null,function*(){return _("request")?yield lr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ot=(e,t)=>{P.on(e,t)};var de=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},st=window.JoliboxRuntime||de;var p=class{constructor(){this.commands=h();this._emitter=new ne}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return _(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var mr="LifecycleSDK.onReady",N=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(mr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var j=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var J=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var F=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var B=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var V=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.19-beta.6";this.runtime=new st;this.ads=new J;this.lifecycle=new N;this.storage=new j;this.keyboard=new F;this.task=new B;this.router=new V;this.getSystemInfoSync=ze.bind(this);this.canIUse=_.bind(this);this.login=tt.bind(this);this.checkSession=rt.bind(this);this.request=nt.bind(this);this.on=ot.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var ue=g;window.JoliboxSDK=ue;})();
1
+ "use strict";(()=>{var mt=Object.defineProperty,dt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Ee=Object.getOwnPropertySymbols;var pt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))pt.call(t,r)&&_e(e,r,t[r]);if(Ee)for(var r of Ee(t))ft.call(t,r)&&_e(e,r,t[r]);return e},O=(e,t)=>dt(e,ut(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var Z=Object.defineProperty,ht=Object.defineProperties,gt=Object.getOwnPropertyDescriptor,Et=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable,ve=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vt=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&ve(e,r,t[r]);if(ye)for(var r of ye(t))yt.call(t,r)&&ve(e,r,t[r]);return e},St=(e,t)=>ht(e,Et(t)),bt=(e,t)=>{for(var r in t)Z(e,r,{get:t[r],enumerable:!0})},be=(e,t,r,n)=>{for(var o=n>1?void 0:n?gt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&Z(t,r,o),o},xt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Rt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ee(e){return typeof e=="string"}function xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function wt(e){return typeof e=="undefined"}function It(e){return wt(e)||e===null}function Tt(e){return typeof e=="function"}function Re(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Lt=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Lt||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},we=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ie=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},I=class extends we{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Dt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Dt});var z=Symbol.for("Jolibox.canIUseMap"),At={};globalThis[z]||(globalThis[z]=At);var Te={get config(){return globalThis[z]}};function te(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var re=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(re||{}),ne=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ne||{}),Ut=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(Ut||{}),Se=["name","params"],Ot=["name","type","location","target","extra","timestamp","userId"],Pt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function C(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ct(e){let t=e.location?C(e.location,Se):null,r=e.target?C(e.target,Se):null;return C(St(vt({},e),{location:t,target:r}),Ot)}function Le(e){let t=e.events.map(n=>Ct(n)),r=C(e.device,Pt);return[e.protocolVersion,t,r,e.project]}var kt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function oe(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}oe();var Kt=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),P={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Mt=()=>P.isiOS?"iOS":P.isAndroid?"Android":P.isMac?"Mac":P.isFacebook?"Facebook":"PC",Nt="device_id",jt="advertising_id",De=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,kt()),window.__joliboxLocalStorage__.getItem(e)),Jt=()=>new URLSearchParams(window.location.search).get("deviceId")||De(Nt),Ft=()=>new URLSearchParams(window.location.search).get("advertisingId")||De(jt),Bt=e=>e.charAt(0).toUpperCase()+e.slice(1),Vt=()=>{var e;let t=new URLSearchParams(window.location.search);return Bt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ae=e=>{if(Kt())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Mt(),n=navigator.language,o=Jt(),s=Ft();return`${t} (${Vt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},q=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};q.Undefined=new q(void 0);var d=q,$t=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},Ht=0,R=class{constructor(e){this.value=e,this.id=Ht++}},w=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof R&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new R(t);return this._listeners?this._listeners instanceof R?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,_,he;if(!this._disposed){if(this._listeners instanceof R)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let ge=this._listeners.indexOf(c);ge>=0&&(this._listeners.splice(ge,1),this._size--,this._size===0&&((he=(_=this.options)==null?void 0:_.onDidRemoveLastListener)==null||he.call(_)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof R?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},se=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new $t,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},X={};bt(X,{None:()=>Gt,filter:()=>zt,once:()=>Ue,toPromise:()=>Wt});var Gt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Wt(e){return new Promise(t=>Ue(e)(t))}function Ue(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function zt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var W=Symbol.for("Jolibox.hostEmitter"),qt=()=>{let e=new se;return globalThis[W]||(globalThis[W]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[W]},v=qt();function Qt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)Xt(e[n],t[n])}function Xt(e,t){if(ee(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Tt(t)){try{if(e instanceof t)return}catch(r){}if(!It(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var k=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Qt(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};k=be([Re],k);var Y=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new k,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Rt(3e4)),this._starActivation}executeCommand(e,...t){return xt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Y=be([Re],Y);var Oe=Symbol.for("Jolibox.commands");function Yt(){return typeof globalThis!="undefined"?globalThis[Oe]:void 0}function Zt(e){typeof globalThis!="undefined"&&(globalThis[Oe]=e)}function h(){let e=Yt();if(e)return e;let t=new k,r=new Y,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return Zt(n),n}var N=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function er(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function tr(){return{platform:1e3,os:"h5",appVersion:"1.1.19",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.19",extra:{}}}var Pe={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},rr=()=>{var t;let e=(t=Pe[window.location.host])!=null?t:Pe.default;return N?e.test:e.prod},nr=rr(),ke=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ce;(Ce=AbortSignal.timeout)!=null||(AbortSignal.timeout=ke);var or=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},sr=or(),ir=e=>m(void 0,null,function*(){try{let r=`${nr}/report`,n=Ae("1.1.19"),o=sr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:ke(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:re.ErrorTrace,location:er(),target:null,extra:e,timestamp:Date.now(),userId:null},r=tr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ne.WebSDK},s=Le(o);yield ir(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var ar=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=ar(),Ke=h(),ie=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},y=ie;window.addEventListener("unhandledrejection",ie.bind(void 0));window.addEventListener("error",ie.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ke.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var ae=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(ae(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ae(e),{major:a,minor:l,patch:i,prerelease:c}=ae(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Me=h(),j=(e,t)=>{Me.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Me.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};oe();var Je="jolibox-sdk-loadermeta",je,A=JSON.parse((je=window.__joliboxLocalStorage__.getItem(Je))!=null?je:"{}"),ce=Date.now(),Ne=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function cr(){return m(this,null,function*(){let t=`${N?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=O(U({},A),{timestamp:ce});if(o){let{bootstrap_version:a}=A;a&&D(a,o)>=0||(s=O(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=A;a&&D(a,n)>=0||(s=O(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Je,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Fe=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=A;i&&c&&!Ne(ce,c)&&L(i)==t&&D(i,r)>=0&&(n=le(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Ie(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();j("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let _=document.createElement("script");_.type="text/javascript",_.innerHTML=c,document.head.appendChild(_),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=A;c&&u&&!Ne(ce,u)&&L(c)==t&&D(c,r)>=0&&(o=me(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),cr()}catch(i){let c=new I(`module evaluate error: ${i}`);S({err:`${c}`})}}};var Be=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){y(new I(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();j("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new I(`module load failed ${o}`))}}};var lr="1.1.19",J=lr,Ge=L(J),We=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),mr=We?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,de="https://jsdelivr.jolibox.com",Ve=window.document.currentScript;Ve&&(de=new URL(Ve.src).origin);var le=e=>`${de}/npm/@jolibox/bootstrap@${e}/dist/index.js`,me=e=>`${de}/npm/@jolibox/implement@${e}/dist/index.js`,dr=e=>/^\d+\.\d+\.\d+$/.test(e),ze=dr(J)?Ge:J,$e=le(ze),He=me(ze);function ur(){We?Be(mr,{bootstrapUrl:$e,implementUrl:He})():Fe({bootstrapUrl:$e,implementUrl:He,currentMajorVersion:Ge,currentVersion:J})()}ur();var qe=h();function Qe(){return qe.excuteCommandSync("API.getSystemInfoSync")}function Xe(){return qe.excuteCommandSync("API.env")}function Ye(e,t){var r;return(r=Te.config[e])==null?void 0:r[t]}function Ze(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var tt="1.1.19";function E(e){var l,i;let r=(i=(l=Xe().data)==null?void 0:l.deviceInfo)==null?void 0:i.platform;if(!r)return!1;let[n,...o]=e.split(":"),s=Ye(r=="h5"?r:"native",n);if(!s)return!1;let a=s.version;return typeof a!="string"||te(tt,a,"<")?!1:o.length===0?!0:et(s,o)||et(s.properties,o)}function et(e,t){if(!e)return!1;let r=Ze(e,t);return r?xe(r)?!0:ee(r)?te(tt,r,">="):!1:!1}var rt=h();function nt(){return m(this,null,function*(){return E("login")?yield rt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ot(){return m(this,null,function*(){return E("checkSession")?yield rt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var pr=h();function st(e){return m(this,null,function*(){return E("request")?yield pr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ue=["onI18nChanged","onBackPress"],it=(e,t)=>{ue.includes(e)||y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3)),v.on(e,t)},at=(e,t)=>{ue.includes(e)||y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3)),v.off(e,t)},ct=(e,t)=>{ue.includes(e)||y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3)),v.once(e,t)};var pe=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},lt=window.JoliboxRuntime||pe;var p=class{constructor(){this.commands=h();this._emitter=new se}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var fr="LifecycleSDK.onReady",F=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(fr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var B=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var $=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var H=class extends p{onLevelFinished(t,r,n){return m(this,null,function*(){let o=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return o?Promise.resolve(o):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",t,{result:r,duration:n})})}onTaskFinished(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskFinished");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskFinished",t,{duration:r}))})}onTaskEvent(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onTaskEvent");return n||(yield this.commands.executeCommand("TaskTrackerSDK.taskEvent",t,r))})}onLevelUpgrade(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return n||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",t,r))})}onHistoryUserLevel(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserLevel");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserLevel",t))})}onHistoryUserScore(t){return m(this,null,function*(){let r=this.canIUseIfThrow("TaskTrackerSDK.onHistoryUserScore");return r||(yield this.commands.executeCommand("TaskTrackerSDK.historyUserScore",t))})}};var G=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}};var g=class g{constructor(){this.jssdkVersion="1.1.19";this.runtime=new lt;this.ads=new V;this.lifecycle=new F;this.storage=new B;this.keyboard=new $;this.task=new H;this.router=new G;this.getSystemInfoSync=Qe.bind(this);this.canIUse=E.bind(this);this.login=nt.bind(this);this.checkSession=ot.bind(this);this.request=st.bind(this);this.on=it.bind(this);this.off=at.bind(this);this.once=ct.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var fe=g;window.JoliboxSDK=fe;})();
package/dist/index.js CHANGED
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
 
3
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
4
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
3
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
5
4
  (_JoliboxSDK2 => {
6
5
  // ../common/dist/index.es.js
7
6
  var M = Object.defineProperty;
8
- var Ee = Object.defineProperties;
9
- var Te = Object.getOwnPropertyDescriptor;
7
+ var xe = Object.defineProperties;
8
+ var Ee = Object.getOwnPropertyDescriptor;
10
9
  var he = Object.getOwnPropertyDescriptors;
11
10
  var J = Object.getOwnPropertySymbols;
12
11
  var Re = Object.prototype.hasOwnProperty;
@@ -17,12 +16,12 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
17
16
  writable: true,
18
17
  value: t
19
18
  }) : n[e] = t;
20
- var x = (n, e) => {
19
+ var _ = (n, e) => {
21
20
  for (var t in e || (e = {})) Re.call(e, t) && G(n, t, e[t]);
22
21
  if (J) for (var t of J(e)) ve.call(e, t) && G(n, t, e[t]);
23
22
  return n;
24
23
  };
25
- var C = (n, e) => Ee(n, he(e));
24
+ var C = (n, e) => xe(n, he(e));
26
25
  var be = (n, e) => {
27
26
  for (var t in e) M(n, t, {
28
27
  get: e[t],
@@ -30,7 +29,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
30
29
  });
31
30
  };
32
31
  var w = (n, e, t, r) => {
33
- for (var o = r > 1 ? void 0 : r ? Te(e, t) : e, i = n.length - 1, a; i >= 0; i--) (a = n[i]) && (o = (r ? a(e, t, o) : a(o)) || o);
32
+ for (var o = r > 1 ? void 0 : r ? Ee(e, t) : e, i = n.length - 1, a; i >= 0; i--) (a = n[i]) && (o = (r ? a(e, t, o) : a(o)) || o);
34
33
  return r && o && M(e, t, o), o;
35
34
  };
36
35
  var N = (n, e, t) => new Promise((r, o) => {
@@ -140,6 +139,25 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
140
139
  this.priority = "P0";
141
140
  }
142
141
  };
142
+ var de = class extends v {
143
+ constructor(t, r, o, i, a) {
144
+ super(t);
145
+ this.message = t;
146
+ this.code = r;
147
+ this.kind = "API_ERROR";
148
+ this.name = "API_ERROR";
149
+ o && (this.errorType = o), i !== void 0 && (this.stack = i), a && (this.priority = a);
150
+ }
151
+ toJSON() {
152
+ return {
153
+ message: this.message,
154
+ stack: this.stack,
155
+ name: this.name,
156
+ code: this.code,
157
+ errorType: this.errorType
158
+ };
159
+ }
160
+ };
143
161
  function b(n) {
144
162
  return function () {
145
163
  var r, o;
@@ -216,7 +234,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
216
234
  function Me(n) {
217
235
  let e = n.location ? P(n.location, ue) : null,
218
236
  t = n.target ? P(n.target, ue) : null;
219
- return P(C(x({}, n), {
237
+ return P(C(_({}, n), {
220
238
  location: e,
221
239
  target: t
222
240
  }), Se);
@@ -271,7 +289,10 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
271
289
  let e = new URLSearchParams(window.location.search).get("deviceId");
272
290
  return e || ge(Fe);
273
291
  };
274
- var He = () => ge(Ve);
292
+ var He = () => {
293
+ let e = new URLSearchParams(window.location.search).get("advertisingId");
294
+ return e || ge(Ve);
295
+ };
275
296
  var Ke = n => n.charAt(0).toUpperCase() + n.slice(1);
276
297
  var Je = () => {
277
298
  var e;
@@ -287,13 +308,13 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
287
308
  i = He();
288
309
  return `${e} (${Je()}${t}; UnknownModel; UnknownSystemVersion; ${r}) uuid/${o} adid/${i} version/${n || ""}`;
289
310
  };
290
- var E = class E2 {
311
+ var x = class x2 {
291
312
  constructor(e) {
292
- this.element = e, this.next = E2.Undefined, this.prev = E2.Undefined;
313
+ this.element = e, this.next = x2.Undefined, this.prev = x2.Undefined;
293
314
  }
294
315
  };
295
- E.Undefined = new E(void 0);
296
- var c = E;
316
+ x.Undefined = new x(void 0);
317
+ var c = x;
297
318
  var k = class {
298
319
  constructor() {
299
320
  this._first = c.Undefined;
@@ -385,9 +406,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
385
406
  r && (t = t.bind(r));
386
407
  let o = new y(t);
387
408
  return this._listeners ? this._listeners instanceof y ? this._listeners = [this._listeners, o] : this._listeners.push(o) : ((a = (i = this.options) == null ? void 0 : i.onWillAddFirstListener) == null || a.call(i, this), this._listeners = o, (s = (l = this.options) == null ? void 0 : l.onDidFirstListener) == null || s.call(l, this)), (d = (m = this.options) == null ? void 0 : m.onDidAddListener) == null || d.call(m, this), this._size++, () => {
388
- var _, R, A, H;
409
+ var T, R, A, H;
389
410
  if (!this._disposed) {
390
- if (this._listeners instanceof y) this._listeners.id === o.id && (this._listeners = void 0, this._size = 0, (R = (_ = this.options) == null ? void 0 : _.onDidRemoveLastListener) == null || R.call(_));else if (this._listeners) {
411
+ if (this._listeners instanceof y) this._listeners.id === o.id && (this._listeners = void 0, this._size = 0, (R = (T = this.options) == null ? void 0 : T.onDidRemoveLastListener) == null || R.call(T));else if (this._listeners) {
391
412
  let K = this._listeners.indexOf(o);
392
413
  K >= 0 && (this._listeners.splice(K, 1), this._size--, this._size === 0 && ((H = (A = this.options) == null ? void 0 : A.onDidRemoveLastListener) == null || H.call(A)));
393
414
  }
@@ -423,16 +444,17 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
423
444
  this.cachedEventQueue = /* @__PURE__ */new Map();
424
445
  }
425
446
  on(e, t) {
426
- var l;
427
- let r = (l = this.listeners.get(e)) != null ? l : new p(),
428
- o = s => t(...s.args),
429
- i = r.event(o);
447
+ let r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
448
+ var s;
449
+ let o = (s = this.listeners.get(e)) != null ? s : new p(),
450
+ i = m => t(...m.args),
451
+ a = o.event(i);
430
452
  this.listerHandlerMap.set(t, {
431
- handler: o,
432
- dispose: i
433
- }), this.listeners.set(e, r);
434
- let a = this.cachedEventQueue.get(e);
435
- if (a) for (let s of a) t(...s.args);
453
+ handler: i,
454
+ dispose: a
455
+ }), this.listeners.set(e, o);
456
+ let l = this.cachedEventQueue.get(e);
457
+ if (l && r) for (let m of l) t(...m.args);
436
458
  }
437
459
  flushCachedEvent(e) {
438
460
  e ? this.cachedEventQueue.delete(e) : this.cachedEventQueue.clear();
@@ -454,9 +476,16 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
454
476
  args: t
455
477
  });
456
478
  }
479
+ once(e, t) {
480
+ var _this = this;
481
+ let r = function () {
482
+ t(...arguments), _this.off(e, r);
483
+ };
484
+ this.on(e, r, false);
485
+ }
457
486
  };
458
- var T = {};
459
- be(T, {
487
+ var E = {};
488
+ be(E, {
460
489
  None: () => ze,
461
490
  filter: () => Be,
462
491
  once: () => ye,
@@ -498,11 +527,12 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
498
527
  return globalThis[j] || (globalThis[j] = {
499
528
  on: n.on.bind(n),
500
529
  off: n.off.bind(n),
501
- emit: n.emit.bind(n)
530
+ emit: n.emit.bind(n),
531
+ once: n.once.bind(n)
502
532
  }), globalThis[j];
503
533
  };
504
534
  var St = We();
505
- function _e(n, e) {
535
+ function Te(n, e) {
506
536
  let t = Math.min(n.length, e.length);
507
537
  for (let r = 0; r < t; r++) Qe(n[r], e[r]);
508
538
  }
@@ -534,7 +564,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
534
564
  for (var _len3 = arguments.length, a = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
535
565
  a[_key3] = arguments[_key3];
536
566
  }
537
- return _e(a, o), i(...a);
567
+ return Te(a, o), i(...a);
538
568
  };
539
569
  }
540
570
  let {
@@ -572,7 +602,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
572
602
  t[_key4 - 1] = arguments[_key4];
573
603
  }
574
604
  return N(this, null, function* () {
575
- return this.registry.getCommand(e) ? this._tryExecuteCommand(e, t) : (yield Promise.all([Promise.race([this._activateStar(), T.toPromise(T.filter(this.registry.onDidRegisterCommand, o => o === e))])]), this._tryExecuteCommand(e, t));
605
+ return this.registry.getCommand(e) ? this._tryExecuteCommand(e, t) : (yield Promise.all([Promise.race([this._activateStar(), E.toPromise(E.filter(this.registry.onDidRegisterCommand, o => o === e))])]), this._tryExecuteCommand(e, t));
576
606
  });
577
607
  }
578
608
  executeCommandThowErr(e) {
@@ -621,12 +651,12 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
621
651
  }
622
652
  };
623
653
  h = w([O], h);
624
- var xe = Symbol.for("Jolibox.commands");
654
+ var _e = Symbol.for("Jolibox.commands");
625
655
  function qe() {
626
- return typeof globalThis != "undefined" ? globalThis[xe] : void 0;
656
+ return typeof globalThis != "undefined" ? globalThis[_e] : void 0;
627
657
  }
628
658
  function Xe(n) {
629
- typeof globalThis != "undefined" && (globalThis[xe] = n);
659
+ typeof globalThis != "undefined" && (globalThis[_e] = n);
630
660
  }
631
661
  function dr() {
632
662
  let n = qe();
@@ -1242,9 +1272,25 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1242
1272
  }
1243
1273
 
1244
1274
  // src/api/on-custom-event.ts
1275
+ var supportedEvents = ["onI18nChanged", "onBackPress"];
1245
1276
  var onCustomEvent = (event, callback) => {
1277
+ if (!supportedEvents.includes(event)) {
1278
+ reportError(new de(`[onCustomEvent] Unsupported event: ${event}`, 2e3));
1279
+ }
1246
1280
  St.on(event, callback);
1247
1281
  };
1282
+ var offCustomEvent = (event, callback) => {
1283
+ if (!supportedEvents.includes(event)) {
1284
+ reportError(new de(`[offCustomEvent] Unsupported event: ${event}`, 2e3));
1285
+ }
1286
+ St.off(event, callback);
1287
+ };
1288
+ var onceCustomEvent = (event, callback) => {
1289
+ if (!supportedEvents.includes(event)) {
1290
+ reportError(new de(`[onceCustomEvent] Unsupported event: ${event}`, 2e3));
1291
+ }
1292
+ St.once(event, callback);
1293
+ };
1248
1294
 
1249
1295
  // src/sdks/runtime.ts
1250
1296
  var FallbackJoliboxRuntime = class {
@@ -1517,6 +1563,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
1517
1563
  this.checkSession = checkSession.bind(this);
1518
1564
  this.request = request.bind(this);
1519
1565
  this.on = onCustomEvent.bind(this);
1566
+ this.off = offCustomEvent.bind(this);
1567
+ this.once = onceCustomEvent.bind(this);
1520
1568
  if (_JoliboxSDK.instance) {
1521
1569
  return _JoliboxSDK.instance;
1522
1570
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@jolibox/sdk",
3
3
  "description": "This project is common Jolibox JS-SDk interfere",
4
- "version": "1.1.19-beta.6",
4
+ "version": "1.1.19",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "typings": "dist/index.d.ts",
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
- "@jolibox/common": "1.1.19-beta.6",
11
- "@jolibox/types": "1.1.19-beta.6"
10
+ "@jolibox/common": "1.1.19",
11
+ "@jolibox/types": "1.1.19"
12
12
  },
13
13
  "devDependencies": {
14
14
  "typescript": "5.7.3",
package/sdk.build.log CHANGED
@@ -1,17 +1,17 @@
1
1
  Invoking: npm run clean && npm run build:cjs && npm run build:esm && npm run build:iife && tsc
2
2
 
3
- > @jolibox/sdk@1.1.19-beta.6 clean
3
+ > @jolibox/sdk@1.1.19 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/sdk@1.1.19-beta.6 build:cjs
7
+ > @jolibox/sdk@1.1.19 build:cjs
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=cjs
9
9
 
10
10
 
11
- > @jolibox/sdk@1.1.19-beta.6 build:esm
11
+ > @jolibox/sdk@1.1.19 build:esm
12
12
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
13
13
 
14
14
 
15
- > @jolibox/sdk@1.1.19-beta.6 build:iife
15
+ > @jolibox/sdk@1.1.19 build:iife
16
16
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
17
17
 
@@ -1,9 +1,33 @@
1
+ import { reportError } from '@/events';
1
2
  import { hostEmitter } from '@jolibox/common';
2
3
  import { HostEventParamsMap } from '@jolibox/types';
4
+ import { APIError } from '@jolibox/common';
3
5
 
4
6
  // Define the custom events we want to support
5
- type CustomEventType = 'onI18nChanged';
7
+ type CustomEventType = 'onI18nChanged' | 'onBackPress';
8
+
9
+ const supportedEvents = ['onI18nChanged', 'onBackPress'];
6
10
 
7
11
  export const onCustomEvent = <T extends CustomEventType>(event: T, callback: HostEventParamsMap[T]) => {
12
+ if (!supportedEvents.includes(event)) {
13
+ reportError(new APIError(`[onCustomEvent] Unsupported event: ${event}`, 2000));
14
+ }
15
+
8
16
  hostEmitter.on(event, callback);
9
17
  };
18
+
19
+ export const offCustomEvent = <T extends CustomEventType>(event: T, callback: HostEventParamsMap[T]) => {
20
+ if (!supportedEvents.includes(event)) {
21
+ reportError(new APIError(`[offCustomEvent] Unsupported event: ${event}`, 2000));
22
+ }
23
+
24
+ hostEmitter.off(event, callback);
25
+ };
26
+
27
+ export const onceCustomEvent = <T extends CustomEventType>(event: T, callback: HostEventParamsMap[T]) => {
28
+ if (!supportedEvents.includes(event)) {
29
+ reportError(new APIError(`[onceCustomEvent] Unsupported event: ${event}`, 2000));
30
+ }
31
+
32
+ hostEmitter.once(event, callback);
33
+ };
package/src/index.ts CHANGED
@@ -8,7 +8,16 @@ import './loader';
8
8
  /**
9
9
  * @public Jolibox JS SDK Entry
10
10
  */
11
- import { getSystemInfoSync, canIUse, login, checkSession, request, onCustomEvent } from './api';
11
+ import {
12
+ getSystemInfoSync,
13
+ canIUse,
14
+ login,
15
+ checkSession,
16
+ request,
17
+ onCustomEvent,
18
+ offCustomEvent,
19
+ onceCustomEvent
20
+ } from './api';
12
21
  import { RuntimeSDK } from './sdks/runtime';
13
22
  import { LifecycleSDK } from './sdks/lifecycle';
14
23
  import { StorageSDK } from './sdks/storage';
@@ -51,6 +60,8 @@ export class JoliboxSDK {
51
60
  checkSession = checkSession.bind(this);
52
61
  request = request.bind(this);
53
62
  on = onCustomEvent.bind(this);
63
+ off = offCustomEvent.bind(this);
64
+ once = onceCustomEvent.bind(this);
54
65
 
55
66
  constructor() {
56
67
  if (JoliboxSDK.instance) {