@jolibox/sdk 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +4 -3
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +30 -1
- package/dist/sdks/payment.d.ts +15 -0
- package/package.json +3 -3
- package/sdk.build.log +4 -4
- package/src/index.ts +10 -0
- package/src/sdks/payment.ts +24 -0
- package/src/sdks/router.ts +2 -1
|
@@ -4,7 +4,7 @@
|
|
|
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": "
|
|
7
|
+
"packages/sdk/package.json": "f70247139a4bc232c25a99b4472d441ee6b1c169",
|
|
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": "
|
|
20
|
+
"packages/sdk/src/index.ts": "9064e8319b592997f1cbb5f5fbeda796a5d0c530",
|
|
21
21
|
"packages/sdk/src/loader/__tests__/version.test.ts": "338ca817bfcb672d1065d6f32872b57bc43951b5",
|
|
22
22
|
"packages/sdk/src/loader/h5.ts": "4733d968c2918918b6383a5a48a4e5ed185a9bdf",
|
|
23
23
|
"packages/sdk/src/loader/index.ts": "0ef5ddb69c89f6f7cd78ee318c7030ca3da8aee4",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"packages/sdk/src/sdks/ads.ts": "bec143d0340fced14fa3d372e82de7cc02c419b0",
|
|
27
27
|
"packages/sdk/src/sdks/keyboard.ts": "b30424cbecffa24c9d5249366a70afe2128e64be",
|
|
28
28
|
"packages/sdk/src/sdks/lifecycle.ts": "4d9a3b770d528f59c0eb9272e18d5c2c5641320d",
|
|
29
|
-
"packages/sdk/src/sdks/
|
|
29
|
+
"packages/sdk/src/sdks/payment.ts": "ce43642ae8b1950c08de6da0a2a4762e58b5a104",
|
|
30
|
+
"packages/sdk/src/sdks/router.ts": "5aca615f05f2c85e098cd6759a0bd7ad6a31a0f2",
|
|
30
31
|
"packages/sdk/src/sdks/runtime.ts": "179ae2ffd60125f6ba058c9b52ca4db46032c26b",
|
|
31
32
|
"packages/sdk/src/sdks/sdk.ts": "789f8be82a9c3257306f3e40d21311a7873d4502",
|
|
32
33
|
"packages/sdk/src/sdks/storage.ts": "43dbbdeea3484e9ff084958bf4137190d300ff17",
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty,vt=Object.defineProperties,yt=Object.getOwnPropertyDescriptor,_t=Object.getOwnPropertyDescriptors,St=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C=(e,t)=>{for(var r in t||(t={}))be.call(t,r)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))bt.call(t,r)&&Se(e,r,t[r]);return e},O=(e,t)=>vt(e,_t(t));var Rt=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},xt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of St(t))!be.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=yt(t,o))||n.enumerable});return e};var It=e=>xt(U({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});var Cr={};Rt(Cr,{JoliboxSDK:()=>Y});module.exports=It(Cr);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var re=Object.defineProperty,wt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptor,Lt=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pt=(e,t)=>{for(var r in t||(t={}))At.call(t,r)&&xe(e,r,t[r]);if(Re)for(var r of Re(t))Dt.call(t,r)&&xe(e,r,t[r]);return e},Ut=(e,t)=>wt(e,Lt(t)),Ct=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,n)=>{for(var o=n>1?void 0:n?Tt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&re(t,r,o),o},Ot=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function kt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function ne(e){return typeof e=="string"}function Le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Nt(e){return typeof e=="undefined"}function Kt(e){return Nt(e)||e===null}function Mt(e){return typeof e=="function"}function Ae(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),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}},De=class extends M{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Pe=class extends De{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},T=class extends De{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var j=class extends M{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Jt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Jt});var Q=Symbol.for("Jolibox.canIUseMap"),Ft={};globalThis[Q]||(globalThis[Q]=Ft);var Ue={get config(){return globalThis[Q]}};var Ie=Symbol.for("Jolibox.canIUseMap.native"),Bt={};globalThis[Ie]||(globalThis[Ie]=Bt);function oe(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){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||{}),ie=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(ie||{}),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||{}),we=["name","params"],$t=["name","type","location","target","extra","timestamp","userId"],Ht=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function N(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Gt(e){let t=e.location?N(e.location,we):null,r=e.target?N(e.target,we):null;return N(Ut(Pt({},e),{location:t,target:r}),$t)}function Ce(e){let t=e.events.map(n=>Gt(n)),r=N(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 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 _=typeof window=="undefined",ce=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},zt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",Yt="device_id",qt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Wt()),window.__joliboxLocalStorage__.getItem(e)),Qt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Yt),Xt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(qt),Zt=e=>e.charAt(0).toUpperCase()+e.slice(1),er=()=>{var e;let t=new URLSearchParams(window.location.search);return Zt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},ke=e=>{if(ce())return window.navigator.userAgent;let t="JoliboxWebSDK",r=zt(),n=navigator.language,o=Qt(),s=Xt();return`${t} (${er()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Ne(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function tr(e){return Ne("api","stg-api",e)}function Ke(e){return`https://${tr(e)}`}function rr(e){return Ne("collect","stg-collect",e)}function Me(e){return`https://${rr(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 m=X,nr=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.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,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,ve;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ye=this._listeners.indexOf(l);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((ve=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||ve.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof 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 o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)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)}},ee={};Ct(ee,{None:()=>sr,filter:()=>ar,once:()=>je,toPromise:()=>ir});var sr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function ir(e){return new Promise(t=>je(e)(t))}function je(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function ar(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var q=Symbol.for("Jolibox.hostEmitter"),cr=()=>{let e=new le;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]},S=cr();function lr(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(ne(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Mt(t)){try{if(e instanceof t)return}catch(r){}if(!Kt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return lr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};K=Te([Ae],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=kt(3e4)),this._starActivation}executeCommand(e,...t){return Ot(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=Te([Ae],te);var Je=Symbol.for("Jolibox.commands");function mr(){return typeof globalThis!="undefined"?globalThis[Je]:void 0}function ur(e){typeof globalThis!="undefined"&&(globalThis[Je]=e)}function u(e=!1){let t=mr();if(!e&&t)return t;let r=new K,n=new te,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ur(o),o}var J=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 fr(){return{platform:1e3,os:"h5",appVersion:"1.2.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.3",extra:{}}}var hr=()=>{var t;return Me((t=J)!=null?t:!1)},gr=hr(),Be=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Fe;(Fe=AbortSignal.timeout)!=null||(AbortSignal.timeout=Be);var Er=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},vr=Er(),yr=e=>d(void 0,null,function*(){try{let r=`${gr}/report`,n=ke("1.2.3"),o=vr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Be(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:se.ErrorTrace,location:pr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=fr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ie.WebSDK},s=Ce(o);yield yr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var _r=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=_r(),Ve=u(),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};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({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,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Ve.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var $e=u(),F=(e,t)=>{$e.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{$e.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ae();var We="jolibox-sdk-loadermeta",Ge,P=JSON.parse((Ge=window.__joliboxLocalStorage__.getItem(We))!=null?Ge:"{}"),ue=Date.now(),He=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Sr(){return d(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:o}=yield r.json(),s=O(C({},P),{timestamp:ue});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=O(C({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=O(C({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(We,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var ze=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!He(ue,l)&&A(a)==t&&D(a,r)>=0&&(n=pe(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Pe(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();F("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!He(ue,h)&&A(l)==t&&D(l,r)>=0&&(o=fe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),Sr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var Ye=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();F("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var br="1.2.3",B=br,Ze=A(B),et=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Rr=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,he="https://jsdelivr.jolibox.com";var qe=window.document.currentScript;qe&&(he=new URL(qe.src).origin);var pe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/bootstrap@${e}/dist/index.js`,fe=(e,t)=>`${t!=null?t:he}/npm/@jolibox/implement@${e}/dist/index.js`,xr=e=>/^\d+\.\d+\.\d+$/.test(e),tt=xr(B)?Ze:B,Qe=pe(tt),Xe=fe(tt);function Ir(){et?Ye(Rr,{bootstrapUrl:Qe,implementUrl:Xe})():ze({bootstrapUrl:Qe,implementUrl:Xe,currentMajorVersion:Ze,currentVersion:B})()}Ir();var wr=u();function rt(){return wr.excuteCommandSync("API.getSystemInfoSync")}function nt(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("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var it="1.2.3";function f(e){let[t,...r]=e.split(":"),n=nt(ce()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||oe(it,o,"<")?!1:r.length===0?!0:st(n,r)||st(n.properties,r)}function st(e,t){if(!e)return!1;let r=ot(e,t);return r?Le(r)?!0:ne(r)?oe(it,r,">="):!1:!1}var at=u();function ct(){return d(this,null,function*(){return f("login")?yield at.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function lt(){return d(this,null,function*(){return f("checkSession")?yield at.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Tr=u();function dt(e){return d(this,null,function*(){return f("request")?yield Tr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var ge=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!ge.includes(e)){y(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},ut=(e,t)=>{if(!ge.includes(e)){y(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},pt=(e,t)=>{if(!ge.includes(e)){y(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Lr=u();function ft(e){return d(this,null,function*(){return f("isNativeSupport")?yield Lr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ar=u();function ht(e){return d(this,null,function*(){return f("callHostMethod")?yield Ar.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Dr=u();function gt(e){return d(this,null,function*(){return f("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=u();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 f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var Ee=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),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},Et=window.JoliboxRuntime||Ee;var Pr="LifecycleSDK.onReady",V=class extends p{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 $=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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 d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var H=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 d(this,null,function*(){})}};var G=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 W=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);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:o,score:s,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Ur=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],z=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(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 E=class E{constructor(){this.jssdkVersion="1.2.3";this.runtime=new Et;this.ads=new H;this.lifecycle=new V;this.storage=new $;this.keyboard=new G;this.task=new W;this.router=new z;this.getSystemInfoSync=rt.bind(this);this.canIUse=f.bind(this);this.login=ct.bind(this);this.checkSession=lt.bind(this);this.request=dt.bind(this);this.on=mt.bind(this);this.off=ut.bind(this);this.once=pt.bind(this);this.isNativeSupport=ft.bind(this);this.callHostMethod=ht.bind(this);this.track=gt.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 U=Object.defineProperty,vt=Object.defineProperties,_t=Object.getOwnPropertyDescriptor,St=Object.getOwnPropertyDescriptors,bt=Object.getOwnPropertyNames,Se=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var be=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C=(e,t)=>{for(var r in t||(t={}))Re.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))Rt.call(t,r)&&be(e,r,t[r]);return e},O=(e,t)=>vt(e,St(t));var xt=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},It=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bt(t))!Re.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=_t(t,o))||n.enumerable});return e};var wt=e=>It(U({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});var Or={};xt(Or,{JoliboxSDK:()=>q});module.exports=wt(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 o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var ne=Object.defineProperty,Tt=Object.defineProperties,Lt=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ut=(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))Pt.call(t,r)&&Ie(e,r,t[r]);return e},Ct=(e,t)=>Tt(e,At(t)),Ot=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},Le=(e,t,r,n)=>{for(var o=n>1?void 0:n?Lt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ne(t,r,o),o},kt=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function 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 Kt(e){return typeof e=="undefined"}function Mt(e){return Kt(e)||e===null}function jt(e){return typeof e=="function"}function De(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),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"}},T=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,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ft={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Ft});var X=Symbol.for("Jolibox.canIUseMap"),Bt={};globalThis[X]||(globalThis[X]=Bt);var Ce={get config(){return globalThis[X]}};var we=Symbol.for("Jolibox.canIUseMap.native"),Vt={};globalThis[we]||(globalThis[we]=Vt);function se(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){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||{}),$t=(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))($t||{}),Te=["name","params"],Ht=["name","type","location","target","extra","timestamp","userId"],Gt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function N(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Wt(e){let t=e.location?N(e.location,Te):null,r=e.target?N(e.target,Te):null;return N(Ct(Ut({},e),{location:t,target:r}),Ht)}function Oe(e){let t=e.events.map(n=>Wt(n)),r=N(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 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 _=typeof window=="undefined",le=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),k={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Yt=()=>k.isiOS?"iOS":k.isAndroid?"Android":k.isMac?"Mac":k.isFacebook?"Facebook":"PC",qt="device_id",Qt="advertising_id",ke=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,zt()),window.__joliboxLocalStorage__.getItem(e)),Xt=()=>new URLSearchParams(window.location.search).get("deviceId")||ke(qt),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"},Ne=e=>{if(le())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Yt(),n=navigator.language,o=Xt(),s=Zt();return`${t} (${tr()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Ke(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function rr(e){return Ke("api","stg-api",e)}function Me(e){return`https://${rr(e)}`}function nr(e){return Ke("collect","stg-collect",e)}function je(e){return`https://${nr(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,or=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},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,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,y,ve;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let _e=this._listeners.indexOf(l);_e>=0&&(this._listeners.splice(_e,1),this._size--,this._size===0&&((ve=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ve.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},me=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)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 or,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:()=>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(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function cr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Q=Symbol.for("Jolibox.hostEmitter"),lr=()=>{let e=new me;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]},S=lr();function mr(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(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 K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new w,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return mr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};K=Le([De],K);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 K,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(),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=Le([De],re);var Fe=Symbol.for("Jolibox.commands");function ur(){return typeof globalThis!="undefined"?globalThis[Fe]:void 0}function pr(e){typeof globalThis!="undefined"&&(globalThis[Fe]=e)}function u(e=!1){let t=ur();if(!e&&t)return t;let r=new K,n=new re,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return pr(o),o}var J=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function fr(){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.2.4",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.4",extra:{}}}var gr=()=>{var t;return je((t=J)!=null?t:!1)},Er=gr(),Ve=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Be;(Be=AbortSignal.timeout)!=null||(AbortSignal.timeout=Ve);var yr=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},vr=yr(),_r=e=>m(void 0,null,function*(){try{let r=`${Er}/report`,n=Ne("1.2.4"),o=vr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Ve(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:ie.ErrorTrace,location:fr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=hr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:ae.WebSDK},s=Oe(o);yield _r(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var Sr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=Sr(),$e=u(),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};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},v=de;window.addEventListener("unhandledrejection",de.bind(void 0));window.addEventListener("error",de.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};$e.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var ue=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(ue(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=ue(e),{major:i,minor:c,patch:a,prerelease:l}=ue(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var He=u(),F=(e,t)=>{He.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{He.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ce();var ze="jolibox-sdk-loadermeta",We,P=JSON.parse((We=window.__joliboxLocalStorage__.getItem(ze))!=null?We:"{}"),pe=Date.now(),Ge=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function br(){return m(this,null,function*(){let t=`${Me(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:o}=yield r.json(),s=O(C({},P),{timestamp:pe});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=O(C({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=O(C({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(ze,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ye=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!Ge(pe,l)&&A(a)==t&&D(a,r)>=0&&(n=fe(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ue(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();F("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=l,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ge(pe,h)&&A(l)==t&&D(l,r)>=0&&(o=he(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),br()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var qe=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>m(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){v(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();F("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var Rr="1.2.4",B=Rr,et=A(B),tt=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),xr=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 fe=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/bootstrap@${e}/dist/index.js`,he=(e,t)=>`${t!=null?t:ge}/npm/@jolibox/implement@${e}/dist/index.js`,Ir=e=>/^\d+\.\d+\.\d+$/.test(e),rt=Ir(B)?et:B,Xe=fe(rt),Ze=he(rt);function wr(){tt?qe(xr,{bootstrapUrl:Xe,implementUrl:Ze})():Ye({bootstrapUrl:Xe,implementUrl:Ze,currentMajorVersion:et,currentVersion:B})()}wr();var Tr=u();function nt(){return Tr.excuteCommandSync("API.getSystemInfoSync")}function ot(e,t){var r;return(r=Ce.config[e])==null?void 0:r[t]}function st(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var at="1.2.4";function f(e){let[t,...r]=e.split(":"),n=ot(le()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||se(at,o,"<")?!1:r.length===0?!0:it(n,r)||it(n.properties,r)}function it(e,t){if(!e)return!1;let r=st(e,t);return r?Ae(r)?!0:oe(r)?se(at,r,">="):!1:!1}var ct=u();function lt(){return m(this,null,function*(){return f("login")?yield ct.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function mt(){return m(this,null,function*(){return f("checkSession")?yield ct.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Lr=u();function dt(e){return m(this,null,function*(){return f("request")?yield Lr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var Ee=["onI18nChanged","onBackPress"],ut=(e,t)=>{if(!Ee.includes(e)){v(new j(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},pt=(e,t)=>{if(!Ee.includes(e)){v(new j(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ft=(e,t)=>{if(!Ee.includes(e)){v(new j(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Ar=u();function ht(e){return m(this,null,function*(){return f("isNativeSupport")?yield Ar.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Dr=u();function gt(e){return m(this,null,function*(){return f("callHostMethod")?yield Dr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Pr=u();function Et(e){return m(this,null,function*(){return f("track")?yield Pr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();this._emitter=new me}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var ye=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),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},yt=window.JoliboxRuntime||ye;var Ur="LifecycleSDK.onReady",V=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Ur,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 m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var H=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 m(this,null,function*(){})}};var G=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 W=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);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:o,score:s,variation:i})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Cr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],z=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Cr.includes(t)?(yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r),{code:"SUCCESS",message:`navigate to ${t} success`}):{code:"FAILURE",message:"invalid path"})})}};var Y=class extends p{constructor(){super()}purchaseGem(t){return m(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 m(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.4";this.runtime=new yt;this.ads=new H;this.lifecycle=new V;this.storage=new $;this.keyboard=new G;this.task=new W;this.router=new z;this.payment=new Y;this.getSystemInfoSync=nt.bind(this);this.canIUse=f.bind(this);this.login=lt.bind(this);this.checkSession=mt.bind(this);this.request=dt.bind(this);this.on=ut.bind(this);this.off=pt.bind(this);this.once=ft.bind(this);this.isNativeSupport=ht.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 q=E;window.JoliboxSDK=q;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { JoliboxAds } from './sdks/ads';
|
|
|
15
15
|
import { KeyboardSDK } from './sdks/keyboard';
|
|
16
16
|
import { TaskTrackerSDK } from './sdks/task';
|
|
17
17
|
import { RouterSDK } from './sdks/router';
|
|
18
|
+
import { PaymentSDK } from './sdks/payment';
|
|
18
19
|
declare global {
|
|
19
20
|
interface Window {
|
|
20
21
|
JoliboxSDK: typeof JoliboxSDK;
|
|
@@ -99,6 +100,14 @@ export declare class JoliboxSDK {
|
|
|
99
100
|
* @type {RouterSDK}
|
|
100
101
|
*/
|
|
101
102
|
readonly router: RouterSDK;
|
|
103
|
+
/**
|
|
104
|
+
* @private
|
|
105
|
+
* @readonly
|
|
106
|
+
* Access to the Payment SDK module.
|
|
107
|
+
* @see {@link PaymentSDK} for more details.
|
|
108
|
+
* @type {PaymentSDK}
|
|
109
|
+
*/
|
|
110
|
+
readonly payment: PaymentSDK;
|
|
102
111
|
/**
|
|
103
112
|
* @public
|
|
104
113
|
* Synchronously gets system information.
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var gt=Object.defineProperty,Et=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))_t.call(t,r)&&_e(e,r,t[r]);return e},C=(e,t)=>Et(e,vt(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var ee=Object.defineProperty,St=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))It.call(t,r)&&be(e,r,t[r]);return e},Tt=(e,t)=>St(e,Rt(t)),Lt=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?bt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ee(t,r,o),o},At=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Dt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function we(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 Ct(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(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))(Ot||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Le=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=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 M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var 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 De={get config(){return globalThis[Y]}};var Re=Symbol.for("Jolibox.canIUseMap.native"),Kt={};globalThis[Re]||(globalThis[Re]=Kt);function re(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){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 ne=(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))(ne||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),Mt=(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))(Mt||{}),xe=["name","params"],jt=["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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ft(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(Tt(wt({},e),{location:t,target:r}),jt)}function Pe(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);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 se(){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}}se();var _=typeof window=="undefined",ie=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",$t="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue($t),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"},Ce=e=>{if(ie())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,o=Gt(),s=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Oe(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function qt(e){return Oe("api","stg-api",e)}function ke(e){return`https://${qt(e)}`}function Qt(e){return Oe("collect","stg-collect",e)}function Ne(e){return`https://${Qt(e)}`}var q=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};q.Undefined=new q(void 0);var m=q,Xt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.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,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,Ee;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((Ee=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||Ee.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ae=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)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)}},X={};Lt(X,{None:()=>er,filter:()=>rr,once:()=>Ke,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Ke(e)(t))}function Ke(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ae;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]},S=nr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)sr(e[n],t[n])}function sr(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ct(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 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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return or(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=Ie([Te],N);var Z=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=Dt(3e4)),this._starActivation}executeCommand(e,...t){return At(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Z=Ie([Te],Z);var Me=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[Me]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[Me]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new Z,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ar(o),o}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.2.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.3",extra:{}}}var dr=()=>{var t;return Ne((t=j)!=null?t:!1)},mr=dr(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},je;(je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var ur=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=ur(),fr=e=>d(void 0,null,function*(){try{let r=`${mr}/report`,n=Ce("1.2.3"),o=pr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:ne.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},s=Pe(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Fe=u(),ce=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?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)}`),b({err:JSON.stringify(t)})})},y=ce;window.addEventListener("unhandledrejection",ce.bind(void 0));window.addEventListener("error",ce.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var le=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(le(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=le(e),{major:i,minor:c,patch:a,prerelease:l}=le(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Be=u(),J=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};se();var He="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(He))!=null?$e:"{}"),de=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return d(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:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!Ve(de,l)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ae(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ve(de,h)&&A(l)==t&&D(l,r)>=0&&(o=ue(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var We=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var Er="1.2.3",F=Er,Qe=A(F),Xe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=Xe?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,pe="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(pe=new URL(ze.src).origin);var me=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ue=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/implement@${e}/dist/index.js`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),Ze=yr(F)?Qe:F,Ye=me(Ze),qe=ue(Ze);function _r(){Xe?We(vr,{bootstrapUrl:Ye,implementUrl:qe})():Ge({bootstrapUrl:Ye,implementUrl:qe,currentMajorVersion:Qe,currentVersion:F})()}_r();var Sr=u();function et(){return Sr.excuteCommandSync("API.getSystemInfoSync")}function tt(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function rt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var ot="1.2.3";function f(e){let[t,...r]=e.split(":"),n=tt(ie()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||re(ot,o,"<")?!1:r.length===0?!0:nt(n,r)||nt(n.properties,r)}function nt(e,t){if(!e)return!1;let r=rt(e,t);return r?we(r)?!0:te(r)?re(ot,r,">="):!1:!1}var st=u();function it(){return d(this,null,function*(){return f("login")?yield st.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function at(){return d(this,null,function*(){return f("checkSession")?yield st.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var br=u();function ct(e){return d(this,null,function*(){return f("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],lt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Rr=u();function ut(e){return d(this,null,function*(){return f("isNativeSupport")?yield Rr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=u();function pt(e){return d(this,null,function*(){return f("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=u();function ft(e){return d(this,null,function*(){return f("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=u();this._emitter=new ae}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var he=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),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ht=window.JoliboxRuntime||he;var wr="LifecycleSDK.onReady",B=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 V=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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 d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return d(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 d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);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:o,score:s,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(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 E=class E{constructor(){this.jssdkVersion="1.2.3";this.runtime=new ht;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.getSystemInfoSync=et.bind(this);this.canIUse=f.bind(this);this.login=it.bind(this);this.checkSession=at.bind(this);this.request=ct.bind(this);this.on=lt.bind(this);this.off=dt.bind(this);this.once=mt.bind(this);this.isNativeSupport=ut.bind(this);this.callHostMethod=pt.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 ge=E;window.JoliboxSDK=ge;export{ge as JoliboxSDK};
|
|
1
|
+
var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))St.call(t,r)&&Se(e,r,t[r]);return e},C=(e,t)=>yt(e,vt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var te=Object.defineProperty,bt=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,Re=(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)&&Re(e,r,t[r]);if(be)for(var r of be(t))wt.call(t,r)&&Re(e,r,t[r]);return e},Lt=(e,t)=>bt(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 o=n>1?void 0:n?Rt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&te(t,r,o),o},Dt=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Pt(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 Ut(e){return typeof e=="undefined"}function Ct(e){return Ut(e)||e===null}function Ot(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),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||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends K{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 K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Nt});var q=Symbol.for("Jolibox.canIUseMap"),Kt={};globalThis[q]||(globalThis[q]=Kt);var Pe={get config(){return globalThis[q]}};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 o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){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||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),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"],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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Bt(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(Lt(Tt({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>Bt(n)),r=k(e.device,Ft);return[e.protocolVersion,t,r,e.project]}var Vt=()=>"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 _=typeof window=="undefined",ae=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},$t=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Ht="device_id",Gt="advertising_id",Ce=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Vt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ce(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ce(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"},Oe=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=$t(),n=navigator.language,o=Wt(),s=zt();return`${t} (${qt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function ke(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function Qt(e){return ke("api","stg-api",e)}function Ne(e){return`https://${Qt(e)}`}function Xt(e){return ke("collect","stg-collect",e)}function Ke(e){return`https://${Xt(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,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 o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},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,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,y,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ye.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof 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 o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)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)}},Z={};At(Z,{None:()=>tr,filter:()=>nr,once:()=>Me,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>Me(e)(t))}function Me(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function nr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Y=Symbol.for("Jolibox.hostEmitter"),or=()=>{let e=new ce;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]},S=or();function sr(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(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(!Ct(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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return sr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=we([Le],N);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 N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Pt(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([Le],ee);var je=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[je]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[je]=e)}function u(e=!1){let t=ar();if(!e&&t)return t;let r=new N,n=new ee,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return cr(o),o}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 mr(){return{platform:1e3,os:"h5",appVersion:"1.2.4",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.4",extra:{}}}var dr=()=>{var t;return Ke((t=j)!=null?t:!1)},ur=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},fr=pr(),hr=e=>m(void 0,null,function*(){try{let r=`${ur}/report`,n=Oe("1.2.4"),o=fr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=mr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Ue(o);yield hr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=gr(),Be=u(),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 K?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)}`),b({err:JSON.stringify(t)})})},v=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Ve=u(),J=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Ge="jolibox-sdk-loadermeta",He,P=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),de=Date.now(),$e=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Er(){return m(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:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ge,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!$e(de,l)&&A(a)==t&&D(a,r)>=0&&(n=ue(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new De(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=l,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!$e(de,h)&&A(l)==t&&D(l,r)>=0&&(o=pe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),Er()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var ze=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>m(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){v(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var yr="1.2.4",F=yr,Xe=A(F),Ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=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,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var ue=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,_r=e=>/^\d+\.\d+\.\d+$/.test(e),et=_r(F)?Xe:F,qe=ue(et),Qe=pe(et);function Sr(){Ze?ze(vr,{bootstrapUrl:qe,implementUrl:Qe})():We({bootstrapUrl:qe,implementUrl:Qe,currentMajorVersion:Xe,currentVersion:F})()}Sr();var br=u();function tt(){return br.excuteCommandSync("API.getSystemInfoSync")}function rt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function nt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var st="1.2.4";function f(e){let[t,...r]=e.split(":"),n=rt(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(st,o,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=nt(e,t);return r?Te(r)?!0:re(r)?ne(st,r,">="):!1:!1}var it=u();function at(){return m(this,null,function*(){return f("login")?yield it.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ct(){return m(this,null,function*(){return f("checkSession")?yield it.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Rr=u();function lt(e){return m(this,null,function*(){return f("request")?yield Rr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!he.includes(e)){v(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!he.includes(e)){v(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ut=(e,t)=>{if(!he.includes(e)){v(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var xr=u();function pt(e){return m(this,null,function*(){return f("isNativeSupport")?yield xr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=u();function ft(e){return m(this,null,function*(){return f("callHostMethod")?yield Ir.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var wr=u();function ht(e){return m(this,null,function*(){return f("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();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 f(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),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},gt=window.JoliboxRuntime||ge;var Tr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Tr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(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 m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);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:o,score:s,variation:i})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Lr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Lr.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 m(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 m(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.4";this.runtime=new gt;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.payment=new z;this.getSystemInfoSync=tt.bind(this);this.canIUse=f.bind(this);this.login=at.bind(this);this.checkSession=ct.bind(this);this.request=lt.bind(this);this.on=mt.bind(this);this.off=dt.bind(this);this.once=ut.bind(this);this.isNativeSupport=pt.bind(this);this.callHostMethod=ft.bind(this);this.track=ht.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};
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var gt=Object.defineProperty,Et=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var _e=(e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&_e(e,r,t[r]);if(ye)for(var r of ye(t))_t.call(t,r)&&_e(e,r,t[r]);return e},C=(e,t)=>Et(e,vt(t));var d=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var ee=Object.defineProperty,St=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,be=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&be(e,r,t[r]);if(Se)for(var r of Se(t))It.call(t,r)&&be(e,r,t[r]);return e},Tt=(e,t)=>St(e,Rt(t)),Lt=(e,t)=>{for(var r in t)ee(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?bt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&ee(t,r,o),o},At=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Dt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function te(e){return typeof e=="string"}function we(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 Ct(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(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))(Ot||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Le=class extends K{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=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 M=class extends K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var 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 De={get config(){return globalThis[Y]}};var Re=Symbol.for("Jolibox.canIUseMap.native"),Kt={};globalThis[Re]||(globalThis[Re]=Kt);function re(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){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 ne=(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))(ne||{}),oe=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(oe||{}),Mt=(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))(Mt||{}),xe=["name","params"],jt=["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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Ft(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(Tt(wt({},e),{location:t,target:r}),jt)}function Pe(e){let t=e.events.map(n=>Ft(n)),r=k(e.device,Jt);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 se(){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}}se();var _=typeof window=="undefined",ie=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Vt=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",$t="device_id",Ht="advertising_id",Ue=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Bt()),window.__joliboxLocalStorage__.getItem(e)),Gt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ue($t),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"},Ce=e=>{if(ie())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Vt(),n=navigator.language,o=Gt(),s=Wt();return`${t} (${Yt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function Oe(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function qt(e){return Oe("api","stg-api",e)}function ke(e){return`https://${qt(e)}`}function Qt(e){return Oe("collect","stg-collect",e)}function Ne(e){return`https://${Qt(e)}`}var q=class Q{constructor(t){this.element=t,this.next=Q.Undefined,this.prev=Q.Undefined}};q.Undefined=new q(void 0);var m=q,Xt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.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,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,v,Ee;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((Ee=(v=this.options)==null?void 0:v.onDidRemoveLastListener)==null||Ee.call(v)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof I?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ae=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)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)}},X={};Lt(X,{None:()=>er,filter:()=>rr,once:()=>Ke,toPromise:()=>tr});var er=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function tr(e){return new Promise(t=>Ke(e)(t))}function Ke(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function rr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var z=Symbol.for("Jolibox.hostEmitter"),nr=()=>{let e=new ae;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]},S=nr();function or(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)sr(e[n],t[n])}function sr(e,t){if(te(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Ct(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 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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return or(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=Ie([Te],N);var Z=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=Dt(3e4)),this._starActivation}executeCommand(e,...t){return At(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),X.toPromise(X.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};Z=Ie([Te],Z);var Me=Symbol.for("Jolibox.commands");function ir(){return typeof globalThis!="undefined"?globalThis[Me]:void 0}function ar(e){typeof globalThis!="undefined"&&(globalThis[Me]=e)}function u(e=!1){let t=ir();if(!e&&t)return t;let r=new N,n=new Z,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return ar(o),o}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.2.3",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.3",extra:{}}}var dr=()=>{var t;return Ne((t=j)!=null?t:!1)},mr=dr(),Je=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},je;(je=AbortSignal.timeout)!=null||(AbortSignal.timeout=Je);var ur=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},pr=ur(),fr=e=>d(void 0,null,function*(){try{let r=`${mr}/report`,n=Ce("1.2.3"),o=pr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Je(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:ne.ErrorTrace,location:cr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=lr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:oe.WebSDK},s=Pe(o);yield fr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var hr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=hr(),Fe=u(),ce=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof K?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)}`),b({err:JSON.stringify(t)})})},y=ce;window.addEventListener("unhandledrejection",ce.bind(void 0));window.addEventListener("error",ce.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Fe.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var le=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(le(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=le(e),{major:i,minor:c,patch:a,prerelease:l}=le(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Be=u(),J=(e,t)=>{Be.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Be.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};se();var He="jolibox-sdk-loadermeta",$e,P=JSON.parse(($e=window.__joliboxLocalStorage__.getItem(He))!=null?$e:"{}"),de=Date.now(),Ve=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function gr(){return d(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:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(He,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var Ge=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!Ve(de,l)&&A(a)==t&&D(a,r)>=0&&(n=me(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new Ae(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let v=document.createElement("script");v.type="text/javascript",v.innerHTML=l,document.head.appendChild(v),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!Ve(de,h)&&A(l)==t&&D(l,r)>=0&&(o=ue(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),gr()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var We=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>d(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){y(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new T(`module load failed ${o}`))}}};var Er="1.2.3",F=Er,Qe=A(F),Xe=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=Xe?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,pe="https://jsdelivr.jolibox.com";var ze=window.document.currentScript;ze&&(pe=new URL(ze.src).origin);var me=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,ue=(e,t)=>`${t!=null?t:pe}/npm/@jolibox/implement@${e}/dist/index.js`,yr=e=>/^\d+\.\d+\.\d+$/.test(e),Ze=yr(F)?Qe:F,Ye=me(Ze),qe=ue(Ze);function _r(){Xe?We(vr,{bootstrapUrl:Ye,implementUrl:qe})():Ge({bootstrapUrl:Ye,implementUrl:qe,currentMajorVersion:Qe,currentVersion:F})()}_r();var Sr=u();function et(){return Sr.excuteCommandSync("API.getSystemInfoSync")}function tt(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function rt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var ot="1.2.3";function f(e){let[t,...r]=e.split(":"),n=tt(ie()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||re(ot,o,"<")?!1:r.length===0?!0:nt(n,r)||nt(n.properties,r)}function nt(e,t){if(!e)return!1;let r=rt(e,t);return r?we(r)?!0:te(r)?re(ot,r,">="):!1:!1}var st=u();function it(){return d(this,null,function*(){return f("login")?yield st.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function at(){return d(this,null,function*(){return f("checkSession")?yield st.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var br=u();function ct(e){return d(this,null,function*(){return f("request")?yield br.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var fe=["onI18nChanged","onBackPress"],lt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!fe.includes(e)){y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},mt=(e,t)=>{if(!fe.includes(e)){y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var Rr=u();function ut(e){return d(this,null,function*(){return f("isNativeSupport")?yield Rr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var xr=u();function pt(e){return d(this,null,function*(){return f("callHostMethod")?yield xr.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var Ir=u();function ft(e){return d(this,null,function*(){return f("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=u();this._emitter=new ae}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return f(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var he=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),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},ht=window.JoliboxRuntime||he;var wr="LifecycleSDK.onReady",B=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 V=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(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 d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return d(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 d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);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:o,score:s,variation:i})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Tr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(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 E=class E{constructor(){this.jssdkVersion="1.2.3";this.runtime=new ht;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.getSystemInfoSync=et.bind(this);this.canIUse=f.bind(this);this.login=it.bind(this);this.checkSession=at.bind(this);this.request=ct.bind(this);this.on=lt.bind(this);this.off=dt.bind(this);this.once=mt.bind(this);this.isNativeSupport=ut.bind(this);this.callHostMethod=pt.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 ge=E;window.JoliboxSDK=ge;})();
|
|
1
|
+
"use strict";(()=>{var Et=Object.defineProperty,yt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,U=(e,t)=>{for(var r in t||(t={}))_t.call(t,r)&&Se(e,r,t[r]);if(_e)for(var r of _e(t))St.call(t,r)&&Se(e,r,t[r]);return e},C=(e,t)=>yt(e,vt(t));var m=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var te=Object.defineProperty,bt=Object.defineProperties,Rt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,Re=(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)&&Re(e,r,t[r]);if(be)for(var r of be(t))wt.call(t,r)&&Re(e,r,t[r]);return e},Lt=(e,t)=>bt(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 o=n>1?void 0:n?Rt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&te(t,r,o),o},Dt=(e,t,r)=>new Promise((n,o)=>{var s=a=>{try{c(r.next(a))}catch(l){o(l)}},i=a=>{try{c(r.throw(a))}catch(l){o(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Pt(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 Ut(e){return typeof e=="undefined"}function Ct(e){return Ut(e)||e===null}function Ot(e){return typeof e=="function"}function Le(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),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||{}),K=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends K{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 K{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Nt={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Nt});var q=Symbol.for("Jolibox.canIUseMap"),Kt={};globalThis[q]||(globalThis[q]=Kt);var Pe={get config(){return globalThis[q]}};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 o=e.split("."),s=t.split("."),i=Math.max(o.length,s.length);for(let c=0;c<i;c++){let a=parseInt(o[c],10)||0,l=parseInt(s[c],10)||0;if(a>l){n=1;break}else if(a<l){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||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),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"],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((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Bt(e){let t=e.location?k(e.location,Ie):null,r=e.target?k(e.target,Ie):null;return k(Lt(Tt({},e),{location:t,target:r}),Jt)}function Ue(e){let t=e.events.map(n=>Bt(n)),r=k(e.device,Ft);return[e.protocolVersion,t,r,e.project]}var Vt=()=>"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 _=typeof window=="undefined",ae=()=>!_&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),O={isiOS:!_&&(navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS")),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:!_&&navigator.userAgent.includes("Android"),isMac:!_&&navigator.userAgent.includes("Mac"),isFacebook:!_&&navigator.userAgent.includes("FB_IAB"),isPC:!_&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},$t=()=>O.isiOS?"iOS":O.isAndroid?"Android":O.isMac?"Mac":O.isFacebook?"Facebook":"PC",Ht="device_id",Gt="advertising_id",Ce=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Vt()),window.__joliboxLocalStorage__.getItem(e)),Wt=()=>new URLSearchParams(window.location.search).get("deviceId")||Ce(Ht),zt=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ce(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"},Oe=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=$t(),n=navigator.language,o=Wt(),s=zt();return`${t} (${qt()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`};function ke(e,t,r){let n=window.location.hostname,o=n.split("."),s=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${s}.jolibox.com`;if(o.length>=2){let i=o.slice(-2).join(".");if(i==="jolibox.com"||i==="pico-game.com"||i==="joyslite.com")return`${s}.${i}`}return`${s}.jolibox.com`}function Qt(e){return ke("api","stg-api",e)}function Ne(e){return`https://${Qt(e)}`}function Xt(e){return ke("collect","stg-collect",e)}function Ke(e){return`https://${Xt(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,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 o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},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,o,s,i,c,a;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new I(t);return this._listeners?this._listeners instanceof I?this._listeners=[this._listeners,l]:this._listeners.push(l):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=l,(i=(s=this.options)==null?void 0:s.onDidFirstListener)==null||i.call(s,this)),(a=(c=this.options)==null?void 0:c.onDidAddListener)==null||a.call(c,this),this._size++,()=>{var h,g,y,ye;if(!this._disposed){if(this._listeners instanceof I)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(g=(h=this.options)==null?void 0:h.onDidRemoveLastListener)==null||g.call(h));else if(this._listeners){let ve=this._listeners.indexOf(l);ve>=0&&(this._listeners.splice(ve,1),this._size--,this._size===0&&((ye=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||ye.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof 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 o=(n=this.listeners.get(e))!=null?n:new w,s=a=>t(...a.args),i=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:i}),this.listeners.set(e,o);let c=this.cachedEventQueue.get(e);if(c&&r)for(let a of c)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)}},Z={};At(Z,{None:()=>tr,filter:()=>nr,once:()=>Me,toPromise:()=>rr});var tr=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function rr(e){return new Promise(t=>Me(e)(t))}function Me(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function nr(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new w(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Y=Symbol.for("Jolibox.hostEmitter"),or=()=>{let e=new ce;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]},S=or();function sr(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(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(!Ct(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 o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return sr(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};N=we([Le],N);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 N,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Pt(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([Le],ee);var je=Symbol.for("Jolibox.commands");function ar(){return typeof globalThis!="undefined"?globalThis[je]:void 0}function cr(e){typeof globalThis!="undefined"&&(globalThis[je]=e)}function u(e=!1){let t=ar();if(!e&&t)return t;let r=new N,n=new ee,o={registerCommand(s,i,c){r.registerCommand({id:s,handler:i,metadata:c})},executeCommand(s,...i){return n.executeCommand(s,...i)},excuteCommandSync(s,...i){return n.executeCommandThowErr(s,...i)}};return cr(o),o}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 mr(){return{platform:1e3,os:"h5",appVersion:"1.2.4",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.2.4",extra:{}}}var dr=()=>{var t;return Ke((t=j)!=null?t:!1)},ur=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},fr=pr(),hr=e=>m(void 0,null,function*(){try{let r=`${ur}/report`,n=Oe("1.2.4"),o=fr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Fe(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:lr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=mr(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Ue(o);yield hr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>S.emit("onDocumentReady",L.startTime));var gr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},L=gr(),Be=u(),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 K?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)}`),b({err:JSON.stringify(t)})})},v=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};Be.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(i=>{b({err:JSON.stringify(s)})})};var me=e=>{var c,a,l;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,i]=[(c=n[0])!=null?c:"0",(a=n[1])!=null?a:"0",(l=n[2])!=null?l:"0"];return{major:o,minor:s,patch:i,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),D=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:i,minor:c,patch:a,prerelease:l}=me(t);return r!==i?r>i?1:-1:n!==c?n>c?1:-1:o!==a?o>a?1:-1:s&&!l?-1:!s&&l?1:s&&l?s>l?1:s<l?-1:0:0};var Ve=u(),J=(e,t)=>{Ve.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},R=(e,t,r)=>{Ve.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Ge="jolibox-sdk-loadermeta",He,P=JSON.parse((He=window.__joliboxLocalStorage__.getItem(Ge))!=null?He:"{}"),de=Date.now(),$e=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function Er(){return m(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:o}=yield r.json(),s=C(U({},P),{timestamp:de});if(o){let{bootstrap_version:i}=P;i&&D(i,o)>=0||(s=C(U({},s),{bootstrap_version:o}))}if(n){let{implement_version:i}=P;i&&D(i,n)>=0||(s=C(U({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ge,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var We=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:a,timestamp:l}=P;a&&l&&!$e(de,l)&&A(a)==t&&D(a,r)>=0&&(n=ue(a));try{let h=new XMLHttpRequest;return h.open("GET",n,!1),h.send(),{script:h.responseText,type:"fetch_from_cdn"}}catch(h){let g=new De(`Bootstrap module faile to fetch ${h}`);b({err:`${g}`})}}function i(){var g;let a=Date.now();J("jsSdkBegin",{t:a}),L.startTime=a;let{script:l,type:h}=(g=s())!=null?g:{};if(l){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=l,document.head.appendChild(y),R("bootstrapModuleLoaded",Date.now()-a,{type:h})}}function c(){let a=Date.now(),{implement_version:l,timestamp:h}=P;l&&h&&!$e(de,h)&&A(l)==t&&D(l,r)>=0&&(o=pe(l));let g=document.createElement("script");g.type="module",g.crossOrigin="anonymous",g.src=o,g.onload=()=>{R("implementModuleLoaded",Date.now()-a,{type:"fetch_from_cdn"})},document.head.appendChild(g)}return()=>{try{i(),c(),Er()}catch(a){let l=new T(`module evaluate error: ${a}`);b({err:`${l}`})}}};var ze=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(i=>m(this,null,function*(){try{let c=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(c),l=yield import(a);return URL.revokeObjectURL(a),l}catch(c){v(new T(`implement module evaluate error in native:${c} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),L.startTime=o;let s=r(t.bootstrapUrl),i=document.createElement("script");i.type="text/javascript",i.innerHTML=s,document.head.appendChild(i),R("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let c=Date.now(),a=r(t.implementUrl);n(a),R("implementModuleLoaded",Date.now()-c,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),v(new T(`module load failed ${o}`))}}};var yr="1.2.4",F=yr,Xe=A(F),Ze=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),vr=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,fe="https://jsdelivr.jolibox.com";var Ye=window.document.currentScript;Ye&&(fe=new URL(Ye.src).origin);var ue=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=(e,t)=>`${t!=null?t:fe}/npm/@jolibox/implement@${e}/dist/index.js`,_r=e=>/^\d+\.\d+\.\d+$/.test(e),et=_r(F)?Xe:F,qe=ue(et),Qe=pe(et);function Sr(){Ze?ze(vr,{bootstrapUrl:qe,implementUrl:Qe})():We({bootstrapUrl:qe,implementUrl:Qe,currentMajorVersion:Xe,currentVersion:F})()}Sr();var br=u();function tt(){return br.excuteCommandSync("API.getSystemInfoSync")}function rt(e,t){var r;return(r=Pe.config[e])==null?void 0:r[t]}function nt(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var st="1.2.4";function f(e){let[t,...r]=e.split(":"),n=rt(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(st,o,"<")?!1:r.length===0?!0:ot(n,r)||ot(n.properties,r)}function ot(e,t){if(!e)return!1;let r=nt(e,t);return r?Te(r)?!0:re(r)?ne(st,r,">="):!1:!1}var it=u();function at(){return m(this,null,function*(){return f("login")?yield it.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function ct(){return m(this,null,function*(){return f("checkSession")?yield it.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Rr=u();function lt(e){return m(this,null,function*(){return f("request")?yield Rr.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],mt=(e,t)=>{if(!he.includes(e)){v(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}S.on(e,t)},dt=(e,t)=>{if(!he.includes(e)){v(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}S.off(e,t)},ut=(e,t)=>{if(!he.includes(e)){v(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}S.once(e,t)};var xr=u();function pt(e){return m(this,null,function*(){return f("isNativeSupport")?yield xr.executeCommand("API.isNativeSupport",e):{code:"FAILURE",message:"[Jolibox SDK] isNativeSupport is not supported in this platform"}})}var Ir=u();function ft(e){return m(this,null,function*(){return f("callHostMethod")?yield Ir.executeCommand("API.callHostMethod",e):{code:"FAILURE",message:"[Jolibox SDK] callHostMethod is not supported in this platform"}})}var wr=u();function ht(e){return m(this,null,function*(){return f("track")?yield wr.executeCommand("API.track",e):{code:"FAILURE",message:"[Jolibox SDK] track is not supported in this platform"}})}var p=class{constructor(){this.commands=u();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 f(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),o=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:n});window.dispatchEvent(o),this.commands.executeCommand("RuntimeSDK.loadProgressEvent",n)}}},gt=window.JoliboxRuntime||ge;var Tr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(Tr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return m(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 m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s,variation:i}=t,c=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");if(c)return Promise.resolve(c);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:o,score:s,variation:i})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o,variation:s}=t,i=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");if(i)return Promise.resolve(i);let c=new CustomEvent("JOLIBOX_TASK_GAME_PLAY_ENDED",{detail:t});return window.dispatchEvent(c),yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o,variation:s})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");if(o)return o;let s=new CustomEvent("JOLIBOX_TASK_LEVEL_UPGRADE",{detail:t});return window.dispatchEvent(s),yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n})})}};var Lr=["openHistory","openDiscover","openGame","openDrama","openFeed","openTopup","openRewards"],W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(Lr.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 m(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 m(this,null,function*(){let t=this.canIUseIfThrow("payment.getGemProducts");return(t==null?void 0:t.code)==="FAILURE"?t:yield this.commands.executeCommand("PaymentSDK.getGemProducts")})}};var E=class E{constructor(){this.jssdkVersion="1.2.4";this.runtime=new gt;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new H;this.task=new G;this.router=new W;this.payment=new z;this.getSystemInfoSync=tt.bind(this);this.canIUse=f.bind(this);this.login=at.bind(this);this.checkSession=ct.bind(this);this.request=lt.bind(this);this.on=mt.bind(this);this.off=dt.bind(this);this.once=ut.bind(this);this.isNativeSupport=pt.bind(this);this.callHostMethod=ft.bind(this);this.track=ht.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;})();
|
package/dist/index.js
CHANGED
|
@@ -1705,7 +1705,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1705
1705
|
};
|
|
1706
1706
|
|
|
1707
1707
|
// src/sdks/router.ts
|
|
1708
|
-
var NavigateToNativePageTypeTypes = ["openHistory", "openDiscover", "openGame", "openDrama", "openFeed", "openTopup"];
|
|
1708
|
+
var NavigateToNativePageTypeTypes = ["openHistory", "openDiscover", "openGame", "openDrama", "openFeed", "openTopup", "openRewards"];
|
|
1709
1709
|
var RouterSDK = class extends BaseSDK {
|
|
1710
1710
|
/**
|
|
1711
1711
|
* @public
|
|
@@ -1786,6 +1786,27 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1786
1786
|
}
|
|
1787
1787
|
};
|
|
1788
1788
|
|
|
1789
|
+
// src/sdks/payment.ts
|
|
1790
|
+
var PaymentSDK = class extends BaseSDK {
|
|
1791
|
+
constructor() {
|
|
1792
|
+
super();
|
|
1793
|
+
}
|
|
1794
|
+
async purchaseGem(params) {
|
|
1795
|
+
const canIUseResult = this.canIUseIfThrow("payment.purchaseGem");
|
|
1796
|
+
if (canIUseResult?.code === "FAILURE") {
|
|
1797
|
+
return canIUseResult;
|
|
1798
|
+
}
|
|
1799
|
+
return await this.commands.executeCommand("PaymentSDK.purchaseGem", params);
|
|
1800
|
+
}
|
|
1801
|
+
async getGemProducts() {
|
|
1802
|
+
const canIUseResult = this.canIUseIfThrow("payment.getGemProducts");
|
|
1803
|
+
if (canIUseResult?.code === "FAILURE") {
|
|
1804
|
+
return canIUseResult;
|
|
1805
|
+
}
|
|
1806
|
+
return await this.commands.executeCommand("PaymentSDK.getGemProducts");
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
|
|
1789
1810
|
// src/index.ts
|
|
1790
1811
|
var JoliboxSDK = (_JoliboxSDK2 = class _JoliboxSDK {
|
|
1791
1812
|
/**
|
|
@@ -1855,6 +1876,14 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1855
1876
|
* @type {RouterSDK}
|
|
1856
1877
|
*/
|
|
1857
1878
|
this.router = new RouterSDK();
|
|
1879
|
+
/**
|
|
1880
|
+
* @private
|
|
1881
|
+
* @readonly
|
|
1882
|
+
* Access to the Payment SDK module.
|
|
1883
|
+
* @see {@link PaymentSDK} for more details.
|
|
1884
|
+
* @type {PaymentSDK}
|
|
1885
|
+
*/
|
|
1886
|
+
this.payment = new PaymentSDK();
|
|
1858
1887
|
//global API
|
|
1859
1888
|
/**
|
|
1860
1889
|
* @public
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Payment, ResponseType } from '@jolibox/types';
|
|
2
|
+
import { BaseSDK } from './sdk';
|
|
3
|
+
export declare class PaymentSDK extends BaseSDK implements Payment {
|
|
4
|
+
constructor();
|
|
5
|
+
purchaseGem(params: {
|
|
6
|
+
productId: string;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
code: ResponseType;
|
|
9
|
+
message: string;
|
|
10
|
+
}>;
|
|
11
|
+
getGemProducts(): Promise<{
|
|
12
|
+
code: ResponseType;
|
|
13
|
+
message: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/sdk",
|
|
3
3
|
"description": "This project is common Jolibox JS-SDk interfere",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.4",
|
|
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.2.
|
|
11
|
-
"@jolibox/types": "1.2.
|
|
10
|
+
"@jolibox/common": "1.2.4",
|
|
11
|
+
"@jolibox/types": "1.2.4"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"typescript": "5.7.3",
|
package/sdk.build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Invoking: npm run clean && npm run build:cjs && npm run build:esm && npm run build:iife && tsc
|
|
2
2
|
|
|
3
|
-
> @jolibox/sdk@1.2.
|
|
3
|
+
> @jolibox/sdk@1.2.4 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/sdk@1.2.
|
|
7
|
+
> @jolibox/sdk@1.2.4 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.2.
|
|
11
|
+
> @jolibox/sdk@1.2.4 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.2.
|
|
15
|
+
> @jolibox/sdk@1.2.4 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
|
@@ -28,6 +28,7 @@ import { JoliboxAds } from './sdks/ads';
|
|
|
28
28
|
import { KeyboardSDK } from './sdks/keyboard';
|
|
29
29
|
import { TaskTrackerSDK } from './sdks/task';
|
|
30
30
|
import { RouterSDK } from './sdks/router';
|
|
31
|
+
import { PaymentSDK } from './sdks/payment';
|
|
31
32
|
|
|
32
33
|
declare global {
|
|
33
34
|
interface Window {
|
|
@@ -123,6 +124,15 @@ export class JoliboxSDK {
|
|
|
123
124
|
*/
|
|
124
125
|
readonly router = new RouterSDK();
|
|
125
126
|
|
|
127
|
+
/**
|
|
128
|
+
* @private
|
|
129
|
+
* @readonly
|
|
130
|
+
* Access to the Payment SDK module.
|
|
131
|
+
* @see {@link PaymentSDK} for more details.
|
|
132
|
+
* @type {PaymentSDK}
|
|
133
|
+
*/
|
|
134
|
+
readonly payment = new PaymentSDK();
|
|
135
|
+
|
|
126
136
|
//global API
|
|
127
137
|
/**
|
|
128
138
|
* @public
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Payment, ResponseType } from '@jolibox/types';
|
|
2
|
+
import { BaseSDK } from './sdk';
|
|
3
|
+
|
|
4
|
+
export class PaymentSDK extends BaseSDK implements Payment {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async purchaseGem(params: { productId: string }) {
|
|
10
|
+
const canIUseResult = this.canIUseIfThrow('payment.purchaseGem');
|
|
11
|
+
if (canIUseResult?.code === 'FAILURE') {
|
|
12
|
+
return canIUseResult;
|
|
13
|
+
}
|
|
14
|
+
return await this.commands.executeCommand('PaymentSDK.purchaseGem', params);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async getGemProducts() {
|
|
18
|
+
const canIUseResult = this.canIUseIfThrow('payment.getGemProducts');
|
|
19
|
+
if (canIUseResult?.code === 'FAILURE') {
|
|
20
|
+
return canIUseResult;
|
|
21
|
+
}
|
|
22
|
+
return await this.commands.executeCommand('PaymentSDK.getGemProducts');
|
|
23
|
+
}
|
|
24
|
+
}
|