@jolibox/sdk 1.3.2 → 1.3.3

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,10 +1,10 @@
1
1
  {
2
2
  "files": {
3
- "packages/sdk/.rush/temp/shrinkwrap-deps.json": "220776b56349f58e6c3047ae379258684eeeaf5c",
3
+ "packages/sdk/.rush/temp/shrinkwrap-deps.json": "8b599f178b3938f513f0608c27d24eebe2e97d36",
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": "1faf4bc26adc2a38be49cc2806f5bd5435550351",
7
+ "packages/sdk/package.json": "28938a57695d299db46db7327fe4711f45028269",
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/call-host-method.ts": "e373cd15fe1d9d1a86c3276545017c49e954c223",
@@ -17,7 +17,7 @@
17
17
  "packages/sdk/src/api/request.ts": "117baeceb72bd1602a01f3e1fe586faaea48d155",
18
18
  "packages/sdk/src/api/track.ts": "423184430f6d9e6fd24da3328612fe7c3ac20275",
19
19
  "packages/sdk/src/events.ts": "124aa9c3dbfa2477ba4d365d63446fae6b542f1f",
20
- "packages/sdk/src/index.ts": "9064e8319b592997f1cbb5f5fbeda796a5d0c530",
20
+ "packages/sdk/src/index.ts": "3fdfe6dcc13553bb861587effbb05560b16a2d41",
21
21
  "packages/sdk/src/loader/__tests__/version.test.ts": "338ca817bfcb672d1065d6f32872b57bc43951b5",
22
22
  "packages/sdk/src/loader/h5.ts": "d4428c67612fd9cf5540afa2bdd3cd17db0f5c98",
23
23
  "packages/sdk/src/loader/index.ts": "0ef5ddb69c89f6f7cd78ee318c7030ca3da8aee4",
@@ -27,6 +27,7 @@
27
27
  "packages/sdk/src/sdks/keyboard.ts": "b30424cbecffa24c9d5249366a70afe2128e64be",
28
28
  "packages/sdk/src/sdks/lifecycle.ts": "4d9a3b770d528f59c0eb9272e18d5c2c5641320d",
29
29
  "packages/sdk/src/sdks/payment.ts": "cdbc5596d049a47163adcf7f371ad2f5b98439e3",
30
+ "packages/sdk/src/sdks/rewards.ts": "40d907e50221b09905582ed2d8ffb69c6ac9c993",
30
31
  "packages/sdk/src/sdks/router.ts": "5aca615f05f2c85e098cd6759a0bd7ad6a31a0f2",
31
32
  "packages/sdk/src/sdks/runtime.ts": "179ae2ffd60125f6ba058c9b52ca4db46032c26b",
32
33
  "packages/sdk/src/sdks/sdk.ts": "789f8be82a9c3257306f3e40d21311a7873d4502",
@@ -167,7 +167,7 @@
167
167
  "/balanced-match/1.0.2": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
168
168
  "/brace-expansion/2.0.1": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
169
169
  "/browserslist/4.24.4": "sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A==",
170
- "/caniuse-lite/1.0.30001726": "sha512-VQAUIUzBiZ/UnlM28fSp2CRF3ivUn1BWEvxMcVTNwpw91Py1pGbPIyIKtd+tzct9C3ouceCVdGAXxZOpZAsgdw==",
170
+ "/caniuse-lite/1.0.30001757": "sha512-r0nnL/I28Zi/yjk1el6ilj27tKcdjLsNqAOZr0yVjWPrSQyHgKI2INaEWw21bAQSv2LXRt1XuCS/GomNpWOxsQ==",
171
171
  "/chalk/4.1.2": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
172
172
  "/color-convert/2.0.1": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
173
173
  "/color-name/1.1.4": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
@@ -239,7 +239,7 @@
239
239
  "/unicode-match-property-ecmascript/2.0.0": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==",
240
240
  "/unicode-match-property-value-ecmascript/2.2.0": "sha512-4IehN3V/+kkr5YeSSDDQG8QLqO26XpL2XP3GQtqwlT/QYSECAwFztxVHjlbh0+gjJ3XmNLS0zDsbgs9jWKExLg==",
241
241
  "/unicode-property-aliases-ecmascript/2.1.0": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==",
242
- "/update-browserslist-db/1.1.2_browserslist@4.24.4": "sha512-PPypAm5qvlD7XMZC3BujecnaOxwhrtoFR+Dqkk5Aa/6DssiH0ibKoketaj9w8LP7Bont1rYeoV5plxD7RTEPRg==",
242
+ "/update-browserslist-db/1.1.4_browserslist@4.24.4": "sha512-q0SPT4xyU84saUX+tomz1WLkxUbuaJnR1xWt17M7fJtEJigJeWUNGUqrauFXsHnqev9y9JTRGwk13tFBuKby4A==",
243
243
  "/which/2.0.2": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
244
244
  "/wrap-ansi/7.0.0": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
245
245
  "/wrap-ansi/8.1.0": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var P=Object.defineProperty,yt=Object.defineProperties,vt=Object.getOwnPropertyDescriptor,_t=Object.getOwnPropertyDescriptors,Rt=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var Re=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))be.call(t,r)&&Re(e,r,t[r]);if(_e)for(var r of _e(t))bt.call(t,r)&&Re(e,r,t[r]);return e},O=(e,t)=>yt(e,_t(t));var xt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},It=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Rt(t))!be.call(e,s)&&s!==r&&P(e,s,{get:()=>t[s],enumerable:!(n=vt(t,s))||n.enumerable});return e};var wt=e=>It(P({},"__esModule",{value:!0}),e);var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});var Ur={};xt(Ur,{JoliboxSDK:()=>Y});module.exports=wt(Ur);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 ne=Object.defineProperty,Tt=Object.defineProperties,Ct=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pt=(e,t)=>{for(var r in t||(t={}))Dt.call(t,r)&&Ie(e,r,t[r]);if(xe)for(var r of xe(t))Lt.call(t,r)&&Ie(e,r,t[r]);return e},Ut=(e,t)=>Tt(e,At(t)),Ot=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,n)=>{for(var s=n>1?void 0:n?Ct(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&ne(t,r,s),s},kt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 Kt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function se(e){return typeof e=="string"}function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Nt(e){return typeof e=="undefined"}function Mt(e){return Nt(e)||e===null}function jt(e){return typeof e=="function"}function De(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var qt=(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))(qt||{}),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}},Le=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Pe=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var j=class extends M{constructor(e,t,r,n,s){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),s&&(this.priority=s)}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 Jt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Jt});var X=Symbol.for("Jolibox.canIUseMap"),Ft={};globalThis[X]||(globalThis[X]=Ft);var Ue={get config(){return globalThis[X]}};var we=Symbol.for("Jolibox.canIUseMap.native"),$t={};globalThis[we]||(globalThis[we]=$t);function oe(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let a=parseInt(s[l],10)||0,u=parseInt(o[l],10)||0;if(a>u){n=1;break}else if(a<u){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 ie=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ie||{}),ae=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ae||{}),Bt=(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))(Bt||{}),Te=["name","params"],Vt=["name","type","location","target","extra","timestamp","userId"],Ht=["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((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function Gt(e){let t=e.location?K(e.location,Te):null,r=e.target?K(e.target,Te):null;return K(Ut(Pt({},e),{location:t,target:r}),Vt)}function Oe(e){let t=e.events.map(n=>Gt(n)),r=K(e.device,Ht);return[e.protocolVersion,t,r,e.project]}var Wt=()=>"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 ce(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};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}}ce();var v=typeof window=="undefined",le=()=>!v&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!v&&(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:!v&&navigator.userAgent.includes("Android"),isMac:!v&&navigator.userAgent.includes("Mac"),isFacebook:!v&&navigator.userAgent.includes("FB_IAB"),isPC:!v&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},zt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Yt="device_id",Qt="advertising_id",ke=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Wt()),window.__joliboxLocalStorage__.getItem(e)),Xt=()=>new URLSearchParams(window.location.search).get("deviceId")||ke(Yt),Zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||ke(Qt),er=e=>e.charAt(0).toUpperCase()+e.slice(1),tr=()=>{var e;let t=new URLSearchParams(window.location.search);return er((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ke=e=>{if(le())return window.navigator.userAgent;let t="JoliboxWebSDK",r=zt(),n=navigator.language,s=Xt(),o=Zt();return`${t} (${tr()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function Ne(e,t,r){let n=window.location.hostname,s=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(s.length>=2){let i=s.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${o}.${i}`}return`${o}.jolibox.com`}function Me(e){return`https://${Ne("api","stg-api",e)}`}function rr(e){return Ne("collect","stg-collect",e)}function je(e){return`https://${rr(e)}`}var Z=class ee{constructor(t){this.element=t,this.next=ee.Undefined,this.prev=ee.Undefined}};Z.Undefined=new Z(void 0);var d=Z,nr=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 s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.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}},sr=0,I=class{constructor(e){this.value=e,this.id=sr++}},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 I&&(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,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let u=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,u]:this._listeners.push(u):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=u,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,S,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===u.id&&(this._listeners=void 0,this._size=0,(g=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||g.call(f));else if(this._listeners){let ve=this._listeners.indexOf(u);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(S=this.options)==null?void 0:S.onDidRemoveLastListener)==null||ye.call(S)))}}}}),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(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ue=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let s=(n=this.listeners.get(e))!=null?n:new w,o=a=>t(...a.args),i=s.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:i}),this.listeners.set(e,s);let l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)t(...a.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 nr,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)}},te={};Ot(te,{None:()=>or,filter:()=>ar,once:()=>qe,toPromise:()=>ir});var or=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ir(e){return new Promise(t=>qe(e)(t))}function qe(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function ar(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new w(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var Q=Symbol.for("Jolibox.hostEmitter"),cr=()=>{let e=new ue;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]},_=cr();function lr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ur(e[n],t[n])}function ur(e,t){if(se(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(jt(t)){try{if(e instanceof t)return}catch(r){}if(!Mt(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 N=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 s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return lr(s,r),n(...s)}}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}};N=Ce([De],N);var re=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Kt(3e4)),this._starActivation}executeCommand(e,...t){return kt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),te.toPromise(te.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}}};re=Ce([De],re);var Je=Symbol.for("Jolibox.commands");function dr(){return typeof globalThis!="undefined"?globalThis[Je]:void 0}function mr(e){typeof globalThis!="undefined"&&(globalThis[Je]=e)}function m(e=!1){let t=dr();if(!e&&t)return t;let r=new N,n=new re,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return mr(s),s}var q=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function pr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function hr(){return{platform:1e3,os:"h5",appVersion:"1.3.2",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.2",extra:{}}}var fr=()=>{var t;return je((t=q)!=null?t:!1)},gr=fr(),$e=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Fe;(Fe=AbortSignal.timeout)!=null||(AbortSignal.timeout=$e);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},Sr=Er(),yr=e=>c(void 0,null,function*(){try{let r=`${gr}/report`,n=Ke("1.3.2"),s=Sr,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:$e(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:ie.ErrorTrace,location:pr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=hr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ae.WebSDK},o=Oe(s);yield yr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var vr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=vr(),Be=m(),de=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};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),R({err:JSON.stringify(t)})})},y=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.bind(void 0));window.onerror=(e,t,r,n,s)=>{let o={message:e,source:t,lineno:r,colno:n,stack:s==null?void 0:s.stack,errorString:s==null?void 0:s.toString()};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var me=e=>{var l,a,u;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),[s,o,i]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(u=n[2])!=null?u:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=me(e),{major:i,minor:l,patch:a,prerelease:u}=me(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!u?-1:!o&&u?1:o&&u?o>u?1:o<u?-1:0:0};var Ve=m(),J=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ce();var We="jolibox-sdk-loadermeta",Ge,L=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(We))!=null?Ge:"{}"),pe=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function _r(){return c(this,null,function*(){let t=`${Me(q)}/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:s}=yield r.json(),o=O(U({},L),{timestamp:pe});if(s){let{bootstrap_version:i}=L;i&&D(i,s)>=0||(o=O(U({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&D(i,n)>=0||(o=O(U({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(We,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var ze=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:u}=L;a&&u&&!He(pe,u)&&A(a)==t&&D(a,r)>=0&&(n=he(a));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let g=new Pe(`Bootstrap module faile to fetch ${f}`);R({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),C.startTime=a;let{script:u,type:f}=(g=o())!=null?g:{};if(u){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=u,document.head.appendChild(S),b("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:u,timestamp:f}=L;u&&f&&!He(pe,f)&&A(u)==t&&D(u,r)>=0&&(s=fe(u));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{b("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),_r()}catch(a){let u=new T(`module evaluate error: ${a}`);R({err:`${u}`})}}};var Ye=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),u=yield import(a);return URL.revokeObjectURL(a),u}catch(l){y(new T(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();J("jsSdkBegin",{t:s}),C.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),b("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Rr="1.3.2",F=Rr,et=A(F),tt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),br=tt?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,ge="https://jsdelivr.jolibox.com";var Qe=window.document.currentScript;Qe&&(ge=new URL(Qe.src).origin);var he=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/bootstrap@${e}/dist/index.js`,fe=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/implement@${e}/dist/index.js`,xr=e=>/^\d+\.\d+\.\d+$/.test(e),rt=xr(F)?et:F,Xe=he(rt),Ze=fe(rt);function Ir(){tt?Ye(br,{bootstrapUrl:Xe,implementUrl:Ze})():ze({bootstrapUrl:Xe,implementUrl:Ze,currentMajorVersion:et,currentVersion:F})()}Ir();var wr=m();function nt(){return wr.excuteCommandSync("API.getSystemInfoSync")}function st(e,t){var r;return(r=Ue.config[e])==null?void 0:r[t]}function ot(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var at="1.3.2";function h(e){let[t,...r]=e.split(":"),n=st(le()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||oe(at,s,"<")?!1:r.length===0?!0:it(n,r)||it(n.properties,r)}function it(e,t){if(!e)return!1;let r=ot(e,t);return r?Ae(r)?!0:se(r)?oe(at,r,">="):!1:!1}var ct=m();function lt(){return c(this,null,function*(){return h("login")?yield ct.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ut(){return c(this,null,function*(){return h("checkSession")?yield ct.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Tr=m();function dt(e){return c(this,null,function*(){return h("request")?yield Tr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Ee=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},pt=(e,t)=>{if(!Ee.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},ht=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var Cr=m();function ft(e){return c(this,null,function*(){return h("isNativeSupport")?yield Cr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=m();function gt(e){return c(this,null,function*(){return h("callHostMethod")?yield Ar.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Dr=m();function Et(e){return c(this,null,function*(){return h("track")?yield Dr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=m();this._emitter=new ue}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Se=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(s),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},St=window.JoliboxRuntime||Se;var Lr="LifecycleSDK.onReady",$=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Lr,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 c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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,n)})}removeItem(t){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(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)}}initAd(r){return c(this,null,function*(){})}};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){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:s,score:o,variation:i}=t,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:s,score:o,variation:i})})}onGamePlayEnded(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:s,variation:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(s)return s;let o=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(o),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Pr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends p{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Pr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var z=class extends p{constructor(){super()}purchaseGem(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.purchaseGem");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.purchaseGem",t)})}getGemProducts(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var E=class E{constructor(){this.jssdkVersion="1.3.2";this.runtime=new St;this.ads=new V;this.lifecycle=new $;this.storage=new B;this.keyboard=new H;this.task=new G;this.router=new W;this.payment=new z;this.getSystemInfoSync=nt.bind(this);this.canIUse=h.bind(this);this.login=lt.bind(this);this.checkSession=ut.bind(this);this.request=dt.bind(this);this.on=mt.bind(this);this.off=pt.bind(this);this.once=ht.bind(this);this.isNativeSupport=ft.bind(this);this.callHostMethod=gt.bind(this);this.track=Et.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var Y=E;window.JoliboxSDK=Y;
1
+ "use strict";var P=Object.defineProperty,vt=Object.defineProperties,_t=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,xt=Object.getOwnPropertyNames,Re=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var xe=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))be.call(t,r)&&xe(e,r,t[r]);if(Re)for(var r of Re(t))bt.call(t,r)&&xe(e,r,t[r]);return e},O=(e,t)=>vt(e,Rt(t));var It=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},wt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xt(t))!be.call(e,s)&&s!==r&&P(e,s,{get:()=>t[s],enumerable:!(n=_t(t,s))||n.enumerable});return e};var Ct=e=>wt(P({},"__esModule",{value:!0}),e);var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);l((r=r.apply(e,t)).next())});var Or={};It(Or,{JoliboxSDK:()=>Q});module.exports=Ct(Or);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 se=Object.defineProperty,Dt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,we=(e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ut=(e,t)=>{for(var r in t||(t={}))Lt.call(t,r)&&we(e,r,t[r]);if(Ie)for(var r of Ie(t))Pt.call(t,r)&&we(e,r,t[r]);return e},Ot=(e,t)=>Dt(e,At(t)),kt=(e,t)=>{for(var r in t)se(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var s=n>1?void 0:n?Tt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&se(t,r,s),s},Kt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 Nt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function oe(e){return typeof e=="string"}function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Mt(e){return typeof e=="undefined"}function jt(e){return Mt(e)||e===null}function qt(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Jt=(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))(Jt||{}),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}},Pe=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ue=class extends Pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},C=class extends Pe{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var j=class extends M{constructor(e,t,r,n,s){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),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ft={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:Ft});var Z=Symbol.for("Jolibox.canIUseMap"),$t={};globalThis[Z]||(globalThis[Z]=$t);var Oe={get config(){return globalThis[Z]}};var Ce=Symbol.for("Jolibox.canIUseMap.native"),Bt={};globalThis[Ce]||(globalThis[Ce]=Bt);function ie(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let a=parseInt(s[l],10)||0,u=parseInt(o[l],10)||0;if(a>u){n=1;break}else if(a<u){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 ae=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(ae||{}),ce=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ce||{}),Vt=(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))(Vt||{}),De=["name","params"],Ht=["name","type","location","target","extra","timestamp","userId"],Gt=["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((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function Wt(e){let t=e.location?K(e.location,De):null,r=e.target?K(e.target,De):null;return K(Ot(Ut({},e),{location:t,target:r}),Ht)}function ke(e){let t=e.events.map(n=>Wt(n)),r=K(e.device,Gt);return[e.protocolVersion,t,r,e.project]}var zt=()=>"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 le(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};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}}le();var v=typeof window=="undefined",ue=()=>!v&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!v&&(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:!v&&navigator.userAgent.includes("Android"),isMac:!v&&navigator.userAgent.includes("Mac"),isFacebook:!v&&navigator.userAgent.includes("FB_IAB"),isPC:!v&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Yt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Qt="device_id",Xt="advertising_id",Ke=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,zt()),window.__joliboxLocalStorage__.getItem(e)),Zt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ke(Qt),er=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ke(Xt),tr=e=>e.charAt(0).toUpperCase()+e.slice(1),rr=()=>{var e;let t=new URLSearchParams(window.location.search);return tr((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ne=e=>{if(ue())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Yt(),n=navigator.language,s=Zt(),o=er();return`${t} (${rr()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function Me(e,t,r){let n=window.location.hostname,s=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(s.length>=2){let i=s.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${o}.${i}`}return`${o}.jolibox.com`}function je(e){return`https://${Me("api","stg-api",e)}`}function nr(e){return Me("collect","stg-collect",e)}function qe(e){return`https://${nr(e)}`}var ee=class te{constructor(t){this.element=t,this.next=te.Undefined,this.prev=te.Undefined}};ee.Undefined=new ee(void 0);var d=ee,sr=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 s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.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}},or=0,I=class{constructor(e){this.value=e,this.id=or++}},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 I&&(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,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let u=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,u]:this._listeners.push(u):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=u,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,E,ve;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===u.id&&(this._listeners=void 0,this._size=0,(g=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||g.call(f));else if(this._listeners){let _e=this._listeners.indexOf(u);_e>=0&&(this._listeners.splice(_e,1),this._size--,this._size===0&&((ve=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ve.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(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},de=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let s=(n=this.listeners.get(e))!=null?n:new w,o=a=>t(...a.args),i=s.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:i}),this.listeners.set(e,s);let l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)t(...a.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 sr,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)}},re={};kt(re,{None:()=>ir,filter:()=>cr,once:()=>Je,toPromise:()=>ar});var ir=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ar(e){return new Promise(t=>Je(e)(t))}function Je(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function cr(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new w(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var X=Symbol.for("Jolibox.hostEmitter"),lr=()=>{let e=new de;return globalThis[X]||(globalThis[X]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[X]},_=lr();function ur(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)dr(e[n],t[n])}function dr(e,t){if(oe(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(qt(t)){try{if(e instanceof t)return}catch(r){}if(!jt(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 N=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 s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return ur(s,r),n(...s)}}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}};N=Te([Le],N);var ne=class{constructor(){this._onWillExecuteCommand=new w,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new w,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Nt(3e4)),this._starActivation}executeCommand(e,...t){return Kt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),re.toPromise(re.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}}};ne=Te([Le],ne);var Fe=Symbol.for("Jolibox.commands");function mr(){return typeof globalThis!="undefined"?globalThis[Fe]:void 0}function pr(e){typeof globalThis!="undefined"&&(globalThis[Fe]=e)}function p(e=!1){let t=mr();if(!e&&t)return t;let r=new N,n=new ne,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return pr(s),s}var q=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function hr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function fr(){return{platform:1e3,os:"h5",appVersion:"1.3.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.3",extra:{}}}var gr=()=>{var t;return qe((t=q)!=null?t:!1)},Sr=gr(),Be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},$e;($e=AbortSignal.timeout)!=null||(AbortSignal.timeout=Be);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},yr=Er(),vr=e=>c(void 0,null,function*(){try{let r=`${Sr}/report`,n=Ne("1.3.3"),s=yr,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Be(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:ae.ErrorTrace,location:hr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=fr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ce.WebSDK},o=ke(s);yield vr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",D.startTime));var _r=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},D=_r(),Ve=p(),me=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};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),R({err:JSON.stringify(t)})})},y=me;window.addEventListener("unhandledrejection",me.bind(void 0));window.addEventListener("error",me.bind(void 0));window.onerror=(e,t,r,n,s)=>{let o={message:e,source:t,lineno:r,colno:n,stack:s==null?void 0:s.stack,errorString:s==null?void 0:s.toString()};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var pe=e=>{var l,a,u;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),[s,o,i]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(u=n[2])!=null?u:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},T=e=>parseInt(pe(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=pe(e),{major:i,minor:l,patch:a,prerelease:u}=pe(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!u?-1:!o&&u?1:o&&u?o>u?1:o<u?-1:0:0};var He=p(),J=(e,t)=>{He.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{He.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};le();var ze="jolibox-sdk-loadermeta",We,L=JSON.parse((We=window.__joliboxLocalStorage__.getItem(ze))!=null?We:"{}"),he=Date.now(),Ge=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Rr(){return c(this,null,function*(){let t=`${je(q)}/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:s}=yield r.json(),o=O(U({},L),{timestamp:he});if(s){let{bootstrap_version:i}=L;i&&A(i,s)>=0||(o=O(U({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&A(i,n)>=0||(o=O(U({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(ze,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ye=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:u}=L;a&&u&&!Ge(he,u)&&T(a)==t&&A(a,r)>=0&&(n=fe(a));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let g=new Ue(`Bootstrap module faile to fetch ${f}`);R({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),D.startTime=a;let{script:u,type:f}=(g=o())!=null?g:{};if(u){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=u,document.head.appendChild(E),x("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:u,timestamp:f}=L;u&&f&&!Ge(he,f)&&T(u)==t&&A(u,r)>=0&&(s=ge(u));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Rr()}catch(a){let u=new C(`module evaluate error: ${a}`);R({err:`${u}`})}}};var Qe=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),u=yield import(a);return URL.revokeObjectURL(a),u}catch(l){y(new C(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();J("jsSdkBegin",{t:s}),D.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),x("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new C(`module load failed ${s}`))}}};var xr="1.3.3",F=xr,tt=T(F),rt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),br=rt?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,Se="https://jsdelivr.jolibox.com";var Xe=window.document.currentScript;Xe&&(Se=new URL(Xe.src).origin);var fe=(e,t)=>`${t!=null?t:Se}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ge=(e,t)=>`${t!=null?t:Se}/npm/@jolibox/implement@${e}/dist/index.js`,Ir=e=>/^\d+\.\d+\.\d+$/.test(e),nt=Ir(F)?tt:F,Ze=fe(nt),et=ge(nt);function wr(){rt?Qe(br,{bootstrapUrl:Ze,implementUrl:et})():Ye({bootstrapUrl:Ze,implementUrl:et,currentMajorVersion:tt,currentVersion:F})()}wr();var Cr=p();function st(){return Cr.excuteCommandSync("API.getSystemInfoSync")}function ot(e,t){var r;return(r=Oe.config[e])==null?void 0:r[t]}function it(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var ct="1.3.3";function h(e){let[t,...r]=e.split(":"),n=ot(ue()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||ie(ct,s,"<")?!1:r.length===0?!0:at(n,r)||at(n.properties,r)}function at(e,t){if(!e)return!1;let r=it(e,t);return r?Ae(r)?!0:oe(r)?ie(ct,r,">="):!1:!1}var lt=p();function ut(){return c(this,null,function*(){return h("login")?yield lt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function dt(){return c(this,null,function*(){return h("checkSession")?yield lt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Dr=p();function mt(e){return c(this,null,function*(){return h("request")?yield Dr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Ee=["onI18nChanged","onBackPress"],pt=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},ht=(e,t)=>{if(!Ee.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},ft=(e,t)=>{if(!Ee.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var Tr=p();function gt(e){return c(this,null,function*(){return h("isNativeSupport")?yield Tr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=p();function St(e){return c(this,null,function*(){return h("callHostMethod")?yield Ar.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Lr=p();function Et(e){return c(this,null,function*(){return h("track")?yield Lr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var m=class{constructor(){this.commands=p();this._emitter=new de}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ye=class extends m{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(s),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},yt=window.JoliboxRuntime||ye;var Pr="LifecycleSDK.onReady",$=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Pr,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 m{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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,n)})}removeItem(t){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var V=class extends m{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)}}initAd(r){return c(this,null,function*(){})}};var H=class extends m{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 m{onLevelFinished(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:s,score:o,variation:i}=t,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:s,score:o,variation:i})})}onGamePlayEnded(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:s,variation:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(s)return s;let o=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(o),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Ur=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends m{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Ur.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var z=class extends m{constructor(){super()}purchaseGem(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.purchaseGem");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.purchaseGem",t)})}getGemProducts(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var Y=class extends m{constructor(){super()}getCoinDetails(r){return c(this,arguments,function*({onUpdate:t}){let n=this.canIUseIfThrow("rewards.getCoinDetails");return(n==null?void 0:n.code)==="FAILURE"?n:yield this.commands.executeCommand("RewardsSDK.getCoinDetails",t)})}};var S=class S{constructor(){this.jssdkVersion="1.3.3";this.runtime=new yt;this.ads=new V;this.lifecycle=new $;this.storage=new B;this.keyboard=new H;this.task=new G;this.router=new W;this.payment=new z;this.rewards=new Y;this.getSystemInfoSync=st.bind(this);this.canIUse=h.bind(this);this.login=ut.bind(this);this.checkSession=dt.bind(this);this.request=mt.bind(this);this.on=pt.bind(this);this.off=ht.bind(this);this.once=ft.bind(this);this.isNativeSupport=gt.bind(this);this.callHostMethod=St.bind(this);this.track=Et.bind(this);if(S.instance)return S.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},S.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return S.instance||(S.instance=new S),S.instance}};S.instance=null;var Q=S;window.JoliboxSDK=Q;
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ import { KeyboardSDK } from './sdks/keyboard';
16
16
  import { TaskTrackerSDK } from './sdks/task';
17
17
  import { RouterSDK } from './sdks/router';
18
18
  import { PaymentSDK } from './sdks/payment';
19
+ import { RewardsSDK } from './sdks/rewards';
19
20
  declare global {
20
21
  interface Window {
21
22
  JoliboxSDK: typeof JoliboxSDK;
@@ -108,6 +109,14 @@ export declare class JoliboxSDK {
108
109
  * @type {PaymentSDK}
109
110
  */
110
111
  readonly payment: PaymentSDK;
112
+ /**
113
+ * @public
114
+ * @readonly
115
+ * Access to the Rewards SDK module.
116
+ * @see {@link RewardsSDK} for more details.
117
+ * @type {RewardsSDK}
118
+ */
119
+ readonly rewards: RewardsSDK;
111
120
  /**
112
121
  * @public
113
122
  * Synchronously gets system information.
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- var Et=Object.defineProperty,St=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var ve=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))vt.call(t,r)&&_e(e,r,t[r]);if(ve)for(var r of ve(t))_t.call(t,r)&&_e(e,r,t[r]);return e},U=(e,t)=>St(e,yt(t));var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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,Rt=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&be(e,r,t[r]);if(Re)for(var r of Re(t))wt.call(t,r)&&be(e,r,t[r]);return e},Ct=(e,t)=>Rt(e,xt(t)),At=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{for(var s=n>1?void 0:n?bt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&te(t,r,s),s},Dt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 Lt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function Te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Pt(e){return typeof e=="undefined"}function Ut(e){return Pt(e)||e===null}function Ot(e){return typeof e=="function"}function Ce(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var kt=(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))(kt||{}),N=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}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var De=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends N{constructor(e,t,r,n,s){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),s&&(this.priority=s)}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 Kt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Kt});var Y=Symbol.for("Jolibox.canIUseMap"),Nt={};globalThis[Y]||(globalThis[Y]=Nt);var Le={get config(){return globalThis[Y]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),Mt={};globalThis[xe]||(globalThis[xe]=Mt);function ne(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let a=parseInt(s[l],10)||0,u=parseInt(o[l],10)||0;if(a>u){n=1;break}else if(a<u){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 se=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(se||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),jt=(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))(jt||{}),Ie=["name","params"],qt=["name","type","location","target","extra","timestamp","userId"],Jt=["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((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function Ft(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(Ct(Tt({},e),{location:t,target:r}),qt)}function Pe(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);return[e.protocolVersion,t,r,e.project]}var $t=()=>"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(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};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 v=typeof window=="undefined",ae=()=>!v&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!v&&(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:!v&&navigator.userAgent.includes("Android"),isMac:!v&&navigator.userAgent.includes("Mac"),isFacebook:!v&&navigator.userAgent.includes("FB_IAB"),isPC:!v&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Bt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Vt="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,$t()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue(Vt),Wt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Ht),zt=e=>e.charAt(0).toUpperCase()+e.slice(1),Yt=()=>{var e;let t=new URLSearchParams(window.location.search);return zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Oe=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Bt(),n=navigator.language,s=Gt(),o=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function ke(e,t,r){let n=window.location.hostname,s=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(s.length>=2){let i=s.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${o}.${i}`}return`${o}.jolibox.com`}function Ke(e){return`https://${ke("api","stg-api",e)}`}function Qt(e){return ke("collect","stg-collect",e)}function Ne(e){return`https://${Qt(e)}`}var Q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};Q.Undefined=new Q(void 0);var d=Q,Xt=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 s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.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}},Zt=0,I=class{constructor(e){this.value=e,this.id=Zt++}},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 I&&(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,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let u=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,u]:this._listeners.push(u):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=u,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,S,Se;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===u.id&&(this._listeners=void 0,this._size=0,(g=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||g.call(f));else if(this._listeners){let ye=this._listeners.indexOf(u);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((Se=(S=this.options)==null?void 0:S.onDidRemoveLastListener)==null||Se.call(S)))}}}}),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(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let s=(n=this.listeners.get(e))!=null?n:new w,o=a=>t(...a.args),i=s.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:i}),this.listeners.set(e,s);let l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)t(...a.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 Xt,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={};At(Z,{None:()=>er,filter:()=>rr,once:()=>Me,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Me(e)(t))}function Me(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function rr(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new w(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ce;return globalThis[z]||(globalThis[z]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[z]},_=nr();function sr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)or(e[n],t[n])}function or(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 s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return sr(s,r),n(...s)}}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=we([Ce],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=Lt(3e4)),this._starActivation}executeCommand(e,...t){return Dt(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=we([Ce],ee);var je=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[je]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[je]=e)}function m(e=!1){let t=ir();if(!e&&t)return t;let r=new K,n=new ee,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return ar(s),s}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function cr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function lr(){return{platform:1e3,os:"h5",appVersion:"1.3.2",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.2",extra:{}}}var ur=()=>{var t;return Ne((t=j)!=null?t:!1)},dr=ur(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},qe;(qe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var mr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=mr(),hr=e=>c(void 0,null,function*(){try{let r=`${dr}/report`,n=Oe("1.3.2"),s=pr,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:se.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},o=Pe(s);yield hr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var fr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=fr(),Fe=m(),le=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 N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),R({err:JSON.stringify(t)})})},y=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,s)=>{let o={message:e,source:t,lineno:r,colno:n,stack:s==null?void 0:s.stack,errorString:s==null?void 0:s.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var ue=e=>{var l,a,u;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),[s,o,i]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(u=n[2])!=null?u:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},A=e=>parseInt(ue(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ue(e),{major:i,minor:l,patch:a,prerelease:u}=ue(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!u?-1:!o&&u?1:o&&u?o>u?1:o<u?-1:0:0};var $e=m(),q=(e,t)=>{$e.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{$e.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var He="jolibox-sdk-loadermeta",Ve,L=JSON.parse((Ve=window.__joliboxLocalStorage__.getItem(He))!=null?Ve:"{}"),de=Date.now(),Be=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return c(this,null,function*(){let t=`${Ke(j)}/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:s}=yield r.json(),o=U(P({},L),{timestamp:de});if(s){let{bootstrap_version:i}=L;i&&D(i,s)>=0||(o=U(P({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&D(i,n)>=0||(o=U(P({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:u}=L;a&&u&&!Be(de,u)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let g=new De(`Bootstrap module faile to fetch ${f}`);R({err:`${g}`})}}function i(){var g;let a=Date.now();q("jsSdkBegin",{t:a}),C.startTime=a;let{script:u,type:f}=(g=o())!=null?g:{};if(u){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=u,document.head.appendChild(S),b("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:u,timestamp:f}=L;u&&f&&!Be(de,f)&&A(u)==t&&D(u,r)>=0&&(s=pe(u));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{b("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),gr()}catch(a){let u=new T(`module evaluate error: ${a}`);R({err:`${u}`})}}};var We=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),u=yield import(a);return URL.revokeObjectURL(a),u}catch(l){y(new T(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();q("jsSdkBegin",{t:s}),C.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),b("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Er="1.3.2",J=Er,Xe=A(J),Ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Sr=Ze?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,he="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(he=new URL(ze.src).origin);var me=(e,t)=>`${t!=null?t:he}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/implement@${e}/dist/index.js`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),et=yr(J)?Xe:J,Ye=me(et),Qe=pe(et);function vr(){Ze?We(Sr,{bootstrapUrl:Ye,implementUrl:Qe})():Ge({bootstrapUrl:Ye,implementUrl:Qe,currentMajorVersion:Xe,currentVersion:J})()}vr();var _r=m();function tt(){return _r.excuteCommandSync("API.getSystemInfoSync")}function rt(e,t){var r;return(r=Le.config[e])==null?void 0:r[t]}function nt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var ot="1.3.2";function h(e){let[t,...r]=e.split(":"),n=rt(ae()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||ne(ot,s,"<")?!1:r.length===0?!0:st(n,r)||st(n.properties,r)}function st(e,t){if(!e)return!1;let r=nt(e,t);return r?Te(r)?!0:re(r)?ne(ot,r,">="):!1:!1}var it=m();function at(){return c(this,null,function*(){return h("login")?yield it.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ct(){return c(this,null,function*(){return h("checkSession")?yield it.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Rr=m();function lt(e){return c(this,null,function*(){return h("request")?yield Rr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],ut=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var br=m();function pt(e){return c(this,null,function*(){return h("isNativeSupport")?yield br.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=m();function ht(e){return c(this,null,function*(){return h("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=m();function ft(e){return c(this,null,function*(){return h("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=m();this._emitter=new ce}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ge=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(s),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},gt=window.JoliboxRuntime||ge;var wr="LifecycleSDK.onReady",F=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,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 $=class extends p{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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,n)})}removeItem(t){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var B=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)}}initAd(r){return c(this,null,function*(){})}};var V=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){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:s,score:o,variation:i}=t,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:s,score:o,variation:i})})}onGamePlayEnded(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:s,variation:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(s)return s;let o=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(o),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],G=class extends p{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var W=class extends p{constructor(){super()}purchaseGem(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.purchaseGem");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.purchaseGem",t)})}getGemProducts(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var E=class E{constructor(){this.jssdkVersion="1.3.2";this.runtime=new gt;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new H;this.router=new G;this.payment=new W;this.getSystemInfoSync=tt.bind(this);this.canIUse=h.bind(this);this.login=at.bind(this);this.checkSession=ct.bind(this);this.request=lt.bind(this);this.on=ut.bind(this);this.off=dt.bind(this);this.once=mt.bind(this);this.isNativeSupport=pt.bind(this);this.callHostMethod=ht.bind(this);this.track=ft.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var Ee=E;window.JoliboxSDK=Ee;export{Ee as JoliboxSDK};
1
+ var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var Re=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Re(e,r,t[r]);if(_e)for(var r of _e(t))Rt.call(t,r)&&Re(e,r,t[r]);return e},U=(e,t)=>yt(e,vt(t));var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 re=Object.defineProperty,xt=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Dt=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&be(e,r,t[r]);if(xe)for(var r of xe(t))Ct.call(t,r)&&be(e,r,t[r]);return e},Tt=(e,t)=>xt(e,It(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,n)=>{for(var s=n>1?void 0:n?bt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&re(t,r,s),s},Lt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ot(e){return Ut(e)||e===null}function kt(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Kt=(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))(Kt||{}),N=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}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},C=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends N{constructor(e,t,r,n,s){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),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:Nt});var Q=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[Q]||(globalThis[Q]=Mt);var Pe={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[Ie]||(globalThis[Ie]=jt);function se(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let a=parseInt(s[l],10)||0,u=parseInt(o[l],10)||0;if(a>u){n=1;break}else if(a<u){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.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),qt=(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))(qt||{}),we=["name","params"],Jt=["name","type","location","target","extra","timestamp","userId"],Ft=["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((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function $t(e){let t=e.location?k(e.location,we):null,r=e.target?k(e.target,we):null;return k(Tt(Dt({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>$t(n)),r=k(e.device,Ft);return[e.protocolVersion,t,r,e.project]}var Bt=()=>"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 ae(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};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}}ae();var v=typeof window=="undefined",ce=()=>!v&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!v&&(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:!v&&navigator.userAgent.includes("Android"),isMac:!v&&navigator.userAgent.includes("Mac"),isFacebook:!v&&navigator.userAgent.includes("FB_IAB"),isPC:!v&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Ht="device_id",Gt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Gt),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Qt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Qt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function Ke(e,t,r){let n=window.location.hostname,s=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(s.length>=2){let i=s.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${o}.${i}`}return`${o}.jolibox.com`}function Ne(e){return`https://${Ke("api","stg-api",e)}`}function Xt(e){return Ke("collect","stg-collect",e)}function Me(e){return`https://${Xt(e)}`}var X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var d=X,Zt=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 s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.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}},er=0,I=class{constructor(e){this.value=e,this.id=er++}},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 I&&(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,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let u=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,u]:this._listeners.push(u):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=u,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,E,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===u.id&&(this._listeners=void 0,this._size=0,(g=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||g.call(f));else if(this._listeners){let ve=this._listeners.indexOf(u);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ye.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(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},le=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let s=(n=this.listeners.get(e))!=null?n:new w,o=a=>t(...a.args),i=s.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:i}),this.listeners.set(e,s);let l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)t(...a.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 Zt,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)}},ee={};At(ee,{None:()=>tr,filter:()=>nr,once:()=>je,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function nr(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new w(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var Y=Symbol.for("Jolibox.hostEmitter"),sr=()=>{let e=new le;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},_=sr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ir(e[n],t[n])}function ir(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(kt(t)){try{if(e instanceof t)return}catch(r){}if(!Ot(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 s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return or(s,r),n(...s)}}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=Ce([Te],K);var te=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=Pt(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(),ee.toPromise(ee.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}}};te=Ce([Te],te);var qe=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[qe]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[qe]=e)}function p(e=!1){let t=ar();if(!e&&t)return t;let r=new K,n=new te,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return cr(s),s}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function lr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function ur(){return{platform:1e3,os:"h5",appVersion:"1.3.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.3",extra:{}}}var dr=()=>{var t;return Me((t=j)!=null?t:!1)},mr=dr(),Fe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Je;(Je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Fe);var pr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},hr=pr(),fr=e=>c(void 0,null,function*(){try{let r=`${mr}/report`,n=ke("1.3.3"),s=hr,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=ur(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},o=Ue(s);yield fr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",D.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},D=gr(),$e=p(),ue=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 N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),R({err:JSON.stringify(t)})})},y=ue;window.addEventListener("unhandledrejection",ue.bind(void 0));window.addEventListener("error",ue.bind(void 0));window.onerror=(e,t,r,n,s)=>{let o={message:e,source:t,lineno:r,colno:n,stack:s==null?void 0:s.stack,errorString:s==null?void 0:s.toString()};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var de=e=>{var l,a,u;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),[s,o,i]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(u=n[2])!=null?u:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},T=e=>parseInt(de(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=de(e),{major:i,minor:l,patch:a,prerelease:u}=de(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!u?-1:!o&&u?1:o&&u?o>u?1:o<u?-1:0:0};var Be=p(),q=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var Ge="jolibox-sdk-loadermeta",He,L=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),me=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){return c(this,null,function*(){let t=`${Ne(j)}/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:s}=yield r.json(),o=U(P({},L),{timestamp:me});if(s){let{bootstrap_version:i}=L;i&&A(i,s)>=0||(o=U(P({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&A(i,n)>=0||(o=U(P({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ge,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:u}=L;a&&u&&!Ve(me,u)&&T(a)==t&&A(a,r)>=0&&(n=pe(a));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let g=new Le(`Bootstrap module faile to fetch ${f}`);R({err:`${g}`})}}function i(){var g;let a=Date.now();q("jsSdkBegin",{t:a}),D.startTime=a;let{script:u,type:f}=(g=o())!=null?g:{};if(u){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=u,document.head.appendChild(E),x("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:u,timestamp:f}=L;u&&f&&!Ve(me,f)&&T(u)==t&&A(u,r)>=0&&(s=he(u));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Sr()}catch(a){let u=new C(`module evaluate error: ${a}`);R({err:`${u}`})}}};var ze=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),u=yield import(a);return URL.revokeObjectURL(a),u}catch(l){y(new C(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();q("jsSdkBegin",{t:s}),D.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),x("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new C(`module load failed ${s}`))}}};var Er="1.3.3",J=Er,Ze=T(J),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),yr=et?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,he=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,vr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=vr(J)?Ze:J,Qe=pe(tt),Xe=he(tt);function _r(){et?ze(yr,{bootstrapUrl:Qe,implementUrl:Xe})():We({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:J})()}_r();var Rr=p();function rt(){return Rr.excuteCommandSync("API.getSystemInfoSync")}function nt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function st(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var it="1.3.3";function h(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||se(it,s,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=st(e,t);return r?De(r)?!0:ne(r)?se(it,r,">="):!1:!1}var at=p();function ct(){return c(this,null,function*(){return h("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return c(this,null,function*(){return h("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var xr=p();function ut(e){return c(this,null,function*(){return h("request")?yield xr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],dt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var br=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield br.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=p();function ft(e){return c(this,null,function*(){return h("callHostMethod")?yield Ir.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var wr=p();function gt(e){return c(this,null,function*(){return h("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var m=class{constructor(){this.commands=p();this._emitter=new le}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Se=class extends m{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(s),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},St=window.JoliboxRuntime||Se;var Cr="LifecycleSDK.onReady",F=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Cr,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 $=class extends m{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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,n)})}removeItem(t){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var B=class extends m{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)}}initAd(r){return c(this,null,function*(){})}};var V=class extends m{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 m{onLevelFinished(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:s,score:o,variation:i}=t,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:s,score:o,variation:i})})}onGamePlayEnded(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:s,variation:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(s)return s;let o=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(o),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Dr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],G=class extends m{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Dr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var W=class extends m{constructor(){super()}purchaseGem(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.purchaseGem");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.purchaseGem",t)})}getGemProducts(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var z=class extends m{constructor(){super()}getCoinDetails(r){return c(this,arguments,function*({onUpdate:t}){let n=this.canIUseIfThrow("rewards.getCoinDetails");return(n==null?void 0:n.code)==="FAILURE"?n:yield this.commands.executeCommand("RewardsSDK.getCoinDetails",t)})}};var S=class S{constructor(){this.jssdkVersion="1.3.3";this.runtime=new St;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new H;this.router=new G;this.payment=new W;this.rewards=new z;this.getSystemInfoSync=rt.bind(this);this.canIUse=h.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=ut.bind(this);this.on=dt.bind(this);this.off=mt.bind(this);this.once=pt.bind(this);this.isNativeSupport=ht.bind(this);this.callHostMethod=ft.bind(this);this.track=gt.bind(this);if(S.instance)return S.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},S.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return S.instance||(S.instance=new S),S.instance}};S.instance=null;var Ee=S;window.JoliboxSDK=Ee;export{Ee as JoliboxSDK};
@@ -1 +1 @@
1
- "use strict";(()=>{var Et=Object.defineProperty,St=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var ve=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))vt.call(t,r)&&_e(e,r,t[r]);if(ve)for(var r of ve(t))_t.call(t,r)&&_e(e,r,t[r]);return e},U=(e,t)=>St(e,yt(t));var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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,Rt=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&be(e,r,t[r]);if(Re)for(var r of Re(t))wt.call(t,r)&&be(e,r,t[r]);return e},Ct=(e,t)=>Rt(e,xt(t)),At=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{for(var s=n>1?void 0:n?bt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&te(t,r,s),s},Dt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 Lt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function Te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Pt(e){return typeof e=="undefined"}function Ut(e){return Pt(e)||e===null}function Ot(e){return typeof e=="function"}function Ce(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var kt=(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))(kt||{}),N=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}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var De=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends N{constructor(e,t,r,n,s){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),s&&(this.priority=s)}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 Kt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Kt});var Y=Symbol.for("Jolibox.canIUseMap"),Nt={};globalThis[Y]||(globalThis[Y]=Nt);var Le={get config(){return globalThis[Y]}};var xe=Symbol.for("Jolibox.canIUseMap.native"),Mt={};globalThis[xe]||(globalThis[xe]=Mt);function ne(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let a=parseInt(s[l],10)||0,u=parseInt(o[l],10)||0;if(a>u){n=1;break}else if(a<u){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 se=(e=>(e[e.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(se||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),jt=(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))(jt||{}),Ie=["name","params"],qt=["name","type","location","target","extra","timestamp","userId"],Jt=["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((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function Ft(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(Ct(Tt({},e),{location:t,target:r}),qt)}function Pe(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);return[e.protocolVersion,t,r,e.project]}var $t=()=>"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(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};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 v=typeof window=="undefined",ae=()=>!v&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!v&&(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:!v&&navigator.userAgent.includes("Android"),isMac:!v&&navigator.userAgent.includes("Mac"),isFacebook:!v&&navigator.userAgent.includes("FB_IAB"),isPC:!v&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Bt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Vt="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,$t()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue(Vt),Wt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ue(Ht),zt=e=>e.charAt(0).toUpperCase()+e.slice(1),Yt=()=>{var e;let t=new URLSearchParams(window.location.search);return zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Oe=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Bt(),n=navigator.language,s=Gt(),o=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function ke(e,t,r){let n=window.location.hostname,s=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(s.length>=2){let i=s.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${o}.${i}`}return`${o}.jolibox.com`}function Ke(e){return`https://${ke("api","stg-api",e)}`}function Qt(e){return ke("collect","stg-collect",e)}function Ne(e){return`https://${Qt(e)}`}var Q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};Q.Undefined=new Q(void 0);var d=Q,Xt=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 s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.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}},Zt=0,I=class{constructor(e){this.value=e,this.id=Zt++}},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 I&&(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,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let u=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,u]:this._listeners.push(u):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=u,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,S,Se;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===u.id&&(this._listeners=void 0,this._size=0,(g=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||g.call(f));else if(this._listeners){let ye=this._listeners.indexOf(u);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((Se=(S=this.options)==null?void 0:S.onDidRemoveLastListener)==null||Se.call(S)))}}}}),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(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let s=(n=this.listeners.get(e))!=null?n:new w,o=a=>t(...a.args),i=s.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:i}),this.listeners.set(e,s);let l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)t(...a.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 Xt,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={};At(Z,{None:()=>er,filter:()=>rr,once:()=>Me,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Me(e)(t))}function Me(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function rr(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new w(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ce;return globalThis[z]||(globalThis[z]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[z]},_=nr();function sr(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)or(e[n],t[n])}function or(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 s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return sr(s,r),n(...s)}}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=we([Ce],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=Lt(3e4)),this._starActivation}executeCommand(e,...t){return Dt(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=we([Ce],ee);var je=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[je]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[je]=e)}function m(e=!1){let t=ir();if(!e&&t)return t;let r=new K,n=new ee,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return ar(s),s}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function cr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function lr(){return{platform:1e3,os:"h5",appVersion:"1.3.2",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.2",extra:{}}}var ur=()=>{var t;return Ne((t=j)!=null?t:!1)},dr=ur(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},qe;(qe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var mr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=mr(),hr=e=>c(void 0,null,function*(){try{let r=`${dr}/report`,n=Oe("1.3.2"),s=pr,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:se.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),s={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},o=Pe(s);yield hr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",C.startTime));var fr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},C=fr(),Fe=m(),le=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 N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),R({err:JSON.stringify(t)})})},y=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,s)=>{let o={message:e,source:t,lineno:r,colno:n,stack:s==null?void 0:s.stack,errorString:s==null?void 0:s.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var ue=e=>{var l,a,u;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),[s,o,i]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(u=n[2])!=null?u:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},A=e=>parseInt(ue(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=ue(e),{major:i,minor:l,patch:a,prerelease:u}=ue(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!u?-1:!o&&u?1:o&&u?o>u?1:o<u?-1:0:0};var $e=m(),q=(e,t)=>{$e.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{$e.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var He="jolibox-sdk-loadermeta",Ve,L=JSON.parse((Ve=window.__joliboxLocalStorage__.getItem(He))!=null?Ve:"{}"),de=Date.now(),Be=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return c(this,null,function*(){let t=`${Ke(j)}/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:s}=yield r.json(),o=U(P({},L),{timestamp:de});if(s){let{bootstrap_version:i}=L;i&&D(i,s)>=0||(o=U(P({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&D(i,n)>=0||(o=U(P({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:u}=L;a&&u&&!Be(de,u)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let g=new De(`Bootstrap module faile to fetch ${f}`);R({err:`${g}`})}}function i(){var g;let a=Date.now();q("jsSdkBegin",{t:a}),C.startTime=a;let{script:u,type:f}=(g=o())!=null?g:{};if(u){let S=document.createElement("script");S.type="text/javascript",S.innerHTML=u,document.head.appendChild(S),b("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:u,timestamp:f}=L;u&&f&&!Be(de,f)&&A(u)==t&&D(u,r)>=0&&(s=pe(u));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{b("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),gr()}catch(a){let u=new T(`module evaluate error: ${a}`);R({err:`${u}`})}}};var We=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),u=yield import(a);return URL.revokeObjectURL(a),u}catch(l){y(new T(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();q("jsSdkBegin",{t:s}),C.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),b("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new T(`module load failed ${s}`))}}};var Er="1.3.2",J=Er,Xe=A(J),Ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Sr=Ze?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,he="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(he=new URL(ze.src).origin);var me=(e,t)=>`${t!=null?t:he}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/implement@${e}/dist/index.js`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),et=yr(J)?Xe:J,Ye=me(et),Qe=pe(et);function vr(){Ze?We(Sr,{bootstrapUrl:Ye,implementUrl:Qe})():Ge({bootstrapUrl:Ye,implementUrl:Qe,currentMajorVersion:Xe,currentVersion:J})()}vr();var _r=m();function tt(){return _r.excuteCommandSync("API.getSystemInfoSync")}function rt(e,t){var r;return(r=Le.config[e])==null?void 0:r[t]}function nt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var ot="1.3.2";function h(e){let[t,...r]=e.split(":"),n=rt(ae()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||ne(ot,s,"<")?!1:r.length===0?!0:st(n,r)||st(n.properties,r)}function st(e,t){if(!e)return!1;let r=nt(e,t);return r?Te(r)?!0:re(r)?ne(ot,r,">="):!1:!1}var it=m();function at(){return c(this,null,function*(){return h("login")?yield it.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ct(){return c(this,null,function*(){return h("checkSession")?yield it.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Rr=m();function lt(e){return c(this,null,function*(){return h("request")?yield Rr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],ut=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var br=m();function pt(e){return c(this,null,function*(){return h("isNativeSupport")?yield br.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=m();function ht(e){return c(this,null,function*(){return h("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=m();function ft(e){return c(this,null,function*(){return h("track")?yield Ir.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=m();this._emitter=new ce}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ge=class extends p{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(s),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},gt=window.JoliboxRuntime||ge;var wr="LifecycleSDK.onReady",F=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(wr,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 $=class extends p{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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,n)})}removeItem(t){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var B=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)}}initAd(r){return c(this,null,function*(){})}};var V=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){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:s,score:o,variation:i}=t,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:s,score:o,variation:i})})}onGamePlayEnded(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:s,variation:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(s)return s;let o=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(o),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],G=class extends p{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Tr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var W=class extends p{constructor(){super()}purchaseGem(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.purchaseGem");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.purchaseGem",t)})}getGemProducts(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var E=class E{constructor(){this.jssdkVersion="1.3.2";this.runtime=new gt;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new H;this.router=new G;this.payment=new W;this.getSystemInfoSync=tt.bind(this);this.canIUse=h.bind(this);this.login=at.bind(this);this.checkSession=ct.bind(this);this.request=lt.bind(this);this.on=ut.bind(this);this.off=dt.bind(this);this.once=mt.bind(this);this.isNativeSupport=pt.bind(this);this.callHostMethod=ht.bind(this);this.track=ft.bind(this);if(E.instance)return E.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},E.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return E.instance||(E.instance=new E),E.instance}};E.instance=null;var Ee=E;window.JoliboxSDK=Ee;})();
1
+ "use strict";(()=>{var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var Re=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Re(e,r,t[r]);if(_e)for(var r of _e(t))Rt.call(t,r)&&Re(e,r,t[r]);return e},U=(e,t)=>yt(e,vt(t));var c=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 re=Object.defineProperty,xt=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Dt=(e,t)=>{for(var r in t||(t={}))wt.call(t,r)&&be(e,r,t[r]);if(xe)for(var r of xe(t))Ct.call(t,r)&&be(e,r,t[r]);return e},Tt=(e,t)=>xt(e,It(t)),At=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,n)=>{for(var s=n>1?void 0:n?bt(t,r):t,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(n?i(t,r,s):i(s))||s);return n&&s&&re(t,r,s),s},Lt=(e,t,r)=>new Promise((n,s)=>{var o=a=>{try{l(r.next(a))}catch(u){s(u)}},i=a=>{try{l(r.throw(a))}catch(u){s(u)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,i);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 s=this._eventListeners[r].indexOf(n);s!==-1&&this._eventListeners[r].splice(s,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 Pt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Ut(e){return typeof e=="undefined"}function Ot(e){return Ut(e)||e===null}function kt(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...s){return r||(r=new t(...s)),r};return n.prototype=t.prototype,n}var Kt=(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))(Kt||{}),N=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}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},C=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends N{constructor(e,t,r,n,s){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),s&&(this.priority=s)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function b(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:b("log"),warn:b("warn"),info:b("info"),error:b("error"),debug:b("debug")};Object.assign(globalThis,{logger:Nt});var Q=Symbol.for("Jolibox.canIUseMap"),Mt={};globalThis[Q]||(globalThis[Q]=Mt);var Pe={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),jt={};globalThis[Ie]||(globalThis[Ie]=jt);function se(e,t,r){let n=0;if(e!==t){let s=e.split("."),o=t.split("."),i=Math.max(s.length,o.length);for(let l=0;l<i;l++){let a=parseInt(s[l],10)||0,u=parseInt(o[l],10)||0;if(a>u){n=1;break}else if(a<u){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.Other=0]="Other",e[e.Route=1]="Route",e[e.Click=2]="Click",e[e.View=3]="View",e[e.Expose=4]="Expose",e[e.Swipe=5]="Swipe",e[e.Input=6]="Input",e[e.Select=7]="Select",e[e.SwitchOn=8]="SwitchOn",e[e.SwitchOff=9]="SwitchOff",e[e.Submit=10]="Submit",e[e.Scroll=11]="Scroll",e[e.Hide=12]="Hide",e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),qt=(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))(qt||{}),we=["name","params"],Jt=["name","type","location","target","extra","timestamp","userId"],Ft=["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((s,o)=>(s[o]=String(n[o]),s),{})}return e[r]})}function $t(e){let t=e.location?k(e.location,we):null,r=e.target?k(e.target,we):null;return k(Tt(Dt({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>$t(n)),r=k(e.device,Ft);return[e.protocolVersion,t,r,e.project]}var Bt=()=>"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 ae(){if(typeof window=="undefined")return{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},length:0,key:()=>null};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}}ae();var v=typeof window=="undefined",ce=()=>!v&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!v&&(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:!v&&navigator.userAgent.includes("Android"),isMac:!v&&navigator.userAgent.includes("Mac"),isFacebook:!v&&navigator.userAgent.includes("FB_IAB"),isPC:!v&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Ht="device_id",Gt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Gt),Yt=e=>e.charAt(0).toUpperCase()+e.slice(1),Qt=()=>{var e;let t=new URLSearchParams(window.location.search);return Yt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,s=Wt(),o=zt();return`${t} (${Qt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${s} adid/${o} version/${e||""}`};function Ke(e,t,r){let n=window.location.hostname,s=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(s.length>=2){let i=s.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${o}.${i}`}return`${o}.jolibox.com`}function Ne(e){return`https://${Ke("api","stg-api",e)}`}function Xt(e){return Ke("collect","stg-collect",e)}function Me(e){return`https://${Xt(e)}`}var X=class Z{constructor(t){this.element=t,this.next=Z.Undefined,this.prev=Z.Undefined}};X.Undefined=new X(void 0);var d=X,Zt=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 s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.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}},er=0,I=class{constructor(e){this.value=e,this.id=er++}},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 I&&(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,s,o,i,l,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let u=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,u]:this._listeners.push(u):((s=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||s.call(n,this),this._listeners=u,(i=(o=this.options)==null?void 0:o.onDidFirstListener)==null||i.call(o,this)),(a=(l=this.options)==null?void 0:l.onDidAddListener)==null||a.call(l,this),this._size++,()=>{var f,g,E,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===u.id&&(this._listeners=void 0,this._size=0,(g=(f=this.options)==null?void 0:f.onDidRemoveLastListener)==null||g.call(f));else if(this._listeners){let ve=this._listeners.indexOf(u);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(E=this.options)==null?void 0:E.onDidRemoveLastListener)==null||ye.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(s){n(s)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},le=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let s=(n=this.listeners.get(e))!=null?n:new w,o=a=>t(...a.args),i=s.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:i}),this.listeners.set(e,s);let l=this.cachedEventQueue.get(e);if(l&&r)for(let a of l)t(...a.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 Zt,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)}},ee={};At(ee,{None:()=>tr,filter:()=>nr,once:()=>je,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(s=>{if(!n)return n=!0,t.call(r,s)},null)}}function nr(e,t){return(r=>{let n,s={onWillAddFirstListener(){n=r(o.fire,o)}},o=new w(s);return o.event})((r,n=null)=>e(s=>t(s)&&r.call(n,s),null))}var Y=Symbol.for("Jolibox.hostEmitter"),sr=()=>{let e=new le;return globalThis[Y]||(globalThis[Y]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Y]},_=sr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ir(e[n],t[n])}function ir(e,t){if(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(kt(t)){try{if(e instanceof t)return}catch(r){}if(!Ot(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 s of e.metadata.args)r.push(s.constraint);let n=e.handler;e.handler=function(...s){return or(s,r),n(...s)}}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=Ce([Te],K);var te=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=Pt(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(),ee.toPromise(ee.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}}};te=Ce([Te],te);var qe=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[qe]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[qe]=e)}function p(e=!1){let t=ar();if(!e&&t)return t;let r=new K,n=new te,s={registerCommand(o,i,l){r.registerCommand({id:o,handler:i,metadata:l})},executeCommand(o,...i){return n.executeCommand(o,...i)},excuteCommandSync(o,...i){return n.executeCommandThowErr(o,...i)}};return cr(s),s}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function lr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function ur(){return{platform:1e3,os:"h5",appVersion:"1.3.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.3.3",extra:{}}}var dr=()=>{var t;return Me((t=j)!=null?t:!1)},mr=dr(),Fe=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Je;(Je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Fe);var pr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},hr=pr(),fr=e=>c(void 0,null,function*(){try{let r=`${mr}/report`,n=ke("1.3.3"),s=hr,o={"Content-Type":"application/json"};return n&&(o["x-user-agent"]=n),s&&(o["x-joli-source"]=s),yield fetch(r,{method:"POST",headers:o,body:JSON.stringify(e),signal:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function R(e){return c(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=ur(),s={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},o=Ue(s);yield fr(o)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>_.emit("onDocumentReady",D.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},D=gr(),$e=p(),ue=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 N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),R({err:JSON.stringify(t)})})},y=ue;window.addEventListener("unhandledrejection",ue.bind(void 0));window.addEventListener("error",ue.bind(void 0));window.onerror=(e,t,r,n,s)=>{let o={message:e,source:t,lineno:r,colno:n,stack:s==null?void 0:s.stack,errorString:s==null?void 0:s.toString()};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(o)}}).catch(i=>{R({err:JSON.stringify(o)})})};var de=e=>{var l,a,u;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),[s,o,i]=[(l=n[0])!=null?l:"0",(a=n[1])!=null?a:"0",(u=n[2])!=null?u:"0"];return{major:s,minor:o,patch:i,prerelease:t,build:r}},T=e=>parseInt(de(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:s,prerelease:o}=de(e),{major:i,minor:l,patch:a,prerelease:u}=de(t);return r!==i?r>i?1:-1:n!==l?n>l?1:-1:s!==a?s>a?1:-1:o&&!u?-1:!o&&u?1:o&&u?o>u?1:o<u?-1:0:0};var Be=p(),q=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},x=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var Ge="jolibox-sdk-loadermeta",He,L=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),me=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){return c(this,null,function*(){let t=`${Ne(j)}/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:s}=yield r.json(),o=U(P({},L),{timestamp:me});if(s){let{bootstrap_version:i}=L;i&&A(i,s)>=0||(o=U(P({},o),{bootstrap_version:s}))}if(n){let{implement_version:i}=L;i&&A(i,n)>=0||(o=U(P({},o),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ge,JSON.stringify(o))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,s=e.implementUrl;function o(){let{bootstrap_version:a,timestamp:u}=L;a&&u&&!Ve(me,u)&&T(a)==t&&A(a,r)>=0&&(n=pe(a));try{let f=new XMLHttpRequest;return f.open("GET",n,!1),f.send(),{script:f.responseText,type:"fetch_from_cdn"}}catch(f){let g=new Le(`Bootstrap module faile to fetch ${f}`);R({err:`${g}`})}}function i(){var g;let a=Date.now();q("jsSdkBegin",{t:a}),D.startTime=a;let{script:u,type:f}=(g=o())!=null?g:{};if(u){let E=document.createElement("script");E.type="text/javascript",E.innerHTML=u,document.head.appendChild(E),x("bootstrapModuleLoaded",Date.now()-a,{type:f})}}function l(){let a=Date.now(),{implement_version:u,timestamp:f}=L;u&&f&&!Ve(me,f)&&T(u)==t&&A(u,r)>=0&&(s=he(u));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=s,g.onload=()=>{x("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),l(),Sr()}catch(a){let u=new C(`module evaluate error: ${a}`);R({err:`${u}`})}}};var ze=(e,t)=>{let r=s=>{let o=e({path:s});if(!o)throw`module ${s} load failed ${o}`;return o};function n(s){(i=>c(this,null,function*(){try{let l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l),u=yield import(a);return URL.revokeObjectURL(a),u}catch(l){y(new C(`implement module evaluate error in native:${l} `))}}))(s)}return()=>{try{let s=Date.now();q("jsSdkBegin",{t:s}),D.startTime=s;let o=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=o,document.head.appendChild(i),x("bootstrapModuleLoaded",Date.now()-s,{type:"native"});let l=Date.now(),a=r(t.implementUrl);n(a),x("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(s){console.error(`native load script error: ${s}`),y(new C(`module load failed ${s}`))}}};var Er="1.3.3",J=Er,Ze=T(J),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),yr=et?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return typeof r=="object"&&"content"in r?r.content:r}}:void 0,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,he=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,vr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=vr(J)?Ze:J,Qe=pe(tt),Xe=he(tt);function _r(){et?ze(yr,{bootstrapUrl:Qe,implementUrl:Xe})():We({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:J})()}_r();var Rr=p();function rt(){return Rr.excuteCommandSync("API.getSystemInfoSync")}function nt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function st(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=e;for(let o of n)if(s&&(typeof s=="object"||Array.isArray(s)))s=s[o];else return r;return s===void 0?r:s}var it="1.3.3";function h(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let s=n.version;return typeof s!="string"||se(it,s,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=st(e,t);return r?De(r)?!0:ne(r)?se(it,r,">="):!1:!1}var at=p();function ct(){return c(this,null,function*(){return h("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return c(this,null,function*(){return h("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var xr=p();function ut(e){return c(this,null,function*(){return h("request")?yield xr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],dt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}_.on(e,t)},mt=(e,t)=>{if(!ge.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}_.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}_.once(e,t)};var br=p();function ht(e){return c(this,null,function*(){return h("isNativeSupport")?yield br.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=p();function ft(e){return c(this,null,function*(){return h("callHostMethod")?yield Ir.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var wr=p();function gt(e){return c(this,null,function*(){return h("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var m=class{constructor(){this.commands=p();this._emitter=new le}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return h(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Se=class extends m{constructor(){super(...arguments);this.loadFinished=()=>{let r=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(r),this.commands.executeCommand("RuntimeSDK.loadFinishedEvent")};this.notifyLoadProgress=r=>{let n=Math.ceil(r),s=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(s),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},St=window.JoliboxRuntime||Se;var Cr="LifecycleSDK.onReady",F=class extends m{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Cr,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 $=class extends m{getItem(t){return c(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return c(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,n)})}removeItem(t){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return c(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var B=class extends m{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)}}initAd(r){return c(this,null,function*(){})}};var V=class extends m{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 m{onLevelFinished(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:s,score:o,variation:i}=t,l=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(l)return Promise.resolve(l);let a=new CustomEvent("JOLIBOX_TASK_LEVEL_FINISHED",{detail:t});return window.dispatchEvent(a),yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:s,score:o,variation:i})})}onGamePlayEnded(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:s,variation:o}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let l=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(l),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:s,variation:o})})}onLevelUpgrade(t){return c(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(s)return s;let o=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(o),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Dr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],G=class extends m{openSchema(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return c(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return c(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Dr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var W=class extends m{constructor(){super()}purchaseGem(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.purchaseGem");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.purchaseGem",t)})}getGemProducts(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}getSubscriptionPlans(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.getSubscriptionPlans");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getSubscriptionPlans")})}subscribe(t){return c(this,null,function*(){let r=this.canIUseIfThrow("payment.subscribe");return(r==null?void 0:r.code)==="FAILURE"?r:yield this.commands.executeCommand("PaymentSDK.subscribe",{productId:t.productId})})}flushSubInfoCache(){return c(this,null,function*(){let t=this.canIUseIfThrow("payment.flushSubInfoCache");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.flushSubInfoCache")})}};var z=class extends m{constructor(){super()}getCoinDetails(r){return c(this,arguments,function*({onUpdate:t}){let n=this.canIUseIfThrow("rewards.getCoinDetails");return(n==null?void 0:n.code)==="FAILURE"?n:yield this.commands.executeCommand("RewardsSDK.getCoinDetails",t)})}};var S=class S{constructor(){this.jssdkVersion="1.3.3";this.runtime=new St;this.ads=new B;this.lifecycle=new F;this.storage=new $;this.keyboard=new V;this.task=new H;this.router=new G;this.payment=new W;this.rewards=new z;this.getSystemInfoSync=rt.bind(this);this.canIUse=h.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=ut.bind(this);this.on=dt.bind(this);this.off=mt.bind(this);this.once=pt.bind(this);this.isNativeSupport=ht.bind(this);this.callHostMethod=ft.bind(this);this.track=gt.bind(this);if(S.instance)return S.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},S.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return S.instance||(S.instance=new S),S.instance}};S.instance=null;var Ee=S;window.JoliboxSDK=Ee;})();
package/dist/index.js CHANGED
@@ -1827,6 +1827,30 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
1827
1827
  }
1828
1828
  };
1829
1829
 
1830
+ // src/sdks/rewards.ts
1831
+ var RewardsSDK = class extends BaseSDK {
1832
+ constructor() {
1833
+ super();
1834
+ }
1835
+ /**
1836
+ * @private
1837
+ * 获取用户金币详细信息,包括金币余额、现金余额、宝石余额和订阅用户信息. 内部方法,供小程序调用
1838
+ * @see {@link getCoinDetails} for more details.
1839
+ * @returns Promise<StandardResponse<ICoinDetailsData>> - 包含用户余额和订阅信息的响应
1840
+ */
1841
+ async getCoinDetails(_ref) {
1842
+ let {
1843
+ onUpdate
1844
+ } = _ref;
1845
+ const canIUseResult = this.canIUseIfThrow("rewards.getCoinDetails");
1846
+ if (canIUseResult?.code === "FAILURE") {
1847
+ return canIUseResult;
1848
+ }
1849
+ const result = await this.commands.executeCommand("RewardsSDK.getCoinDetails", onUpdate);
1850
+ return result;
1851
+ }
1852
+ };
1853
+
1830
1854
  // src/index.ts
1831
1855
  var JoliboxSDK = (_JoliboxSDK2 = class _JoliboxSDK {
1832
1856
  /**
@@ -1904,6 +1928,14 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
1904
1928
  * @type {PaymentSDK}
1905
1929
  */
1906
1930
  this.payment = new PaymentSDK();
1931
+ /**
1932
+ * @public
1933
+ * @readonly
1934
+ * Access to the Rewards SDK module.
1935
+ * @see {@link RewardsSDK} for more details.
1936
+ * @type {RewardsSDK}
1937
+ */
1938
+ this.rewards = new RewardsSDK();
1907
1939
  //global API
1908
1940
  /**
1909
1941
  * @public
@@ -0,0 +1,14 @@
1
+ import { Rewards, StandardResponse, ICoinDetailsData } from '@jolibox/types';
2
+ import { BaseSDK } from './sdk';
3
+ export declare class RewardsSDK extends BaseSDK implements Rewards {
4
+ constructor();
5
+ /**
6
+ * @private
7
+ * 获取用户金币详细信息,包括金币余额、现金余额、宝石余额和订阅用户信息. 内部方法,供小程序调用
8
+ * @see {@link getCoinDetails} for more details.
9
+ * @returns Promise<StandardResponse<ICoinDetailsData>> - 包含用户余额和订阅信息的响应
10
+ */
11
+ getCoinDetails({ onUpdate }: {
12
+ onUpdate?: (data: ICoinDetailsData) => void | Promise<void>;
13
+ }): Promise<StandardResponse<ICoinDetailsData>>;
14
+ }
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@jolibox/sdk",
3
3
  "description": "This project is common Jolibox JS-SDk interfere",
4
- "version": "1.3.2",
4
+ "version": "1.3.3",
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.3.2",
11
- "@jolibox/types": "1.3.2"
10
+ "@jolibox/common": "1.3.3",
11
+ "@jolibox/types": "1.3.3"
12
12
  },
13
13
  "devDependencies": {
14
14
  "typescript": "5.7.3",
15
- "@jolibox/eslint-config": "1.0.0",
15
+ "@jolibox/eslint-config": "1.0.1-beta.16",
16
16
  "@types/jest": "28.1.1",
17
17
  "rimraf": "6.0.1",
18
18
  "esbuild": "0.24.2",
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.3.2 clean
3
+ > @jolibox/sdk@1.3.3 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/sdk@1.3.2 build:cjs
7
+ > @jolibox/sdk@1.3.3 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.3.2 build:esm
11
+ > @jolibox/sdk@1.3.3 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.3.2 build:iife
15
+ > @jolibox/sdk@1.3.3 build:iife
16
16
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
17
17
 
package/src/index.ts CHANGED
@@ -29,6 +29,7 @@ import { KeyboardSDK } from './sdks/keyboard';
29
29
  import { TaskTrackerSDK } from './sdks/task';
30
30
  import { RouterSDK } from './sdks/router';
31
31
  import { PaymentSDK } from './sdks/payment';
32
+ import { RewardsSDK } from './sdks/rewards';
32
33
 
33
34
  declare global {
34
35
  interface Window {
@@ -133,6 +134,15 @@ export class JoliboxSDK {
133
134
  */
134
135
  readonly payment = new PaymentSDK();
135
136
 
137
+ /**
138
+ * @public
139
+ * @readonly
140
+ * Access to the Rewards SDK module.
141
+ * @see {@link RewardsSDK} for more details.
142
+ * @type {RewardsSDK}
143
+ */
144
+ readonly rewards = new RewardsSDK();
145
+
136
146
  //global API
137
147
  /**
138
148
  * @public
@@ -0,0 +1,32 @@
1
+ import { Rewards, StandardResponse, ICoinDetailsData } from '@jolibox/types';
2
+ import { BaseSDK } from './sdk';
3
+
4
+ export class RewardsSDK extends BaseSDK implements Rewards {
5
+ constructor() {
6
+ super();
7
+ }
8
+
9
+ /**
10
+ * @private
11
+ * 获取用户金币详细信息,包括金币余额、现金余额、宝石余额和订阅用户信息. 内部方法,供小程序调用
12
+ * @see {@link getCoinDetails} for more details.
13
+ * @returns Promise<StandardResponse<ICoinDetailsData>> - 包含用户余额和订阅信息的响应
14
+ */
15
+ async getCoinDetails({
16
+ onUpdate
17
+ }: {
18
+ onUpdate?: (data: ICoinDetailsData) => void | Promise<void>;
19
+ }): Promise<StandardResponse<ICoinDetailsData>> {
20
+ const canIUseResult = this.canIUseIfThrow('rewards.getCoinDetails');
21
+
22
+ if (canIUseResult?.code === 'FAILURE') {
23
+ return canIUseResult as StandardResponse<ICoinDetailsData>;
24
+ }
25
+
26
+ const result = (await this.commands.executeCommand(
27
+ 'RewardsSDK.getCoinDetails',
28
+ onUpdate
29
+ )) as StandardResponse<ICoinDetailsData>;
30
+ return result;
31
+ }
32
+ }