@jolibox/implement 1.4.13 → 1.4.14

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.
@@ -4,7 +4,7 @@
4
4
  "packages/implement/.eslintrc.js": "7a3d2747dc887655ca9e2d3ff621f7dfd98500b9",
5
5
  "packages/implement/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
6
6
  "packages/implement/esbuild.config.js": "0a49e35996f74ca72898dec126c76086d7a39ffc",
7
- "packages/implement/package.json": "48d192dda1cd4bb5d9d81c2c102f395c37f7aac3",
7
+ "packages/implement/package.json": "ee2695d9f89a7b073bd7f98820ef3eceb226017a",
8
8
  "packages/implement/src/common/ads/ads-action-detection.ts": "5a7b9f85d7eab9e744f8a9fc7638063f43baa214",
9
9
  "packages/implement/src/common/ads/anti-cheating.test.ts": "e2ff3dc6760cfd28d0f8c15703d7fb20d43df583",
10
10
  "packages/implement/src/common/ads/anti-cheating.ts": "a3ffb6a78e289e1c0ce45c7f7c0cee000e75e541",
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Eh=Object.create;var ho=Object.defineProperty,Ih=Object.defineProperties,Ah=Object.getOwnPropertyDescriptor,Sh=Object.getOwnPropertyDescriptors,Ch=Object.getOwnPropertyNames,_n=Object.getOwnPropertySymbols,vl=Object.getPrototypeOf,mo=Object.prototype.hasOwnProperty,gl=Object.prototype.propertyIsEnumerable,Rh=Reflect.get;var pl=(e,t,r)=>t in e?ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,X=(e,t)=>{for(var r in t||(t={}))mo.call(t,r)&&pl(e,r,t[r]);if(_n)for(var r of _n(t))gl.call(t,r)&&pl(e,r,t[r]);return e},xe=(e,t)=>Ih(e,Sh(t));var Rr=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var _l=(e,t)=>{var r={};for(var n in e)mo.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&_n)for(var n of _n(e))t.indexOf(n)<0&&gl.call(e,n)&&(r[n]=e[n]);return r};var re=(e,t)=>()=>(e&&(t=e(e=0)),t);var po=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Oh=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ch(t))!mo.call(e,i)&&i!==r&&ho(e,i,{get:()=>t[i],enumerable:!(n=Ah(t,i))||n.enumerable});return e};var vo=(e,t,r)=>(r=e!=null?Eh(vl(e)):{},Oh(t||!e||!e.__esModule?ho(r,"default",{value:e,enumerable:!0}):r,e));var yl=(e,t,r)=>Rh(vl(e),r,t);var E=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((r=r.apply(e,t)).next())});function Uh(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function So(e){return typeof e=="string"}function Cl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Rl(e){return typeof e=="object"&&Array.isArray(e)}function Bh(e){return typeof e=="undefined"}function Mh(e){return Bh(e)||e===null}function Gh(e){return typeof e=="function"}function Ol(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function kl(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,o){for(let a in o)if(Object.prototype.hasOwnProperty.call(o,a)){let s=i[a],l=o[a],c=r(s,l,a,i,o);c!==void 0?i[a]=c:El(l)&&El(s)?i[a]=n(Ao({},s),l):Array.isArray(l)&&Array.isArray(s)?i[a]=[...s,...l]:i[a]=l}return i}return n(e,t)}function El(e){return e&&typeof e=="object"&&e.constructor===Object}function Tl(e,t){if(Array.isArray(e))return e.concat(t)}function xr(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:l=!0}=r,c=()=>(a=e.apply(o,i),i=void 0,o=void 0,a),m=function(...d){i=d,o=this;let p=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!p&&c()},t),p)return c()};return m.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},m.flush=()=>{if(n)return clearTimeout(n),n=null,c()},m}function jh(e,t){return(...r)=>t(e,...r)}function Dl(e){return t=>jh(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Fh(`${i}`))}})}function Or(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function yn(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((i,o)=>(i[o]=String(n[o]),i),{})}return e[r]})}function Wh(e){let t=e.location?yn(e.location,Al):null,r=e.target?yn(e.target,Al):null;return yn(Dh(Ao({},e),{location:t,target:r}),$h)}function To(e){let t=e.events.map(n=>Wh(n)),r=yn(e.device,Kh);return[e.protocolVersion,t,r,e.project]}function zh(){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}}function Po(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com"||a==="mporia.com"||a==="pingplus.ai")return`${o}.${a}`}return`${o}.jolibox.com`}function Bl(e){return Po("app","stg-app",e)}function tr(e){return`https://${Po("api","stg-api",e)}`}function rm(e){return Po("collect","stg-collect",e)}function Ml(e){return`https://${rm(e)}`}function am(e){return new Promise(t=>Gl(e)(t))}function Gl(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function sm(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Tr(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function cm(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)dm(e[n],t[n])}function dm(e,t){if(So(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Gh(t)){try{if(e instanceof t)return}catch(r){}if(!Mh(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")}}function um(){return typeof globalThis!="undefined"?globalThis[Jl]:void 0}function fm(e){typeof globalThis!="undefined"&&(globalThis[Jl]=e)}function Ae(e=!1){let t=um();if(!e&&t)return t;let r=new bn,n=new Eo,i={registerCommand(o,a,s){r.registerCommand({id:o,handler:a,metadata:s})},executeCommand(o,...a){return n.executeCommand(o,...a)},excuteCommandSync(o,...a){return n.executeCommandThowErr(o,...a)}};return fm(i),i}var Io,kh,Th,xh,bl,Nh,Ph,wl,Ao,Dh,Lh,Sl,Bt,Jh,Co,Ro,xl,Nl,Fh,Pl,wn,En,Oo,Pe,_o,Hh,ko,Il,qh,Mt,er,Vh,Al,$h,Kh,We,Zt,Yh,Ne,Xh,Qh,Zh,Ll,xo,No,em,tm,Ul,Gt,yo,ae,nm,im,kr,Tr,et,wo,om,go,lm,kt,bn,Eo,Jl,W=re(()=>{"use strict";Io=Object.defineProperty,kh=Object.defineProperties,Th=Object.getOwnPropertyDescriptor,xh=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,Nh=Object.prototype.hasOwnProperty,Ph=Object.prototype.propertyIsEnumerable,wl=(e,t,r)=>t in e?Io(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ao=(e,t)=>{for(var r in t||(t={}))Nh.call(t,r)&&wl(e,r,t[r]);if(bl)for(var r of bl(t))Ph.call(t,r)&&wl(e,r,t[r]);return e},Dh=(e,t)=>kh(e,xh(t)),Lh=(e,t)=>{for(var r in t)Io(e,r,{get:t[r],enumerable:!0})},Sl=(e,t,r,n)=>{for(var i=n>1?void 0:n?Th(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&Io(t,r,i),i},Bt=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((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 i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,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}Jh=(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))(Jh||{}),Co=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}},Ro=class extends Co{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},xl=class extends Co{constructor(){super(...arguments),this.kind="USER_ERROR"}},Nl=class extends xl{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Fh=class extends xl{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Pl=class extends Ro{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},wn=class extends Ro{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},En=class extends Co{constructor(e,t,r,n,i){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),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Oo=class extends Ro{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Pe={log:Or("log"),warn:Or("warn"),info:Or("info"),error:Or("error"),debug:Or("debug")};Object.assign(globalThis,{logger:Pe});_o=Symbol.for("Jolibox.canIUseMap"),Hh={};globalThis[_o]||(globalThis[_o]=Hh);ko={get config(){return globalThis[_o]}},Il=Symbol.for("Jolibox.canIUseMap.native"),qh={};globalThis[Il]||(globalThis[Il]=qh);Mt=(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))(Mt||{}),er=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(er||{}),Vh=(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))(Vh||{}),Al=["name","params"],$h=["name","type","location","target","extra","timestamp","userId"],Kh=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];We=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});zh();Zt=typeof window=="undefined",Yh=()=>!Zt&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Ne={isiOS:!Zt&&(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:!Zt&&navigator.userAgent.includes("Android"),isMac:!Zt&&navigator.userAgent.includes("Mac"),isFacebook:!Zt&&navigator.userAgent.includes("FB_IAB"),isPC:!Zt&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Xh=()=>Ne.isiOS?"iOS":Ne.isAndroid?"Android":Ne.isMac?"Mac":Ne.isFacebook?"Facebook":"PC",Qh="device_id",Zh="advertising_id",Ll=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,We()),window.__joliboxLocalStorage__.getItem(e)),xo=()=>new URLSearchParams(window.location.search).get("deviceId")||Ll(Qh),No=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ll(Zh),em=e=>e.charAt(0).toUpperCase()+e.slice(1),tm=()=>{var e;let t=new URLSearchParams(window.location.search);return em((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ul=e=>{if(Yh())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Xh(),n=navigator.language,i=xo(),o=No();return`${t} (${tm()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${i} adid/${o} version/${e||""}`};Gt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=Ao({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return Bt(this,null,function*(){let r=this.config.keyGenerator(e,t),n=this.pendingRequests.get(r);if(n)return console.log(`[RequestCacheService] Reusing pending request for ${e}`),n;let i=this.requestInternal(e,t),o=this.createTimeoutPromise(),a=Promise.race([i,o]).catch(s=>Bt(this,null,function*(){if(s.message.includes("timeout")){let l=this.getValidCachedData(r);if(l)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}throw s}));this.pendingRequests.set(r,a),i.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${e}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${e}:`,s)});try{return yield a}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return Bt(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,l=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",l),l){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let d=yield this.requestAdapter.execute(e,t),p=this.requestAdapter.extractRealTimeData(d),h=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,d);return h&&!this.config.consistencyChecker(l,h)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,h,s),d):this.requestAdapter.mergeData(l,p)}catch(d){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,d),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let c=yield this.requestAdapter.execute(e,t),m=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,c);return m&&this.setCachedDataWithSequence(a,m,s),c})}createTimeoutPromise(){return new Promise((e,t)=>{setTimeout(()=>{t(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(e){let t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),null):t.data:null}setCachedDataWithSequence(e,t,r,n){let i=this.cache.get(e);if(i&&i.sequence>r){console.log(`[RequestCacheService] Ignoring stale cache update for ${e} (current: ${i.sequence}, incoming: ${r})`);return}let o=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:o,expiresAt:o+this.config.duration,key:e,sequence:r,metadata:n}),this.cacheSequences.set(e,r),console.log(`[RequestCacheService] Updated cache for ${e} with sequence ${r}`)}refreshCache(e,t){return Bt(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return Bt(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),o=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${o})`);let a=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,a);return s&&(this.setCachedDataWithSequence(i,s,o),console.log(`[RequestCacheService] Force updated cache for ${e}`)),a})}warmupCache(e,t){return Bt(this,null,function*(){let r=this.config.keyGenerator(e,t);if(this.pendingRequests.has(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - request in progress`);return}if(this.hasValidCache(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${e}`),yield this.forceRequest(e,t)}catch(n){console.warn(`[RequestCacheService] Cache warmup failed for ${e}:`,n)}})}clearCache(e){e?(this.cache.delete(e),this.cacheSequences.delete(e),this.pendingRequests.delete(e),console.log(`[RequestCacheService] Cleared cache for ${e}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let e=Date.now();for(let[t,r]of this.cache)e>r.expiresAt&&(this.cache.delete(t),this.cacheSequences.delete(t));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let e=Date.now(),t=0,r=0;for(let n of this.cache.values())e>n.expiresAt?r++:t++;return{cacheCount:this.cache.size,validCount:t,expiredCount:r,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(e){let t=this.cache.get(e);return t?Date.now()<=t.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(e){return this.pendingRequests.has(e)}getCacheSequence(e){return this.cacheSequences.get(e)}},yo=class bo{constructor(t){this.element=t,this.next=bo.Undefined,this.prev=bo.Undefined}};yo.Undefined=new yo(void 0);ae=yo,nm=class{constructor(){this._first=ae.Undefined,this._last=ae.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ae.Undefined}clear(){let e=this._first;for(;e!==ae.Undefined;){let t=e.next;e.prev=ae.Undefined,e.next=ae.Undefined,e=t}this._first=ae.Undefined,this._last=ae.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new ae(e);if(this._first===ae.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==ae.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ae.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ae.Undefined&&e.next!==ae.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ae.Undefined&&e.next===ae.Undefined?(this._first=ae.Undefined,this._last=ae.Undefined):e.next===ae.Undefined?(this._last=this._last.prev,this._last.next=ae.Undefined):e.prev===ae.Undefined&&(this._first=this._first.next,this._first.prev=ae.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ae.Undefined;)yield e.element,e=e.next}},im=0,kr=class{constructor(e){this.value=e,this.id=im++}},Tr=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 kr&&(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,i,o,a,s,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new kr(t);return this._listeners?this._listeners instanceof kr?this._listeners=[this._listeners,c]:this._listeners.push(c):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=c,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var m,d,p,h;if(!this._disposed){if(this._listeners instanceof kr)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(d=(m=this.options)==null?void 0:m.onDidRemoveLastListener)==null||d.call(m));else if(this._listeners){let b=this._listeners.indexOf(c);b>=0&&(this._listeners.splice(b,1),this._size--,this._size===0&&((h=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||h.call(p)))}}}}),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(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof kr?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},et=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Tr,o=l=>t(...l.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let l of s)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new nm,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)}},wo={};Lh(wo,{None:()=>om,filter:()=>sm,once:()=>Gl,toPromise:()=>am});om=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});go=Symbol.for("Jolibox.hostEmitter"),lm=()=>{let e=new et;return globalThis[go]||(globalThis[go]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[go]},kt=lm();bn=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Tr,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return cm(i,r),n(...i)}}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}};bn=Sl([Ol],bn);Eo=class{constructor(){this._onWillExecuteCommand=new Tr,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Tr,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new bn,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Uh(3e4)),this._starActivation}executeCommand(e,...t){return Bt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),wo.toPromise(wo.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}}};Eo=Sl([Ol],Eo);Jl=Symbol.for("Jolibox.commands")});function je(e,t={}){Do.emit("ERROR_REPORT",{error:e,options:t})}var Do,Jt,ut=re(()=>{"use strict";W();W();Do=new et,Jt=new et;je.debounce=xr(je,50,{leading:!0})});var Lo,hm,Fl,jl,Hl=re(()=>{"use strict";W();ut();Lo=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(i){return{}}},hm=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Fl=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[o,a,s]=i;return{headerJson:Lo(o),payloadJson:Lo(a),signature:Lo(s)}}else throw"joli_source is missing"}catch(r){return je(new Pl(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},jl=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=hm(e),o=r[2];return`${n}.${i}.${o}`}return t}});var mm,In,ql,Uo=re(()=>{"use strict";W();mm="1.4.13",In=()=>mm,ql=()=>{let e=In();return`${Ul(e)}`}});function Mo(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var pm,Vl,Bo,$l,se,vm,L,pe=re(()=>{"use strict";W();Hl();Uo();W();pm={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:xo(),adId:No(),pixelRatio:window.devicePixelRatio||1,platform:Ne.isAndroid?"android":Ne.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:In()},schema:window.location.href,platform:Ne.isAndroid?"android":Ne.isiOS?"ios":"h5"},Bo=(Vl=globalThis.joliboxJSCore)==null?void 0:Vl.env,se=Object.assign({},($l=Bo==null?void 0:Bo())!=null?$l:pm);vm=()=>{var I,A,w,R,O,D,M,S,N,J,q;let{payloadJson:e,headerJson:t,signature:r}=se.schema.length?Fl(se.schema):{},n=`${se.deviceInfo.did}-${new Date().getTime()}`,o=new URL(se.schema.length?se.schema:window.location.href).searchParams,a=(w=(A=(I=o.get("mpId"))!=null?I:o.get("appId"))!=null?A:o.get("gameId"))!=null?w:"",s=(D=(O=(R=se.clientSessionId)!=null?R:e==null?void 0:e.sessionId)!=null?O:o.get("sessionId"))!=null?D:n,l=!!((S=(M=e==null?void 0:e.testAdsMode)!=null?M:e==null?void 0:e.__testAdsMode)!=null?S:o.get("testAdsMode")==="true"),c=(q=(J=(N=e==null?void 0:e.joliboxEnv)!=null?N:e==null?void 0:e.__joliboxEnv)!=null?J:o.get("joliboxEnv"))!=null?q:"production",m=c==="staging",d=t==null?void 0:t.channel,h=new URL(window.location.href).searchParams,b=e==null?void 0:e.__shouldInterupt;return{get startTime(){var U;return(U=performance.timeOrigin)!=null?U:performance.timing.navigationStart},get testMode(){return m},get testAdsMode(){return l},get joliboxEnv(){return c},get joliSource(){var U,G;return(G=(U=h.get("joliSource"))!=null?U:o.get("joliSource"))!=null?G:null},get mpId(){var U;return(U=a!=null?a:e==null?void 0:e.id)!=null?U:""},get mpVersion(){var U;return(U=t==null?void 0:t.ver)!=null?U:In()},get mpType(){var U,G;return(G=(U=t==null?void 0:t.__mpType)!=null?U:e==null?void 0:e.__mpType)!=null?G:"game"},get platform(){var U;return((U=se.platform)!=null?U:se.deviceInfo.platform).toLowerCase()},get deviceInfo(){return se.deviceInfo},get sdkInfo(){return se.sdkInfo},get hostInfo(){return se.hostInfo},get hostUserInfo(){return se.hostUserInfo},get sessionId(){var U,G;return(G=(U=se.clientSessionId)!=null?U:s)!=null?G:n},get channel(){return d},get webviewId(){var U;return(U=se.webviewId)!=null?U:-1},get shouldInterupt(){return b},get from(){return e==null?void 0:e.__from},get baseApiHost(){return Bl(m)},get adId(){var U;return(U=se.deviceInfo.adId)!=null?U:se.deviceInfo.did},get language(){return se.deviceInfo.lang},get sdkEnvironment(){return Mo("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Mo("gamedistribution","jolibox")?"gamedistribution":Mo("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var V,K,Fe;let U=(V=se.deviceInfo.pixelRatio)!=null?V:1,G=(K=se.deviceInfo.statusBarHeight)!=null?K:e==null?void 0:e.__androidStatusBarHeight,j=(Fe=se.deviceInfo.navigationBarHeight)!=null?Fe:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:G!==void 0?G/U:20,navigationBarHeight:j!==void 0?j/U:10}},get abTests(){var U,G;return(G=(U=se.abValues)==null?void 0:U.split(","))!=null?G:[]},get mpInfo(){var U;return(U=se.mpInfo)!=null?U:{mpName:"unknown"}},onEnvConfigChanged:U=>{kl(se,U,Tl)},encodeJoliSourceQuery:U=>{var G,j;return t&&r?jl(X(X({},e),U),(G=o.get("joliSource"))!=null?G:""):(j=o.get("joliSource"))!=null?j:""},setDoExitDirectly:()=>{b=!1}}},L=vm()});var Go,Wl,gm,_m,Kl,ym,zl=re(()=>{"use strict";W();ut();pe();W();Go=!1,Wl=(e,t)=>e==null?!1:t in e,gm=e=>Wl(e,"kind"),_m=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Kl=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=L.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=L.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:_m(e.name)},i=xe(X({},n),{env:t.environment,isFromUser:r});r?Jt.emit("GLOBAL_USER_ERROR",e,i):Jt.emit("GLOBAL_ERROR",e,i)},ym=e=>Wl(e,"kind")&&e.kind==="USER_ERROR";Do.on("ERROR_REPORT",({error:e,options:t})=>{if(Go)return;Go=!0;let r=gm(e)&&e.raw?e.raw:e;try{let n=ym(e);Kl(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new Oo(`${i}, origin error: ${r.message}`);Pe.error(o),Kl(new Oo(o.message),{environment:t.environment},!1)}finally{Go=!1}})});var Jo,Fo=re(()=>{"use strict";ut();W();ut();Jo=e=>new Nl(e)});function Yl(e,t){let r=(n,i,o)=>{let c=i!=null?i:{},{eventType:a}=c,s=_l(c,["eventType"]),l=xe(X({tag:n,eventType:o!=null?o:a!=null?a:Mt.Other},t),{extra:X({},s)});n=="globalJsError"?je(new wn(JSON.stringify(l))):e("systemLog",l,L.webviewId)};return r.debounce=xr(r,500,{leading:!0}),r}function Xl(e){let t=(r,n,i)=>{var s;let o=(s=i&&JSON.stringify(i))!=null?s:0,a={speed_value_type:r,total_duration:n};o&&Object.assign(a,{extra:o}),e("joliboxSpeedAnalysis",a)};return t.debounce=xr(t,500,{leading:!0}),t}var Ql=re(()=>{"use strict";W();W();ut();pe()});function Zl(e,t){let r=Yl(e,t),n=Xl(r);return{track:r,trackPerformance:n}}var ec=re(()=>{"use strict";Ql()});var jo=re(()=>{"use strict"});var An,tc=re(()=>{"use strict";pe();W();W();An=class{constructor(t){this.apiHost=t;this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return E(this,null,function*(){let r=`${this.apiHost}/api/fe-configs/js-sdk/samples-config`,n=yield(yield fetch(r)).json();this.samplesConfig=n})}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:r}=this.samplesConfig;for(let[n,i]of Object.entries(r))if(i.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(n);return!1}getDevice(){var n,i,o,a,s;let{nativeSDKVersion:t,jssdkVersion:r}=L.sdkInfo;return{platform:1e3,os:L.deviceInfo.platform,appVersion:(n=t!=null?t:r)!=null?n:"1.0.0",appId:(o=(i=L.hostInfo)==null?void 0:i.aid)!=null?o:"1",model:(a=L.deviceInfo.model)!=null?a:"UnknownModel",brand:(s=L.deviceInfo.brand)!=null?s:"UnknownBrand",uuid:L.deviceInfo.did,jsSdkVersion:r,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:"GamePage",params:r}}trackEvent(t,r,n){return E(this,null,function*(){var d;if(this.checkIsSampled(t))return;let i=t.location?t.location:yield this.getLocation(),o=t.target||null,a=t.extra||null,{hostUserInfo:s}=L;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let l=this.deviceInfo,m={protocolVersion:"1.0.0",events:[xe(X({},t),{location:i,target:o,extra:a,timestamp:Date.now(),userId:(d=s==null?void 0:s.uid)!=null?d:null})],device:l,project:r};try{n?yield this.doReport(To(m),n):yield this.doReport(To(m))}catch(p){Pe.log("[Jolibox SDK] report API error",p)}})}}});var Ho=re(()=>{"use strict";ec();jo();tc()});var qo,rc,ft,Sn,ze,rr=re(()=>{"use strict";Uo();pe();W();qo=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};(rc=AbortSignal.timeout)!=null||(AbortSignal.timeout=qo);ft=class e{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20;this.getNetworkStatus=()=>this.networkRequests.length===0?!0:this.networkRequests.filter(n=>n).length/this.networkRequests.length>=.6}static getInstance(){return e._instance||(e._instance=new e),e._instance}create(t){let r=new Sn(t);return e.getInstance().httpClients.add(r),r}recordNetworkRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}},Sn=class{constructor(t){this.xua=ql();this.getJoliSource=()=>L.joliSource;var n;let r=tr(L.testMode);this.baseUrl=(n=t==null?void 0:t.baseUrl)!=null?n:r}get(t,r){return E(this,null,function*(){try{let{query:n,timeout:i}=r!=null?r:{},{headers:o}=r!=null?r:{},a=n?new URLSearchParams(n):null,s=a==null?void 0:a.toString(),l=`${this.baseUrl}${t}${s?`?${s}`:""}`,c=this.xua,m=this.getJoliSource();o=Object.assign({},o!=null?o:{},c?{"x-user-agent":c}:{},m?{"x-joli-source":m}:{});let d=yield fetch(l,{method:"GET",headers:o,credentials:"include",signal:qo(i!=null?i:3e4)});return ft.getInstance().recordNetworkRequest(!0),yield d.json()}catch(n){throw ft.getInstance().recordNetworkRequest(!1),n}})}post(t,r){return E(this,null,function*(){try{let{data:n,query:i,timeout:o}=r!=null?r:{},{headers:a}=r!=null?r:{},s=i?new URLSearchParams(i):null,l=s==null?void 0:s.toString(),c=`${this.baseUrl}${t}${l?`?${l}`:""}`,m=this.xua,d=this.getJoliSource();a=Object.assign({},a!=null?a:{},{"Content-Type":"application/json"},m?{"x-user-agent":m}:{},d?{"x-joli-source":d}:{},{"x-os-type":Ne.isAndroid?"ANDROID":Ne.isiOS?"IOS":"PC"},{"x-runtime-type":"WEB"});let p=yield fetch(c,{method:"POST",headers:a,body:JSON.stringify(n),signal:qo(o!=null?o:3e4),credentials:"include"});ft.getInstance().recordNetworkRequest(!0);let h=p.headers.get("content-type");if(h!=null&&h.includes("application/octet-stream"))try{return p.blob()}catch(b){return yield p.arrayBuffer()}if(h!=null&&h.includes("multipart/form-data")||h!=null&&h.includes("application/x-www-form-urlencoded"))try{return p.formData()}catch(b){return yield p.text()}if(h!=null&&h.includes("application/json"))try{return yield p.json()}catch(b){return yield p.text()}return p}catch(n){throw ft.getInstance().recordNetworkRequest(!1),n}})}put(t,r){return E(this,null,function*(){try{let{data:n,query:i,timeout:o}=r!=null?r:{},{headers:a}=r!=null?r:{},s=i?new URLSearchParams(i):null,l=s==null?void 0:s.toString(),c=`${this.baseUrl}${t}${l?`?${l}`:""}`,m=this.xua,d=this.getJoliSource();a=Object.assign({},a!=null?a:{},{"Content-Type":"application/json"},m?{"x-user-agent":m}:{},d?{"x-joli-source":d}:{});let p=yield fetch(c,{method:"PUT",headers:a,credentials:"include",body:JSON.stringify(n!=null?n:{})});if(!p.ok)throw ft.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${p.status}`);return ft.getInstance().recordNetworkRequest(!0),yield p.json()}catch(n){throw console.error("Error:",n),n}})}};window.JoliboxHttpClient=Sn;ze=ft.getInstance()});var Vo,Cn,$o=re(()=>{"use strict";pe();Ho();rr();W();Vo=class extends An{constructor(){super(...arguments);this.httpClient=ze.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var r;return Ml((r=L.testMode)!=null?r:!1)}doReport(r){this.httpClient.post("/report",{data:r,timeout:5e3}).catch(n=>{console.info("report error",n)})}},Cn=new Vo(tr(L.testMode))});var bm,nc=re(()=>{"use strict";zl();W();Fo();W();$o();pe();bm=(e,t)=>{var i,o,a;let r={message:t.message,stack:(i=t.stack)!=null?i:"",errorType:t.name,source:0},n={name:e,type:Mt.ErrorTrace,location:null,target:null,extra:r,timestamp:Date.now(),userId:(a=(o=L.hostUserInfo)==null?void 0:o.uid)!=null?a:null};Cn.trackEvent(n,er.WebSDK)};Jt.on("GLOBAL_ERROR",(e,t)=>{bm(t.tag,e)});Jt.on("GLOBAL_USER_ERROR",(e,t)=>{Pe.log("UserError",e,t)})});var Rn,ic=re(()=>{"use strict";Rn=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(t)});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let h=Date.now(),b=h-r;b>=this.interval&&(this.visible&&(a+=Math.min(b,this.interval+1e3),t(a)),r=h),n=requestAnimationFrame(s)},l=()=>{m(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let h=Date.now();h-r>=this.interval&&(r=h)},this.interval)},c=()=>{d(),r=Date.now(),n=requestAnimationFrame(s)},m=()=>{n&&(cancelAnimationFrame(n),n=0)},d=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",h=>{o&&(console.log("visible",h),h?c():l())});let p=this.visible;return{start(){o||(o=!0,p?c():l())},stop(){o=!1,m(),d()}}}}});var oc,ac=re(()=>{"use strict";oc=`-----BEGIN PUBLIC KEY-----
1
+ var Eh=Object.create;var ho=Object.defineProperty,Ih=Object.defineProperties,Ah=Object.getOwnPropertyDescriptor,Sh=Object.getOwnPropertyDescriptors,Ch=Object.getOwnPropertyNames,_n=Object.getOwnPropertySymbols,vl=Object.getPrototypeOf,mo=Object.prototype.hasOwnProperty,gl=Object.prototype.propertyIsEnumerable,Rh=Reflect.get;var pl=(e,t,r)=>t in e?ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,X=(e,t)=>{for(var r in t||(t={}))mo.call(t,r)&&pl(e,r,t[r]);if(_n)for(var r of _n(t))gl.call(t,r)&&pl(e,r,t[r]);return e},xe=(e,t)=>Ih(e,Sh(t));var Rr=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var _l=(e,t)=>{var r={};for(var n in e)mo.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&_n)for(var n of _n(e))t.indexOf(n)<0&&gl.call(e,n)&&(r[n]=e[n]);return r};var re=(e,t)=>()=>(e&&(t=e(e=0)),t);var po=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Oh=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ch(t))!mo.call(e,i)&&i!==r&&ho(e,i,{get:()=>t[i],enumerable:!(n=Ah(t,i))||n.enumerable});return e};var vo=(e,t,r)=>(r=e!=null?Eh(vl(e)):{},Oh(t||!e||!e.__esModule?ho(r,"default",{value:e,enumerable:!0}):r,e));var yl=(e,t,r)=>Rh(vl(e),r,t);var E=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((r=r.apply(e,t)).next())});function Uh(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function So(e){return typeof e=="string"}function Cl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Rl(e){return typeof e=="object"&&Array.isArray(e)}function Bh(e){return typeof e=="undefined"}function Mh(e){return Bh(e)||e===null}function Gh(e){return typeof e=="function"}function Ol(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function kl(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,o){for(let a in o)if(Object.prototype.hasOwnProperty.call(o,a)){let s=i[a],l=o[a],c=r(s,l,a,i,o);c!==void 0?i[a]=c:El(l)&&El(s)?i[a]=n(Ao({},s),l):Array.isArray(l)&&Array.isArray(s)?i[a]=[...s,...l]:i[a]=l}return i}return n(e,t)}function El(e){return e&&typeof e=="object"&&e.constructor===Object}function Tl(e,t){if(Array.isArray(e))return e.concat(t)}function xr(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:l=!0}=r,c=()=>(a=e.apply(o,i),i=void 0,o=void 0,a),m=function(...d){i=d,o=this;let p=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,l&&!p&&c()},t),p)return c()};return m.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},m.flush=()=>{if(n)return clearTimeout(n),n=null,c()},m}function jh(e,t){return(...r)=>t(e,...r)}function Dl(e){return t=>jh(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new Fh(`${i}`))}})}function Or(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function yn(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((i,o)=>(i[o]=String(n[o]),i),{})}return e[r]})}function Wh(e){let t=e.location?yn(e.location,Al):null,r=e.target?yn(e.target,Al):null;return yn(Dh(Ao({},e),{location:t,target:r}),$h)}function To(e){let t=e.events.map(n=>Wh(n)),r=yn(e.device,Kh);return[e.protocolVersion,t,r,e.project]}function zh(){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}}function Po(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com"||a==="mporia.com"||a==="pingplus.ai")return`${o}.${a}`}return`${o}.jolibox.com`}function Bl(e){return Po("app","stg-app",e)}function tr(e){return`https://${Po("api","stg-api",e)}`}function rm(e){return Po("collect","stg-collect",e)}function Ml(e){return`https://${rm(e)}`}function am(e){return new Promise(t=>Gl(e)(t))}function Gl(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function sm(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Tr(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function cm(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)dm(e[n],t[n])}function dm(e,t){if(So(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Gh(t)){try{if(e instanceof t)return}catch(r){}if(!Mh(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")}}function um(){return typeof globalThis!="undefined"?globalThis[Jl]:void 0}function fm(e){typeof globalThis!="undefined"&&(globalThis[Jl]=e)}function Ae(e=!1){let t=um();if(!e&&t)return t;let r=new bn,n=new Eo,i={registerCommand(o,a,s){r.registerCommand({id:o,handler:a,metadata:s})},executeCommand(o,...a){return n.executeCommand(o,...a)},excuteCommandSync(o,...a){return n.executeCommandThowErr(o,...a)}};return fm(i),i}var Io,kh,Th,xh,bl,Nh,Ph,wl,Ao,Dh,Lh,Sl,Bt,Jh,Co,Ro,xl,Nl,Fh,Pl,wn,En,Oo,Pe,_o,Hh,ko,Il,qh,Mt,er,Vh,Al,$h,Kh,We,Zt,Yh,Ne,Xh,Qh,Zh,Ll,xo,No,em,tm,Ul,Gt,yo,ae,nm,im,kr,Tr,et,wo,om,go,lm,kt,bn,Eo,Jl,W=re(()=>{"use strict";Io=Object.defineProperty,kh=Object.defineProperties,Th=Object.getOwnPropertyDescriptor,xh=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,Nh=Object.prototype.hasOwnProperty,Ph=Object.prototype.propertyIsEnumerable,wl=(e,t,r)=>t in e?Io(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ao=(e,t)=>{for(var r in t||(t={}))Nh.call(t,r)&&wl(e,r,t[r]);if(bl)for(var r of bl(t))Ph.call(t,r)&&wl(e,r,t[r]);return e},Dh=(e,t)=>kh(e,xh(t)),Lh=(e,t)=>{for(var r in t)Io(e,r,{get:t[r],enumerable:!0})},Sl=(e,t,r,n)=>{for(var i=n>1?void 0:n?Th(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&Io(t,r,i),i},Bt=(e,t,r)=>new Promise((n,i)=>{var o=l=>{try{s(r.next(l))}catch(c){i(c)}},a=l=>{try{s(r.throw(l))}catch(c){i(c)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((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 i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,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}Jh=(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))(Jh||{}),Co=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}},Ro=class extends Co{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},xl=class extends Co{constructor(){super(...arguments),this.kind="USER_ERROR"}},Nl=class extends xl{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},Fh=class extends xl{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Pl=class extends Ro{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},wn=class extends Ro{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},En=class extends Co{constructor(e,t,r,n,i){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),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},Oo=class extends Ro{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Pe={log:Or("log"),warn:Or("warn"),info:Or("info"),error:Or("error"),debug:Or("debug")};Object.assign(globalThis,{logger:Pe});_o=Symbol.for("Jolibox.canIUseMap"),Hh={};globalThis[_o]||(globalThis[_o]=Hh);ko={get config(){return globalThis[_o]}},Il=Symbol.for("Jolibox.canIUseMap.native"),qh={};globalThis[Il]||(globalThis[Il]=qh);Mt=(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))(Mt||{}),er=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(er||{}),Vh=(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))(Vh||{}),Al=["name","params"],$h=["name","type","location","target","extra","timestamp","userId"],Kh=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];We=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});zh();Zt=typeof window=="undefined",Yh=()=>!Zt&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),Ne={isiOS:!Zt&&(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:!Zt&&navigator.userAgent.includes("Android"),isMac:!Zt&&navigator.userAgent.includes("Mac"),isFacebook:!Zt&&navigator.userAgent.includes("FB_IAB"),isPC:!Zt&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Xh=()=>Ne.isiOS?"iOS":Ne.isAndroid?"Android":Ne.isMac?"Mac":Ne.isFacebook?"Facebook":"PC",Qh="device_id",Zh="advertising_id",Ll=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,We()),window.__joliboxLocalStorage__.getItem(e)),xo=()=>new URLSearchParams(window.location.search).get("deviceId")||Ll(Qh),No=()=>new URLSearchParams(window.location.search).get("advertisingId")||Ll(Zh),em=e=>e.charAt(0).toUpperCase()+e.slice(1),tm=()=>{var e;let t=new URLSearchParams(window.location.search);return em((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ul=e=>{if(Yh())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Xh(),n=navigator.language,i=xo(),o=No();return`${t} (${tm()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${i} adid/${o} version/${e||""}`};Gt=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=Ao({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return Bt(this,null,function*(){let r=this.config.keyGenerator(e,t),n=this.pendingRequests.get(r);if(n)return console.log(`[RequestCacheService] Reusing pending request for ${e}`),n;let i=this.requestInternal(e,t),o=this.createTimeoutPromise(),a=Promise.race([i,o]).catch(s=>Bt(this,null,function*(){if(s.message.includes("timeout")){let l=this.getValidCachedData(r);if(l)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}throw s}));this.pendingRequests.set(r,a),i.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${e}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${e}:`,s)});try{return yield a}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return Bt(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,l=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",l),l){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let d=yield this.requestAdapter.execute(e,t),p=this.requestAdapter.extractRealTimeData(d),h=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,d);return h&&!this.config.consistencyChecker(l,h)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,h,s),d):this.requestAdapter.mergeData(l,p)}catch(d){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,d),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(l):l}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let c=yield this.requestAdapter.execute(e,t),m=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,c);return m&&this.setCachedDataWithSequence(a,m,s),c})}createTimeoutPromise(){return new Promise((e,t)=>{setTimeout(()=>{t(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(e){let t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),null):t.data:null}setCachedDataWithSequence(e,t,r,n){let i=this.cache.get(e);if(i&&i.sequence>r){console.log(`[RequestCacheService] Ignoring stale cache update for ${e} (current: ${i.sequence}, incoming: ${r})`);return}let o=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:o,expiresAt:o+this.config.duration,key:e,sequence:r,metadata:n}),this.cacheSequences.set(e,r),console.log(`[RequestCacheService] Updated cache for ${e} with sequence ${r}`)}refreshCache(e,t){return Bt(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return Bt(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),o=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${o})`);let a=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,a);return s&&(this.setCachedDataWithSequence(i,s,o),console.log(`[RequestCacheService] Force updated cache for ${e}`)),a})}warmupCache(e,t){return Bt(this,null,function*(){let r=this.config.keyGenerator(e,t);if(this.pendingRequests.has(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - request in progress`);return}if(this.hasValidCache(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${e}`),yield this.forceRequest(e,t)}catch(n){console.warn(`[RequestCacheService] Cache warmup failed for ${e}:`,n)}})}clearCache(e){e?(this.cache.delete(e),this.cacheSequences.delete(e),this.pendingRequests.delete(e),console.log(`[RequestCacheService] Cleared cache for ${e}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let e=Date.now();for(let[t,r]of this.cache)e>r.expiresAt&&(this.cache.delete(t),this.cacheSequences.delete(t));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let e=Date.now(),t=0,r=0;for(let n of this.cache.values())e>n.expiresAt?r++:t++;return{cacheCount:this.cache.size,validCount:t,expiredCount:r,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(e){let t=this.cache.get(e);return t?Date.now()<=t.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(e){return this.pendingRequests.has(e)}getCacheSequence(e){return this.cacheSequences.get(e)}},yo=class bo{constructor(t){this.element=t,this.next=bo.Undefined,this.prev=bo.Undefined}};yo.Undefined=new yo(void 0);ae=yo,nm=class{constructor(){this._first=ae.Undefined,this._last=ae.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ae.Undefined}clear(){let e=this._first;for(;e!==ae.Undefined;){let t=e.next;e.prev=ae.Undefined,e.next=ae.Undefined,e=t}this._first=ae.Undefined,this._last=ae.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new ae(e);if(this._first===ae.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==ae.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ae.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ae.Undefined&&e.next!==ae.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ae.Undefined&&e.next===ae.Undefined?(this._first=ae.Undefined,this._last=ae.Undefined):e.next===ae.Undefined?(this._last=this._last.prev,this._last.next=ae.Undefined):e.prev===ae.Undefined&&(this._first=this._first.next,this._first.prev=ae.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ae.Undefined;)yield e.element,e=e.next}},im=0,kr=class{constructor(e){this.value=e,this.id=im++}},Tr=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 kr&&(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,i,o,a,s,l;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new kr(t);return this._listeners?this._listeners instanceof kr?this._listeners=[this._listeners,c]:this._listeners.push(c):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=c,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(l=(s=this.options)==null?void 0:s.onDidAddListener)==null||l.call(s,this),this._size++,()=>{var m,d,p,h;if(!this._disposed){if(this._listeners instanceof kr)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(d=(m=this.options)==null?void 0:m.onDidRemoveLastListener)==null||d.call(m));else if(this._listeners){let b=this._listeners.indexOf(c);b>=0&&(this._listeners.splice(b,1),this._size--,this._size===0&&((h=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||h.call(p)))}}}}),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(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof kr?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},et=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Tr,o=l=>t(...l.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let l of s)t(...l.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new nm,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)}},wo={};Lh(wo,{None:()=>om,filter:()=>sm,once:()=>Gl,toPromise:()=>am});om=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});go=Symbol.for("Jolibox.hostEmitter"),lm=()=>{let e=new et;return globalThis[go]||(globalThis[go]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[go]},kt=lm();bn=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Tr,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return cm(i,r),n(...i)}}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}};bn=Sl([Ol],bn);Eo=class{constructor(){this._onWillExecuteCommand=new Tr,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Tr,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new bn,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Uh(3e4)),this._starActivation}executeCommand(e,...t){return Bt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),wo.toPromise(wo.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}}};Eo=Sl([Ol],Eo);Jl=Symbol.for("Jolibox.commands")});function je(e,t={}){Do.emit("ERROR_REPORT",{error:e,options:t})}var Do,Jt,ut=re(()=>{"use strict";W();W();Do=new et,Jt=new et;je.debounce=xr(je,50,{leading:!0})});var Lo,hm,Fl,jl,Hl=re(()=>{"use strict";W();ut();Lo=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(i){return{}}},hm=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Fl=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[o,a,s]=i;return{headerJson:Lo(o),payloadJson:Lo(a),signature:Lo(s)}}else throw"joli_source is missing"}catch(r){return je(new Pl(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},jl=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=hm(e),o=r[2];return`${n}.${i}.${o}`}return t}});var mm,In,ql,Uo=re(()=>{"use strict";W();mm="1.4.14",In=()=>mm,ql=()=>{let e=In();return`${Ul(e)}`}});function Mo(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var pm,Vl,Bo,$l,se,vm,L,pe=re(()=>{"use strict";W();Hl();Uo();W();pm={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:xo(),adId:No(),pixelRatio:window.devicePixelRatio||1,platform:Ne.isAndroid?"android":Ne.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:In()},schema:window.location.href,platform:Ne.isAndroid?"android":Ne.isiOS?"ios":"h5"},Bo=(Vl=globalThis.joliboxJSCore)==null?void 0:Vl.env,se=Object.assign({},($l=Bo==null?void 0:Bo())!=null?$l:pm);vm=()=>{var I,A,w,R,O,D,M,S,N,J,q;let{payloadJson:e,headerJson:t,signature:r}=se.schema.length?Fl(se.schema):{},n=`${se.deviceInfo.did}-${new Date().getTime()}`,o=new URL(se.schema.length?se.schema:window.location.href).searchParams,a=(w=(A=(I=o.get("mpId"))!=null?I:o.get("appId"))!=null?A:o.get("gameId"))!=null?w:"",s=(D=(O=(R=se.clientSessionId)!=null?R:e==null?void 0:e.sessionId)!=null?O:o.get("sessionId"))!=null?D:n,l=!!((S=(M=e==null?void 0:e.testAdsMode)!=null?M:e==null?void 0:e.__testAdsMode)!=null?S:o.get("testAdsMode")==="true"),c=(q=(J=(N=e==null?void 0:e.joliboxEnv)!=null?N:e==null?void 0:e.__joliboxEnv)!=null?J:o.get("joliboxEnv"))!=null?q:"production",m=c==="staging",d=t==null?void 0:t.channel,h=new URL(window.location.href).searchParams,b=e==null?void 0:e.__shouldInterupt;return{get startTime(){var U;return(U=performance.timeOrigin)!=null?U:performance.timing.navigationStart},get testMode(){return m},get testAdsMode(){return l},get joliboxEnv(){return c},get joliSource(){var U,G;return(G=(U=h.get("joliSource"))!=null?U:o.get("joliSource"))!=null?G:null},get mpId(){var U;return(U=a!=null?a:e==null?void 0:e.id)!=null?U:""},get mpVersion(){var U;return(U=t==null?void 0:t.ver)!=null?U:In()},get mpType(){var U,G;return(G=(U=t==null?void 0:t.__mpType)!=null?U:e==null?void 0:e.__mpType)!=null?G:"game"},get platform(){var U;return((U=se.platform)!=null?U:se.deviceInfo.platform).toLowerCase()},get deviceInfo(){return se.deviceInfo},get sdkInfo(){return se.sdkInfo},get hostInfo(){return se.hostInfo},get hostUserInfo(){return se.hostUserInfo},get sessionId(){var U,G;return(G=(U=se.clientSessionId)!=null?U:s)!=null?G:n},get channel(){return d},get webviewId(){var U;return(U=se.webviewId)!=null?U:-1},get shouldInterupt(){return b},get from(){return e==null?void 0:e.__from},get baseApiHost(){return Bl(m)},get adId(){var U;return(U=se.deviceInfo.adId)!=null?U:se.deviceInfo.did},get language(){return se.deviceInfo.lang},get sdkEnvironment(){return Mo("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Mo("gamedistribution","jolibox")?"gamedistribution":Mo("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var V,K,Fe;let U=(V=se.deviceInfo.pixelRatio)!=null?V:1,G=(K=se.deviceInfo.statusBarHeight)!=null?K:e==null?void 0:e.__androidStatusBarHeight,j=(Fe=se.deviceInfo.navigationBarHeight)!=null?Fe:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:G!==void 0?G/U:20,navigationBarHeight:j!==void 0?j/U:10}},get abTests(){var U,G;return(G=(U=se.abValues)==null?void 0:U.split(","))!=null?G:[]},get mpInfo(){var U;return(U=se.mpInfo)!=null?U:{mpName:"unknown"}},onEnvConfigChanged:U=>{kl(se,U,Tl)},encodeJoliSourceQuery:U=>{var G,j;return t&&r?jl(X(X({},e),U),(G=o.get("joliSource"))!=null?G:""):(j=o.get("joliSource"))!=null?j:""},setDoExitDirectly:()=>{b=!1}}},L=vm()});var Go,Wl,gm,_m,Kl,ym,zl=re(()=>{"use strict";W();ut();pe();W();Go=!1,Wl=(e,t)=>e==null?!1:t in e,gm=e=>Wl(e,"kind"),_m=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Kl=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=L.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=L.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:_m(e.name)},i=xe(X({},n),{env:t.environment,isFromUser:r});r?Jt.emit("GLOBAL_USER_ERROR",e,i):Jt.emit("GLOBAL_ERROR",e,i)},ym=e=>Wl(e,"kind")&&e.kind==="USER_ERROR";Do.on("ERROR_REPORT",({error:e,options:t})=>{if(Go)return;Go=!0;let r=gm(e)&&e.raw?e.raw:e;try{let n=ym(e);Kl(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new Oo(`${i}, origin error: ${r.message}`);Pe.error(o),Kl(new Oo(o.message),{environment:t.environment},!1)}finally{Go=!1}})});var Jo,Fo=re(()=>{"use strict";ut();W();ut();Jo=e=>new Nl(e)});function Yl(e,t){let r=(n,i,o)=>{let c=i!=null?i:{},{eventType:a}=c,s=_l(c,["eventType"]),l=xe(X({tag:n,eventType:o!=null?o:a!=null?a:Mt.Other},t),{extra:X({},s)});n=="globalJsError"?je(new wn(JSON.stringify(l))):e("systemLog",l,L.webviewId)};return r.debounce=xr(r,500,{leading:!0}),r}function Xl(e){let t=(r,n,i)=>{var s;let o=(s=i&&JSON.stringify(i))!=null?s:0,a={speed_value_type:r,total_duration:n};o&&Object.assign(a,{extra:o}),e("joliboxSpeedAnalysis",a)};return t.debounce=xr(t,500,{leading:!0}),t}var Ql=re(()=>{"use strict";W();W();ut();pe()});function Zl(e,t){let r=Yl(e,t),n=Xl(r);return{track:r,trackPerformance:n}}var ec=re(()=>{"use strict";Ql()});var jo=re(()=>{"use strict"});var An,tc=re(()=>{"use strict";pe();W();W();An=class{constructor(t){this.apiHost=t;this.deviceInfo=null;this.samplesConfig=null;this.fetchSamplesConfig()}fetchSamplesConfig(){return E(this,null,function*(){let r=`${this.apiHost}/api/fe-configs/js-sdk/samples-config`,n=yield(yield fetch(r)).json();this.samplesConfig=n})}checkIsSampled(t){if(!this.samplesConfig)return!1;let{samples:r}=this.samplesConfig;for(let[n,i]of Object.entries(r))if(i.includes(t.name))return Math.floor(Math.random()*101)<parseFloat(n);return!1}getDevice(){var n,i,o,a,s;let{nativeSDKVersion:t,jssdkVersion:r}=L.sdkInfo;return{platform:1e3,os:L.deviceInfo.platform,appVersion:(n=t!=null?t:r)!=null?n:"1.0.0",appId:(o=(i=L.hostInfo)==null?void 0:i.aid)!=null?o:"1",model:(a=L.deviceInfo.model)!=null?a:"UnknownModel",brand:(s=L.deviceInfo.brand)!=null?s:"UnknownBrand",uuid:L.deviceInfo.did,jsSdkVersion:r,extra:{}}}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:"GamePage",params:r}}trackEvent(t,r,n){return E(this,null,function*(){var d;if(this.checkIsSampled(t))return;let i=t.location?t.location:yield this.getLocation(),o=t.target||null,a=t.extra||null,{hostUserInfo:s}=L;this.deviceInfo||(this.deviceInfo=yield this.getDevice());let l=this.deviceInfo,m={protocolVersion:"1.0.0",events:[xe(X({},t),{location:i,target:o,extra:a,timestamp:Date.now(),userId:(d=s==null?void 0:s.uid)!=null?d:null})],device:l,project:r};try{n?yield this.doReport(To(m),n):yield this.doReport(To(m))}catch(p){Pe.log("[Jolibox SDK] report API error",p)}})}}});var Ho=re(()=>{"use strict";ec();jo();tc()});var qo,rc,ft,Sn,ze,rr=re(()=>{"use strict";Uo();pe();W();qo=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};(rc=AbortSignal.timeout)!=null||(AbortSignal.timeout=qo);ft=class e{constructor(){this.httpClients=new WeakSet;this.networkRequests=[];this.maxRequestsToTrack=20;this.getNetworkStatus=()=>this.networkRequests.length===0?!0:this.networkRequests.filter(n=>n).length/this.networkRequests.length>=.6}static getInstance(){return e._instance||(e._instance=new e),e._instance}create(t){let r=new Sn(t);return e.getInstance().httpClients.add(r),r}recordNetworkRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxRequestsToTrack&&this.networkRequests.shift()}},Sn=class{constructor(t){this.xua=ql();this.getJoliSource=()=>L.joliSource;var n;let r=tr(L.testMode);this.baseUrl=(n=t==null?void 0:t.baseUrl)!=null?n:r}get(t,r){return E(this,null,function*(){try{let{query:n,timeout:i}=r!=null?r:{},{headers:o}=r!=null?r:{},a=n?new URLSearchParams(n):null,s=a==null?void 0:a.toString(),l=`${this.baseUrl}${t}${s?`?${s}`:""}`,c=this.xua,m=this.getJoliSource();o=Object.assign({},o!=null?o:{},c?{"x-user-agent":c}:{},m?{"x-joli-source":m}:{});let d=yield fetch(l,{method:"GET",headers:o,credentials:"include",signal:qo(i!=null?i:3e4)});return ft.getInstance().recordNetworkRequest(!0),yield d.json()}catch(n){throw ft.getInstance().recordNetworkRequest(!1),n}})}post(t,r){return E(this,null,function*(){try{let{data:n,query:i,timeout:o}=r!=null?r:{},{headers:a}=r!=null?r:{},s=i?new URLSearchParams(i):null,l=s==null?void 0:s.toString(),c=`${this.baseUrl}${t}${l?`?${l}`:""}`,m=this.xua,d=this.getJoliSource();a=Object.assign({},a!=null?a:{},{"Content-Type":"application/json"},m?{"x-user-agent":m}:{},d?{"x-joli-source":d}:{},{"x-os-type":Ne.isAndroid?"ANDROID":Ne.isiOS?"IOS":"PC"},{"x-runtime-type":"WEB"});let p=yield fetch(c,{method:"POST",headers:a,body:JSON.stringify(n),signal:qo(o!=null?o:3e4),credentials:"include"});ft.getInstance().recordNetworkRequest(!0);let h=p.headers.get("content-type");if(h!=null&&h.includes("application/octet-stream"))try{return p.blob()}catch(b){return yield p.arrayBuffer()}if(h!=null&&h.includes("multipart/form-data")||h!=null&&h.includes("application/x-www-form-urlencoded"))try{return p.formData()}catch(b){return yield p.text()}if(h!=null&&h.includes("application/json"))try{return yield p.json()}catch(b){return yield p.text()}return p}catch(n){throw ft.getInstance().recordNetworkRequest(!1),n}})}put(t,r){return E(this,null,function*(){try{let{data:n,query:i,timeout:o}=r!=null?r:{},{headers:a}=r!=null?r:{},s=i?new URLSearchParams(i):null,l=s==null?void 0:s.toString(),c=`${this.baseUrl}${t}${l?`?${l}`:""}`,m=this.xua,d=this.getJoliSource();a=Object.assign({},a!=null?a:{},{"Content-Type":"application/json"},m?{"x-user-agent":m}:{},d?{"x-joli-source":d}:{});let p=yield fetch(c,{method:"PUT",headers:a,credentials:"include",body:JSON.stringify(n!=null?n:{})});if(!p.ok)throw ft.getInstance().recordNetworkRequest(!1),new Error(`HTTP error! status: ${p.status}`);return ft.getInstance().recordNetworkRequest(!0),yield p.json()}catch(n){throw console.error("Error:",n),n}})}};window.JoliboxHttpClient=Sn;ze=ft.getInstance()});var Vo,Cn,$o=re(()=>{"use strict";pe();Ho();rr();W();Vo=class extends An{constructor(){super(...arguments);this.httpClient=ze.create({baseUrl:this.apiBaseURL})}get apiBaseURL(){var r;return Ml((r=L.testMode)!=null?r:!1)}doReport(r){this.httpClient.post("/report",{data:r,timeout:5e3}).catch(n=>{console.info("report error",n)})}},Cn=new Vo(tr(L.testMode))});var bm,nc=re(()=>{"use strict";zl();W();Fo();W();$o();pe();bm=(e,t)=>{var i,o,a;let r={message:t.message,stack:(i=t.stack)!=null?i:"",errorType:t.name,source:0},n={name:e,type:Mt.ErrorTrace,location:null,target:null,extra:r,timestamp:Date.now(),userId:(a=(o=L.hostUserInfo)==null?void 0:o.uid)!=null?a:null};Cn.trackEvent(n,er.WebSDK)};Jt.on("GLOBAL_ERROR",(e,t)=>{bm(t.tag,e)});Jt.on("GLOBAL_USER_ERROR",(e,t)=>{Pe.log("UserError",e,t)})});var Rn,ic=re(()=>{"use strict";Rn=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(t)});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let h=Date.now(),b=h-r;b>=this.interval&&(this.visible&&(a+=Math.min(b,this.interval+1e3),t(a)),r=h),n=requestAnimationFrame(s)},l=()=>{m(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let h=Date.now();h-r>=this.interval&&(r=h)},this.interval)},c=()=>{d(),r=Date.now(),n=requestAnimationFrame(s)},m=()=>{n&&(cancelAnimationFrame(n),n=0)},d=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",h=>{o&&(console.log("visible",h),h?c():l())});let p=this.visible;return{start(){o||(o=!0,p?c():l())},stop(){o=!1,m(),d()}}}}});var oc,ac=re(()=>{"use strict";oc=`-----BEGIN PUBLIC KEY-----
2
2
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs29BUZPZdQwNDEYtXufp
3
3
  IGF40RBoddFzoD2ixl6PjyKWFXF8kxGS++HNtLspxhLvWoE12IZvrP7+whSpgHcy
4
4
  4ryuW86mOdHnP9iyeK69GosHz3lVhQjF9UdhJDXB7P/zdj3VlVzZIj0yL+YvZjO0
@@ -255,7 +255,7 @@ or `);this.errors.push(o)}return n}},Hn=class extends ve{constructor(...t){super
255
255
  width: 100%;
256
256
  height: 100%;
257
257
  }
258
- `,Xu=e=>{let{state:t}=e,{afterAd:r,adDismissed:n,adViewed:i,adBreakDone:o,adLoaded:a,adLinkClicked:s,visible:l,src:c}=t,[m,d]=_t(!1),p=b=>{var I,A,w,R;d(!1),l.value=!1,b==="dismiss"?(I=n.value)==null||I.call(n):b==="viewed"&&((A=i.value)==null||A.call(i)),(w=r.value)==null||w.call(r),(R=o.value)==null||R.call(o)},h=()=>{var b;(b=a.value)==null||b.call(a)};return hr("appsrockets_ad_dismissed",()=>p("dismiss")),hr("appsrockets_ad_rewarded",()=>p("viewed")),hr("appsrockets_ad_completed",()=>p("viewed")),hr("appsrockets_ad_skipped",()=>p("viewed")),hr("appsrockets_ad_clicked",b=>{var I;return(I=s.value)==null?void 0:I.call(s,b)}),hr("appsrockets_ad_loaded",()=>d(!0)),l.value?$("div",{className:P_,style:{display:m?"flex":"none"},children:l.value&&$("iframe",{src:c.value,onLoad:h,allowFullScreen:!0,allow:"autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-modals allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation allow-top-navigation allow-top-navigation-by-user-activation allow-top-navigation-to-custom-protocols"})}):null};function Et(e,t,r){return(t=D_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function D_(e){var t=L_(e,"string");return typeof t=="symbol"?t:t+""}function L_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Is=class{constructor(t,r){Et(this,"name","APPSROCKETS"),Et(this,"initialized",!1),Et(this,"initCompleter",null),Et(this,"context",void 0),Et(this,"adsOverlay",null),Et(this,"adsIsShowing",!1),Et(this,"lastUnDisplayedAdBreak",null),Et(this,"state",Yu()),Et(this,"processUrl",(n,i)=>{var o;let a=this.context.getContextInfo(),s=new URL(n),l=new URLSearchParams(s.search);return l.has("joliSource")||l.set("joliSource",a.joliSource),l.get("osType")||l.set("osType",a.osType),l.get("runtimeType")||l.set("runtimeType",a.runtimeType),l.get("mode")||l.set("mode","AFG"),l.get("deviceId")||l.set("deviceId",a.deviceId),l.get("statusBarHeight")||l.set("statusBarHeight",((o=this.context.getWindowInfo().statusBarHeight)!=null?o:0).toString()),l.get("adsType")||l.set("adsType",i),s.search=l.toString(),s.toString()}),this.context=t}init(){return E(this,null,function*(){var t;this.adsOverlay=document.createElement("div"),this.adsOverlay.setAttribute("data-placement-info","afg-appsrockets"),it($(Xu,{state:this.state}),this.adsOverlay),document.documentElement.appendChild(this.adsOverlay),this.initialized=!0,(t=this.initCompleter)==null||t.call(this)})}adConfig(t){var r;if(this.initialized){(r=t.onReady)==null||r.call(t);return}this.initCompleter=()=>{var n;(n=t.onReady)==null||n.call(t)}}adBreak(t,r){var n,i,o,a,s,l,c,m;if(!this.initialized||!this.adsOverlay||!r.params.url){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"});return}if(this.adsIsShowing){(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}let d=h=>{var b,I;(I=(b=this.context).handleLinkClicked)==null||I.call(b,h)},p=t.type==="reward"?"REWARD":"INTERSTITIAL";switch(t.type){case"preroll":{(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"start":case"browse":case"next":case"pause":{(a=t.beforeAd)==null||a.call(t);let h=()=>{var A;this.adsIsShowing=!1,(A=t.afterAd)==null||A.call(t)},b=()=>{var A;this.adsIsShowing=!1,(A=t.adBreakDone)==null||A.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"})},I=()=>{var A;this.adsIsShowing=!1,(A=t.adBreakDone)==null||A.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"noAdPreloaded"})};ue(()=>{this.adsIsShowing=!0,this.state.afterAd.value=h,this.state.adBreakDone.value=b,this.state.src.value=this.processUrl(r.params.url,p),this.state.adLinkClicked.value=d,this.state.adError.value=I,this.state.visible.value=!0});break}case"reward":{this.lastUnDisplayedAdBreak&&((l=(s=this.lastUnDisplayedAdBreak).adBreakDone)==null||l.call(s,{breakType:this.lastUnDisplayedAdBreak.type,breakName:this.lastUnDisplayedAdBreak.type==="preroll"?"":this.lastUnDisplayedAdBreak.name,breakFormat:this.lastUnDisplayedAdBreak.type==="reward"?"reward":"interstitial",breakStatus:"ignored"}),this.lastUnDisplayedAdBreak=null),(c=t.beforeAd)==null||c.call(t);let h=()=>{var D;this.adsIsShowing=!1,(D=t.afterAd)==null||D.call(t)},b={breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"ignored"},I=()=>{var D;this.adsIsShowing=!1,b.breakStatus="dismissed",(D=t.adDismissed)==null||D.call(t)},A=()=>{var D;this.adsIsShowing=!1,b.breakStatus="viewed",(D=t.adViewed)==null||D.call(t)},w=()=>{var D;this.adsIsShowing=!1,(D=t.adBreakDone)==null||D.call(t,b)},R=()=>{this.adsIsShowing=!1,b.breakStatus="noAdPreloaded"};ue(()=>{this.state.afterAd.value=h,this.state.adDismissed.value=I,this.state.adViewed.value=A,this.state.adBreakDone.value=w,this.state.adLinkClicked.value=d,this.state.adError.value=R});let O=()=>{var D;if(this.lastUnDisplayedAdBreak=null,!this.adsOverlay){(D=t.adBreakDone)==null||D.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"notReady"});return}this.adsIsShowing=!0,ue(()=>{this.state.src.value=this.processUrl(r.params.url,p),this.state.visible.value=!0})};this.lastUnDisplayedAdBreak=t,(m=t.beforeReward)==null||m.call(t,O);break}}}},Qu=()=>{window.googletag=window.googletag||{cmd:[]},window.googletag.pubadsReady||window.googletag.cmd.push(()=>{window.googletag.enableServices()})};function Re(e,t,r){return(t=U_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function U_(e){var t=B_(e,"string");return typeof t=="symbol"?t:t+""}function B_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Zu=class{constructor(e,t,r){Re(this,"adUnit",void 0),Re(this,"project",void 0),Re(this,"keyValue",void 0),Re(this,"adsContext",null),Re(this,"rewardedSlot",null),Re(this,"rewardedPayload",null),Re(this,"readyEvent",null),Re(this,"withCommand",function(){googletag.cmd.push(...arguments)}),Re(this,"init",()=>{var n;this.rewardedSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.REWARDED),this.rewardedSlot&&(this.rewardedSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().addEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().addEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.keyValue&&(Object.keys(this.keyValue).forEach(i=>{var o;(o=this.rewardedSlot)==null||o.setTargeting(i,this.keyValue[i])}),Object.keys(this.keyValue).includes("project")||(n=this.rewardedSlot)==null||n.setTargeting("project",this.project)),googletag.display(this.rewardedSlot))}),Re(this,"destroy",n=>{var i,o;this.rewardedPayload=null,this.readyEvent=null,googletag.pubads().removeEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().removeEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().removeEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().removeEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.rewardedSlot&&(googletag.destroySlots([this.rewardedSlot]),this.rewardedSlot=null),(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),Re(this,"reinit",n=>{this.destroy(n),this.init()}),Re(this,"handleSlotReady",n=>{n.slot===this.rewardedSlot&&(this.readyEvent=n)}),Re(this,"handleSlotClosed",n=>{var i,o;if(this.adsContext&&n.slot===this.rewardedSlot){let a=this.rewardedPayload?"viewed":"dismissed";a==="viewed"?this.adsContext.adViewed():this.adsContext.adDismissed(),(o=(i=this.adsContext).afterAd)==null||o.call(i),this.withCommand(()=>{this.reinit(a)})}}),Re(this,"handleSlotGranted",n=>{this.adsContext&&n.slot===this.rewardedSlot&&(this.rewardedPayload=n.payload)}),Re(this,"handleSlotRenderEnded",n=>{n.slot===this.rewardedSlot&&n.isEmpty&&this.adsContext&&this.withCommand(()=>{this.reinit("frequencyCapped")})}),Re(this,"requestAds",n=>{this.withCommand(()=>{if(this.adsContext){this.destroy("ignored");return}if(this.rewardedSlot||this.init(),this.adsContext=n,!this.rewardedSlot){this.reinit("notReady");return}if(this.readyEvent)this.adsContext.beforeReward(()=>{var i,o,a;(o=(i=this.adsContext)==null?void 0:i.beforeAd)==null||o.call(i),(a=this.readyEvent)==null||a.makeRewardedVisible()});else{let i=o=>{o.slot===this.rewardedSlot&&this.adsContext&&(googletag.pubads().removeEventListener("rewardedSlotReady",i),this.readyEvent=o,this.adsContext.beforeReward(()=>{var a,s,l;(s=(a=this.adsContext)==null?void 0:a.beforeAd)==null||s.call(a),(l=this.readyEvent)==null||l.makeRewardedVisible()}))};googletag.pubads().addEventListener("rewardedSlotReady",i),window.setTimeout(()=>{this.readyEvent||(this.reinit("timeout"),googletag.pubads().removeEventListener("rewardedSlotReady",i))},500)}})}),this.adUnit=e,this.project=t,this.keyValue=r,Qu(),this.withCommand(()=>{this.init()})}};function Ge(e,t,r){return(t=M_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function M_(e){var t=G_(e,"string");return typeof t=="symbol"?t:t+""}function G_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var As=class{constructor(t,r,n){var i=this;Ge(this,"adUnit",void 0),Ge(this,"project",void 0),Ge(this,"keyValue",void 0),Ge(this,"adsContext",null),Ge(this,"gamingInterstitialSlot",null),Ge(this,"readyEvent",null),Ge(this,"isRetrying",!1),Ge(this,"withCommand",function(){googletag.cmd.push(...arguments)}),Ge(this,"init",()=>{var o;this.gamingInterstitialSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL),this.gamingInterstitialSlot&&(this.gamingInterstitialSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("gameManualInterstitialSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("gameManualInterstitialSlotClosed",this.handleSlotClosed),this.keyValue&&(Object.keys(this.keyValue).forEach(a=>{var s;(s=this.gamingInterstitialSlot)==null||s.setTargeting(a,this.keyValue[a])}),Object.keys(this.keyValue).includes("project")||(o=this.gamingInterstitialSlot)==null||o.setTargeting("project",this.project)),googletag.display(this.gamingInterstitialSlot))}),Ge(this,"destroy",function(o){var a,s;(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1])&&((s=(a=i.adsContext)==null?void 0:a.onEnd)==null||s.call(a,o),o!=="ignored"&&(i.adsContext=null)),googletag.pubads().removeEventListener("gameManualInterstitialSlotReady",i.handleSlotReady),googletag.pubads().removeEventListener("gameManualInterstitialSlotClosed",i.handleSlotClosed),i.gamingInterstitialSlot&&(googletag.destroySlots([i.gamingInterstitialSlot]),i.gamingInterstitialSlot=null,i.readyEvent=null)}),Ge(this,"reinit",function(o){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;i.destroy(o,a),i.init()}),Ge(this,"handleSlotReady",o=>{this.gamingInterstitialSlot===o.slot&&(this.readyEvent=o)}),Ge(this,"handleSlotClosed",o=>{var a,s;this.adsContext&&this.gamingInterstitialSlot===o.slot&&((s=(a=this.adsContext).afterAd)==null||s.call(a),this.withCommand(()=>{this.reinit("viewed")}))}),Ge(this,"requestAds",o=>{this.withCommand(()=>{var a,s,l;if(this.adsContext){this.destroy("ignored");return}if(this.gamingInterstitialSlot||this.init(),this.adsContext=o,!this.gamingInterstitialSlot){this.reinit("notReady");return}this.readyEvent?((a=o.beforeAd)==null||a.call(o),this.readyEvent.makeGameManualInterstitialVisible()):((l=(s=this.adsContext).onEnd)==null||l.call(s,"frequencyCapped"),this.adsContext=null,this.isRetrying||(this.isRetrying=!0,window.setTimeout(()=>{this.readyEvent||this.withCommand(()=>{this.reinit("frequencyCapped",!1)}),this.isRetrying=!1},31e3)))})}),Qu(),this.adUnit=t,this.project=r,this.keyValue=n,this.withCommand(()=>{this.init()})}};function Wt(e,t,r){return(t=J_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function J_(e){var t=F_(e,"string");return typeof t=="symbol"?t:t+""}function F_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ss=class{constructor(t,r){Wt(this,"name","GOOGLE_GPT"),Wt(this,"context",void 0),Wt(this,"contextInfo",void 0),Wt(this,"initParams",void 0),Wt(this,"rewardAdManager",void 0),Wt(this,"interstitialManager",void 0),Wt(this,"insertScript",()=>{let n="jolibox-google-gpt",i=document.getElementById(n);i||(i=window.document.createElement("script"),i.id=n,i.async=!0,i.src="https://securepubads.g.doubleclick.net/tag/js/gpt.js",i.crossOrigin="anonymous",document.head.appendChild(i))}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.initParams=r,this.insertScript()}init(){return E(this,null,function*(){let t=this.contextInfo.testAdsMode?"/22639388115/rewarded_web_example":this.initParams.rewardedSlot,r=this.contextInfo.testAdsMode?"/6355419/Travel/Europe/France/Paris":this.initParams.interstitialSlot,n=`minigame-${this.contextInfo.runtimeType==="APP"?"app":"h5"}`;t&&(this.rewardAdManager=new Zu(t,n,this.initParams.keyValue)),r&&(this.interstitialManager=new As(r,n,this.initParams.keyValue))})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:a})}});break}default:{if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}this.interstitialManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,onEnd:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:a})}});break}}}};function ns(e,t,r){return(t=j_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j_(e){var t=H_(e,"string");return typeof t=="symbol"?t:t+""}function H_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Cs=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GAME";ns(this,"context",void 0),ns(this,"placement","GAME"),ns(this,"contextInfo",void 0),this.context=t,this.placement=r,this.contextInfo=this.context.getContextInfo()}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:this.placement==="GAME"?"GamePage":"DramaPage",params:r}}getDevice(){var t,r,n,i;return{platform:(t=this.contextInfo.platform)!=null?t:Su.WebSDK,os:this.contextInfo.osType+"_"+this.contextInfo.runtimeType,appVersion:"1.0.0",appId:(r=this.contextInfo.hostAppId)!=null?r:"1",model:(n=this.contextInfo.deviceModel)!=null?n:"UnknownModel",brand:(i=this.contextInfo.deviceBrand)!=null?i:"UnknownBrand",uuid:this.contextInfo.deviceId,jsSdkVersion:"1.0.0",extra:{}}}serialize(t,r){var n;let i={protocolVersion:"1.0.0",events:[{name:t,type:Iu.System,location:this.getLocation(),target:null,extra:r,timestamp:Date.now(),userId:(n=this.contextInfo.userId)!=null?n:null}],device:this.getDevice(),project:Au.WebSDK};return Kv(i)}};function Le(e,t,r){return(t=q_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function q_(e){var t=V_(e,"string");return typeof t=="symbol"?t:t+""}function V_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var an=class{constructor(t){Le(this,"context",void 0),Le(this,"adsTrackSerializer",void 0),Le(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo(),this.adsTrackSerializer=new Cs(this.context)}getRequestContextData(t){var r,n;this.contextInfo=this.context.getContextInfo();let{width:i,height:o}=this.context.getWindowInfo();return{report:JSON.stringify(this.adsTrackSerializer.serialize(t,{sessionId:this.contextInfo.sessionId,objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId,testAdsMode:this.contextInfo.testAdsMode})),osType:this.contextInfo.osType,runtimeType:this.contextInfo.runtimeType,sessionId:this.contextInfo.sessionId,deviceId:this.contextInfo.deviceId,adId:this.contextInfo.adId,deviceModel:(r=this.contextInfo.deviceModel)!=null?r:"UnknownModel",deviceBrand:(n=this.contextInfo.deviceBrand)!=null?n:"UnknownBrand",dimension:{width:i,height:o}}}getRequestBizParams(){return{objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId}}},qi=class{constructor(t,r){var n=this;Le(this,"context",void 0),Le(this,"contextInfo",void 0),Le(this,"requestContext",void 0),Le(this,"pendingAFGAdsInfo",{REWARD:Promise.resolve(null),INTERSTITIAL:Promise.resolve(null)}),Le(this,"pendingAFVAdsInfo",Promise.resolve(null)),Le(this,"doFetchAdsInfo",i=>E(this,null,function*(){let o=i==="afv"?"AdsAFVSDKRequest":"AdsAFGSDKAdBreak",a=[];switch(i){case"afv":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}case"reward":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}default:{a=["INTERSTITIAL"];break}}let s=i==="afv"?void 0:"cached",{data:l,code:c}=yield this.context.httpClient.post("/api/ads/info",{data:{contextData:this.requestContext.getRequestContextData(o),bizParams:this.requestContext.getRequestBizParams(),adsTypes:a,testAdsMode:this.contextInfo.testAdsMode,name:s}});return c==="SUCCESS"||c==="BYPASS_ADS"?{code:c,data:l}:null})),Le(this,"cacheRewardInfo",()=>{this.pendingAFGAdsInfo.REWARD=this.doFetchAdsInfo("reward").catch(()=>null)}),Le(this,"cacheInterstitialInfo",i=>{this.pendingAFGAdsInfo.INTERSTITIAL=this.doFetchAdsInfo(i).catch(()=>null)}),Le(this,"cacheAFVInfo",()=>{this.pendingAFVAdsInfo=this.doFetchAdsInfo("afv").catch(()=>null)}),Le(this,"cacheNextAFGAdsInfo",i=>E(this,null,function*(){i==="reward"?this.cacheRewardInfo():this.cacheInterstitialInfo(i)})),Le(this,"getAFGAdsInfo",i=>E(this,null,function*(){let o=yield i==="reward"?this.pendingAFGAdsInfo.REWARD:this.pendingAFGAdsInfo.INTERSTITIAL;return this.cacheNextAFGAdsInfo(i),o})),Le(this,"getAFVAdsInfo",function(){return E(this,arguments,function*(){if(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0]){let i=yield n.pendingAFVAdsInfo;return n.cacheAFVInfo(),i}else return n.cacheAFVInfo(),yield n.pendingAFVAdsInfo})}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.requestContext=new an(t),r!=null&&r.reward&&this.cacheRewardInfo(),r!=null&&r.interstitial&&this.cacheInterstitialInfo("start"),r!=null&&r.afv&&this.cacheAFVInfo()}};function $_(e,t,r){return(t=K_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function K_(e){var t=W_(e,"string");return typeof t=="symbol"?t:t+""}function W_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var z_=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(e)try{e(...r)}catch(i){console.error("[JoliboxSDK] Callback error:",i)}},Vi=class{constructor(t){this.context=t,$_(this,"canIUseHelper",void 0),this.context=t;let{canIUseNative:r}=Ud(()=>this.context.getContextInfo().deviceInfo.nativeSDKVersionCode||1e6,()=>this.context.getContextInfo().deviceInfo.platform||"h5");this.canIUseHelper=r}loadAdsAsync(t){return E(this,null,function*(){try{let{errNo:r,errMsg:n}=yield Si("loadAdsAsync",{params:{providers:t.providers}});return r!==0||n.length>0?{code:"FAILURE",message:n||"Failed to load ads"}:{code:"SUCCESS",message:"Ads loaded successfully"}}catch(r){return{code:"FAILURE",message:`Failed to load ads: ${r instanceof Error?r.message:String(r)}`}}})}canIUse(){return Gi()&&this.canIUseHelper("loadAdsAsync")&&this.canIUseHelper("showAdAsync")}showAdAsync(t){return E(this,null,function*(){try{let r=yield Si("showAdAsync",{params:{providers:t.providers}});if(r.errNo!==0)return{code:"FAILURE",message:r.errMsg||"Failed to show ad"};let n=r.data.UUID;if(t.callbacks){let i=t.timeout!==void 0?t.timeout:-1,o=null,a=()=>{Hd("onAdsStateChange",s),o&&(clearTimeout(o),o=null)},s=l=>{var c;if(l.UUID!==n)return;let m=(c=t.callbacks)==null?void 0:c[l.event];m&&z_(m,l.data),["onAdClosed","onAdError","onAdDismissed"].includes(l.event)&&a()};jd("onAdsStateChange",s),i>0&&(o=setTimeout(()=>{a(),console.warn(`[JoliboxSDK] Event listener for ad ${n} auto-cleaned after ${i}ms timeout`)},i))}return{code:"SUCCESS",message:"Ad shown successfully"}}catch(r){return{code:"FAILURE",message:`Failed to show ad: ${r instanceof Error?r.message:String(r)}`}}})}isAdsReadySync(t){try{let{errNo:r,data:n}=Si("isAdsReadySync",{params:{providers:t.providers}});return r!==0||!n?(console.warn("[Jolibox SDK]isAdsReadySync returned an error or no data"),!1):!0}catch(r){return console.warn("[Jolibox SDK]isAdsReadySync invocation failed:",r),!1}}};function It(e,t,r){return(t=Y_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Y_(e){var t=X_(e,"string");return typeof t=="symbol"?t:t+""}function X_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Rs=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){It(this,"providers",void 0),It(this,"helper",void 0),It(this,"adsContext",null),It(this,"_isAdsReady",!1),It(this,"init",()=>E(this,null,function*(){this.helper.canIUse()?(yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1:this._isAdsReady=!1})),It(this,"destroy",n=>{var i,o;this._isAdsReady=!1,(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),It(this,"reinit",n=>E(this,null,function*(){this.destroy(n),yield this.init()})),It(this,"requestAds",(n,i)=>E(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=n,i&&i.length>0&&(this.providers=i);try{this.isAdsReady?this.showAd():yield this.reinit("frequencyCapped")}catch(o){this.destroy("notReady")}})),It(this,"showAd",()=>{if(!this.adsContext){this.destroy("error");return}let n=!1,i=!1;this.adsContext.beforeReward(()=>E(this,null,function*(){var o,a;(a=(o=this.adsContext)==null?void 0:o.beforeAd)==null||a.call(o);let s=c=>{var m,d,p;i||(i=!0,c==="dismissed"&&((m=this.adsContext)==null||m.adDismissed()),(p=(d=this.adsContext)==null?void 0:d.afterAd)==null||p.call(d),this.reinit(c))},l={onAdShow:()=>{},onAdError:()=>{s("error")},onAdRewarded:()=>{var c;n=!0,(c=this.adsContext)==null||c.adViewed()},onAdDismissed:()=>{s(n?"viewed":"dismissed")},onAdClosed:()=>{s(n?"viewed":"dismissed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:l})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")}))}),this.providers=r,this.helper=new Vi(t),this.init()}};function At(e,t,r){return(t=Q_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Q_(e){var t=Z_(e,"string");return typeof t=="symbol"?t:t+""}function Z_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Os=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){var n=this;At(this,"providers",void 0),At(this,"helper",void 0),At(this,"adsContext",null),At(this,"_isAdsReady",!1),At(this,"init",()=>E(this,null,function*(){this.helper.canIUse()&&((yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1)})),At(this,"destroy",function(i){var o,a;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n._isAdsReady=!1,s&&((a=(o=n.adsContext)==null?void 0:o.onEnd)==null||a.call(o,i),i!=="ignored"&&(n.adsContext=null))}),At(this,"reinit",function(o){return E(this,arguments,function*(i){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n.destroy(i,a),yield n.init()})}),At(this,"requestAds",(i,o)=>E(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=i,o&&o.length>0&&(this.providers=o);try{this.isAdsReady?yield this.showAd():yield this.reinit("frequencyCapped")}catch(a){this.destroy("notReady")}})),At(this,"showAd",()=>E(this,null,function*(){var i,o;if(!this.adsContext){this.destroy("error");return}let a=!1;(o=(i=this.adsContext).beforeAd)==null||o.call(i);let s=c=>{var m,d;a||(a=!0,(d=(m=this.adsContext)==null?void 0:m.afterAd)==null||d.call(m),this.reinit(c))},l={onAdShow:()=>{},onAdError:()=>{s("error")},onAdDismissed:()=>{s("dismissed")},onAdClosed:()=>{s("viewed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:l})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")})),this.providers=r,this.helper=new Vi(t),this.init()}};function Zr(e,t,r){return(t=ey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ey(e){var t=ty(e,"string");return typeof t=="symbol"?t:t+""}function ty(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ks=class{constructor(t,r){Zr(this,"name","INTERNAL_NATIVE"),Zr(this,"context",void 0),Zr(this,"rewardAdManager",void 0),Zr(this,"interstitialManager",void 0),Zr(this,"initProviders",void 0),this.context=t,this.initProviders=r.providers;let n=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],r.providers),i=this.getConfigsByTypes(["INTERSTITIAL"],r.providers);n.length>0&&(this.rewardAdManager=new Rs(this.context,n)),i.length>0&&(this.interstitialManager=new Os(this.context,i))}getConfigsByTypes(t,r,n){let i=[];return(n?n.map(o=>r.find(a=>a.provider===o.provider)).filter(o=>!!o):r).forEach(o=>{t.forEach(a=>{let s="";a==="REWARD"&&(s=o.params.adUnitId.reward),a==="REWARD_INTERSTITIAL"&&(s=o.params.adUnitId.rewardInterstitial),a==="INTERSTITIAL"&&(s=o.params.adUnitId.interstitial),a==="NATIVE"&&(s=o.params.adUnitId.nativeAds),s&&i.push({provider:o.provider,params:{placementId:s,adsType:a,extra:o.params.extra}})})}),i}init(){return E(this,null,function*(){})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}let a=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],this.initProviders,r.params);this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:s=>{var l;(l=t.adBreakDone)==null||l.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:s})}},a);break}default:{let a=t;if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}let s=this.getConfigsByTypes(["INTERSTITIAL"],this.initProviders,r.params);this.interstitialManager.requestAds({beforeAd:a.beforeAd,afterAd:a.afterAd,onEnd:l=>{var c;(c=t.adBreakDone)==null||c.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:l})}},s);break}}}},is="jolibox-nb-proxy",ry=0;function ny(e,t){return t==="call"&&e.join(".")==="GameSDK.showRewardAd"?0:15e3}function pu(e,t,r,n){return new Promise((i,o)=>{if(!window.parent||window.parent===window){o(new Error("[ParentProxy] No parent window"));return}let a=`${is}-${++ry}`,s=m=>{let d=m.data;(d==null?void 0:d.type)===`${is}:response`&&d.id===a&&(window.removeEventListener("message",s),c&&clearTimeout(c),d.error?o(new Error(d.error)):i(d.result))},l=ny(e,t),c=l>0?window.setTimeout(()=>{window.removeEventListener("message",s),o(new Error(`[ParentProxy] Timeout after ${l}ms: ${e.join(".")}.${t}`))},l):null;window.addEventListener("message",s),window.parent.postMessage({type:`${is}:request`,id:a,path:e,action:t,args:r,value:n},"*")})}function ef(e){return console.log("[JoliboxSDK] NewsBreak createProxyForPath basePath:",e),new Proxy(()=>{},{get(t,r){if(console.log("[JoliboxSDK] NewsBreak createProxyForPath get:",r),!(r==="then"||r==="toJSON"||typeof r=="symbol"))return ef([...e,r])},set(t,r,n){return console.log("[JoliboxSDK] NewsBreak createProxyForPath set:",r),pu([...e,r],"set",void 0,n).catch(i=>{console.warn(`[ParentProxy] set ${[...e,r].join(".")} failed:`,i)}),!0},apply(t,r,n){return console.log("[JoliboxSDK] NewsBreak createProxyForPath apply:",n),pu(e,"call",n)}})}function iy(e){return ef([e])}var Ui=()=>{try{if(window.parent&&window.parent!==window)return iy("GameSDK")}catch(e){}};function mr(e,t,r){return(t=oy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function oy(e){var t=ay(e,"string");return typeof t=="symbol"?t:t+""}function ay(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ts=class{constructor(){mr(this,"adsContext",null),mr(this,"init",()=>E(this,null,function*(){console.log("[JoliboxSDK] NewsBreak init");let t=Ui();if(t)try{let r=yield t.createRewardAd({platform:"jolibox"});console.log("[JoliboxSDK] NewsBreak init createRewardAd result:",r)}catch(r){console.log("[JoliboxSDK] NewsBreak init createRewardAd error:",r)}})),mr(this,"destroy",t=>{var r,n;(n=(r=this.adsContext)==null?void 0:r.adBreakDone)==null||n.call(r,t),t!=="ignored"&&(this.adsContext=null)}),mr(this,"reinit",t=>E(this,null,function*(){console.log("[JoliboxSDK] NewsBreak reinit breakStatus:",t),this.destroy(t),yield this.init()})),mr(this,"requestAds",t=>E(this,null,function*(){if(console.log("[JoliboxSDK] NewsBreak newsbreak this.adsContext",this.adsContext),this.adsContext){this.destroy("ignored");return}this.adsContext=t;let r=Ui();if(console.log("[JoliboxSDK] NewsBreak newsbreak sdk",r),!r){this.destroy("notReady");return}this.showAd()})),mr(this,"showAd",()=>{if(console.log("[JoliboxSDK] NewsBreak showAd"),!this.adsContext){this.destroy("error");return}this.adsContext.beforeReward(()=>E(this,null,function*(){var t,r,n,i,o,a,s,l,c,m,d,p,h,b;(r=(t=this.adsContext)==null?void 0:t.beforeAd)==null||r.call(t);let I=Ui();if(!I){(i=(n=this.adsContext)==null?void 0:n.afterAd)==null||i.call(n),this.reinit("error");return}try{let A=yield I.showRewardAd();if(console.log("[JoliboxSDK] NewsBreak showRewardAd result:",A),!A.success){(a=(o=this.adsContext)==null?void 0:o.afterAd)==null||a.call(o),this.reinit("error");return}A.rewardGranted?((s=this.adsContext)==null||s.adViewed(),(c=(l=this.adsContext)==null?void 0:l.afterAd)==null||c.call(l),this.reinit("viewed")):((m=this.adsContext)==null||m.adDismissed(),(p=(d=this.adsContext)==null?void 0:d.afterAd)==null||p.call(d),this.reinit("dismissed"))}catch(A){console.error("[JoliboxSDK] NewsBreak showRewardAd failed:",A),(b=(h=this.adsContext)==null?void 0:h.afterAd)==null||b.call(h),this.reinit("error")}}))}),this.init()}};function vu(e,t,r){return(t=sy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function sy(e){var t=ly(e,"string");return typeof t=="symbol"?t:t+""}function ly(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var xs=class{constructor(){vu(this,"name","NEWSBREAK"),vu(this,"rewardAdManager",void 0)}init(){return E(this,null,function*(){let t=Ui();if(!t){console.warn("[JoliboxSDK] NewsBreak GameSDK is not available on window");return}t.onEnter(),this.rewardAdManager=new Ts})}adConfig(t,r){}adBreak(t,r){var n,i;if(t.type!=="reward"){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:o=>{var a;(a=t.adBreakDone)==null||a.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:o})}})}};function Qe(e,t,r){return(t=cy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cy(e){var t=dy(e,"string");return typeof t=="symbol"?t:t+""}function dy(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var sn=class{constructor(t){if(Qe(this,"context",void 0),Qe(this,"contextInfo",void 0),Qe(this,"providers",{}),Qe(this,"channelPolicy",void 0),Qe(this,"adsActionDetection",void 0),Qe(this,"requestContext",void 0),Qe(this,"adsRequest",void 0),Qe(this,"initialized",!1),Qe(this,"adsIsShowing",!1),Qe(this,"lastAdBreak",void 0),Qe(this,"initializedTimeStamp",Date.now()),t)this.context=t,this.channelPolicy=new fs(this.context),this.adsActionDetection=new us(this.context),this.contextInfo=this.context.getContextInfo(),this.adsRequest=new qi(t),this.requestContext=new an(t);else throw new Error("JoliboxAdsForGame requires a configuration object")}init(t){return E(this,null,function*(){window.adsbygoogle=window.adsbygoogle||[];let{data:r}=yield this.context.httpClient.post("/api/ads/init",{data:{contextData:this.requestContext.getRequestContextData("AdsAFGSDKInit"),bizParams:this.requestContext.getRequestBizParams(),testAdsMode:this.contextInfo.testAdsMode}});if((r==null?void 0:r.length)>0){let n=r.filter(s=>s.isNative),i=r.filter(s=>!s.isNative),o={provider:"INTERNAL_NATIVE",params:{providers:n}},a=i.concat([o]);for(let s of a)switch(s.provider){case"GOOGLE_GPT":{let l=new Ss(this.context,s.params);yield l.init(),this.providers[s.provider]=l;break}case"ADSENSE":case"ADSENSE_ADMOB":{let l=new hs(this.context,s.params);yield l.init(),this.providers[s.provider]=l;break}case"OKSPIN":{let l=new ws(this.context,s.params);yield l.init(),this.providers.OKSPIN=l;break}case"APPSROCKETS":{let l=new Is(this.context,s.params);yield l.init(),this.providers.APPSROCKETS=l;break}case"ADSENSE_BANNER_AS_AFG":{let l=new Es(this.context,s.params);yield l.init(),this.providers.ADSENSE_BANNER_AS_AFG=l;break}case"INTERNAL_NATIVE":{let l=new ks(this.context,s.params);yield l.init(),this.providers.INTERNAL_NATIVE=l;break}case"NEWSBREAK":{console.log("[JoliboxSDK] NewsBreak Provider",s);let l=new xs;yield l.init(),this.providers.NEWSBREAK=l;break}}}this.adsRequest.cacheInterstitialInfo("start"),this.adsRequest.cacheRewardInfo(),this.initialized=!0})}adConfig(t){this.providers.ADSENSE?this.providers.ADSENSE.adConfig(t):window.adsbygoogle.push(t)}adBreak(t){return E(this,null,function*(){var r,n,i,o,a,s,l,c,m,d,p,h,b,I,A,w;let R=Date.now();if(R-this.initializedTimeStamp<3e3){(r=t.adBreakDone)==null||r.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}if(this.lastAdBreak&&R-this.lastAdBreak<500){console.warn("[Jolibox SDK Ads] You can't call adBreak too frequently"),(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.lastAdBreak=R,this.adsIsShowing){console.warn("[Jolibox SDK Ads] You can't call adBreak while ad is showing"),(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.initialized||(yield this.init()),t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}if(!this.context.checkNetwork()&&!this.providers.NEWSBREAK){(a=t.adBreakDone)==null||a.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}try{let O=yield this.adsRequest.getAFGAdsInfo(t.type),D=O==null?void 0:O.data,M=O==null?void 0:O.code;if(M==="BYPASS_ADS"){switch(t.type){case"preroll":{(s=t.adBreakDone)==null||s.call(t,{breakType:t.type,breakFormat:"interstitial",breakStatus:"viewed"});break}case"reward":{t.beforeReward(()=>{var S,N,J,q;(S=t.beforeAd)==null||S.call(t),(N=t.adViewed)==null||N.call(t),(J=t.afterAd)==null||J.call(t),(q=t.adBreakDone)==null||q.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"viewed"})});break}default:{(l=t.beforeAd)==null||l.call(t),(c=t.afterAd)==null||c.call(t),(m=t.adBreakDone)==null||m.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"});break}}return}if(!D||M!=="SUCCESS"){(d=t.adBreakDone)==null||d.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}else{if(D.length===0){(p=t.adBreakDone)==null||p.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}let S=!0,N=null,J=new ds(this.context);this.adsActionDetection.adBreakIsShowing=!0;let q=D.filter(V=>V.isNative).sort((V,K)=>V.seq-K.seq),U=D.filter(V=>!V.isNative).sort((V,K)=>V.seq-K.seq),G={seq:(b=(h=q[0])==null?void 0:h.seq)!=null?b:0,provider:"INTERNAL_NATIVE",params:q},j;for(q.length>0?j=[G].concat(U):j=U,j=j.sort((V,K)=>V.seq-K.seq).map((V,K)=>Sv(yu({},V),{seq:K}));j.length>0;){let V=j.shift(),K=this.providers[V.provider];if(K){let[Fe,Yt]=yield J.callAdBreakAndContinue(K,t,V,Xt=>{var ct;this.adsIsShowing=Xt,(ct=this.context.eventEmitter)==null||ct.emit("isAdShowing",Xt)});S=Fe,N=Yt}else S=!0,N={breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"};if(!S)break}S&&N&&((I=t.adBreakDone)==null||I.call(t,N))}}catch(O){(A=t.adBreakDone)==null||A.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}finally{this.adsIsShowing=!1,(w=this.context.eventEmitter)==null||w.emit("isAdShowing",!1),this.adsActionDetection.adBreakIsShowing=!1}})}adUnit(t){console.warn("This method has been deprecated. We will not support AdSense AdUnit in the future.")}};function ki(e,t,r){return(t=uy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function uy(e){var t=fy(e,"string");return typeof t=="symbol"?t:t+""}function fy(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ns=class{constructor(t){ki(this,"context",void 0),ki(this,"currentProvider",void 0),ki(this,"continueCallback",void 0),ki(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo()}get paramsToTrack(){var t,r;return{provider:(r=(t=this.currentProvider)==null?void 0:t.name)!=null?r:null}}wrapAdRequested(t){return()=>{this.context.track("CallAFVRequest",this.paramsToTrack),t==null||t()}}wrapAdLoaded(t){return r=>{this.context.track("CallAFVLoad",this.paramsToTrack),t==null||t(r)}}wrapAdPlaying(t){return r=>{var n,i;this.context.track("CallAFVPlaying",this.paramsToTrack),Gi()&&this.context.track("mmp_ad_impression",{ad_network:(i=(n=this.currentProvider)==null?void 0:n.name)!=null?i:"",ad_format:"AFV",module:"drama",game_id:this.contextInfo.objectId}),t==null||t(r)}}wrapAdCompleted(t){return r=>{var n;this.context.track("CallAFVCompleted",this.paramsToTrack),t==null||t(r),(n=this.continueCallback)==null||n.call(this,[!1,null])}}wrapAdError(t){return r=>{var n;this.context.track("CallAFVError",this.paramsToTrack),(n=this.continueCallback)==null||n.call(this,[!0,r])}}callAdRequestAndContinue(t,r,n){return E(this,null,function*(){return this.currentProvider=t,new Promise(i=>{this.continueCallback=i;let o=Object.assign({},r);o.onAdRequested=this.wrapAdRequested(r.onAdRequested),o.onAdLoaded=this.wrapAdLoaded(r.onAdLoaded),o.onAdPlaying=this.wrapAdPlaying(r.onAdPlaying),o.onAdCompleted=this.wrapAdCompleted(r.onAdCompleted),o.onAdError=this.wrapAdError(r.onAdError),t.requestAd(o,n)})})}};function os(e,t,r){return(t=hy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function hy(e){var t=my(e,"string");return typeof t=="symbol"?t:t+""}function my(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ke=class e extends Error{constructor(t,r){super(t.message),os(this,"name",void 0),os(this,"type",void 0),os(this,"raw",void 0),this.name="AFVRequestError",this.type=r,this.raw=t,this.stack=t.stack,this.message=t.message}static from(t,r){switch(r){case"GOOGLE_IMA_ERROR":return new e(t,r);case"JOLIBOX_IMA_ERROR":return new e(t,r)}}};function oe(e,t,r){return(t=py(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function py(e){var t=vy(e,"string");return typeof t=="symbol"?t:t+""}function vy(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ps=class{constructor(t,r,n){oe(this,"adsLoader",void 0),oe(this,"adDisplayContainer",void 0),oe(this,"isAdPlaying",!1),oe(this,"isContentFinished",!1),oe(this,"videoContent",void 0),oe(this,"adContainer",void 0),oe(this,"adsManager",void 0),oe(this,"intervalTimer",void 0),oe(this,"completed",!1),oe(this,"adTagUrl",void 0),oe(this,"notifyRequestAd",void 0),oe(this,"notifyLoaded",void 0),oe(this,"notifyPlayingAd",void 0),oe(this,"notifyCompleted",void 0),oe(this,"notifyError",void 0),oe(this,"destroy",()=>{var i,o,a,s,l,c,m,d,p,h,b;this.intervalTimer&&clearInterval(this.intervalTimer),(i=this.adsManager)==null||i.stop(),(o=this.adDisplayContainer)==null||o.destroy(),(a=this.adsLoader)==null||a.removeEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded),(s=this.adsLoader)==null||s.removeEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),(l=this.adsManager)==null||l.removeEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),(c=this.adsManager)==null||c.removeEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested),(m=this.adsManager)==null||m.removeEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested),(d=this.adsManager)==null||d.removeEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAdEvent),(p=this.adsManager)==null||p.removeEventListener(window.google.ima.AdEvent.Type.LOADED,this.onAdEvent),(h=this.adsManager)==null||h.removeEventListener(window.google.ima.AdEvent.Type.STARTED,this.onAdEvent),(b=this.adsManager)==null||b.removeEventListener(window.google.ima.AdEvent.Type.COMPLETE,this.onAdEvent)}),oe(this,"requestAds",(i,o)=>E(this,null,function*(){var a;this.createAdDisplayContainer(),this.notifyRequestAd=i.onAdRequested,this.notifyLoaded=i.onAdLoaded,this.notifyPlayingAd=i.onAdPlaying,this.notifyCompleted=i.onAdCompleted,this.notifyError=d=>{var p;return(p=i.onAdError)==null?void 0:p.call(i,ke.from(d,"GOOGLE_IMA_ERROR"))},this.adsLoader=new window.google.ima.AdsLoader(this.adDisplayContainer),this.adsLoader.addEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded,!1),this.adsLoader.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1);let s=()=>{var d;this.isAdPlaying||(this.isContentFinished=!0,(d=this.adsLoader)==null||d.contentComplete())};this.videoContent.onended=s;let l=new window.google.ima.AdsRequest;l.vastLoadTimeout=1e4;let c="";Object.keys(o.params).forEach(d=>{let p=window.encodeURIComponent(o.params[d]);c+=`&${d}=${p}`});let m=`${this.adTagUrl}${c}`;l.adTagUrl=m,l.linearAdSlotWidth=640,l.linearAdSlotHeight=400,l.nonLinearAdSlotWidth=640,l.nonLinearAdSlotHeight=150,this.adsLoader.requestAds(l),(a=this.notifyRequestAd)==null||a.call(this)})),oe(this,"createAdDisplayContainer",()=>{this.adDisplayContainer=new window.google.ima.AdDisplayContainer(this.adContainer,this.videoContent)}),oe(this,"playAds",()=>{var i,o;this.videoContent.load(),this.adDisplayContainer.initialize(),this.completed=!1;try{(i=this.adsManager)==null||i.init(window.document.body.clientWidth,window.document.body.clientHeight,window.google.ima.ViewMode.NORMAL),(o=this.adsManager)==null||o.start()}catch(a){console.error("[JoliboxAFV] Google IMA Error: ",a),this.videoContent.play()}}),oe(this,"onAdsManagerLoaded",i=>{let o=new window.google.ima.AdsRenderingSettings;o.restoreCustomPlaybackStateOnAdBreakComplete=!0,o.loadVideoTimeout=1e4,this.adsManager=i.getAdsManager(this.videoContent,o),this.adsManager.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.LOADED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.STARTED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.COMPLETE,this.onAdEvent),i.type==="adsManagerLoaded"&&this.playAds()}),oe(this,"onAdEvent",i=>{var o,a,s,l;let c=i.getAd();switch(i.type){case window.google.ima.AdEvent.Type.LOADED:c!=null&&c.isLinear()||this.videoContent.play(),(o=this.notifyLoaded)==null||o.call(this,i);break;case window.google.ima.AdEvent.Type.STARTED:c!=null&&c.isLinear()&&(this.intervalTimer=window.setInterval(function(){},300)),(a=this.notifyPlayingAd)==null||a.call(this,i);break;case window.google.ima.AdEvent.Type.COMPLETE:c!=null&&c.isLinear()&&clearInterval(this.intervalTimer),this.completed||(this.completed=!0,(s=this.notifyCompleted)==null||s.call(this,i));break;case window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED:c!=null&&c.isLinear()&&clearInterval(this.intervalTimer),this.completed||(this.completed=!0,(l=this.notifyCompleted)==null||l.call(this,i));break}}),oe(this,"onAdError",i=>{var o,a;(o=this.notifyError)==null||o.call(this,i.getError()),(a=this.adsManager)==null||a.destroy()}),oe(this,"onContentPauseRequested",()=>{this.isAdPlaying=!0,this.videoContent.pause()}),oe(this,"onContentResumeRequested",()=>{this.isAdPlaying=!1}),this.adTagUrl=t,this.videoContent=r,this.adContainer=n}},Bi=(e=>(e[e.ADS_REQUEST_NETWORK_ERROR=1012]="ADS_REQUEST_NETWORK_ERROR",e[e.ASSET_FALLBACK_FAILED=1021]="ASSET_FALLBACK_FAILED",e[e.AUTOPLAY_DISALLOWED=1205]="AUTOPLAY_DISALLOWED",e[e.COMPANION_AD_LOADING_FAILED=603]="COMPANION_AD_LOADING_FAILED",e[e.COMPANION_REQUIRED_ERROR=602]="COMPANION_REQUIRED_ERROR",e[e.FAILED_TO_REQUEST_ADS=1005]="FAILED_TO_REQUEST_ADS",e[e.INVALID_AD_TAG=1013]="INVALID_AD_TAG",e[e.INVALID_ADX_EXTENSION=1105]="INVALID_ADX_EXTENSION",e[e.INVALID_ARGUMENTS=1101]="INVALID_ARGUMENTS",e[e.NONLINEAR_DIMENSIONS_ERROR=501]="NONLINEAR_DIMENSIONS_ERROR",e[e.OVERLAY_AD_LOADING_FAILED=502]="OVERLAY_AD_LOADING_FAILED",e[e.OVERLAY_AD_PLAYING_FAILED=500]="OVERLAY_AD_PLAYING_FAILED",e[e.STREAM_INITIALIZATION_FAILED=1020]="STREAM_INITIALIZATION_FAILED",e[e.UNKNOWN_AD_RESPONSE=1010]="UNKNOWN_AD_RESPONSE",e[e.UNKNOWN_ERROR=900]="UNKNOWN_ERROR",e[e.UNSUPPORTED_LOCALE=1011]="UNSUPPORTED_LOCALE",e[e.VAST_ASSET_NOT_FOUND=1007]="VAST_ASSET_NOT_FOUND",e[e.VAST_EMPTY_RESPONSE=1009]="VAST_EMPTY_RESPONSE",e[e.VAST_LINEAR_ASSET_MISMATCH=403]="VAST_LINEAR_ASSET_MISMATCH",e[e.VAST_LOAD_TIMEOUT=301]="VAST_LOAD_TIMEOUT",e[e.VAST_MALFORMED_RESPONSE=100]="VAST_MALFORMED_RESPONSE",e[e.VAST_MEDIA_LOAD_TIMEOUT=402]="VAST_MEDIA_LOAD_TIMEOUT",e[e.VAST_NO_ADS_AFTER_WRAPPER=303]="VAST_NO_ADS_AFTER_WRAPPER",e[e.VAST_NONLINEAR_ASSET_MISMATCH=503]="VAST_NONLINEAR_ASSET_MISMATCH",e[e.VAST_PROBLEM_DISPLAYING_MEDIA_FILE=405]="VAST_PROBLEM_DISPLAYING_MEDIA_FILE",e[e.VAST_SCHEMA_VALIDATION_ERROR=101]="VAST_SCHEMA_VALIDATION_ERROR",e[e.VAST_TOO_MANY_REDIRECTS=302]="VAST_TOO_MANY_REDIRECTS",e[e.VAST_TRAFFICKING_ERROR=200]="VAST_TRAFFICKING_ERROR",e[e.VAST_UNEXPECTED_DURATION_ERROR=202]="VAST_UNEXPECTED_DURATION_ERROR",e[e.VAST_UNEXPECTED_LINEARITY=201]="VAST_UNEXPECTED_LINEARITY",e[e.VAST_UNSUPPORTED_VERSION=102]="VAST_UNSUPPORTED_VERSION",e[e.VAST_WRAPPER_ERROR=300]="VAST_WRAPPER_ERROR",e[e.VIDEO_PLAY_ERROR=400]="VIDEO_PLAY_ERROR",e[e.VPAID_ERROR=901]="VPAID_ERROR",e))(Bi||{}),gy=()=>{let e=Y(!1),t=Y(!1),r=Y(null),n=Fr(),i=Fr();return{visible:e,canRetry:t,retry:r,videoRef:n,adContainerRef:i}},_y=Te`
258
+ `,Xu=e=>{let{state:t}=e,{afterAd:r,adDismissed:n,adViewed:i,adBreakDone:o,adLoaded:a,adLinkClicked:s,visible:l,src:c}=t,[m,d]=_t(!1),p=b=>{var I,A,w,R;d(!1),l.value=!1,b==="dismiss"?(I=n.value)==null||I.call(n):b==="viewed"&&((A=i.value)==null||A.call(i)),(w=r.value)==null||w.call(r),(R=o.value)==null||R.call(o)},h=()=>{var b;(b=a.value)==null||b.call(a)};return hr("appsrockets_ad_dismissed",()=>p("dismiss")),hr("appsrockets_ad_rewarded",()=>p("viewed")),hr("appsrockets_ad_completed",()=>p("viewed")),hr("appsrockets_ad_skipped",()=>p("viewed")),hr("appsrockets_ad_clicked",b=>{var I;return(I=s.value)==null?void 0:I.call(s,b)}),hr("appsrockets_ad_loaded",()=>d(!0)),l.value?$("div",{className:P_,style:{display:m?"flex":"none"},children:l.value&&$("iframe",{src:c.value,onLoad:h,allowFullScreen:!0,allow:"autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-modals allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation allow-top-navigation allow-top-navigation-by-user-activation allow-top-navigation-to-custom-protocols"})}):null};function Et(e,t,r){return(t=D_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function D_(e){var t=L_(e,"string");return typeof t=="symbol"?t:t+""}function L_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Is=class{constructor(t,r){Et(this,"name","APPSROCKETS"),Et(this,"initialized",!1),Et(this,"initCompleter",null),Et(this,"context",void 0),Et(this,"adsOverlay",null),Et(this,"adsIsShowing",!1),Et(this,"lastUnDisplayedAdBreak",null),Et(this,"state",Yu()),Et(this,"processUrl",(n,i)=>{var o;let a=this.context.getContextInfo(),s=new URL(n),l=new URLSearchParams(s.search);return l.has("joliSource")||l.set("joliSource",a.joliSource),l.get("osType")||l.set("osType",a.osType),l.get("runtimeType")||l.set("runtimeType",a.runtimeType),l.get("mode")||l.set("mode","AFG"),l.get("deviceId")||l.set("deviceId",a.deviceId),l.get("statusBarHeight")||l.set("statusBarHeight",((o=this.context.getWindowInfo().statusBarHeight)!=null?o:0).toString()),l.get("adsType")||l.set("adsType",i),s.search=l.toString(),s.toString()}),this.context=t}init(){return E(this,null,function*(){var t;this.adsOverlay=document.createElement("div"),this.adsOverlay.setAttribute("data-placement-info","afg-appsrockets"),it($(Xu,{state:this.state}),this.adsOverlay),document.documentElement.appendChild(this.adsOverlay),this.initialized=!0,(t=this.initCompleter)==null||t.call(this)})}adConfig(t){var r;if(this.initialized){(r=t.onReady)==null||r.call(t);return}this.initCompleter=()=>{var n;(n=t.onReady)==null||n.call(t)}}adBreak(t,r){var n,i,o,a,s,l,c,m;if(!this.initialized||!this.adsOverlay||!r.params.url){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"});return}if(this.adsIsShowing){(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}let d=h=>{var b,I;(I=(b=this.context).handleLinkClicked)==null||I.call(b,h)},p=t.type==="reward"?"REWARD":"INTERSTITIAL";switch(t.type){case"preroll":{(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"start":case"browse":case"next":case"pause":{(a=t.beforeAd)==null||a.call(t);let h=()=>{var A;this.adsIsShowing=!1,(A=t.afterAd)==null||A.call(t)},b=()=>{var A;this.adsIsShowing=!1,(A=t.adBreakDone)==null||A.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"})},I=()=>{var A;this.adsIsShowing=!1,(A=t.adBreakDone)==null||A.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"noAdPreloaded"})};ue(()=>{this.adsIsShowing=!0,this.state.afterAd.value=h,this.state.adBreakDone.value=b,this.state.src.value=this.processUrl(r.params.url,p),this.state.adLinkClicked.value=d,this.state.adError.value=I,this.state.visible.value=!0});break}case"reward":{this.lastUnDisplayedAdBreak&&((l=(s=this.lastUnDisplayedAdBreak).adBreakDone)==null||l.call(s,{breakType:this.lastUnDisplayedAdBreak.type,breakName:this.lastUnDisplayedAdBreak.type==="preroll"?"":this.lastUnDisplayedAdBreak.name,breakFormat:this.lastUnDisplayedAdBreak.type==="reward"?"reward":"interstitial",breakStatus:"ignored"}),this.lastUnDisplayedAdBreak=null),(c=t.beforeAd)==null||c.call(t);let h=()=>{var D;this.adsIsShowing=!1,(D=t.afterAd)==null||D.call(t)},b={breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"ignored"},I=()=>{var D;this.adsIsShowing=!1,b.breakStatus="dismissed",(D=t.adDismissed)==null||D.call(t)},A=()=>{var D;this.adsIsShowing=!1,b.breakStatus="viewed",(D=t.adViewed)==null||D.call(t)},w=()=>{var D;this.adsIsShowing=!1,(D=t.adBreakDone)==null||D.call(t,b)},R=()=>{this.adsIsShowing=!1,b.breakStatus="noAdPreloaded"};ue(()=>{this.state.afterAd.value=h,this.state.adDismissed.value=I,this.state.adViewed.value=A,this.state.adBreakDone.value=w,this.state.adLinkClicked.value=d,this.state.adError.value=R});let O=()=>{var D;if(this.lastUnDisplayedAdBreak=null,!this.adsOverlay){(D=t.adBreakDone)==null||D.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"notReady"});return}this.adsIsShowing=!0,ue(()=>{this.state.src.value=this.processUrl(r.params.url,p),this.state.visible.value=!0})};this.lastUnDisplayedAdBreak=t,(m=t.beforeReward)==null||m.call(t,O);break}}}},Qu=()=>{window.googletag=window.googletag||{cmd:[]},window.googletag.pubadsReady||window.googletag.cmd.push(()=>{window.googletag.enableServices()})};function Re(e,t,r){return(t=U_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function U_(e){var t=B_(e,"string");return typeof t=="symbol"?t:t+""}function B_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Zu=class{constructor(e,t,r){Re(this,"adUnit",void 0),Re(this,"project",void 0),Re(this,"keyValue",void 0),Re(this,"adsContext",null),Re(this,"rewardedSlot",null),Re(this,"rewardedPayload",null),Re(this,"readyEvent",null),Re(this,"withCommand",function(){googletag.cmd.push(...arguments)}),Re(this,"init",()=>{var n;this.rewardedSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.REWARDED),this.rewardedSlot&&(this.rewardedSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().addEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().addEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.keyValue&&(Object.keys(this.keyValue).forEach(i=>{var o;(o=this.rewardedSlot)==null||o.setTargeting(i,this.keyValue[i])}),Object.keys(this.keyValue).includes("project")||(n=this.rewardedSlot)==null||n.setTargeting("project",this.project)),googletag.display(this.rewardedSlot))}),Re(this,"destroy",n=>{var i,o;this.rewardedPayload=null,this.readyEvent=null,googletag.pubads().removeEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().removeEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().removeEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().removeEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.rewardedSlot&&(googletag.destroySlots([this.rewardedSlot]),this.rewardedSlot=null),(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),Re(this,"reinit",n=>{this.destroy(n),this.init()}),Re(this,"handleSlotReady",n=>{n.slot===this.rewardedSlot&&(this.readyEvent=n)}),Re(this,"handleSlotClosed",n=>{var i,o;if(this.adsContext&&n.slot===this.rewardedSlot){let a=this.rewardedPayload?"viewed":"dismissed";a==="viewed"?this.adsContext.adViewed():this.adsContext.adDismissed(),(o=(i=this.adsContext).afterAd)==null||o.call(i),this.withCommand(()=>{this.reinit(a)})}}),Re(this,"handleSlotGranted",n=>{this.adsContext&&n.slot===this.rewardedSlot&&(this.rewardedPayload=n.payload)}),Re(this,"handleSlotRenderEnded",n=>{n.slot===this.rewardedSlot&&n.isEmpty&&this.adsContext&&this.withCommand(()=>{this.reinit("frequencyCapped")})}),Re(this,"requestAds",n=>{this.withCommand(()=>{if(this.adsContext){this.destroy("ignored");return}if(this.rewardedSlot||this.init(),this.adsContext=n,!this.rewardedSlot){this.reinit("notReady");return}if(this.readyEvent)this.adsContext.beforeReward(()=>{var i,o,a;(o=(i=this.adsContext)==null?void 0:i.beforeAd)==null||o.call(i),(a=this.readyEvent)==null||a.makeRewardedVisible()});else{let i=o=>{o.slot===this.rewardedSlot&&this.adsContext&&(googletag.pubads().removeEventListener("rewardedSlotReady",i),this.readyEvent=o,this.adsContext.beforeReward(()=>{var a,s,l;(s=(a=this.adsContext)==null?void 0:a.beforeAd)==null||s.call(a),(l=this.readyEvent)==null||l.makeRewardedVisible()}))};googletag.pubads().addEventListener("rewardedSlotReady",i),window.setTimeout(()=>{this.readyEvent||(this.reinit("timeout"),googletag.pubads().removeEventListener("rewardedSlotReady",i))},500)}})}),this.adUnit=e,this.project=t,this.keyValue=r,Qu(),this.withCommand(()=>{this.init()})}};function Ge(e,t,r){return(t=M_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function M_(e){var t=G_(e,"string");return typeof t=="symbol"?t:t+""}function G_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var As=class{constructor(t,r,n){var i=this;Ge(this,"adUnit",void 0),Ge(this,"project",void 0),Ge(this,"keyValue",void 0),Ge(this,"adsContext",null),Ge(this,"gamingInterstitialSlot",null),Ge(this,"readyEvent",null),Ge(this,"isRetrying",!1),Ge(this,"withCommand",function(){googletag.cmd.push(...arguments)}),Ge(this,"init",()=>{var o;this.gamingInterstitialSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL),this.gamingInterstitialSlot&&(this.gamingInterstitialSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("gameManualInterstitialSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("gameManualInterstitialSlotClosed",this.handleSlotClosed),this.keyValue&&(Object.keys(this.keyValue).forEach(a=>{var s;(s=this.gamingInterstitialSlot)==null||s.setTargeting(a,this.keyValue[a])}),Object.keys(this.keyValue).includes("project")||(o=this.gamingInterstitialSlot)==null||o.setTargeting("project",this.project)),googletag.display(this.gamingInterstitialSlot))}),Ge(this,"destroy",function(o){var a,s;(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1])&&((s=(a=i.adsContext)==null?void 0:a.onEnd)==null||s.call(a,o),o!=="ignored"&&(i.adsContext=null)),googletag.pubads().removeEventListener("gameManualInterstitialSlotReady",i.handleSlotReady),googletag.pubads().removeEventListener("gameManualInterstitialSlotClosed",i.handleSlotClosed),i.gamingInterstitialSlot&&(googletag.destroySlots([i.gamingInterstitialSlot]),i.gamingInterstitialSlot=null,i.readyEvent=null)}),Ge(this,"reinit",function(o){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;i.destroy(o,a),i.init()}),Ge(this,"handleSlotReady",o=>{this.gamingInterstitialSlot===o.slot&&(this.readyEvent=o)}),Ge(this,"handleSlotClosed",o=>{var a,s;this.adsContext&&this.gamingInterstitialSlot===o.slot&&((s=(a=this.adsContext).afterAd)==null||s.call(a),this.withCommand(()=>{this.reinit("viewed")}))}),Ge(this,"requestAds",o=>{this.withCommand(()=>{var a,s,l;if(this.adsContext){this.destroy("ignored");return}if(this.gamingInterstitialSlot||this.init(),this.adsContext=o,!this.gamingInterstitialSlot){this.reinit("notReady");return}this.readyEvent?((a=o.beforeAd)==null||a.call(o),this.readyEvent.makeGameManualInterstitialVisible()):((l=(s=this.adsContext).onEnd)==null||l.call(s,"frequencyCapped"),this.adsContext=null,this.isRetrying||(this.isRetrying=!0,window.setTimeout(()=>{this.readyEvent||this.withCommand(()=>{this.reinit("frequencyCapped",!1)}),this.isRetrying=!1},31e3)))})}),Qu(),this.adUnit=t,this.project=r,this.keyValue=n,this.withCommand(()=>{this.init()})}};function Wt(e,t,r){return(t=J_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function J_(e){var t=F_(e,"string");return typeof t=="symbol"?t:t+""}function F_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ss=class{constructor(t,r){Wt(this,"name","GOOGLE_GPT"),Wt(this,"context",void 0),Wt(this,"contextInfo",void 0),Wt(this,"initParams",void 0),Wt(this,"rewardAdManager",void 0),Wt(this,"interstitialManager",void 0),Wt(this,"insertScript",()=>{let n="jolibox-google-gpt",i=document.getElementById(n);i||(i=window.document.createElement("script"),i.id=n,i.async=!0,i.src="https://securepubads.g.doubleclick.net/tag/js/gpt.js",i.crossOrigin="anonymous",document.head.appendChild(i))}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.initParams=r,this.insertScript()}init(){return E(this,null,function*(){let t=this.contextInfo.testAdsMode?"/22639388115/rewarded_web_example":this.initParams.rewardedSlot,r=this.contextInfo.testAdsMode?"/6355419/Travel/Europe/France/Paris":this.initParams.interstitialSlot,n=`minigame-${this.contextInfo.runtimeType==="APP"?"app":"h5"}`;t&&(this.rewardAdManager=new Zu(t,n,this.initParams.keyValue)),r&&(this.interstitialManager=new As(r,n,this.initParams.keyValue))})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:a})}});break}default:{if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}this.interstitialManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,onEnd:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:a})}});break}}}};function ns(e,t,r){return(t=j_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j_(e){var t=H_(e,"string");return typeof t=="symbol"?t:t+""}function H_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Cs=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GAME";ns(this,"context",void 0),ns(this,"placement","GAME"),ns(this,"contextInfo",void 0),this.context=t,this.placement=r,this.contextInfo=this.context.getContextInfo()}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:this.placement==="GAME"?"GamePage":"DramaPage",params:r}}getDevice(){var t,r,n,i;return{platform:(t=this.contextInfo.platform)!=null?t:Su.WebSDK,os:this.contextInfo.osType+"_"+this.contextInfo.runtimeType,appVersion:"1.0.0",appId:(r=this.contextInfo.hostAppId)!=null?r:"1",model:(n=this.contextInfo.deviceModel)!=null?n:"UnknownModel",brand:(i=this.contextInfo.deviceBrand)!=null?i:"UnknownBrand",uuid:this.contextInfo.deviceId,jsSdkVersion:"1.0.0",extra:{}}}serialize(t,r){var n;let i={protocolVersion:"1.0.0",events:[{name:t,type:Iu.System,location:this.getLocation(),target:null,extra:r,timestamp:Date.now(),userId:(n=this.contextInfo.userId)!=null?n:null}],device:this.getDevice(),project:Au.WebSDK};return Kv(i)}};function Le(e,t,r){return(t=q_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function q_(e){var t=V_(e,"string");return typeof t=="symbol"?t:t+""}function V_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var an=class{constructor(t){Le(this,"context",void 0),Le(this,"adsTrackSerializer",void 0),Le(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo(),this.adsTrackSerializer=new Cs(this.context)}getRequestContextData(t){var r,n;this.contextInfo=this.context.getContextInfo();let{width:i,height:o}=this.context.getWindowInfo();return{report:JSON.stringify(this.adsTrackSerializer.serialize(t,{sessionId:this.contextInfo.sessionId,objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId,testAdsMode:this.contextInfo.testAdsMode})),osType:this.contextInfo.osType,runtimeType:this.contextInfo.runtimeType,sessionId:this.contextInfo.sessionId,deviceId:this.contextInfo.deviceId,adId:this.contextInfo.adId,deviceModel:(r=this.contextInfo.deviceModel)!=null?r:"UnknownModel",deviceBrand:(n=this.contextInfo.deviceBrand)!=null?n:"UnknownBrand",dimension:{width:i,height:o}}}getRequestBizParams(){return{objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId}}},qi=class{constructor(t,r){var n=this;Le(this,"context",void 0),Le(this,"contextInfo",void 0),Le(this,"requestContext",void 0),Le(this,"pendingAFGAdsInfo",{REWARD:Promise.resolve(null),INTERSTITIAL:Promise.resolve(null)}),Le(this,"pendingAFVAdsInfo",Promise.resolve(null)),Le(this,"doFetchAdsInfo",i=>E(this,null,function*(){let o=i==="afv"?"AdsAFVSDKRequest":"AdsAFGSDKAdBreak",a=[];switch(i){case"afv":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}case"reward":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}default:{a=["INTERSTITIAL"];break}}let s=i==="afv"?void 0:"cached",{data:l,code:c}=yield this.context.httpClient.post("/api/ads/info",{data:{contextData:this.requestContext.getRequestContextData(o),bizParams:this.requestContext.getRequestBizParams(),adsTypes:a,testAdsMode:this.contextInfo.testAdsMode,name:s}});return c==="SUCCESS"||c==="BYPASS_ADS"?{code:c,data:l}:null})),Le(this,"cacheRewardInfo",()=>{this.pendingAFGAdsInfo.REWARD=this.doFetchAdsInfo("reward").catch(()=>null)}),Le(this,"cacheInterstitialInfo",i=>{this.pendingAFGAdsInfo.INTERSTITIAL=this.doFetchAdsInfo(i).catch(()=>null)}),Le(this,"cacheAFVInfo",()=>{this.pendingAFVAdsInfo=this.doFetchAdsInfo("afv").catch(()=>null)}),Le(this,"cacheNextAFGAdsInfo",i=>E(this,null,function*(){i==="reward"?this.cacheRewardInfo():this.cacheInterstitialInfo(i)})),Le(this,"getAFGAdsInfo",i=>E(this,null,function*(){let o=yield i==="reward"?this.pendingAFGAdsInfo.REWARD:this.pendingAFGAdsInfo.INTERSTITIAL;return this.cacheNextAFGAdsInfo(i),o})),Le(this,"getAFVAdsInfo",function(){return E(this,arguments,function*(){if(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0]){let i=yield n.pendingAFVAdsInfo;return n.cacheAFVInfo(),i}else return n.cacheAFVInfo(),yield n.pendingAFVAdsInfo})}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.requestContext=new an(t),r!=null&&r.reward&&this.cacheRewardInfo(),r!=null&&r.interstitial&&this.cacheInterstitialInfo("start"),r!=null&&r.afv&&this.cacheAFVInfo()}};function $_(e,t,r){return(t=K_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function K_(e){var t=W_(e,"string");return typeof t=="symbol"?t:t+""}function W_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var z_=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(e)try{e(...r)}catch(i){console.error("[JoliboxSDK] Callback error:",i)}},Vi=class{constructor(t){this.context=t,$_(this,"canIUseHelper",void 0),this.context=t;let{canIUseNative:r}=Ud(()=>this.context.getContextInfo().deviceInfo.nativeSDKVersionCode||1e6,()=>this.context.getContextInfo().deviceInfo.platform||"h5");this.canIUseHelper=r}loadAdsAsync(t){return E(this,null,function*(){try{let{errNo:r,errMsg:n}=yield Si("loadAdsAsync",{params:{providers:t.providers}});return r!==0||n.length>0?{code:"FAILURE",message:n||"Failed to load ads"}:{code:"SUCCESS",message:"Ads loaded successfully"}}catch(r){return{code:"FAILURE",message:`Failed to load ads: ${r instanceof Error?r.message:String(r)}`}}})}canIUse(){return Gi()&&this.canIUseHelper("loadAdsAsync")&&this.canIUseHelper("showAdAsync")}showAdAsync(t){return E(this,null,function*(){try{let r=yield Si("showAdAsync",{params:{providers:t.providers}});if(r.errNo!==0)return{code:"FAILURE",message:r.errMsg||"Failed to show ad"};let n=r.data.UUID;if(t.callbacks){let i=t.timeout!==void 0?t.timeout:-1,o=null,a=()=>{Hd("onAdsStateChange",s),o&&(clearTimeout(o),o=null)},s=l=>{var c;if(l.UUID!==n)return;let m=(c=t.callbacks)==null?void 0:c[l.event];m&&z_(m,l.data),["onAdClosed","onAdError","onAdDismissed"].includes(l.event)&&a()};jd("onAdsStateChange",s),i>0&&(o=setTimeout(()=>{a(),console.warn(`[JoliboxSDK] Event listener for ad ${n} auto-cleaned after ${i}ms timeout`)},i))}return{code:"SUCCESS",message:"Ad shown successfully"}}catch(r){return{code:"FAILURE",message:`Failed to show ad: ${r instanceof Error?r.message:String(r)}`}}})}isAdsReadySync(t){try{let{errNo:r,data:n}=Si("isAdsReadySync",{params:{providers:t.providers}});return r!==0||!n?(console.warn("[Jolibox SDK]isAdsReadySync returned an error or no data"),!1):!0}catch(r){return console.warn("[Jolibox SDK]isAdsReadySync invocation failed:",r),!1}}};function It(e,t,r){return(t=Y_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Y_(e){var t=X_(e,"string");return typeof t=="symbol"?t:t+""}function X_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Rs=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){It(this,"providers",void 0),It(this,"helper",void 0),It(this,"adsContext",null),It(this,"_isAdsReady",!1),It(this,"init",()=>E(this,null,function*(){this.helper.canIUse()?(yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1:this._isAdsReady=!1})),It(this,"destroy",n=>{var i,o;this._isAdsReady=!1,(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),It(this,"reinit",n=>E(this,null,function*(){this.destroy(n),yield this.init()})),It(this,"requestAds",(n,i)=>E(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=n,i&&i.length>0&&(this.providers=i);try{this.isAdsReady?this.showAd():yield this.reinit("frequencyCapped")}catch(o){this.destroy("notReady")}})),It(this,"showAd",()=>{if(!this.adsContext){this.destroy("error");return}let n=!1,i=!1;this.adsContext.beforeReward(()=>E(this,null,function*(){var o,a;(a=(o=this.adsContext)==null?void 0:o.beforeAd)==null||a.call(o);let s=c=>{var m,d,p;i||(i=!0,c==="dismissed"&&((m=this.adsContext)==null||m.adDismissed()),(p=(d=this.adsContext)==null?void 0:d.afterAd)==null||p.call(d),this.reinit(c))},l={onAdShow:()=>{},onAdError:()=>{s("error")},onAdRewarded:()=>{var c;n=!0,(c=this.adsContext)==null||c.adViewed()},onAdDismissed:()=>{s(n?"viewed":"dismissed")},onAdClosed:()=>{s(n?"viewed":"dismissed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:l})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")}))}),this.providers=r,this.helper=new Vi(t),this.init()}};function At(e,t,r){return(t=Q_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Q_(e){var t=Z_(e,"string");return typeof t=="symbol"?t:t+""}function Z_(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Os=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){var n=this;At(this,"providers",void 0),At(this,"helper",void 0),At(this,"adsContext",null),At(this,"_isAdsReady",!1),At(this,"init",()=>E(this,null,function*(){this.helper.canIUse()&&((yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1)})),At(this,"destroy",function(i){var o,a;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n._isAdsReady=!1,s&&((a=(o=n.adsContext)==null?void 0:o.onEnd)==null||a.call(o,i),i!=="ignored"&&(n.adsContext=null))}),At(this,"reinit",function(o){return E(this,arguments,function*(i){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n.destroy(i,a),yield n.init()})}),At(this,"requestAds",(i,o)=>E(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=i,o&&o.length>0&&(this.providers=o);try{this.isAdsReady?yield this.showAd():yield this.reinit("frequencyCapped")}catch(a){this.destroy("notReady")}})),At(this,"showAd",()=>E(this,null,function*(){var i,o;if(!this.adsContext){this.destroy("error");return}let a=!1;(o=(i=this.adsContext).beforeAd)==null||o.call(i);let s=c=>{var m,d;a||(a=!0,(d=(m=this.adsContext)==null?void 0:m.afterAd)==null||d.call(m),this.reinit(c))},l={onAdShow:()=>{},onAdError:()=>{s("error")},onAdDismissed:()=>{s("dismissed")},onAdClosed:()=>{s("viewed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:l})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")})),this.providers=r,this.helper=new Vi(t),this.init()}};function Zr(e,t,r){return(t=ey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ey(e){var t=ty(e,"string");return typeof t=="symbol"?t:t+""}function ty(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ks=class{constructor(t,r){Zr(this,"name","INTERNAL_NATIVE"),Zr(this,"context",void 0),Zr(this,"rewardAdManager",void 0),Zr(this,"interstitialManager",void 0),Zr(this,"initProviders",void 0),this.context=t,this.initProviders=r.providers;let n=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],r.providers),i=this.getConfigsByTypes(["INTERSTITIAL"],r.providers);n.length>0&&(this.rewardAdManager=new Rs(this.context,n)),i.length>0&&(this.interstitialManager=new Os(this.context,i))}getConfigsByTypes(t,r,n){let i=[];return(n?n.map(o=>r.find(a=>a.provider===o.provider)).filter(o=>!!o):r).forEach(o=>{t.forEach(a=>{let s="";a==="REWARD"&&(s=o.params.adUnitId.reward),a==="REWARD_INTERSTITIAL"&&(s=o.params.adUnitId.rewardInterstitial),a==="INTERSTITIAL"&&(s=o.params.adUnitId.interstitial),a==="NATIVE"&&(s=o.params.adUnitId.nativeAds),s&&i.push({provider:o.provider,params:{placementId:s,adsType:a,extra:o.params.extra}})})}),i}init(){return E(this,null,function*(){})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}let a=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],this.initProviders,r.params);this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:s=>{var l;(l=t.adBreakDone)==null||l.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:s})}},a);break}default:{let a=t;if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}let s=this.getConfigsByTypes(["INTERSTITIAL"],this.initProviders,r.params);this.interstitialManager.requestAds({beforeAd:a.beforeAd,afterAd:a.afterAd,onEnd:l=>{var c;(c=t.adBreakDone)==null||c.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:l})}},s);break}}}},is="jolibox-nb-proxy",ry=0;function ny(e,t){return t==="call"&&e.join(".")==="GameSDK.showRewardAd"?0:15e3}function pu(e,t,r,n){return new Promise((i,o)=>{if(!window.parent||window.parent===window){o(new Error("[ParentProxy] No parent window"));return}let a=`${is}-${++ry}`,s=m=>{let d=m.data;(d==null?void 0:d.type)===`${is}:response`&&d.id===a&&(window.removeEventListener("message",s),c&&clearTimeout(c),d.error?o(new Error(d.error)):i(d.result))},l=ny(e,t),c=l>0?window.setTimeout(()=>{window.removeEventListener("message",s),o(new Error(`[ParentProxy] Timeout after ${l}ms: ${e.join(".")}.${t}`))},l):null;window.addEventListener("message",s),window.parent.postMessage({type:`${is}:request`,id:a,path:e,action:t,args:r,value:n},"*")})}function ef(e){return console.log("[JoliboxSDK] NewsBreak createProxyForPath basePath:",e),new Proxy(()=>{},{get(t,r){if(console.log("[JoliboxSDK] NewsBreak createProxyForPath get:",r),!(r==="then"||r==="toJSON"||typeof r=="symbol"))return ef([...e,r])},set(t,r,n){return console.log("[JoliboxSDK] NewsBreak createProxyForPath set:",r),pu([...e,r],"set",void 0,n).catch(i=>{console.warn(`[ParentProxy] set ${[...e,r].join(".")} failed:`,i)}),!0},apply(t,r,n){return console.log("[JoliboxSDK] NewsBreak createProxyForPath apply:",n),pu(e,"call",n)}})}function iy(e){return ef([e])}var Ui=()=>{try{if(window.parent&&window.parent!==window)return iy("GameSDK")}catch(e){}};function mr(e,t,r){return(t=oy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function oy(e){var t=ay(e,"string");return typeof t=="symbol"?t:t+""}function ay(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ts=class{constructor(){mr(this,"adsContext",null),mr(this,"init",()=>E(this,null,function*(){console.log("[JoliboxSDK] NewsBreak init");let t=Ui();if(t)try{let r=yield t.createRewardAd({platform:"jolibox"});console.log("[JoliboxSDK] NewsBreak init createRewardAd result:",r)}catch(r){console.log("[JoliboxSDK] NewsBreak init createRewardAd error:",r)}})),mr(this,"destroy",t=>{var r,n;(n=(r=this.adsContext)==null?void 0:r.adBreakDone)==null||n.call(r,t),t!=="ignored"&&(this.adsContext=null)}),mr(this,"reinit",t=>E(this,null,function*(){console.log("[JoliboxSDK] NewsBreak reinit breakStatus:",t),this.destroy(t),yield this.init()})),mr(this,"requestAds",t=>E(this,null,function*(){if(console.log("[JoliboxSDK] NewsBreak newsbreak this.adsContext",this.adsContext),this.adsContext){this.destroy("ignored");return}this.adsContext=t;let r=Ui();if(console.log("[JoliboxSDK] NewsBreak newsbreak sdk",r),!r){this.destroy("notReady");return}this.showAd()})),mr(this,"showAd",()=>{if(console.log("[JoliboxSDK] NewsBreak showAd"),!this.adsContext){this.destroy("error");return}this.adsContext.beforeReward(()=>E(this,null,function*(){var t,r,n,i,o,a,s,l,c,m,d,p,h,b;(r=(t=this.adsContext)==null?void 0:t.beforeAd)==null||r.call(t);let I=Ui();if(!I){(i=(n=this.adsContext)==null?void 0:n.afterAd)==null||i.call(n),this.reinit("error");return}try{let A=yield I.showRewardAd();if(console.log("[JoliboxSDK] NewsBreak showRewardAd result:",A),!A.success){(a=(o=this.adsContext)==null?void 0:o.afterAd)==null||a.call(o),this.reinit("error");return}A.rewardGranted?((s=this.adsContext)==null||s.adViewed(),(c=(l=this.adsContext)==null?void 0:l.afterAd)==null||c.call(l),this.reinit("viewed")):((m=this.adsContext)==null||m.adDismissed(),(p=(d=this.adsContext)==null?void 0:d.afterAd)==null||p.call(d),this.reinit("dismissed"))}catch(A){console.error("[JoliboxSDK] NewsBreak showRewardAd failed:",A),(b=(h=this.adsContext)==null?void 0:h.afterAd)==null||b.call(h),this.reinit("error")}}))}),this.init()}};function vu(e,t,r){return(t=sy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function sy(e){var t=ly(e,"string");return typeof t=="symbol"?t:t+""}function ly(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var xs=class{constructor(){vu(this,"name","NEWSBREAK"),vu(this,"rewardAdManager",void 0)}init(){return E(this,null,function*(){let t=Ui();if(!t){console.warn("[JoliboxSDK] NewsBreak GameSDK is not available on window");return}t.onEnter(),this.rewardAdManager=new Ts})}adConfig(t,r){}adBreak(t,r){var n,i;if(t.type!=="reward"){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:o=>{var a;(a=t.adBreakDone)==null||a.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:o})}})}};function Qe(e,t,r){return(t=cy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cy(e){var t=dy(e,"string");return typeof t=="symbol"?t:t+""}function dy(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var sn=class{constructor(t){if(Qe(this,"context",void 0),Qe(this,"contextInfo",void 0),Qe(this,"providers",{}),Qe(this,"channelPolicy",void 0),Qe(this,"adsActionDetection",void 0),Qe(this,"requestContext",void 0),Qe(this,"adsRequest",void 0),Qe(this,"initialized",!1),Qe(this,"adsIsShowing",!1),Qe(this,"lastAdBreak",void 0),Qe(this,"initializedTimeStamp",Date.now()),t)this.context=t,this.channelPolicy=new fs(this.context),this.adsActionDetection=new us(this.context),this.contextInfo=this.context.getContextInfo(),this.adsRequest=new qi(t),this.requestContext=new an(t);else throw new Error("JoliboxAdsForGame requires a configuration object")}init(t){return E(this,null,function*(){window.adsbygoogle=window.adsbygoogle||[];let{data:r}=yield this.context.httpClient.post("/api/ads/init",{data:{contextData:this.requestContext.getRequestContextData("AdsAFGSDKInit"),bizParams:this.requestContext.getRequestBizParams(),testAdsMode:this.contextInfo.testAdsMode}});if((r==null?void 0:r.length)>0){let n=r.filter(s=>s.isNative),i=r.filter(s=>!s.isNative),o={provider:"INTERNAL_NATIVE",params:{providers:n}},a=i.concat([o]);for(let s of a)switch(s.provider){case"GOOGLE_GPT":{let l=new Ss(this.context,s.params);yield l.init(),this.providers[s.provider]=l;break}case"ADSENSE":case"ADSENSE_ADMOB":{let l=new hs(this.context,s.params);yield l.init(),this.providers[s.provider]=l;break}case"OKSPIN":{let l=new ws(this.context,s.params);yield l.init(),this.providers.OKSPIN=l;break}case"APPSROCKETS":{let l=new Is(this.context,s.params);yield l.init(),this.providers.APPSROCKETS=l;break}case"ADSENSE_BANNER_AS_AFG":{let l=new Es(this.context,s.params);yield l.init(),this.providers.ADSENSE_BANNER_AS_AFG=l;break}case"INTERNAL_NATIVE":{let l=new ks(this.context,s.params);yield l.init(),this.providers.INTERNAL_NATIVE=l;break}case"NEWSBREAK":{console.log("[JoliboxSDK] NewsBreak Provider",s);let l=new xs;yield l.init(),this.providers.NEWSBREAK=l;break}}}this.adsRequest.cacheInterstitialInfo("start"),this.adsRequest.cacheRewardInfo(),this.initialized=!0})}adConfig(t){this.providers.ADSENSE?this.providers.ADSENSE.adConfig(t):window.adsbygoogle.push(t)}adBreak(t){return E(this,null,function*(){var r,n,i,o,a,s,l,c,m,d,p,h,b,I,A,w;let R=Date.now();if(R-this.initializedTimeStamp<3e3){console.log("[Jolibox SDK Ads] too soon"),(r=t.adBreakDone)==null||r.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}if(this.lastAdBreak&&R-this.lastAdBreak<500){console.warn("[Jolibox SDK Ads] You can't call adBreak too frequently"),(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.lastAdBreak=R,this.adsIsShowing){console.warn("[Jolibox SDK Ads] You can't call adBreak while ad is showing"),(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.initialized||(yield this.init()),t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}if(!this.context.checkNetwork()&&!this.providers.NEWSBREAK){console.log("[Jolibox SDK Ads] net not ready"),(a=t.adBreakDone)==null||a.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}try{let O=yield this.adsRequest.getAFGAdsInfo(t.type),D=O==null?void 0:O.data,M=O==null?void 0:O.code;if(M==="BYPASS_ADS"){switch(t.type){case"preroll":{(s=t.adBreakDone)==null||s.call(t,{breakType:t.type,breakFormat:"interstitial",breakStatus:"viewed"});break}case"reward":{t.beforeReward(()=>{var S,N,J,q;(S=t.beforeAd)==null||S.call(t),(N=t.adViewed)==null||N.call(t),(J=t.afterAd)==null||J.call(t),(q=t.adBreakDone)==null||q.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"viewed"})});break}default:{(l=t.beforeAd)==null||l.call(t),(c=t.afterAd)==null||c.call(t),(m=t.adBreakDone)==null||m.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"});break}}return}if(!D||M!=="SUCCESS"){console.log("[Jolibox SDK Ads] not SUCCESS"),(d=t.adBreakDone)==null||d.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}else{if(D.length===0){console.log("[Jolibox SDK Ads] ads info empty"),(p=t.adBreakDone)==null||p.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}let S=!0,N=null,J=new ds(this.context);this.adsActionDetection.adBreakIsShowing=!0;let q=D.filter(V=>V.isNative).sort((V,K)=>V.seq-K.seq),U=D.filter(V=>!V.isNative).sort((V,K)=>V.seq-K.seq),G={seq:(b=(h=q[0])==null?void 0:h.seq)!=null?b:0,provider:"INTERNAL_NATIVE",params:q},j;for(q.length>0?j=[G].concat(U):j=U,j=j.sort((V,K)=>V.seq-K.seq).map((V,K)=>Sv(yu({},V),{seq:K}));j.length>0;){let V=j.shift(),K=this.providers[V.provider];if(K){let[Fe,Yt]=yield J.callAdBreakAndContinue(K,t,V,Xt=>{var ct;this.adsIsShowing=Xt,(ct=this.context.eventEmitter)==null||ct.emit("isAdShowing",Xt)});S=Fe,N=Yt}else S=!0,N={breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"};if(!S)break}S&&N&&((I=t.adBreakDone)==null||I.call(t,N))}}catch(O){console.log("[Jolibox SDK Ads] error:",O),(A=t.adBreakDone)==null||A.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}finally{this.adsIsShowing=!1,(w=this.context.eventEmitter)==null||w.emit("isAdShowing",!1),this.adsActionDetection.adBreakIsShowing=!1}})}adUnit(t){console.warn("This method has been deprecated. We will not support AdSense AdUnit in the future.")}};function ki(e,t,r){return(t=uy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function uy(e){var t=fy(e,"string");return typeof t=="symbol"?t:t+""}function fy(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ns=class{constructor(t){ki(this,"context",void 0),ki(this,"currentProvider",void 0),ki(this,"continueCallback",void 0),ki(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo()}get paramsToTrack(){var t,r;return{provider:(r=(t=this.currentProvider)==null?void 0:t.name)!=null?r:null}}wrapAdRequested(t){return()=>{this.context.track("CallAFVRequest",this.paramsToTrack),t==null||t()}}wrapAdLoaded(t){return r=>{this.context.track("CallAFVLoad",this.paramsToTrack),t==null||t(r)}}wrapAdPlaying(t){return r=>{var n,i;this.context.track("CallAFVPlaying",this.paramsToTrack),Gi()&&this.context.track("mmp_ad_impression",{ad_network:(i=(n=this.currentProvider)==null?void 0:n.name)!=null?i:"",ad_format:"AFV",module:"drama",game_id:this.contextInfo.objectId}),t==null||t(r)}}wrapAdCompleted(t){return r=>{var n;this.context.track("CallAFVCompleted",this.paramsToTrack),t==null||t(r),(n=this.continueCallback)==null||n.call(this,[!1,null])}}wrapAdError(t){return r=>{var n;this.context.track("CallAFVError",this.paramsToTrack),(n=this.continueCallback)==null||n.call(this,[!0,r])}}callAdRequestAndContinue(t,r,n){return E(this,null,function*(){return this.currentProvider=t,new Promise(i=>{this.continueCallback=i;let o=Object.assign({},r);o.onAdRequested=this.wrapAdRequested(r.onAdRequested),o.onAdLoaded=this.wrapAdLoaded(r.onAdLoaded),o.onAdPlaying=this.wrapAdPlaying(r.onAdPlaying),o.onAdCompleted=this.wrapAdCompleted(r.onAdCompleted),o.onAdError=this.wrapAdError(r.onAdError),t.requestAd(o,n)})})}};function os(e,t,r){return(t=hy(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function hy(e){var t=my(e,"string");return typeof t=="symbol"?t:t+""}function my(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ke=class e extends Error{constructor(t,r){super(t.message),os(this,"name",void 0),os(this,"type",void 0),os(this,"raw",void 0),this.name="AFVRequestError",this.type=r,this.raw=t,this.stack=t.stack,this.message=t.message}static from(t,r){switch(r){case"GOOGLE_IMA_ERROR":return new e(t,r);case"JOLIBOX_IMA_ERROR":return new e(t,r)}}};function oe(e,t,r){return(t=py(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function py(e){var t=vy(e,"string");return typeof t=="symbol"?t:t+""}function vy(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ps=class{constructor(t,r,n){oe(this,"adsLoader",void 0),oe(this,"adDisplayContainer",void 0),oe(this,"isAdPlaying",!1),oe(this,"isContentFinished",!1),oe(this,"videoContent",void 0),oe(this,"adContainer",void 0),oe(this,"adsManager",void 0),oe(this,"intervalTimer",void 0),oe(this,"completed",!1),oe(this,"adTagUrl",void 0),oe(this,"notifyRequestAd",void 0),oe(this,"notifyLoaded",void 0),oe(this,"notifyPlayingAd",void 0),oe(this,"notifyCompleted",void 0),oe(this,"notifyError",void 0),oe(this,"destroy",()=>{var i,o,a,s,l,c,m,d,p,h,b;this.intervalTimer&&clearInterval(this.intervalTimer),(i=this.adsManager)==null||i.stop(),(o=this.adDisplayContainer)==null||o.destroy(),(a=this.adsLoader)==null||a.removeEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded),(s=this.adsLoader)==null||s.removeEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),(l=this.adsManager)==null||l.removeEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),(c=this.adsManager)==null||c.removeEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested),(m=this.adsManager)==null||m.removeEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested),(d=this.adsManager)==null||d.removeEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAdEvent),(p=this.adsManager)==null||p.removeEventListener(window.google.ima.AdEvent.Type.LOADED,this.onAdEvent),(h=this.adsManager)==null||h.removeEventListener(window.google.ima.AdEvent.Type.STARTED,this.onAdEvent),(b=this.adsManager)==null||b.removeEventListener(window.google.ima.AdEvent.Type.COMPLETE,this.onAdEvent)}),oe(this,"requestAds",(i,o)=>E(this,null,function*(){var a;this.createAdDisplayContainer(),this.notifyRequestAd=i.onAdRequested,this.notifyLoaded=i.onAdLoaded,this.notifyPlayingAd=i.onAdPlaying,this.notifyCompleted=i.onAdCompleted,this.notifyError=d=>{var p;return(p=i.onAdError)==null?void 0:p.call(i,ke.from(d,"GOOGLE_IMA_ERROR"))},this.adsLoader=new window.google.ima.AdsLoader(this.adDisplayContainer),this.adsLoader.addEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded,!1),this.adsLoader.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1);let s=()=>{var d;this.isAdPlaying||(this.isContentFinished=!0,(d=this.adsLoader)==null||d.contentComplete())};this.videoContent.onended=s;let l=new window.google.ima.AdsRequest;l.vastLoadTimeout=1e4;let c="";Object.keys(o.params).forEach(d=>{let p=window.encodeURIComponent(o.params[d]);c+=`&${d}=${p}`});let m=`${this.adTagUrl}${c}`;l.adTagUrl=m,l.linearAdSlotWidth=640,l.linearAdSlotHeight=400,l.nonLinearAdSlotWidth=640,l.nonLinearAdSlotHeight=150,this.adsLoader.requestAds(l),(a=this.notifyRequestAd)==null||a.call(this)})),oe(this,"createAdDisplayContainer",()=>{this.adDisplayContainer=new window.google.ima.AdDisplayContainer(this.adContainer,this.videoContent)}),oe(this,"playAds",()=>{var i,o;this.videoContent.load(),this.adDisplayContainer.initialize(),this.completed=!1;try{(i=this.adsManager)==null||i.init(window.document.body.clientWidth,window.document.body.clientHeight,window.google.ima.ViewMode.NORMAL),(o=this.adsManager)==null||o.start()}catch(a){console.error("[JoliboxAFV] Google IMA Error: ",a),this.videoContent.play()}}),oe(this,"onAdsManagerLoaded",i=>{let o=new window.google.ima.AdsRenderingSettings;o.restoreCustomPlaybackStateOnAdBreakComplete=!0,o.loadVideoTimeout=1e4,this.adsManager=i.getAdsManager(this.videoContent,o),this.adsManager.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.LOADED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.STARTED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.COMPLETE,this.onAdEvent),i.type==="adsManagerLoaded"&&this.playAds()}),oe(this,"onAdEvent",i=>{var o,a,s,l;let c=i.getAd();switch(i.type){case window.google.ima.AdEvent.Type.LOADED:c!=null&&c.isLinear()||this.videoContent.play(),(o=this.notifyLoaded)==null||o.call(this,i);break;case window.google.ima.AdEvent.Type.STARTED:c!=null&&c.isLinear()&&(this.intervalTimer=window.setInterval(function(){},300)),(a=this.notifyPlayingAd)==null||a.call(this,i);break;case window.google.ima.AdEvent.Type.COMPLETE:c!=null&&c.isLinear()&&clearInterval(this.intervalTimer),this.completed||(this.completed=!0,(s=this.notifyCompleted)==null||s.call(this,i));break;case window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED:c!=null&&c.isLinear()&&clearInterval(this.intervalTimer),this.completed||(this.completed=!0,(l=this.notifyCompleted)==null||l.call(this,i));break}}),oe(this,"onAdError",i=>{var o,a;(o=this.notifyError)==null||o.call(this,i.getError()),(a=this.adsManager)==null||a.destroy()}),oe(this,"onContentPauseRequested",()=>{this.isAdPlaying=!0,this.videoContent.pause()}),oe(this,"onContentResumeRequested",()=>{this.isAdPlaying=!1}),this.adTagUrl=t,this.videoContent=r,this.adContainer=n}},Bi=(e=>(e[e.ADS_REQUEST_NETWORK_ERROR=1012]="ADS_REQUEST_NETWORK_ERROR",e[e.ASSET_FALLBACK_FAILED=1021]="ASSET_FALLBACK_FAILED",e[e.AUTOPLAY_DISALLOWED=1205]="AUTOPLAY_DISALLOWED",e[e.COMPANION_AD_LOADING_FAILED=603]="COMPANION_AD_LOADING_FAILED",e[e.COMPANION_REQUIRED_ERROR=602]="COMPANION_REQUIRED_ERROR",e[e.FAILED_TO_REQUEST_ADS=1005]="FAILED_TO_REQUEST_ADS",e[e.INVALID_AD_TAG=1013]="INVALID_AD_TAG",e[e.INVALID_ADX_EXTENSION=1105]="INVALID_ADX_EXTENSION",e[e.INVALID_ARGUMENTS=1101]="INVALID_ARGUMENTS",e[e.NONLINEAR_DIMENSIONS_ERROR=501]="NONLINEAR_DIMENSIONS_ERROR",e[e.OVERLAY_AD_LOADING_FAILED=502]="OVERLAY_AD_LOADING_FAILED",e[e.OVERLAY_AD_PLAYING_FAILED=500]="OVERLAY_AD_PLAYING_FAILED",e[e.STREAM_INITIALIZATION_FAILED=1020]="STREAM_INITIALIZATION_FAILED",e[e.UNKNOWN_AD_RESPONSE=1010]="UNKNOWN_AD_RESPONSE",e[e.UNKNOWN_ERROR=900]="UNKNOWN_ERROR",e[e.UNSUPPORTED_LOCALE=1011]="UNSUPPORTED_LOCALE",e[e.VAST_ASSET_NOT_FOUND=1007]="VAST_ASSET_NOT_FOUND",e[e.VAST_EMPTY_RESPONSE=1009]="VAST_EMPTY_RESPONSE",e[e.VAST_LINEAR_ASSET_MISMATCH=403]="VAST_LINEAR_ASSET_MISMATCH",e[e.VAST_LOAD_TIMEOUT=301]="VAST_LOAD_TIMEOUT",e[e.VAST_MALFORMED_RESPONSE=100]="VAST_MALFORMED_RESPONSE",e[e.VAST_MEDIA_LOAD_TIMEOUT=402]="VAST_MEDIA_LOAD_TIMEOUT",e[e.VAST_NO_ADS_AFTER_WRAPPER=303]="VAST_NO_ADS_AFTER_WRAPPER",e[e.VAST_NONLINEAR_ASSET_MISMATCH=503]="VAST_NONLINEAR_ASSET_MISMATCH",e[e.VAST_PROBLEM_DISPLAYING_MEDIA_FILE=405]="VAST_PROBLEM_DISPLAYING_MEDIA_FILE",e[e.VAST_SCHEMA_VALIDATION_ERROR=101]="VAST_SCHEMA_VALIDATION_ERROR",e[e.VAST_TOO_MANY_REDIRECTS=302]="VAST_TOO_MANY_REDIRECTS",e[e.VAST_TRAFFICKING_ERROR=200]="VAST_TRAFFICKING_ERROR",e[e.VAST_UNEXPECTED_DURATION_ERROR=202]="VAST_UNEXPECTED_DURATION_ERROR",e[e.VAST_UNEXPECTED_LINEARITY=201]="VAST_UNEXPECTED_LINEARITY",e[e.VAST_UNSUPPORTED_VERSION=102]="VAST_UNSUPPORTED_VERSION",e[e.VAST_WRAPPER_ERROR=300]="VAST_WRAPPER_ERROR",e[e.VIDEO_PLAY_ERROR=400]="VIDEO_PLAY_ERROR",e[e.VPAID_ERROR=901]="VPAID_ERROR",e))(Bi||{}),gy=()=>{let e=Y(!1),t=Y(!1),r=Y(null),n=Fr(),i=Fr();return{visible:e,canRetry:t,retry:r,videoRef:n,adContainerRef:i}},_y=Te`
259
259
  ${ye}
260
260
  position: fixed;
261
261
  left: 0;
@@ -1,4 +1,4 @@
1
- var AO=Object.create;var Na=Object.defineProperty,CO=Object.defineProperties,kO=Object.getOwnPropertyDescriptor,xO=Object.getOwnPropertyDescriptors,TO=Object.getOwnPropertyNames,Ra=Object.getOwnPropertySymbols,PO=Object.getPrototypeOf,zl=Object.prototype.hasOwnProperty,jh=Object.prototype.propertyIsEnumerable;var Fh=(e,t,r)=>t in e?Na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))zl.call(t,r)&&Fh(e,r,t[r]);if(Ra)for(var r of Ra(t))jh.call(t,r)&&Fh(e,r,t[r]);return e},B=(e,t)=>CO(e,xO(t));var Qe=(e,t)=>{var r={};for(var n in e)zl.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ra)for(var n of Ra(e))t.indexOf(n)<0&&jh.call(e,n)&&(r[n]=e[n]);return r};var T=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Bh=(e,t)=>{for(var r in t)Na(e,r,{get:t[r],enumerable:!0})},OO=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of TO(t))!zl.call(e,i)&&i!==r&&Na(e,i,{get:()=>t[i],enumerable:!(n=kO(t,i))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?AO(PO(e)):{},OO(t||!e||!e.__esModule?Na(r,"default",{value:e,enumerable:!0}):r,e));var g=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});function UO(e){return!!(e!=null&&e.__nativeBuffers__)}function tu(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!UO(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let i;n.value?i=n.value:n.base64&&(i=MO(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function jO(e={},t=!1){let r=e,n=[];for(let[i,o]of Object.entries(r))if(o!==void 0&&o instanceof ArrayBuffer&&o.byteLength!==void 0){let a=t?{value:o,key:i}:{base64:FO(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function HO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function eg(e){return typeof e=="string"}function Kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Jh(e){return typeof e=="number"&&!isNaN(e)}function $O(e){return typeof e=="undefined"}function WO(e){return $O(e)||e===null}function tg(e){return typeof e=="function"}function zO(e){return Kn(e)&&tg(e.then)}function rg(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Yi(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function tR(e,t,r){let n=e;for(let i of t)if(n&&typeof n=="object")n=n[i];else return r;return n===void 0?r:n}function aR(){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}}function dR(e){return new Promise(t=>ng(e)(t))}function ng(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function pR(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Zi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function mR(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)hR(e[n],t[n])}function hR(e,t){if(eg(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(tg(t)){try{if(e instanceof t)return}catch(r){}if(!WO(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")}}function Ze(e,t){if(nu.config[e]){Fa.warn(`[can i use] ${e} already registered`);return}nu.config[e]=gr({},t)}function $h(e,t){return`[${e}]:${t}`}function SR(e,t){Wh||(Xl=new La({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Ql=new La({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Zl=new La({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{Xl.flush(),Ql.flush(),Zl.flush()}),Wh=!0);function r(i){var o,a;let{method:s,args:c,startTime:l,isForeground:d,errMsg:u=`${s}:fail no errMsg`,errNo:p=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=i,{receiveJSInvoke:m,invokeCallback:v}=f,b=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";Xl.report({status:b,method:n(s,c),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-l}),l&&m&&v&&(Ql.report({status:b,method:s,isForeground:d,duration:Number((m-l).toFixed(3))}),Zl.report({status:b,method:s,isForeground:d,duration:Number((Date.now()-v).toFixed(3))}))}function n(i,o){return(i==="callHostMethod"||i==="callHostMethodSync")&&o!=null&&o.method?`${i}-${o.method}`:i}return r}function CR(e,t){let r=0,n=!0,i=AR.resolveMap,o=SR(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,eu.forEach(c=>Ua(this,[c],function*({method:l,args:d,resolve:u}){let p=yield s(l,d);u(p)})),eu.length=0});let a=(c,l)=>{let d=i.get(Number(c));if(!d)return;let u=tu(l);d(u),i.delete(Number(c))},s=(c,l)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let m=new VO;if(i.set(r,m.resolve),!n&&yR.includes(c))return new Promise(C=>{eu.push({method:c,args:l,resolve:C})});let v=LO(gr({},{method:c,startTime:p,args:l,isForeground:f}),{invokeType:"js-bridge"}),b=!IR&&vR.includes(c),y=jO(l,b),_=b?y:JSON.stringify(y),E;if(c.endsWith("Sync")||bR.includes(c)?E=(d=e.call)==null?void 0:d.call(e,c,y,r):typeof _=="string"?E=e.invoke(c,_,r):E=(u=e.call)==null?void 0:u.call(e,c,_,r),E){try{typeof E=="string"&&(E=JSON.parse(E)),E=tu(E)}catch(C){Fa.error(C)}return i.delete(r),E.errorCode&&(E.errorCode=$h(c,E.errorCode)),o(gr(gr({},v),E)),E}return c.endsWith("Sync")&&i.delete(r),m.promise.then(C=>(C.errorCode&&(C.errorCode=$h(c,C.errorCode)),o(gr(gr({},v),C)),C))};return{invokeNative:s,applyNative:(c,l)=>{let d=s(c,l);return zO(d)?d.then(u=>zh(c,u)):zh(c,d)},invokeHandler:a}}function zh(e,t){if(!Kn(t)){Fa.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=qO(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new QO(n,i,o,a);return s}function kR(e){if(globalThis[Da])return globalThis[Da];let t=new au,r=new au,n=new La({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),globalThis[Da]={onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(i,o,a){let s=tu(o),c;if(s.__extra){c=s.params;let{type:l,startTime:d}=s.__extra;n.report({type:l,event:i,duration:Date.now()-d})}else c=s;if(i===ig){c.forEach(l=>{let[d,u]=l;try{r.emit(d.slice(Qi.length),u,a)}catch(p){}});return}if(i.startsWith(Qi)){r.emit(i.slice(Qi.length),c,a);return}t.emit(i,c,a)}},globalThis[Da]}function xR(e){let t=new Map,r=new Map,n,i;return{publish:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(`${Qi}${o}`,a,d);return}n||(n=Promise.resolve().then(()=>{t.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(ig,d,p)}catch(p){}}),n=void 0,t.clear()}));let l=t.get(s);l||(l=[],t.set(s,l)),l.push([`${Qi}${o}`,a])},emitNative:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(o,a,d),console.log("emitNative",o,a,d);return}i||(i=Promise.resolve().then(()=>{r.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(_R,d,p)}catch(p){}}),i=void 0,r.clear()}));let l=r.get(s);l||(l=[],r.set(s,l)),l.push([o,a])}}}function TR(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:i,unsubscribe:o}=kR(e),{invokeNative:a,invokeHandler:s,applyNative:c}=CR(e,r),{publish:l,emitNative:d}=xR(e);return{invokeHandler:s,subscribeHandler:t,applyNative:c,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:l,subscribe:i,unsubscribe:o}}function og(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var RO,NO,DO,qa,Yh,Xh,Gh,gr,LO,qO,Ua,MO,FO,Qh,BO,GO,Zh,JO,VO,KO,YO,Ma,XO,QO,ZO,Kl,Fa,Hh,eR,ru,rR,nu,nR,iR,oR,zn,sR,_z,iu,he,cR,lR,Xi,Zi,au,su,uR,Yl,fR,wz,cu,Vh,Sz,ja,gR,Qi,vR,yR,bR,ig,_R,wR,La,Wh,Xl,Ql,Zl,eu,IR,lu,ER,AR,Da,uu,Rt,ag,sg,PR,cg,Kh,de,L,we,lg,OR,ug,hn,Iz,Ez,ce=T(()=>{"use strict";RO=Object.defineProperty,NO=Object.defineProperties,DO=Object.getOwnPropertyDescriptors,qa=Object.getOwnPropertySymbols,Yh=Object.prototype.hasOwnProperty,Xh=Object.prototype.propertyIsEnumerable,Gh=(e,t,r)=>t in e?RO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gr=(e,t)=>{for(var r in t||(t={}))Yh.call(t,r)&&Gh(e,r,t[r]);if(qa)for(var r of qa(t))Xh.call(t,r)&&Gh(e,r,t[r]);return e},LO=(e,t)=>NO(e,DO(t)),qO=(e,t)=>{var r={};for(var n in e)Yh.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&qa)for(var n of qa(e))t.indexOf(n)<0&&Xh.call(e,n)&&(r[n]=e[n]);return r},Ua=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});MO=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer};FO=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(r[i]);return btoa(t)};Qh=Object.defineProperty,BO=Object.getOwnPropertyDescriptor,GO=(e,t)=>{for(var r in t)Qh(e,r,{get:t[r],enumerable:!0})},Zh=(e,t,r,n)=>{for(var i=n>1?void 0:n?BO(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&Qh(t,r,i),i},JO=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((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 i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,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}VO=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};KO=(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))(KO||{}),YO=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}},Ma=class extends YO{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},XO=class extends Ma{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},QO=class extends Ma{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},ZO=class extends Ma{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Kl=class extends Ma{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};Fa={log:Yi("log"),warn:Yi("warn"),info:Yi("info"),error:Yi("error"),debug:Yi("debug")};Object.assign(globalThis,{logger:Fa});Hh=Symbol.for("Jolibox.canIUseMap"),eR={};globalThis[Hh]||(globalThis[Hh]=eR);ru=Symbol.for("Jolibox.canIUseMap.native"),rR={};globalThis[ru]||(globalThis[ru]=rR);nu={get config(){return globalThis[ru]}},nR=(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))(nR||{}),iR=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(iR||{}),oR=(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))(oR||{});aR();zn=typeof window=="undefined",sR=()=>!zn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),_z={isiOS:!zn&&(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:!zn&&navigator.userAgent.includes("Android"),isMac:!zn&&navigator.userAgent.includes("Mac"),isFacebook:!zn&&navigator.userAgent.includes("FB_IAB"),isPC:!zn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},iu=class ou{constructor(t){this.element=t,this.next=ou.Undefined,this.prev=ou.Undefined}};iu.Undefined=new iu(void 0);he=iu,cR=class{constructor(){this._first=he.Undefined,this._last=he.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===he.Undefined}clear(){let e=this._first;for(;e!==he.Undefined;){let t=e.next;e.prev=he.Undefined,e.next=he.Undefined,e=t}this._first=he.Undefined,this._last=he.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new he(e);if(this._first===he.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==he.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==he.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==he.Undefined&&e.next!==he.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===he.Undefined&&e.next===he.Undefined?(this._first=he.Undefined,this._last=he.Undefined):e.next===he.Undefined?(this._last=this._last.prev,this._last.next=he.Undefined):e.prev===he.Undefined&&(this._first=this._first.next,this._first.prev=he.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==he.Undefined;)yield e.element,e=e.next}},lR=0,Xi=class{constructor(e){this.value=e,this.id=lR++}},Zi=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 Xi&&(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,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new Xi(t);return this._listeners?this._listeners instanceof Xi?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Xi)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),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(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Xi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},au=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Zi,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.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 cR,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)}},su={};GO(su,{None:()=>uR,filter:()=>pR,once:()=>ng,toPromise:()=>dR});uR=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Yl=Symbol.for("Jolibox.hostEmitter"),fR=()=>{let e=new au;return globalThis[Yl]||(globalThis[Yl]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Yl]},wz=fR();cu=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Zi,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return mR(i,r),n(...i)}}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}};cu=Zh([rg],cu);Vh=class{constructor(){this._onWillExecuteCommand=new Zi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Zi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new cu,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=HO(3e4)),this._starActivation}executeCommand(e,...t){return JO(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),su.toPromise(su.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}}};Vh=Zh([rg],Vh);Sz=Symbol.for("Jolibox.commands");Ze("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});Ze("requestProductDetailsAsync",{version:102e4});Ze("invokeSubscriptionPanelSync",{version:107e4,properties:{type:{game:107e4,drama:107e4}}});Ze("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Ze("getABTest",{version:1050100,platforms:{android:1050100,ios:!1}});Ze("userTrackAsync",{version:1e6});Ze("openMiniapp",{version:1050100});Ze("requestCoinDetailsSync",{version:1070100});Ze("requestCoinDetailsAsync",{version:1070100});Ze("sendServerEventAsync",{version:1070100});Ze("requestGameLeaderboardSync",{version:108e4});Ze("requestGameLeaderboardAsync",{version:108e4});Ze("notifyTaskGameInfoAsync",{version:1080100});Ze("loadAdsAsync",{version:1070200});Ze("showAdAsync",{version:1070200});Ze("onJoliboxHideLoading",{version:1070300});ja=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let c=nu.config[a];if(!c)return!1;let l=(o=t==null?void 0:t())!=null?o:"",d=c.version;if(c.platforms&&l in c.platforms){let p=c.platforms[l];if(p===!1)return!1;typeof p=="number"&&(d=p)}if(typeof d!="number")return!1;let u=e();return typeof u!="number"||u<d?!1:s.length===0?!0:n(c,s,u)||n(c.properties,s,u)}function n(i,o,a){if(!i)return!1;let s=tR(i,o);if(!s)return!1;if(Kn(s)){let c=s.version;return Jh(c)?typeof a=="number"&&a>=c:!0}return Jh(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};gR=()=>sR(),Qi="custom_event_",vR=[],yR=[],bR=["env","createRequestTask","login"],ig="__batch_event__",_R="__native_batch_event__",wR=e=>e==="pv"?e:"default",La=class{constructor(e){this.interval=30,this.lastReportTime=0,this.cache={};let{reporter:t,interval:r=30,eventName:n,tagNameOrder:i,metricName:o,type:a}=e;this.reporter=t,this.interval=r,this.eventName=n,this.tagNameOrder=i,this.metricName=o,this.type=wR(a)}report(e){this.type==="pv"?this.addPVPoint(e):this.addPoint(e),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(e){if(Object.keys(this.cache).length){if(e){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(e){let t=(r,n,i,o)=>{let a=n.shift();if(a){let s=o[a];r[s]||(r[s]={}),t(r[s],n,i,o)}else r[i]||(r[i]=[]),r[i].push(o[i])};t(this.cache,[...this.tagNameOrder],this.metricName,e)}addPVPoint(e){let t=(n,i,o,a)=>{let s=i.shift();if(!s&&Kn(a))throw new Kl(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let c=[];if(Kn(a))c.push(...Object.keys(a));else if(eg(a)){if(i.length>0)throw new Kl(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);c.push(a)}else throw new Kl(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(r)}`);c.forEach(l=>{n[l]||(n[l]={});let d=Kn(a)?a[l]:a;t(n[l],[...i],o,d)})}else n[o]?n[o]++:n[o]=1},r={point:e,metricName:this.metricName,tagNameOrder:this.tagNameOrder};t(this.cache,[...this.tagNameOrder],this.metricName,e)}processPoints(e){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:e}}clearPoints(){this.cache={}}},Wh=!1;eu=[],IR=!1,lu=Symbol.for("Jolibox.invokeResolverInstance"),ER=new Map;globalThis[lu]||(globalThis[lu]=ER);AR={get resolveMap(){return globalThis[lu]}};Da=Symbol.for("Jolibox.subscribeInstance");Rt={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){Rt.trigger=e},onDoExit(e){Rt.exit=e},onDoBackPress(e){Rt.backPress=e}},ag=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new XO("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(typeof window!="undefined"&&window.webkit){let e=window.webkit.messageHandlers,t=(i="")=>{Rt.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>Ua(void 0,null,function*(){let o=yield Rt.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});uu={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=og(o,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:i,paramsString:JSON.stringify(s),webviewIds:a}))},call(i,o,a){let s=window.prompt("invoke",JSON.stringify({event:i,paramsString:JSON.stringify(o),callbackId:a}));if(s)return JSON.parse(s)}};let n={onDocumentReady:t,env:ag,doExit:r};globalThis.joliboxJSCore=gr({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{Rt.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>Ua(void 0,null,function*(){let a=yield Rt.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});uu={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let c=og(a,"joliboxJSCore");t.publish(JSON.stringify({event:o,paramsString:JSON.stringify(c),webviewIds:s}))},call(o,a,s){let c=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(a),callbackId:s}));if(c)return JSON.parse(c)},doBackPress(o){return Ua(this,null,function*(){let a=yield Rt.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:ag,doExit:n};globalThis.joliboxJSCore=gr({},i)}sg=uu;if(!sg&&gR())throw new ZO("No joliboxJScore is found, native bridge not found.");PR=gr({},sg),cg=TR(PR),{invokeHandler:Kh}=cg,{applyNative:de,invokeNative:L,onNative:we,offNative:lg,subscribeHandler:OR,publish:ug,emitNative:hn,subscribe:Iz,unsubscribe:Ez}=cg;globalThis.joliboxJSBridge={callHandler:Kh,invokeHandler:Kh,subscribeHandler:OR}});function qR(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Ga(e){return new Promise(t=>setTimeout(t,e))}function io(e){return typeof e=="string"}function vn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function vg(e){return typeof e=="object"&&Array.isArray(e)}function Ja(e){return typeof e=="number"&&!isNaN(e)}function Jr(e){return e===!0||e===!1}function yg(e){return typeof e=="undefined"}function oo(e){return yg(e)||e===null}function UR(e){return typeof e=="function"}function bg(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function _g(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,o){for(let a in o)if(Object.prototype.hasOwnProperty.call(o,a)){let s=i[a],c=o[a],l=r(s,c,a,i,o);l!==void 0?i[a]=l:fg(c)&&fg(s)?i[a]=n(hg({},s),c):Array.isArray(c)&&Array.isArray(s)?i[a]=[...s,...c]:i[a]=c}return i}return n(e,t)}function fg(e){return e&&typeof e=="object"&&e.constructor===Object}function wg(e,t){if(Array.isArray(e))return e.concat(t)}function ao(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:c=!0}=r,l=()=>(a=e.apply(o,i),i=void 0,o=void 0,a),d=function(...u){i=u,o=this;let p=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&l()},t),p)return l()};return d.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,l()},d}function FR(e,t){return(...r)=>t(e,...r)}function Yn(e){return t=>FR(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new zt(`${i}`))}})}function eo(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Cg(e,t,r){let n=0;if(e!==t){let i=e.split("."),o=t.split("."),a=Math.max(i.length,o.length);for(let s=0;s<a;s++){let c=parseInt(i[s],10)||0,l=parseInt(o[s],10)||0;if(c>l){n=1;break}else if(c<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}}function Iu(){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}}function VR(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com"||a==="mporia.com"||a==="pingplus.ai")return`${o}.${a}`}return`${o}.jolibox.com`}function Eu(e){return VR("app","stg-app",e)}function Qn(e){return`https://${Eu(e)}`}function KR(e){return new Promise(t=>Pg(e)(t))}function Pg(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function YR(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new no(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function QR(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ZR(e[n],t[n])}function ZR(e,t){if(io(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(UR(t)){try{if(e instanceof t)return}catch(r){}if(!oo(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")}}function e1(){return typeof globalThis!="undefined"?globalThis[Og]:void 0}function t1(e){typeof globalThis!="undefined"&&(globalThis[Og]=e)}function Y(e=!1){let t=e1();if(!e&&t)return t;let r=new Ba,n=new gu,i={registerCommand(o,a,s){r.registerCommand({id:o,handler:a,metadata:s})},executeCommand(o,...a){return n.executeCommand(o,...a)},excuteCommandSync(o,...a){return n.executeCommandThowErr(o,...a)}};return t1(i),i}var vu,RR,dg,NR,DR,pg,hg,LR,gg,gn,pt,MR,yu,so,bu,Sg,zt,Ha,Ig,Va,Eg,Ag,co,_u,Kt,pu,jR,wu,mg,BR,K,Su,GR,Xn,to,lo,JR,HR,kg,xg,Tg,Ft,fu,ge,$R,WR,ro,no,Yt,hu,zR,du,XR,Se,Ba,gu,Og,R=T(()=>{"use strict";vu=Object.defineProperty,RR=Object.getOwnPropertyDescriptor,dg=Object.getOwnPropertySymbols,NR=Object.prototype.hasOwnProperty,DR=Object.prototype.propertyIsEnumerable,pg=(e,t,r)=>t in e?vu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,hg=(e,t)=>{for(var r in t||(t={}))NR.call(t,r)&&pg(e,r,t[r]);if(dg)for(var r of dg(t))DR.call(t,r)&&pg(e,r,t[r]);return e},LR=(e,t)=>{for(var r in t)vu(e,r,{get:t[r],enumerable:!0})},gg=(e,t,r,n)=>{for(var i=n>1?void 0:n?RR(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&vu(t,r,i),i},gn=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((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 i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,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}pt=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};MR=(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))(MR||{}),yu=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}},so=class extends yu{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},bu=class extends yu{constructor(){super(...arguments),this.kind="USER_ERROR"}},Sg=class extends bu{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},zt=class extends bu{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Ha=class extends bu{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_PAYMENT_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Ig=class extends so{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Va=class extends so{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="INTERNAL_PAYMENT_ERROR",this.priority="P0",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Eg=class extends so{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},Ag=class extends so{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},co=class extends yu{constructor(e,t,r,n,i){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),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},_u=class extends so{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Kt={log:eo("log"),warn:eo("warn"),info:eo("info"),error:eo("error"),debug:eo("debug")};Object.assign(globalThis,{logger:Kt});pu=Symbol.for("Jolibox.canIUseMap"),jR={};globalThis[pu]||(globalThis[pu]=jR);wu={get config(){return globalThis[pu]}},mg=Symbol.for("Jolibox.canIUseMap.native"),BR={};globalThis[mg]||(globalThis[mg]=BR);K=(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))(K||{}),Su=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Su||{}),GR=(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))(GR||{}),Xn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});Iu();to=typeof window=="undefined",lo={isiOS:!to&&(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:!to&&navigator.userAgent.includes("Android"),isMac:!to&&navigator.userAgent.includes("Mac"),isFacebook:!to&&navigator.userAgent.includes("FB_IAB"),isPC:!to&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},JR="device_id",HR="advertising_id",kg=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Xn()),window.__joliboxLocalStorage__.getItem(e)),xg=()=>new URLSearchParams(window.location.search).get("deviceId")||kg(JR),Tg=()=>new URLSearchParams(window.location.search).get("advertisingId")||kg(HR);Ft=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=hg({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return gn(this,null,function*(){let r=this.config.keyGenerator(e,t),n=this.pendingRequests.get(r);if(n)return console.log(`[RequestCacheService] Reusing pending request for ${e}`),n;let i=this.requestInternal(e,t),o=this.createTimeoutPromise(),a=Promise.race([i,o]).catch(s=>gn(this,null,function*(){if(s.message.includes("timeout")){let c=this.getValidCachedData(r);if(c)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}throw s}));this.pendingRequests.set(r,a),i.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${e}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${e}:`,s)});try{return yield a}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return gn(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,c=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",c),c){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let u=yield this.requestAdapter.execute(e,t),p=this.requestAdapter.extractRealTimeData(u),f=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,u);return f&&!this.config.consistencyChecker(c,f)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,f,s),u):this.requestAdapter.mergeData(c,p)}catch(u){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,u),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let l=yield this.requestAdapter.execute(e,t),d=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,l);return d&&this.setCachedDataWithSequence(a,d,s),l})}createTimeoutPromise(){return new Promise((e,t)=>{setTimeout(()=>{t(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(e){let t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),null):t.data:null}setCachedDataWithSequence(e,t,r,n){let i=this.cache.get(e);if(i&&i.sequence>r){console.log(`[RequestCacheService] Ignoring stale cache update for ${e} (current: ${i.sequence}, incoming: ${r})`);return}let o=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:o,expiresAt:o+this.config.duration,key:e,sequence:r,metadata:n}),this.cacheSequences.set(e,r),console.log(`[RequestCacheService] Updated cache for ${e} with sequence ${r}`)}refreshCache(e,t){return gn(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return gn(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),o=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${o})`);let a=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,a);return s&&(this.setCachedDataWithSequence(i,s,o),console.log(`[RequestCacheService] Force updated cache for ${e}`)),a})}warmupCache(e,t){return gn(this,null,function*(){let r=this.config.keyGenerator(e,t);if(this.pendingRequests.has(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - request in progress`);return}if(this.hasValidCache(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${e}`),yield this.forceRequest(e,t)}catch(n){console.warn(`[RequestCacheService] Cache warmup failed for ${e}:`,n)}})}clearCache(e){e?(this.cache.delete(e),this.cacheSequences.delete(e),this.pendingRequests.delete(e),console.log(`[RequestCacheService] Cleared cache for ${e}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let e=Date.now();for(let[t,r]of this.cache)e>r.expiresAt&&(this.cache.delete(t),this.cacheSequences.delete(t));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let e=Date.now(),t=0,r=0;for(let n of this.cache.values())e>n.expiresAt?r++:t++;return{cacheCount:this.cache.size,validCount:t,expiredCount:r,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(e){let t=this.cache.get(e);return t?Date.now()<=t.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(e){return this.pendingRequests.has(e)}getCacheSequence(e){return this.cacheSequences.get(e)}},fu=class mu{constructor(t){this.element=t,this.next=mu.Undefined,this.prev=mu.Undefined}};fu.Undefined=new fu(void 0);ge=fu,$R=class{constructor(){this._first=ge.Undefined,this._last=ge.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ge.Undefined}clear(){let e=this._first;for(;e!==ge.Undefined;){let t=e.next;e.prev=ge.Undefined,e.next=ge.Undefined,e=t}this._first=ge.Undefined,this._last=ge.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new ge(e);if(this._first===ge.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==ge.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ge.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ge.Undefined&&e.next!==ge.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ge.Undefined&&e.next===ge.Undefined?(this._first=ge.Undefined,this._last=ge.Undefined):e.next===ge.Undefined?(this._last=this._last.prev,this._last.next=ge.Undefined):e.prev===ge.Undefined&&(this._first=this._first.next,this._first.prev=ge.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ge.Undefined;)yield e.element,e=e.next}},WR=0,ro=class{constructor(e){this.value=e,this.id=WR++}},no=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 ro&&(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,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new ro(t);return this._listeners?this._listeners instanceof ro?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof ro)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),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(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof ro?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Yt=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new no,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.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 $R,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)}},hu={};LR(hu,{None:()=>zR,filter:()=>YR,once:()=>Pg,toPromise:()=>KR});zR=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});du=Symbol.for("Jolibox.hostEmitter"),XR=()=>{let e=new Yt;return globalThis[du]||(globalThis[du]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[du]},Se=XR();Ba=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new no,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return QR(i,r),n(...i)}}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}};Ba=gg([bg],Ba);gu=class{constructor(){this._onWillExecuteCommand=new no,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new no,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Ba,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=qR(3e4)),this._starActivation}executeCommand(e,...t){return gn(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),hu.toPromise(hu.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}}};gu=gg([bg],gu);Og=Symbol.for("Jolibox.commands")});function ke(e,t={}){Au.emit("ERROR_REPORT",{error:e,options:t})}var Au,yn,_t=T(()=>{"use strict";R();R();Au=new Yt,yn=new Yt;ke.debounce=ao(ke,50,{leading:!0})});var Cu,r1,Rg,Ng,Dg=T(()=>{"use strict";R();_t();Cu=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(i){return{}}},r1=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Rg=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[o,a,s]=i;return{headerJson:Cu(o),payloadJson:Cu(a),signature:Cu(s)}}else throw"joli_source is missing"}catch(r){return ke(new Ig(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},Ng=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=r1(e),o=r[2];return`${n}.${i}.${o}`}return t}});var n1,ku,Lg=T(()=>{"use strict";R();n1="1.4.13",ku=()=>n1});function Tu(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var i1,qg,xu,Ug,ve,o1,I,$=T(()=>{"use strict";R();Dg();Lg();R();i1={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:xg(),adId:Tg(),pixelRatio:window.devicePixelRatio||1,platform:lo.isAndroid?"android":lo.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:ku()},schema:window.location.href,platform:lo.isAndroid?"android":lo.isiOS?"ios":"h5"},xu=(qg=globalThis.joliboxJSCore)==null?void 0:qg.env,ve=Object.assign({},(Ug=xu==null?void 0:xu())!=null?Ug:i1);o1=()=>{var v,b,y,_,E,C,x,k,A,H,ue;let{payloadJson:e,headerJson:t,signature:r}=ve.schema.length?Rg(ve.schema):{},n=`${ve.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ve.schema.length?ve.schema:window.location.href).searchParams,a=(y=(b=(v=o.get("mpId"))!=null?v:o.get("appId"))!=null?b:o.get("gameId"))!=null?y:"",s=(C=(E=(_=ve.clientSessionId)!=null?_:e==null?void 0:e.sessionId)!=null?E:o.get("sessionId"))!=null?C:n,c=!!((k=(x=e==null?void 0:e.testAdsMode)!=null?x:e==null?void 0:e.__testAdsMode)!=null?k:o.get("testAdsMode")==="true"),l=(ue=(H=(A=e==null?void 0:e.joliboxEnv)!=null?A:e==null?void 0:e.__joliboxEnv)!=null?H:o.get("joliboxEnv"))!=null?ue:"production",d=l==="staging",u=t==null?void 0:t.channel,f=new URL(window.location.href).searchParams,m=e==null?void 0:e.__shouldInterupt;return{get startTime(){var N;return(N=performance.timeOrigin)!=null?N:performance.timing.navigationStart},get testMode(){return d},get testAdsMode(){return c},get joliboxEnv(){return l},get joliSource(){var N,O;return(O=(N=f.get("joliSource"))!=null?N:o.get("joliSource"))!=null?O:null},get mpId(){var N;return(N=a!=null?a:e==null?void 0:e.id)!=null?N:""},get mpVersion(){var N;return(N=t==null?void 0:t.ver)!=null?N:ku()},get mpType(){var N,O;return(O=(N=t==null?void 0:t.__mpType)!=null?N:e==null?void 0:e.__mpType)!=null?O:"game"},get platform(){var N;return((N=ve.platform)!=null?N:ve.deviceInfo.platform).toLowerCase()},get deviceInfo(){return ve.deviceInfo},get sdkInfo(){return ve.sdkInfo},get hostInfo(){return ve.hostInfo},get hostUserInfo(){return ve.hostUserInfo},get sessionId(){var N,O;return(O=(N=ve.clientSessionId)!=null?N:s)!=null?O:n},get channel(){return u},get webviewId(){var N;return(N=ve.webviewId)!=null?N:-1},get shouldInterupt(){return m},get from(){return e==null?void 0:e.__from},get baseApiHost(){return Eu(d)},get adId(){var N;return(N=ve.deviceInfo.adId)!=null?N:ve.deviceInfo.did},get language(){return ve.deviceInfo.lang},get sdkEnvironment(){return Tu("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Tu("gamedistribution","jolibox")?"gamedistribution":Tu("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var J,V,Mt;let N=(J=ve.deviceInfo.pixelRatio)!=null?J:1,O=(V=ve.deviceInfo.statusBarHeight)!=null?V:e==null?void 0:e.__androidStatusBarHeight,F=(Mt=ve.deviceInfo.navigationBarHeight)!=null?Mt:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:O!==void 0?O/N:20,navigationBarHeight:F!==void 0?F/N:10}},get abTests(){var N,O;return(O=(N=ve.abValues)==null?void 0:N.split(","))!=null?O:[]},get mpInfo(){var N;return(N=ve.mpInfo)!=null?N:{mpName:"unknown"}},onEnvConfigChanged:N=>{_g(ve,N,wg)},encodeJoliSourceQuery:N=>{var O,F;return t&&r?Ng(P(P({},e),N),(O=o.get("joliSource"))!=null?O:""):(F=o.get("joliSource"))!=null?F:""},setDoExitDirectly:()=>{m=!1}}},I=o1()});var Pu,Fg,a1,s1,Mg,c1,jg=T(()=>{"use strict";R();_t();$();R();Pu=!1,Fg=(e,t)=>e==null?!1:t in e,a1=e=>Fg(e,"kind"),s1=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Mg=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=I.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:s1(e.name)},i=B(P({},n),{env:t.environment,isFromUser:r});r?yn.emit("GLOBAL_USER_ERROR",e,i):yn.emit("GLOBAL_ERROR",e,i)},c1=e=>Fg(e,"kind")&&e.kind==="USER_ERROR";Au.on("ERROR_REPORT",({error:e,options:t})=>{if(Pu)return;Pu=!0;let r=a1(e)&&e.raw?e.raw:e;try{let n=c1(e);Mg(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new _u(`${i}, origin error: ${r.message}`);Kt.error(o),Mg(new _u(o.message),{environment:t.environment},!1)}finally{Pu=!1}})});var xe,Ou,Hr=T(()=>{"use strict";_t();R();_t();xe=(e,t)=>{var r,n;return new co((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Ou=e=>new Sg(e)});var Bg=T(()=>{"use strict";jg();Hr();R();ce();yn.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};L("trackAsync",{event:"reportJsError",data:r})});yn.on("GLOBAL_USER_ERROR",(e,t)=>{Kt.log("UserError",e,t)})});var Ru=T(()=>{"use strict"});function Gg(e,t){let r=(n,i,o)=>{let l=i!=null?i:{},{eventType:a}=l,s=Qe(l,["eventType"]),c=B(P({tag:n,eventType:o!=null?o:a!=null?a:K.Other},t),{extra:P({},s)});n=="globalJsError"?ke(new Ag(JSON.stringify(c))):e("systemLog",c,I.webviewId)};return r.debounce=ao(r,500,{leading:!0}),r}function Jg(e){let t=(r,n,i)=>{var s;let o=(s=i&&JSON.stringify(i))!=null?s:0,a={speed_value_type:r,total_duration:n};o&&Object.assign(a,{extra:o}),e("joliboxSpeedAnalysis",a)};return t.debounce=ao(t,500,{leading:!0}),t}var Hg=T(()=>{"use strict";R();R();_t();$()});function Vg(e,t){let r=Gg(e,t),n=Jg(r);return{track:r,trackPerformance:n}}var $g=T(()=>{"use strict";Hg()});var Wg=T(()=>{"use strict";$();R();R()});var zg=T(()=>{"use strict";$g();Ru();Wg()});var $a,Kg=T(()=>{"use strict";$a=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(t)});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let f=Date.now(),m=f-r;m>=this.interval&&(this.visible&&(a+=Math.min(m,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},c=()=>{d(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},l=()=>{u(),r=Date.now(),n=requestAnimationFrame(s)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",f=>{o&&(console.log("visible",f),f?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,d(),u()}}}}});function Wa(e,t,r){var c,l,d;let n=new Map,i=(c=r==null?void 0:r.baseUrl)!=null?c:Qn(I.testMode),o=(l=r==null?void 0:r.type)!=null?l:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return we("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let f=u,{requestTaskId:v,state:b}=f,y=Qe(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(y):p.reject(y),n.delete(v)}else if(u.state==="fail"){let m=u,{requestTaskId:v,state:b}=m,y=Qe(m,["requestTaskId","state"]);p.reject(y),n.delete(v)}else Kt.warn("onRequestTaskStateChange unknown event",u)}),Se.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...m)=>g(this,[f,...m],function*(u,p={}){let v=Date.now(),b=l1(u,B(P({},p),{baseUrl:i})),{method:y="GET",responseType:_="text",dataType:E="json",timeout:C,enableCache:x=!1,appendHostCookie:k=!0}=p,A=Object.assign({"content-type":"application/json"},a,p.header),H={url:b,method:y,header:A,enableCache:x,responseType:_,appendHostCookie:k};if(y=="POST"||y=="PUT"){let J=d1(p.data,A["content-type"]);H.data=J}C&&Object.assign(H,{timeout:C});let{data:{requestTaskId:ue}}=L(e,H);if(typeof ue!="string")throw xe({code:-1,msg:"requestTaskId is not a string"});let{resolve:N,reject:O,promise:F}=new pt;n.set(ue,{resolve:N,reject:O});try{let J=yield F,{data:V}=J;return E==="json"&&typeof V=="string"&&(V=u1(V)),{url:b,timeout:C,method:y,response:B(P({},J),{data:V})}}catch(J){let V=J;if(vn(V)){let{errMsg:Mt,prefetchDetail:Mh,isPrefetch:Wl,errNo:Oa}=V;io(Mt)&&ke(xe({code:-1,msg:Mt},{errNo:Oa,errMsg:Mt}))}throw J}})}function u1(e){try{return JSON.parse(e.trim())}catch(t){return e}}function d1(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var l1,Nu=T(()=>{"use strict";R();ce();_t();Hr();$();l1=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,i=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${i?`?${i}`:""}`:`${e}${i?`?${i}`:""}`}});var Du,Yg,X,ft=T(()=>{"use strict";Nu();$();R();Du={};(Yg=I.hostUserInfo)!=null&&Yg.token&&(Du["x-joli-token"]=I.hostUserInfo.token);I.joliSource&&(Du["x-joli-source"]=I.joliSource);X=Wa("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:Qn(I.testMode),defaultHeaders:Du})});function Xg(e){let t=wu.config[e];return t||(t={},wu.config[e]=t),(r,n)=>{if(t[r]){Kt.warn(`[can i use] ${r} already registered`);return}t[r]=P({},n)}}var Qg=T(()=>{"use strict";R()});function Lu(e){Zg=e}function za(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>za(t)):Object.keys(e).reduce((t,r)=>(t[r]=za(e[r]),t),{})}function vr(e){return typeof e=="number"}function qu(e){let t=Uu(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Uu(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Zg,Oe,Ka,Ya,Xa,Qa,Zn,Za,es,ts,rs,ns,is,os,as,ss,cs,ls,us,Mu=T(()=>{"use strict";Zg=!1;Oe=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Zg)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${qu(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return za(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:za(this._default)}optional(){return this._optional=!0,this}};Ka=class extends Oe{validate(t){return this._optional&&t===void 0?!0:vr(t)?vr(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):vr(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):vr(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},Ya=class extends Oe{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Xa=class extends Oe{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(vr(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(vr(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},Qa=class extends Oe{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},Zn=class extends Oe{validate(t){return!0}},Za=class extends Oe{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},es=class extends Oe{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},ts=class extends Oe{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},rs=class extends Oe{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${qu(t)}`)}return!0}},ns=class extends Oe{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(vr(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(vr(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(vr(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let i=!0;if(r.forEach((o,a)=>{if(n.path=`${this.path}[${a}]`,n.errors=this.errors,o===void 0&&n.hasDefault){r[a]=n.defaultValue;return}n.validate(o)||(n.hasFallback?r[a]=n.fallbackValue:i=!1)}),this._uniqueItems){let o=new Map;for(let a in r)o.has(r[a])?i=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${o.get(r[a])}] and ${this.path}[${a}] are identical)`):o.set(r[a],a)}return i}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},is=class extends Oe{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Uu(r)!=="object")return this.fail({expect:"object",actual:r});let i=r,o=this._value;o.errors=this.errors;let a=!0;for(let s in i){let c=i[s];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?o.path=`${this.path}.${s}`:o.path=`${this.path}["${s}"]`,!(c===void 0&&o._optional)){if(c===void 0&&o.hasDefault){i[s]=o.defaultValue;continue}o.validate(c)||(o.hasFallback?i[s]=o.fallbackValue:a=!1)}}return a}},os=class extends Oe{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Uu(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,i=!0;for(let o in this._object){let a=n[o],s=this._object[o];if(s.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(o)?s.path=`${this.path}.${o}`:s.path=`${this.path}["${o}"]`,!(s._optional&&a===void 0)){if(a===void 0&&s.hasDefault){n[o]=s.defaultValue;continue}s.validate(a)||(s.hasFallback?n[o]=s.fallbackValue:i=!1)}}return i}},as=class extends Oe{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:qu(this.value),actual:r}):!0}},ss=class extends Oe{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,i=this._items.length;for(let o=0;o<i;o++){let a=this._items[o];if(a.errors=[],a.path=this.path,!a.validate(t))r.push(a.errors.join("; "));else if(!n){n=!0;break}}if(!n){let o=r.join(`
1
+ var AO=Object.create;var Na=Object.defineProperty,CO=Object.defineProperties,kO=Object.getOwnPropertyDescriptor,xO=Object.getOwnPropertyDescriptors,TO=Object.getOwnPropertyNames,Ra=Object.getOwnPropertySymbols,PO=Object.getPrototypeOf,zl=Object.prototype.hasOwnProperty,jh=Object.prototype.propertyIsEnumerable;var Fh=(e,t,r)=>t in e?Na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))zl.call(t,r)&&Fh(e,r,t[r]);if(Ra)for(var r of Ra(t))jh.call(t,r)&&Fh(e,r,t[r]);return e},B=(e,t)=>CO(e,xO(t));var Qe=(e,t)=>{var r={};for(var n in e)zl.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ra)for(var n of Ra(e))t.indexOf(n)<0&&jh.call(e,n)&&(r[n]=e[n]);return r};var T=(e,t)=>()=>(e&&(t=e(e=0)),t);var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Bh=(e,t)=>{for(var r in t)Na(e,r,{get:t[r],enumerable:!0})},OO=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of TO(t))!zl.call(e,i)&&i!==r&&Na(e,i,{get:()=>t[i],enumerable:!(n=kO(t,i))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?AO(PO(e)):{},OO(t||!e||!e.__esModule?Na(r,"default",{value:e,enumerable:!0}):r,e));var g=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});function UO(e){return!!(e!=null&&e.__nativeBuffers__)}function tu(e){if(typeof e=="string")try{e=JSON.parse(e)}catch(r){return{}}if(typeof e!="object"||e===null)return{};if(!UO(e))return e;let t=e.__nativeBuffers__;if(delete e.__nativeBuffers__,t)for(let r=0;r<t.length;r++){let n=t[r];if(n){let i;n.value?i=n.value:n.base64&&(i=MO(n.base64)),typeof i!="undefined"&&i instanceof ArrayBuffer&&(e[n.key]=i)}}return e}function jO(e={},t=!1){let r=e,n=[];for(let[i,o]of Object.entries(r))if(o!==void 0&&o instanceof ArrayBuffer&&o.byteLength!==void 0){let a=t?{value:o,key:i}:{base64:FO(o),key:i};n.push(a),delete r[i]}return n.length>0&&(r.__nativeBuffers__=n),r}function HO(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function eg(e){return typeof e=="string"}function Kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Jh(e){return typeof e=="number"&&!isNaN(e)}function $O(e){return typeof e=="undefined"}function WO(e){return $O(e)||e===null}function tg(e){return typeof e=="function"}function zO(e){return Kn(e)&&tg(e.then)}function rg(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function Yi(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function tR(e,t,r){let n=e;for(let i of t)if(n&&typeof n=="object")n=n[i];else return r;return n===void 0?r:n}function aR(){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}}function dR(e){return new Promise(t=>ng(e)(t))}function ng(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function pR(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new Zi(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function mR(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)hR(e[n],t[n])}function hR(e,t){if(eg(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(tg(t)){try{if(e instanceof t)return}catch(r){}if(!WO(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")}}function Ze(e,t){if(nu.config[e]){Fa.warn(`[can i use] ${e} already registered`);return}nu.config[e]=gr({},t)}function $h(e,t){return`[${e}]:${t}`}function SR(e,t){Wh||(Xl=new La({eventName:"jolibox_invoke",tagNameOrder:["status","method","errNo","errMsg","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Ql=new La({eventName:"jolibox_invoke_js2native",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),Zl=new La({eventName:"jolibox_invoke_native2js",tagNameOrder:["status","method","isForeground"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}}),t("onJoliboxEnterBackground",()=>{Xl.flush(),Ql.flush(),Zl.flush()}),Wh=!0);function r(i){var o,a;let{method:s,args:c,startTime:l,isForeground:d,errMsg:u=`${s}:fail no errMsg`,errNo:p=0,__timing:f={receiveJSInvoke:0,invokeCallback:0}}=i,{receiveJSInvoke:m,invokeCallback:v}=f,b=(a=(o=u.match(/\S:(\S+)\s?/))==null?void 0:o[1])!=null?a:"fail";Xl.report({status:b,method:n(s,c),errNo:`${p}`,errMsg:u,isForeground:d,duration:Date.now()-l}),l&&m&&v&&(Ql.report({status:b,method:s,isForeground:d,duration:Number((m-l).toFixed(3))}),Zl.report({status:b,method:s,isForeground:d,duration:Number((Date.now()-v).toFixed(3))}))}function n(i,o){return(i==="callHostMethod"||i==="callHostMethodSync")&&o!=null&&o.method?`${i}-${o.method}`:i}return r}function CR(e,t){let r=0,n=!0,i=AR.resolveMap,o=SR(e,t);t("onJoliboxEnterBackground",()=>{n=!1}),t("onJoliboxEnterForeground",()=>{n=!0,eu.forEach(c=>Ua(this,[c],function*({method:l,args:d,resolve:u}){let p=yield s(l,d);u(p)})),eu.length=0});let a=(c,l)=>{let d=i.get(Number(c));if(!d)return;let u=tu(l);d(u),i.delete(Number(c))},s=(c,l)=>{var d,u;let p=Date.now(),f=`${n}`;r+=1;let m=new VO;if(i.set(r,m.resolve),!n&&yR.includes(c))return new Promise(C=>{eu.push({method:c,args:l,resolve:C})});let v=LO(gr({},{method:c,startTime:p,args:l,isForeground:f}),{invokeType:"js-bridge"}),b=!IR&&vR.includes(c),y=jO(l,b),_=b?y:JSON.stringify(y),E;if(c.endsWith("Sync")||bR.includes(c)?E=(d=e.call)==null?void 0:d.call(e,c,y,r):typeof _=="string"?E=e.invoke(c,_,r):E=(u=e.call)==null?void 0:u.call(e,c,_,r),E){try{typeof E=="string"&&(E=JSON.parse(E)),E=tu(E)}catch(C){Fa.error(C)}return i.delete(r),E.errorCode&&(E.errorCode=$h(c,E.errorCode)),o(gr(gr({},v),E)),E}return c.endsWith("Sync")&&i.delete(r),m.promise.then(C=>(C.errorCode&&(C.errorCode=$h(c,C.errorCode)),o(gr(gr({},v),C)),C))};return{invokeNative:s,applyNative:(c,l)=>{let d=s(c,l);return zO(d)?d.then(u=>zh(c,u)):zh(c,d)},invokeHandler:a}}function zh(e,t){if(!Kn(t)){Fa.warn(`[Jolibox SDK]${e} no response value`);return}let r=t,{errMsg:n,errNo:i,errorType:o,errorCode:a}=r,s=qO(r,["errMsg","errNo","errorType","errorCode"]);if(n&&n!==`${e}:ok`)throw new QO(n,i,o,a);return s}function kR(e){if(globalThis[Da])return globalThis[Da];let t=new au,r=new au,n=new La({eventName:"jolibox_publish",tagNameOrder:["type","event"],metricName:"duration",reporter(i){e.invoke("trackAsync",JSON.stringify({event:"reportMetrics",data:i}),-1)}});return t.on("onJoliboxEnterBackground",()=>{n.flush()}),globalThis[Da]={onNative:t.on.bind(t),offNative:t.off.bind(t),subscribe:r.on.bind(r),unsubscribe:r.off.bind(r),subscribeHandler(i,o,a){let s=tu(o),c;if(s.__extra){c=s.params;let{type:l,startTime:d}=s.__extra;n.report({type:l,event:i,duration:Date.now()-d})}else c=s;if(i===ig){c.forEach(l=>{let[d,u]=l;try{r.emit(d.slice(Qi.length),u,a)}catch(p){}});return}if(i.startsWith(Qi)){r.emit(i.slice(Qi.length),c,a);return}t.emit(i,c,a)}},globalThis[Da]}function xR(e){let t=new Map,r=new Map,n,i;return{publish:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(`${Qi}${o}`,a,d);return}n||(n=Promise.resolve().then(()=>{t.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(ig,d,p)}catch(p){}}),n=void 0,t.clear()}));let l=t.get(s);l||(l=[],t.set(s,l)),l.push([`${Qi}${o}`,a])},emitNative:(o,a,s,c)=>{if(c){let d=s!==void 0?s==="*"?"*":[s]:void 0;e.publish(o,a,d),console.log("emitNative",o,a,d);return}i||(i=Promise.resolve().then(()=>{r.forEach((d,u)=>{try{let p=u!==void 0?u==="*"?"*":[u]:void 0;e.publish(_R,d,p)}catch(p){}}),i=void 0,r.clear()}));let l=r.get(s);l||(l=[],r.set(s,l)),l.push([o,a])}}}function TR(e){let{subscribeHandler:t,onNative:r,offNative:n,subscribe:i,unsubscribe:o}=kR(e),{invokeNative:a,invokeHandler:s,applyNative:c}=CR(e,r),{publish:l,emitNative:d}=xR(e);return{invokeHandler:s,subscribeHandler:t,applyNative:c,invokeNative:a,onNative:r,offNative:n,emitNative:d,publish:l,subscribe:i,unsubscribe:o}}function og(e,t){return{params:e,__extra:{startTime:Date.now(),type:t}}}var RO,NO,DO,qa,Yh,Xh,Gh,gr,LO,qO,Ua,MO,FO,Qh,BO,GO,Zh,JO,VO,KO,YO,Ma,XO,QO,ZO,Kl,Fa,Hh,eR,ru,rR,nu,nR,iR,oR,zn,sR,_z,iu,he,cR,lR,Xi,Zi,au,su,uR,Yl,fR,wz,cu,Vh,Sz,ja,gR,Qi,vR,yR,bR,ig,_R,wR,La,Wh,Xl,Ql,Zl,eu,IR,lu,ER,AR,Da,uu,Rt,ag,sg,PR,cg,Kh,de,L,we,lg,OR,ug,hn,Iz,Ez,ce=T(()=>{"use strict";RO=Object.defineProperty,NO=Object.defineProperties,DO=Object.getOwnPropertyDescriptors,qa=Object.getOwnPropertySymbols,Yh=Object.prototype.hasOwnProperty,Xh=Object.prototype.propertyIsEnumerable,Gh=(e,t,r)=>t in e?RO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gr=(e,t)=>{for(var r in t||(t={}))Yh.call(t,r)&&Gh(e,r,t[r]);if(qa)for(var r of qa(t))Xh.call(t,r)&&Gh(e,r,t[r]);return e},LO=(e,t)=>NO(e,DO(t)),qO=(e,t)=>{var r={};for(var n in e)Yh.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&qa)for(var n of qa(e))t.indexOf(n)<0&&Xh.call(e,n)&&(r[n]=e[n]);return r},Ua=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((r=r.apply(e,t)).next())});MO=e=>{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer};FO=e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(r[i]);return btoa(t)};Qh=Object.defineProperty,BO=Object.getOwnPropertyDescriptor,GO=(e,t)=>{for(var r in t)Qh(e,r,{get:t[r],enumerable:!0})},Zh=(e,t,r,n)=>{for(var i=n>1?void 0:n?BO(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&Qh(t,r,i),i},JO=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((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 i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,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}VO=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};KO=(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))(KO||{}),YO=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}},Ma=class extends YO{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},XO=class extends Ma{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_NATIVE_ERROR"}},QO=class extends Ma{constructor(e,t,r,n){super(e),this.errNo=t,this.name="INTERNAL_APPLY_NATIVE_ERROR",this.errorType=r,this.errorCode=n}},ZO=class extends Ma{constructor(){super(...arguments),this.name="INTERNAL_JSCORE_ERROR",this.priority="P0"}},Kl=class extends Ma{constructor(){super(...arguments),this.name="INTERNAL_METRIC_REPORT_ERROR"}};Fa={log:Yi("log"),warn:Yi("warn"),info:Yi("info"),error:Yi("error"),debug:Yi("debug")};Object.assign(globalThis,{logger:Fa});Hh=Symbol.for("Jolibox.canIUseMap"),eR={};globalThis[Hh]||(globalThis[Hh]=eR);ru=Symbol.for("Jolibox.canIUseMap.native"),rR={};globalThis[ru]||(globalThis[ru]=rR);nu={get config(){return globalThis[ru]}},nR=(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))(nR||{}),iR=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(iR||{}),oR=(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))(oR||{});aR();zn=typeof window=="undefined",sR=()=>!zn&&!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),_z={isiOS:!zn&&(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:!zn&&navigator.userAgent.includes("Android"),isMac:!zn&&navigator.userAgent.includes("Mac"),isFacebook:!zn&&navigator.userAgent.includes("FB_IAB"),isPC:!zn&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},iu=class ou{constructor(t){this.element=t,this.next=ou.Undefined,this.prev=ou.Undefined}};iu.Undefined=new iu(void 0);he=iu,cR=class{constructor(){this._first=he.Undefined,this._last=he.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===he.Undefined}clear(){let e=this._first;for(;e!==he.Undefined;){let t=e.next;e.prev=he.Undefined,e.next=he.Undefined,e=t}this._first=he.Undefined,this._last=he.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new he(e);if(this._first===he.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==he.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==he.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==he.Undefined&&e.next!==he.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===he.Undefined&&e.next===he.Undefined?(this._first=he.Undefined,this._last=he.Undefined):e.next===he.Undefined?(this._last=this._last.prev,this._last.next=he.Undefined):e.prev===he.Undefined&&(this._first=this._first.next,this._first.prev=he.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==he.Undefined;)yield e.element,e=e.next}},lR=0,Xi=class{constructor(e){this.value=e,this.id=lR++}},Zi=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 Xi&&(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,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new Xi(t);return this._listeners?this._listeners instanceof Xi?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof Xi)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),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(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof Xi?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},au=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new Zi,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.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 cR,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)}},su={};GO(su,{None:()=>uR,filter:()=>pR,once:()=>ng,toPromise:()=>dR});uR=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});Yl=Symbol.for("Jolibox.hostEmitter"),fR=()=>{let e=new au;return globalThis[Yl]||(globalThis[Yl]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Yl]},wz=fR();cu=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new Zi,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return mR(i,r),n(...i)}}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}};cu=Zh([rg],cu);Vh=class{constructor(){this._onWillExecuteCommand=new Zi,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new Zi,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new cu,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=HO(3e4)),this._starActivation}executeCommand(e,...t){return JO(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),su.toPromise(su.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}}};Vh=Zh([rg],Vh);Sz=Symbol.for("Jolibox.commands");Ze("requestPaymentSync",{version:1e6,properties:{paymentBody:{appStoreProductId:102e4}}});Ze("requestProductDetailsAsync",{version:102e4});Ze("invokeSubscriptionPanelSync",{version:107e4,properties:{type:{game:107e4,drama:107e4}}});Ze("loginSync",{version:1e6,properties:{skipLogin:102e4,triggerFrom:102e4}});Ze("getABTest",{version:1050100,platforms:{android:1050100,ios:!1}});Ze("userTrackAsync",{version:1e6});Ze("openMiniapp",{version:1050100});Ze("requestCoinDetailsSync",{version:1070100});Ze("requestCoinDetailsAsync",{version:1070100});Ze("sendServerEventAsync",{version:1070100});Ze("requestGameLeaderboardSync",{version:108e4});Ze("requestGameLeaderboardAsync",{version:108e4});Ze("notifyTaskGameInfoAsync",{version:1080100});Ze("loadAdsAsync",{version:1070200});Ze("showAdAsync",{version:1070200});Ze("onJoliboxHideLoading",{version:1070300});ja=(e,t)=>{function r(i){var o;let[a,...s]=i.split(":");if(!a)return!1;let c=nu.config[a];if(!c)return!1;let l=(o=t==null?void 0:t())!=null?o:"",d=c.version;if(c.platforms&&l in c.platforms){let p=c.platforms[l];if(p===!1)return!1;typeof p=="number"&&(d=p)}if(typeof d!="number")return!1;let u=e();return typeof u!="number"||u<d?!1:s.length===0?!0:n(c,s,u)||n(c.properties,s,u)}function n(i,o,a){if(!i)return!1;let s=tR(i,o);if(!s)return!1;if(Kn(s)){let c=s.version;return Jh(c)?typeof a=="number"&&a>=c:!0}return Jh(s)?typeof a=="number"&&a>=s:s===!0}return{canIUseNative:r}};gR=()=>sR(),Qi="custom_event_",vR=[],yR=[],bR=["env","createRequestTask","login"],ig="__batch_event__",_R="__native_batch_event__",wR=e=>e==="pv"?e:"default",La=class{constructor(e){this.interval=30,this.lastReportTime=0,this.cache={};let{reporter:t,interval:r=30,eventName:n,tagNameOrder:i,metricName:o,type:a}=e;this.reporter=t,this.interval=r,this.eventName=n,this.tagNameOrder=i,this.metricName=o,this.type=wR(a)}report(e){this.type==="pv"?this.addPVPoint(e):this.addPoint(e),this.tryReport(!1)}flush(){this.tryReport(!0)}tryReport(e){if(Object.keys(this.cache).length){if(e){this.reporter(this.processPoints(this.cache)),this.clearPoints();return}this.lastReportTime=this.lastReportTime||Date.now(),Date.now()-this.lastReportTime>=this.interval*1e3&&(this.reporter(this.processPoints(this.cache)),this.clearPoints(),this.lastReportTime=Date.now())}}addPoint(e){let t=(r,n,i,o)=>{let a=n.shift();if(a){let s=o[a];r[s]||(r[s]={}),t(r[s],n,i,o)}else r[i]||(r[i]=[]),r[i].push(o[i])};t(this.cache,[...this.tagNameOrder],this.metricName,e)}addPVPoint(e){let t=(n,i,o,a)=>{let s=i.shift();if(!s&&Kn(a))throw new Kl(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);if(s){let c=[];if(Kn(a))c.push(...Object.keys(a));else if(eg(a)){if(i.length>0)throw new Kl(`report value failed to match tagNameOrder, ${JSON.stringify(r)}`);c.push(a)}else throw new Kl(`expected metric value to be a string, but got a(n) ${typeof a}, ${JSON.stringify(r)}`);c.forEach(l=>{n[l]||(n[l]={});let d=Kn(a)?a[l]:a;t(n[l],[...i],o,d)})}else n[o]?n[o]++:n[o]=1},r={point:e,metricName:this.metricName,tagNameOrder:this.tagNameOrder};t(this.cache,[...this.tagNameOrder],this.metricName,e)}processPoints(e){return{eventName:this.eventName,tagNameOrder:this.tagNameOrder,metricName:this.metricName,metricAggregateType:this.type==="pv"?"itoa":"arr",data:e}}clearPoints(){this.cache={}}},Wh=!1;eu=[],IR=!1,lu=Symbol.for("Jolibox.invokeResolverInstance"),ER=new Map;globalThis[lu]||(globalThis[lu]=ER);AR={get resolveMap(){return globalThis[lu]}};Da=Symbol.for("Jolibox.subscribeInstance");Rt={trigger(){},exit(){return Promise.resolve(!1)},backPress(){return Promise.resolve(!1)},onReady(e){Rt.trigger=e},onDoExit(e){Rt.exit=e},onDoBackPress(e){Rt.backPress=e}},ag=e=>{let t=window.prompt("invoke",JSON.stringify({event:"envSync",paramsString:JSON.stringify({})}));if(!t)e.onError(new XO("native env failed"));else{let{data:r}=JSON.parse(t);return r!=null?r:void 0}};if(typeof window!="undefined"&&window.webkit){let e=window.webkit.messageHandlers,t=(i="")=>{Rt.trigger(),e.onDocumentReady.postMessage({path:i})},r=i=>Ua(void 0,null,function*(){let o=yield Rt.exit();e.doExit.postMessage({uuid:i,shouldInterrupt:o})});uu={onDocumentReady:t,doExit:r,invoke(i,o,a){e.invoke.postMessage({event:i,paramsString:o,callbackId:a})},publish(i,o,a){let s=og(o,"joliboxJSCore");window.prompt("publish",JSON.stringify({event:i,paramsString:JSON.stringify(s),webviewIds:a}))},call(i,o,a){let s=window.prompt("invoke",JSON.stringify({event:i,paramsString:JSON.stringify(o),callbackId:a}));if(s)return JSON.parse(s)}};let n={onDocumentReady:t,env:ag,doExit:r};globalThis.joliboxJSCore=gr({},n)}if(typeof window!="undefined"&&window.JoliAndroidSDKBridge){let e,t=window.JoliAndroidSDKBridge,r=(o="")=>{Rt.trigger(),t.onDocumentReady(JSON.stringify({path:o}))},n=o=>Ua(void 0,null,function*(){let a=yield Rt.exit();t.doExit(JSON.stringify({uuid:o,shouldInterrupt:a}))});uu={onDocumentReady:r,invoke(o,a,s){t.invoke(JSON.stringify({event:o,paramsString:a,callbackId:s}))},doExit:n,publish(o,a,s){let c=og(a,"joliboxJSCore");t.publish(JSON.stringify({event:o,paramsString:JSON.stringify(c),webviewIds:s}))},call(o,a,s){let c=window.prompt("invoke",JSON.stringify({event:o,paramsString:JSON.stringify(a),callbackId:s}));if(c)return JSON.parse(c)},doBackPress(o){return Ua(this,null,function*(){let a=yield Rt.backPress();t.doBackPress(JSON.stringify({uuid:o,shouldInterrupt:a}))})}};let i={onDocumentReady:r,env:ag,doExit:n};globalThis.joliboxJSCore=gr({},i)}sg=uu;if(!sg&&gR())throw new ZO("No joliboxJScore is found, native bridge not found.");PR=gr({},sg),cg=TR(PR),{invokeHandler:Kh}=cg,{applyNative:de,invokeNative:L,onNative:we,offNative:lg,subscribeHandler:OR,publish:ug,emitNative:hn,subscribe:Iz,unsubscribe:Ez}=cg;globalThis.joliboxJSBridge={callHandler:Kh,invokeHandler:Kh,subscribeHandler:OR}});function qR(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function Ga(e){return new Promise(t=>setTimeout(t,e))}function io(e){return typeof e=="string"}function vn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function vg(e){return typeof e=="object"&&Array.isArray(e)}function Ja(e){return typeof e=="number"&&!isNaN(e)}function Jr(e){return e===!0||e===!1}function yg(e){return typeof e=="undefined"}function oo(e){return yg(e)||e===null}function UR(e){return typeof e=="function"}function bg(e){let t=e,r=null,n=function(...i){return r||(r=new t(...i)),r};return n.prototype=t.prototype,n}function _g(e,t,r){if(typeof r!="function")throw new Error("[Jolibox SDK]Customizer must be a function");function n(i,o){for(let a in o)if(Object.prototype.hasOwnProperty.call(o,a)){let s=i[a],c=o[a],l=r(s,c,a,i,o);l!==void 0?i[a]=l:fg(c)&&fg(s)?i[a]=n(hg({},s),c):Array.isArray(c)&&Array.isArray(s)?i[a]=[...s,...c]:i[a]=c}return i}return n(e,t)}function fg(e){return e&&typeof e=="object"&&e.constructor===Object}function wg(e,t){if(Array.isArray(e))return e.concat(t)}function ao(e,t,r={}){let n=null,i,o,a,{leading:s=!1,trailing:c=!0}=r,l=()=>(a=e.apply(o,i),i=void 0,o=void 0,a),d=function(...u){i=u,o=this;let p=s&&!n;if(n&&clearTimeout(n),n=setTimeout(()=>{n=null,c&&!p&&l()},t),p)return l()};return d.cancel=()=>{n&&clearTimeout(n),n=null,i=o=void 0},d.flush=()=>{if(n)return clearTimeout(n),n=null,l()},d}function FR(e,t){return(...r)=>t(e,...r)}function Yn(e){return t=>FR(t,function(r,...n){if(typeof r=="function")try{return r.apply(this,n)}catch(i){e(new zt(`${i}`))}})}function eo(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}function Cg(e,t,r){let n=0;if(e!==t){let i=e.split("."),o=t.split("."),a=Math.max(i.length,o.length);for(let s=0;s<a;s++){let c=parseInt(i[s],10)||0,l=parseInt(o[s],10)||0;if(c>l){n=1;break}else if(c<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}}function Iu(){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}}function VR(e,t,r){let n=window.location.hostname,i=n.split("."),o=r?t:e;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n))return`${o}.jolibox.com`;if(i.length>=2){let a=i.slice(-2).join(".");if(a==="jolibox.com"||a==="pico-game.com"||a==="joyslite.com"||a==="mporia.com"||a==="pingplus.ai")return`${o}.${a}`}return`${o}.jolibox.com`}function Eu(e){return VR("app","stg-app",e)}function Qn(e){return`https://${Eu(e)}`}function KR(e){return new Promise(t=>Pg(e)(t))}function Pg(e){return(t,r=null)=>{let n=!1;return e(i=>{if(!n)return n=!0,t.call(r,i)},null)}}function YR(e,t){return(r=>{let n,i={onWillAddFirstListener(){n=r(o.fire,o)}},o=new no(i);return o.event})((r,n=null)=>e(i=>t(i)&&r.call(n,i),null))}function QR(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)ZR(e[n],t[n])}function ZR(e,t){if(io(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(UR(t)){try{if(e instanceof t)return}catch(r){}if(!oo(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")}}function e1(){return typeof globalThis!="undefined"?globalThis[Og]:void 0}function t1(e){typeof globalThis!="undefined"&&(globalThis[Og]=e)}function Y(e=!1){let t=e1();if(!e&&t)return t;let r=new Ba,n=new gu,i={registerCommand(o,a,s){r.registerCommand({id:o,handler:a,metadata:s})},executeCommand(o,...a){return n.executeCommand(o,...a)},excuteCommandSync(o,...a){return n.executeCommandThowErr(o,...a)}};return t1(i),i}var vu,RR,dg,NR,DR,pg,hg,LR,gg,gn,pt,MR,yu,so,bu,Sg,zt,Ha,Ig,Va,Eg,Ag,co,_u,Kt,pu,jR,wu,mg,BR,K,Su,GR,Xn,to,lo,JR,HR,kg,xg,Tg,Ft,fu,ge,$R,WR,ro,no,Yt,hu,zR,du,XR,Se,Ba,gu,Og,R=T(()=>{"use strict";vu=Object.defineProperty,RR=Object.getOwnPropertyDescriptor,dg=Object.getOwnPropertySymbols,NR=Object.prototype.hasOwnProperty,DR=Object.prototype.propertyIsEnumerable,pg=(e,t,r)=>t in e?vu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,hg=(e,t)=>{for(var r in t||(t={}))NR.call(t,r)&&pg(e,r,t[r]);if(dg)for(var r of dg(t))DR.call(t,r)&&pg(e,r,t[r]);return e},LR=(e,t)=>{for(var r in t)vu(e,r,{get:t[r],enumerable:!0})},gg=(e,t,r,n)=>{for(var i=n>1?void 0:n?RR(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(n?a(t,r,i):a(i))||i);return n&&i&&vu(t,r,i),i},gn=(e,t,r)=>new Promise((n,i)=>{var o=c=>{try{s(r.next(c))}catch(l){i(l)}},a=c=>{try{s(r.throw(c))}catch(l){i(l)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(o,a);s((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 i=this._eventListeners[r].indexOf(n);i!==-1&&this._eventListeners[r].splice(i,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}pt=class{constructor(){this.state="pending",this.promise=new Promise((e,t)=>{this.resolve=r=>{this.state==="pending"&&(this.state="fulfilled",e(r))},this.reject=r=>{this.state==="pending"&&(this.state="rejected",t(r))}})}};MR=(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))(MR||{}),yu=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}},so=class extends yu{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}},bu=class extends yu{constructor(){super(...arguments),this.kind="USER_ERROR"}},Sg=class extends bu{constructor(){super(...arguments),this.name="USER_VALIDATE_ERROR"}},zt=class extends bu{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_CUSTOM_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Ha=class extends bu{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="USER_PAYMENT_ERROR",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Ig=class extends so{constructor(){super(...arguments),this.name="INTERNAL_SCHEMA_PARSE_ERROR",this.priority="P0"}},Va=class extends so{constructor(e,t,r){super(e),this.message=e,this.errNo=t,this.name="INTERNAL_PAYMENT_ERROR",this.priority="P0",this.errMsg=e,r&&(this.extra=Object.assign({},this.extra,r))}},Eg=class extends so{constructor(){super(...arguments),this.name="INTERNAL_INVOKE_METHOD_ERROR"}},Ag=class extends so{constructor(){super(...arguments),this.name="INTERNAL_GLOBAL_JS_ERROR",this.priority="P1"}},co=class extends yu{constructor(e,t,r,n,i){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),i&&(this.priority=i)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}},_u=class extends so{constructor(){super(...arguments),this.name="INTERNAL_REPORTER_ERROR"}};Kt={log:eo("log"),warn:eo("warn"),info:eo("info"),error:eo("error"),debug:eo("debug")};Object.assign(globalThis,{logger:Kt});pu=Symbol.for("Jolibox.canIUseMap"),jR={};globalThis[pu]||(globalThis[pu]=jR);wu={get config(){return globalThis[pu]}},mg=Symbol.for("Jolibox.canIUseMap.native"),BR={};globalThis[mg]||(globalThis[mg]=BR);K=(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))(K||{}),Su=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(Su||{}),GR=(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))(GR||{}),Xn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});Iu();to=typeof window=="undefined",lo={isiOS:!to&&(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:!to&&navigator.userAgent.includes("Android"),isMac:!to&&navigator.userAgent.includes("Mac"),isFacebook:!to&&navigator.userAgent.includes("FB_IAB"),isPC:!to&&!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},JR="device_id",HR="advertising_id",kg=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,Xn()),window.__joliboxLocalStorage__.getItem(e)),xg=()=>new URLSearchParams(window.location.search).get("deviceId")||kg(JR),Tg=()=>new URLSearchParams(window.location.search).get("advertisingId")||kg(HR);Ft=class{constructor(e,t={}){this.requestAdapter=e,this.cache=new Map,this.pendingRequests=new Map,this.requestSequence=0,this.cacheSequences=new Map,this.config=hg({duration:10*60*1e3,timeout:3e3,keyGenerator:(r,n)=>r,consistencyChecker:()=>!0},t)}request(e,t){return gn(this,null,function*(){let r=this.config.keyGenerator(e,t),n=this.pendingRequests.get(r);if(n)return console.log(`[RequestCacheService] Reusing pending request for ${e}`),n;let i=this.requestInternal(e,t),o=this.createTimeoutPromise(),a=Promise.race([i,o]).catch(s=>gn(this,null,function*(){if(s.message.includes("timeout")){let c=this.getValidCachedData(r);if(c)return console.warn(`[RequestCacheService] Request timeout, falling back to cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}throw s}));this.pendingRequests.set(r,a),i.then(s=>{console.log(`[RequestCacheService] Background request completed successfully for ${e}`)}).catch(s=>{console.warn(`[RequestCacheService] Background request failed for ${e}:`,s)});try{return yield a}finally{this.pendingRequests.delete(r)}})}requestInternal(e,t){return gn(this,null,function*(){var r,n,i,o;let a=this.config.keyGenerator(e,t),s=++this.requestSequence,c=this.getValidCachedData(a);if(console.log("[RequestCacheService] requestInternal start",e,"cached:",c),c){if(this.requestAdapter.extractRealTimeData&&this.requestAdapter.mergeData)try{let u=yield this.requestAdapter.execute(e,t),p=this.requestAdapter.extractRealTimeData(u),f=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,u);return f&&!this.config.consistencyChecker(c,f)?(console.log(`[RequestCacheService] Cache invalidated due to data change for ${e}`),this.setCachedDataWithSequence(a,f,s),u):this.requestAdapter.mergeData(c,p)}catch(u){return console.warn(`[RequestCacheService] Failed to fetch real-time data, using cache only for ${e}:`,u),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}return console.log(`[RequestCacheService] use cache for ${e}`),this.requestAdapter.processCachedData?this.requestAdapter.processCachedData(c):c}console.log(`[RequestCacheService] Cache miss, fetching fresh data for ${e} (sequence: ${s})`);let l=yield this.requestAdapter.execute(e,t),d=(o=(i=this.requestAdapter).extractCacheableData)==null?void 0:o.call(i,l);return d&&this.setCachedDataWithSequence(a,d,s),l})}createTimeoutPromise(){return new Promise((e,t)=>{setTimeout(()=>{t(new Error(`[RequestCacheService] Request timeout after ${this.config.timeout/1e3} seconds`))},this.config.timeout)})}getValidCachedData(e){let t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),null):t.data:null}setCachedDataWithSequence(e,t,r,n){let i=this.cache.get(e);if(i&&i.sequence>r){console.log(`[RequestCacheService] Ignoring stale cache update for ${e} (current: ${i.sequence}, incoming: ${r})`);return}let o=Date.now();this.cache.set(e,{data:JSON.parse(JSON.stringify(t)),timestamp:o,expiresAt:o+this.config.duration,key:e,sequence:r,metadata:n}),this.cacheSequences.set(e,r),console.log(`[RequestCacheService] Updated cache for ${e} with sequence ${r}`)}refreshCache(e,t){return gn(this,null,function*(){let r=this.config.keyGenerator(e,t);return this.cache.delete(r),this.request(e,t)})}forceRequest(e,t){return gn(this,null,function*(){var r,n;let i=this.config.keyGenerator(e,t),o=++this.requestSequence;console.log(`[RequestCacheService] Force request for ${e} (sequence: ${o})`);let a=yield this.requestAdapter.execute(e,t),s=(n=(r=this.requestAdapter).extractCacheableData)==null?void 0:n.call(r,a);return s&&(this.setCachedDataWithSequence(i,s,o),console.log(`[RequestCacheService] Force updated cache for ${e}`)),a})}warmupCache(e,t){return gn(this,null,function*(){let r=this.config.keyGenerator(e,t);if(this.pendingRequests.has(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - request in progress`);return}if(this.hasValidCache(r)){console.log(`[RequestCacheService] Skipping warmup for ${e} - valid cache exists`);return}try{console.log(`[RequestCacheService] Warming up cache for ${e}`),yield this.forceRequest(e,t)}catch(n){console.warn(`[RequestCacheService] Cache warmup failed for ${e}:`,n)}})}clearCache(e){e?(this.cache.delete(e),this.cacheSequences.delete(e),this.pendingRequests.delete(e),console.log(`[RequestCacheService] Cleared cache for ${e}`)):(this.cache.clear(),this.cacheSequences.clear(),this.pendingRequests.clear(),this.requestSequence=0,console.log("[RequestCacheService] Cleared all cache"))}clearExpiredCache(){let e=Date.now();for(let[t,r]of this.cache)e>r.expiresAt&&(this.cache.delete(t),this.cacheSequences.delete(t));console.log("[RequestCacheService] Cleared expired cache entries")}getCacheStats(){let e=Date.now(),t=0,r=0;for(let n of this.cache.values())e>n.expiresAt?r++:t++;return{cacheCount:this.cache.size,validCount:t,expiredCount:r,pendingRequestCount:this.pendingRequests.size}}getCacheKeys(){return Array.from(this.cache.keys())}hasValidCache(e){let t=this.cache.get(e);return t?Date.now()<=t.expiresAt:!1}getPendingRequestKeys(){return Array.from(this.pendingRequests.keys())}hasPendingRequest(e){return this.pendingRequests.has(e)}getCacheSequence(e){return this.cacheSequences.get(e)}},fu=class mu{constructor(t){this.element=t,this.next=mu.Undefined,this.prev=mu.Undefined}};fu.Undefined=new fu(void 0);ge=fu,$R=class{constructor(){this._first=ge.Undefined,this._last=ge.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ge.Undefined}clear(){let e=this._first;for(;e!==ge.Undefined;){let t=e.next;e.prev=ge.Undefined,e.next=ge.Undefined,e=t}this._first=ge.Undefined,this._last=ge.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new ge(e);if(this._first===ge.Undefined)this._first=r,this._last=r;else if(t){let i=this._last;this._last=r,r.prev=i,i.next=r}else{let i=this._first;this._first=r,r.next=i,i.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==ge.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ge.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ge.Undefined&&e.next!==ge.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ge.Undefined&&e.next===ge.Undefined?(this._first=ge.Undefined,this._last=ge.Undefined):e.next===ge.Undefined?(this._last=this._last.prev,this._last.next=ge.Undefined):e.prev===ge.Undefined&&(this._first=this._first.next,this._first.prev=ge.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ge.Undefined;)yield e.element,e=e.next}},WR=0,ro=class{constructor(e){this.value=e,this.id=WR++}},no=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 ro&&(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,i,o,a,s,c;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let l=new ro(t);return this._listeners?this._listeners instanceof ro?this._listeners=[this._listeners,l]:this._listeners.push(l):((i=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||i.call(n,this),this._listeners=l,(a=(o=this.options)==null?void 0:o.onDidFirstListener)==null||a.call(o,this)),(c=(s=this.options)==null?void 0:s.onDidAddListener)==null||c.call(s,this),this._size++,()=>{var d,u,p,f;if(!this._disposed){if(this._listeners instanceof ro)this._listeners.id===l.id&&(this._listeners=void 0,this._size=0,(u=(d=this.options)==null?void 0:d.onDidRemoveLastListener)==null||u.call(d));else if(this._listeners){let m=this._listeners.indexOf(l);m>=0&&(this._listeners.splice(m,1),this._size--,this._size===0&&((f=(p=this.options)==null?void 0:p.onDidRemoveLastListener)==null||f.call(p)))}}}}),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(i){n(i)}}fire(e){this._listeners&&(this._listeners instanceof ro?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},Yt=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let i=(n=this.listeners.get(e))!=null?n:new no,o=c=>t(...c.args),a=i.event(o);this.listerHandlerMap.set(t,{handler:o,dispose:a}),this.listeners.set(e,i);let s=this.cachedEventQueue.get(e);if(s&&r)for(let c of s)t(...c.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 $R,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)}},hu={};LR(hu,{None:()=>zR,filter:()=>YR,once:()=>Pg,toPromise:()=>KR});zR=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});du=Symbol.for("Jolibox.hostEmitter"),XR=()=>{let e=new Yt;return globalThis[du]||(globalThis[du]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[du]},Se=XR();Ba=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new no,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 i of e.metadata.args)r.push(i.constraint);let n=e.handler;e.handler=function(...i){return QR(i,r),n(...i)}}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}};Ba=gg([bg],Ba);gu=class{constructor(){this._onWillExecuteCommand=new no,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new no,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new Ba,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=qR(3e4)),this._starActivation}executeCommand(e,...t){return gn(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),hu.toPromise(hu.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}}};gu=gg([bg],gu);Og=Symbol.for("Jolibox.commands")});function ke(e,t={}){Au.emit("ERROR_REPORT",{error:e,options:t})}var Au,yn,_t=T(()=>{"use strict";R();R();Au=new Yt,yn=new Yt;ke.debounce=ao(ke,50,{leading:!0})});var Cu,r1,Rg,Ng,Dg=T(()=>{"use strict";R();_t();Cu=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4),n=atob(t+r);try{return JSON.parse(n)}catch(i){return{}}},r1=e=>{let t=JSON.stringify(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Rg=e=>{var t;try{let i=(t=new URL(e).searchParams.get("joliSource"))==null?void 0:t.split(".");if(i!=null&&i.length){let[o,a,s]=i;return{headerJson:Cu(o),payloadJson:Cu(a),signature:Cu(s)}}else throw"joli_source is missing"}catch(r){return ke(new Ig(`${e} not a valid schema: ${r}`)),{headerJson:{},payloadJson:{},signature:{}}}},Ng=(e,t)=>{let r=t.split(".");if(r&&r.length===3){let n=r[0],i=r1(e),o=r[2];return`${n}.${i}.${o}`}return t}});var n1,ku,Lg=T(()=>{"use strict";R();n1="1.4.14",ku=()=>n1});function Tu(e,t){return(document==null?void 0:document.head.querySelector(`meta[name="${e}"][content="${t}"]`))!==null}var i1,qg,xu,Ug,ve,o1,I,$=T(()=>{"use strict";R();Dg();Lg();R();i1={deviceInfo:{brand:"UnknownBrand",model:"UnknownModel",did:xg(),adId:Tg(),pixelRatio:window.devicePixelRatio||1,platform:lo.isAndroid?"android":lo.isiOS?"ios":"h5",system:"UnknownSystemVersion",lang:"zh"},sdkInfo:{nativeSDKVersion:"",jssdkVersion:ku()},schema:window.location.href,platform:lo.isAndroid?"android":lo.isiOS?"ios":"h5"},xu=(qg=globalThis.joliboxJSCore)==null?void 0:qg.env,ve=Object.assign({},(Ug=xu==null?void 0:xu())!=null?Ug:i1);o1=()=>{var v,b,y,_,E,C,x,k,A,H,ue;let{payloadJson:e,headerJson:t,signature:r}=ve.schema.length?Rg(ve.schema):{},n=`${ve.deviceInfo.did}-${new Date().getTime()}`,o=new URL(ve.schema.length?ve.schema:window.location.href).searchParams,a=(y=(b=(v=o.get("mpId"))!=null?v:o.get("appId"))!=null?b:o.get("gameId"))!=null?y:"",s=(C=(E=(_=ve.clientSessionId)!=null?_:e==null?void 0:e.sessionId)!=null?E:o.get("sessionId"))!=null?C:n,c=!!((k=(x=e==null?void 0:e.testAdsMode)!=null?x:e==null?void 0:e.__testAdsMode)!=null?k:o.get("testAdsMode")==="true"),l=(ue=(H=(A=e==null?void 0:e.joliboxEnv)!=null?A:e==null?void 0:e.__joliboxEnv)!=null?H:o.get("joliboxEnv"))!=null?ue:"production",d=l==="staging",u=t==null?void 0:t.channel,f=new URL(window.location.href).searchParams,m=e==null?void 0:e.__shouldInterupt;return{get startTime(){var N;return(N=performance.timeOrigin)!=null?N:performance.timing.navigationStart},get testMode(){return d},get testAdsMode(){return c},get joliboxEnv(){return l},get joliSource(){var N,O;return(O=(N=f.get("joliSource"))!=null?N:o.get("joliSource"))!=null?O:null},get mpId(){var N;return(N=a!=null?a:e==null?void 0:e.id)!=null?N:""},get mpVersion(){var N;return(N=t==null?void 0:t.ver)!=null?N:ku()},get mpType(){var N,O;return(O=(N=t==null?void 0:t.__mpType)!=null?N:e==null?void 0:e.__mpType)!=null?O:"game"},get platform(){var N;return((N=ve.platform)!=null?N:ve.deviceInfo.platform).toLowerCase()},get deviceInfo(){return ve.deviceInfo},get sdkInfo(){return ve.sdkInfo},get hostInfo(){return ve.hostInfo},get hostUserInfo(){return ve.hostUserInfo},get sessionId(){var N,O;return(O=(N=ve.clientSessionId)!=null?N:s)!=null?O:n},get channel(){return u},get webviewId(){var N;return(N=ve.webviewId)!=null?N:-1},get shouldInterupt(){return m},get from(){return e==null?void 0:e.__from},get baseApiHost(){return Eu(d)},get adId(){var N;return(N=ve.deviceInfo.adId)!=null?N:ve.deviceInfo.did},get language(){return ve.deviceInfo.lang},get sdkEnvironment(){return Tu("dlightek","jolibox")?"dlightek":o.get("huaweiQuick")==="true"?"huaweiQuick":Tu("gamedistribution","jolibox")?"gamedistribution":Tu("funmax","jolibox")?"funmax":"jolibox"},get viewport(){var J,V,Mt;let N=(J=ve.deviceInfo.pixelRatio)!=null?J:1,O=(V=ve.deviceInfo.statusBarHeight)!=null?V:e==null?void 0:e.__androidStatusBarHeight,F=(Mt=ve.deviceInfo.navigationBarHeight)!=null?Mt:e==null?void 0:e.__androidNavigationBarHeight;return{statusBarHeight:O!==void 0?O/N:20,navigationBarHeight:F!==void 0?F/N:10}},get abTests(){var N,O;return(O=(N=ve.abValues)==null?void 0:N.split(","))!=null?O:[]},get mpInfo(){var N;return(N=ve.mpInfo)!=null?N:{mpName:"unknown"}},onEnvConfigChanged:N=>{_g(ve,N,wg)},encodeJoliSourceQuery:N=>{var O,F;return t&&r?Ng(P(P({},e),N),(O=o.get("joliSource"))!=null?O:""):(F=o.get("joliSource"))!=null?F:""},setDoExitDirectly:()=>{m=!1}}},I=o1()});var Pu,Fg,a1,s1,Mg,c1,jg=T(()=>{"use strict";R();_t();$();R();Pu=!1,Fg=(e,t)=>e==null?!1:t in e,a1=e=>Fg(e,"kind"),s1=e=>{let t=e.toLowerCase().split("_");return t[0]+t.slice(1).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")},Mg=(e,t={},r)=>{var o,a,s;let n={user_id:(a=(o=I.hostUserInfo)==null?void 0:o.uid)!=null?a:"",device_id:(s=I.deviceInfo.did)!=null?s:"",timestamp:Date.now(),tag:s1(e.name)},i=B(P({},n),{env:t.environment,isFromUser:r});r?yn.emit("GLOBAL_USER_ERROR",e,i):yn.emit("GLOBAL_ERROR",e,i)},c1=e=>Fg(e,"kind")&&e.kind==="USER_ERROR";Au.on("ERROR_REPORT",({error:e,options:t})=>{if(Pu)return;Pu=!0;let r=a1(e)&&e.raw?e.raw:e;try{let n=c1(e);Mg(e,t,n)}catch(n){let i=n instanceof Error?n.message:String(n),o=new _u(`${i}, origin error: ${r.message}`);Kt.error(o),Mg(new _u(o.message),{environment:t.environment},!1)}finally{Pu=!1}})});var xe,Ou,Hr=T(()=>{"use strict";_t();R();_t();xe=(e,t)=>{var r,n;return new co((n=(r=t==null?void 0:t.errMsg)!=null?r:e.msg)!=null?n:"",e.code,e.type)},Ou=e=>new Sg(e)});var Bg=T(()=>{"use strict";jg();Hr();R();ce();yn.on("GLOBAL_ERROR",(e,t)=>{var n;let r={message:e.message,stack:(n=e.stack)!=null?n:"",errorType:e.name,source:0};L("trackAsync",{event:"reportJsError",data:r})});yn.on("GLOBAL_USER_ERROR",(e,t)=>{Kt.log("UserError",e,t)})});var Ru=T(()=>{"use strict"});function Gg(e,t){let r=(n,i,o)=>{let l=i!=null?i:{},{eventType:a}=l,s=Qe(l,["eventType"]),c=B(P({tag:n,eventType:o!=null?o:a!=null?a:K.Other},t),{extra:P({},s)});n=="globalJsError"?ke(new Ag(JSON.stringify(c))):e("systemLog",c,I.webviewId)};return r.debounce=ao(r,500,{leading:!0}),r}function Jg(e){let t=(r,n,i)=>{var s;let o=(s=i&&JSON.stringify(i))!=null?s:0,a={speed_value_type:r,total_duration:n};o&&Object.assign(a,{extra:o}),e("joliboxSpeedAnalysis",a)};return t.debounce=ao(t,500,{leading:!0}),t}var Hg=T(()=>{"use strict";R();R();_t();$()});function Vg(e,t){let r=Gg(e,t),n=Jg(r);return{track:r,trackPerformance:n}}var $g=T(()=>{"use strict";Hg()});var Wg=T(()=>{"use strict";$();R();R()});var zg=T(()=>{"use strict";$g();Ru();Wg()});var $a,Kg=T(()=>{"use strict";$a=class{constructor(t,r){this.eventEmitter=t;this.lastReportTime=0;this.visible=!0;this.reportCount=0;this.notifyIframeGameEvent=(t,r)=>{window.parent&&window.parent.postMessage({type:t,data:r},"*")};this.playGame=t=>{this.reportCount++,(this.reportCount<=3||(this.reportCount-3)%3===0)&&(this.reporter({event:"PLAY_GAME",params:{duration:t}}),this.tracker("PlayGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_PLAY",{duration:t}))};this.timer=this.createRAFTimer(t=>{this.playGame(t)});this.interval=r!=null?r:5*1e3,t.on("visible",n=>{this.visible=n})}start(t){this.reporter({event:"OPEN_GAME",params:{timestamp:Date.now(),duration:t!=null?t:0}}),this.tracker("OpenGame",{duration:t!=null?t:0}),this.notifyIframeGameEvent("JOLIBOX_GAME_OPEN",{duration:t!=null?t:0}),this.timer.start()}close(t){this.reporter({event:"CLOSE_GAME",params:{timestamp:Date.now(),duration:t}}),this.tracker("CloseGame",{duration:t}),this.notifyIframeGameEvent("JOLIBOX_GAME_CLOSE",{duration:t}),this.timer.stop()}createRAFTimer(t){let r=Date.now(),n,i,o=!1,a=0,s=()=>{if(!o)return;let f=Date.now(),m=f-r;m>=this.interval&&(this.visible&&(a+=Math.min(m,this.interval+1e3),t(a)),r=f),n=requestAnimationFrame(s)},c=()=>{d(),r=Date.now(),i=window.setInterval(()=>{if(!o)return;let f=Date.now();f-r>=this.interval&&(r=f)},this.interval)},l=()=>{u(),r=Date.now(),n=requestAnimationFrame(s)},d=()=>{n&&(cancelAnimationFrame(n),n=0)},u=()=>{i&&(clearInterval(i),i=0)};this.eventEmitter.on("visible",f=>{o&&(console.log("visible",f),f?l():c())});let p=this.visible;return{start(){o||(o=!0,p?l():c())},stop(){o=!1,d(),u()}}}}});function Wa(e,t,r){var c,l,d;let n=new Map,i=(c=r==null?void 0:r.baseUrl)!=null?c:Qn(I.testMode),o=(l=r==null?void 0:r.type)!=null?l:"public",a=(d=r==null?void 0:r.defaultHeaders)!=null?d:{};return we("onRequestTaskStateChange",u=>{if(typeof u.requestTaskId!="string")return;let p=n.get(u.requestTaskId);if(p)if(u.state==="success"){let f=u,{requestTaskId:v,state:b}=f,y=Qe(f,["requestTaskId","state"]);u.statusCode===200?p.resolve(y):p.reject(y),n.delete(v)}else if(u.state==="fail"){let m=u,{requestTaskId:v,state:b}=m,y=Qe(m,["requestTaskId","state"]);p.reject(y),n.delete(v)}else Kt.warn("onRequestTaskStateChange unknown event",u)}),Se.on("onLoginComplete",({isLogin:u,token:p})=>{o!=="public"&&u&&p&&(a["X-JOLI-TOKEN"]=p)}),(f,...m)=>g(this,[f,...m],function*(u,p={}){let v=Date.now(),b=l1(u,B(P({},p),{baseUrl:i})),{method:y="GET",responseType:_="text",dataType:E="json",timeout:C,enableCache:x=!1,appendHostCookie:k=!0}=p,A=Object.assign({"content-type":"application/json"},a,p.header),H={url:b,method:y,header:A,enableCache:x,responseType:_,appendHostCookie:k};if(y=="POST"||y=="PUT"){let J=d1(p.data,A["content-type"]);H.data=J}C&&Object.assign(H,{timeout:C});let{data:{requestTaskId:ue}}=L(e,H);if(typeof ue!="string")throw xe({code:-1,msg:"requestTaskId is not a string"});let{resolve:N,reject:O,promise:F}=new pt;n.set(ue,{resolve:N,reject:O});try{let J=yield F,{data:V}=J;return E==="json"&&typeof V=="string"&&(V=u1(V)),{url:b,timeout:C,method:y,response:B(P({},J),{data:V})}}catch(J){let V=J;if(vn(V)){let{errMsg:Mt,prefetchDetail:Mh,isPrefetch:Wl,errNo:Oa}=V;io(Mt)&&ke(xe({code:-1,msg:Mt},{errNo:Oa,errMsg:Mt}))}throw J}})}function u1(e){try{return JSON.parse(e.trim())}catch(t){return e}}function d1(e,t="application/json"){let r=t.toLowerCase();return e===void 0?"":typeof e=="string"||e instanceof ArrayBuffer?e:r.includes("application/x-www-form-urlencoded")||r.includes("application/json")||typeof e=="object"?JSON.stringify(e):String(e)}var l1,Nu=T(()=>{"use strict";R();ce();_t();Hr();$();l1=(e,t)=>{if(/^https?:\/\//.test(e))return e;let r=t==null?void 0:t.query,i=new URLSearchParams(r).toString();return t!=null&&t.baseUrl?`${t.baseUrl}${e}${i?`?${i}`:""}`:`${e}${i?`?${i}`:""}`}});var Du,Yg,X,ft=T(()=>{"use strict";Nu();$();R();Du={};(Yg=I.hostUserInfo)!=null&&Yg.token&&(Du["x-joli-token"]=I.hostUserInfo.token);I.joliSource&&(Du["x-joli-source"]=I.joliSource);X=Wa("createRequestTaskSync","operateRequestTaskSync",{type:"inner",baseUrl:Qn(I.testMode),defaultHeaders:Du})});function Xg(e){let t=wu.config[e];return t||(t={},wu.config[e]=t),(r,n)=>{if(t[r]){Kt.warn(`[can i use] ${r} already registered`);return}t[r]=P({},n)}}var Qg=T(()=>{"use strict";R()});function Lu(e){Zg=e}function za(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>za(t)):Object.keys(e).reduce((t,r)=>(t[r]=za(e[r]),t),{})}function vr(e){return typeof e=="number"}function qu(e){let t=Uu(e);switch(t){case"string":return`"${e}"`;case"number":case"boolean":case"null":case"undefined":return String(e);default:return`a(n) ${t}`}}function Uu(e){return typeof e=="function"?"function":Object.prototype.toString.call(e).slice(8).slice(0,-1).toLowerCase()}var Zg,Oe,Ka,Ya,Xa,Qa,Zn,Za,es,ts,rs,ns,is,os,as,ss,cs,ls,us,Mu=T(()=>{"use strict";Zg=!1;Oe=class{constructor(){this.errors=[];this.hasFallback=!1;this.hasDefault=!1;this._optional=!1}fail(t){if(Zg)if(typeof t=="string")this.errors.push(t);else{let r=`${this.path} should be ${t.expect}`;this._optional&&t.expect!=="undefined"?r+=" or undefined, ":r+=", ",r+=`but got ${qu(t.actual)}`,this.errors.push(r)}return!1}fallback(t){return this.hasFallback=!0,this._fallback=t,this}get fallbackValue(){return za(this._fallback)}default(t){return this.hasDefault=!0,this._default=t,this}get defaultValue(){return typeof this._default=="function"?this._default:za(this._default)}optional(){return this._optional=!0,this}};Ka=class extends Oe{validate(t){return this._optional&&t===void 0?!0:vr(t)?vr(this._min)&&t<this._min?this.fail(`the value of ${this.path} should be greater than or equal to ${this._min}`):vr(this._max)&&t>this._max?this.fail(`the value of ${this.path} should be less than or equal to ${this._max}`):vr(this._greater)&&t<=this._greater?this.fail(`the value of ${this.path} should be greater than ${this._greater}`):this._isInt&&t!==Math.floor(t)?this.fail(`the value of ${this.path} should be integer but got ${t}`):!0:this.fail({expect:"number",actual:t})}min(t){return this._min=t,this}max(t){return this._max=t,this}isInt(t){return this._isInt=t,this}greater(t){return this._greater=t,this}},Ya=class extends Oe{validate(t){return this._optional&&t===void 0?!0:typeof t!="boolean"?this.fail({expect:"boolean",actual:t}):!0}},Xa=class extends Oe{validate(t){if(this._optional&&t===void 0)return!0;if(typeof t!="string")return this.fail({expect:"string",actual:t});if(vr(this._maxLength)&&t.length>this._maxLength)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxLength}`);if(vr(this._minLength)&&t.length<this._minLength)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minLength}`);if(typeof this._pattern=="string"){if(!new RegExp(this._pattern).test(t))return this.fail(`${this.path} should match pattern "${this._pattern}"`)}else if(this._pattern&&!this._pattern.test(t))return this.fail(`${this.path} should match pattern "${this._pattern.toString()}"`);return!0}minLength(t){return this._minLength=t,this}maxLength(t){return this._maxLength=t,this}pattern(t){return this._pattern=t,this}},Qa=class extends Oe{validate(t){return this._optional&&t===void 0?!0:typeof t!="symbol"?this.fail({expect:"symbol",actual:t}):!0}},Zn=class extends Oe{validate(t){return!0}},Za=class extends Oe{validate(t){return t!==void 0?this.fail({expect:"undefined",actual:t}):!0}},es=class extends Oe{validate(t){return this._optional&&t===void 0?!0:t!==null?this.fail({expect:"null",actual:t}):!0}},ts=class extends Oe{validate(t){return this._optional&&t===void 0?!0:typeof t!="function"?this.fail({expect:"function",actual:t}):!0}},rs=class extends Oe{constructor(...t){super(),this._items=t}validate(t){if(this._optional&&t===void 0)return!0;if(!this._items.includes(t)){let r=this._items.map(n=>JSON.stringify(n)).join(", ");return this.fail(`expect ${this.path} to be one of ${r}, but got ${qu(t)}`)}return!0}},ns=class extends Oe{constructor(r){super();this._item=r}validate(r){if(this._optional&&r===void 0)return!0;if(!Array.isArray(r))return this.fail({expect:"array",actual:r});if(vr(this._minItems)&&r.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);if(vr(this._maxItems)&&r.length>this._maxItems)return this.fail(`the length of ${this.path} should be less than or equal to ${this._maxItems}`);if(vr(this._length)&&r.length!==this._length)return this.fail(`the length of ${this.path} should be equal to ${this._length}`);let n=this._item;if(!n)return!0;let i=!0;if(r.forEach((o,a)=>{if(n.path=`${this.path}[${a}]`,n.errors=this.errors,o===void 0&&n.hasDefault){r[a]=n.defaultValue;return}n.validate(o)||(n.hasFallback?r[a]=n.fallbackValue:i=!1)}),this._uniqueItems){let o=new Map;for(let a in r)o.has(r[a])?i=this.fail(`${this.path} should NOT have duplicate items (${this.path}[${o.get(r[a])}] and ${this.path}[${a}] are identical)`):o.set(r[a],a)}return i}minItems(r){return this._minItems=r,this}maxItems(r){return this._maxItems=r,this}uniqueItems(){return this._uniqueItems=!0,this}length(r){return this._length=r,this}},is=class extends Oe{constructor(r){super();this._value=r}validate(r){if(this._optional&&r===void 0)return!0;if(Uu(r)!=="object")return this.fail({expect:"object",actual:r});let i=r,o=this._value;o.errors=this.errors;let a=!0;for(let s in i){let c=i[s];if(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(s)?o.path=`${this.path}.${s}`:o.path=`${this.path}["${s}"]`,!(c===void 0&&o._optional)){if(c===void 0&&o.hasDefault){i[s]=o.defaultValue;continue}o.validate(c)||(o.hasFallback?i[s]=o.fallbackValue:a=!1)}}return a}},os=class extends Oe{constructor(r={}){super();this._object=r}validate(r){if(this._optional&&r===void 0)return!0;if(Uu(r)!=="object")return this.fail({expect:"object",actual:r});let n=r,i=!0;for(let o in this._object){let a=n[o],s=this._object[o];if(s.errors=this.errors,/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(o)?s.path=`${this.path}.${o}`:s.path=`${this.path}["${o}"]`,!(s._optional&&a===void 0)){if(a===void 0&&s.hasDefault){n[o]=s.defaultValue;continue}s.validate(a)||(s.hasFallback?n[o]=s.fallbackValue:i=!1)}}return i}},as=class extends Oe{constructor(r){super();this.value=r}validate(r){return r===void 0&&this._optional?!0:r!==this.value?this.fail({expect:qu(this.value),actual:r}):!0}},ss=class extends Oe{constructor(...t){super(),this._items=t}validate(t){if(t===void 0&&this._optional)return!0;let r=[],n=!1,i=this._items.length;for(let o=0;o<i;o++){let a=this._items[o];if(a.errors=[],a.path=this.path,!a.validate(t))r.push(a.errors.join("; "));else if(!n){n=!0;break}}if(!n){let o=r.join(`
2
2
  or `);this.errors.push(o)}return n}},cs=class extends Oe{constructor(...t){super(),this._items=t;let r=0,n=t.length-1;for(;n>=0;n--){let i=t[n];if(i._optional||i.hasDefault)r+=1;else break}this._minItems=t.length-r}validate(t){if(t===void 0&&this._optional)return!0;if(!Array.isArray(t))return this.fail({expect:"array",actual:t});if(t.length<this._minItems)return this.fail(`the length of ${this.path} should be greater than or equal to ${this._minItems}`);let r=!0;return this._items.forEach((n,i)=>{if(n.path=`${this.path}[${i}]`,n.errors=this.errors,t[i]===void 0&&n.hasDefault){t[i]=n.defaultValue;return}n.validate(t[i])||(n.hasFallback?t[i]=n._fallback:r=!1)}),r}},ls=class extends Oe{validate(t){return t===void 0&&this._optional||t instanceof ArrayBuffer?!0:this.fail({expect:"arraybuffer",actual:t})}},us=class extends Oe{constructor(t){super(),this._ctor=t}validate(t){return t===void 0&&this._optional||t instanceof this._ctor?!0:this.fail({expect:`typedarray of ${this._ctor.name}`,actual:t})}}});function Fu(e,t,r="param"){if(e.errors=[],e.path=r,Lu(!0),!e.validate(t)){let n=e.errors.join(`
3
3
  `);throw e.errors.length=0,Lu(!1),new TypeError(n)}}var S,ju=T(()=>{"use strict";Mu();Mu();S={object(e){return new os(e)},array(e){return new ns(e)},tuple(...e){return new cs(...e)},literal(e){return new as(e)},or(...e){return new ss(...e)},symbol(){return new Qa},record(e){return new is(e)},function(){return new ts},boolean(){return new Ya},string(){return new Xa},number(){return new Ka},undefined(){return new Za},null(){return new es},unknown(){return new Zn},any(){return new Zn},as(){return new Zn},arraybuffer(){return new ls},enum(...e){return new rs(...e)},typedarray(e){return new us(e)}}});var ds,ev,tv=T(()=>{"use strict";R();_t();ju();Hr();ds=1,ev=e=>{function t(n,i){return(...o)=>{var u,p,f,m;let a=Date.now(),s={method:n,trace_id:ds};ds+=1;let c="SUCCESS",l=`${n}:ok`,d=0;try{if(i.paramsSchema)try{Fu(i.paramsSchema,o,"params")}catch(_){throw Ou(`${n}:fail ${_.message}`)}let v=i.implement(...o),b=v,y=`${n}:ok`;if(v&&"code"in v){let{code:_,data:E,message:C}=v;c=_,b=E,y=C}return{code:c,message:y,data:b}}catch(v){let b=v;d=(p=(u=b.code)!=null?u:b.errNo)!=null?p:2e3,c="FAILURE";let y=(m=(f=b.message)!=null?f:b.errMsg)!=null?m:`${v}`;return l=`${n}:${c} ${y.replace(/^\S+:(fail|cancel)\s?/,"")}`,ke(new co(l,d)),{code:c,message:l}}finally{let v=Date.now()-a}}}function r(n,i){return(...o)=>g(this,null,function*(){var p,f,m,v;let a=vg(o)?o:[o],s=Date.now(),c={method:n,trace_id:ds};ds+=1;let l=`${n}:ok`,d="SUCCESS",u={code:d,message:l};try{if(i.paramsSchema)try{Fu(i.paramsSchema,a,"params")}catch(_){throw Ou(_.message)}let y=yield i.implement(...a);if(y&&"code"in y){let{code:_,data:E,message:C}=y;d=_,l=C,y=E}return Object.assign(u,{code:d,message:l,data:y}),u}catch(b){let y=b,_=(f=(p=y.code)!=null?p:y.errNo)!=null?f:2e3;d="FAILURE";let E=(v=(m=y.message)!=null?m:y.errMsg)!=null?v:`${b}`,C=`${n}:${d} ${E.replace(/^\S+:(fail|cancel)\s?/,"")}`;return Object.assign(u,{code:d,message:C}),ke(new co(C,_)),u}finally{let b=Date.now()-s}})}return{createAPI:r,createSyncAPI:t}}});var ye,ps=T(()=>{"use strict";$();ce();({canIUseNative:ye}=ja(()=>I.sdkInfo.nativeSDKVersionCode,()=>I.platform))});function Bu(e){if(typeof e!="number"||e<=0)return"0.0.0";let t=e.toString(),r=0,n=0,i=0;return t.length>=1&&(r=parseInt(t.substring(0,1),10)),t.length>=3&&(n=parseInt(t.substring(1,3),10)),t.length>=5&&(i=parseInt(t.substring(3,5),10)),`${r}.${n}.${i}`}var rv=T(()=>{"use strict"});var z,Q,D,Ve=T(()=>{"use strict";Qg();wt();tv();ju();ps();rv();({createAPI:z,createSyncAPI:Q}=ev(j)),D=Xg("native")});function nv(e){let t=Object.prototype.toString.call(e).split(" ")[1].split("]")[0].toLocaleLowerCase();return t==="array"&&(t="object"),v1.includes(t)?t:""}function iv(e,t){try{switch(t){case"string":return e;case"object":return JSON.parse(e);case"number":return parseFloat(e);case"boolean":return e==="true";default:return""}}catch(r){return""}}function ov(e,t){try{switch(t){case"string":case"number":case"boolean":return`${e}`;case"object":return JSON.stringify(e);default:return""}}catch(r){return""}}var fs,f1,m1,h1,g1,Q6,Z6,v1,Vr,St,uo=T(()=>{"use strict";Ve();ce();R();ft();$();fs=Y(),f1=z("getLocalStorage",{paramsSchema:S.tuple(S.string()),implement(e){return g(this,null,function*(){let{response:t}=yield X(`/api/games/user-storage/${I.mpId}`,{method:"GET",responseType:"json",appendHostCookie:!0,query:{key:e}}),{data:{code:r,message:n,data:i}}=yield t;if(r==="SUCCESS")return{code:r,message:n,data:i==null?void 0:i.value};try{let{data:{data:o,dataType:a}}=yield de("getLocalStorageAsync",{key:e}),s=iv(o,a);return{code:r,message:`${n}. fallback to native`,data:s}}catch(o){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get local storage failed",data:null}}})}});fs.registerCommand("StorageSDK.getItem",f1);D("storage.getItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});m1=z("setStorage",{paramsSchema:S.tuple(S.string(),S.or(S.string(),S.boolean(),S.number())),implement(e,t){return g(this,null,function*(){let r=I.mpId,n=typeof t=="string"?t:String(t),{response:i}=yield X(`/api/games/user-storage/${r}`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e,value:n}}),{data:{code:o,message:a}}=i,s=nv(t),c=ov(t,s);return yield de("setLocalStorageAsync",{key:e,data:c,dataType:s}),o=="SUCCESS"?{code:o,message:a}:{code:o,message:`${a}. fallback to native`}})}});fs.registerCommand("StorageSDK.setItem",m1);D("storage.setItem",{version:"1.0.0",properties:{key:"1.0.0",value:"1.0.0"}});h1=z("removeStorage",{paramsSchema:S.tuple(S.string()),implement(e){return g(this,null,function*(){let t=I.mpId,{response:r}=yield X(`/api/games/user-storage/${t}/remove`,{method:"POST",responseType:"json",appendHostCookie:!0,data:{key:e}}),{data:{code:n,message:i}}=r;return yield de("removeLocalStorageAsync",{key:e}),n==="SUCCESS"?{code:n,message:i}:{code:n,message:"[Jolibox SDK] remove item succ"}})}});fs.registerCommand("StorageSDK.removeItem",h1);D("storage.removeItem",{version:"1.0.0",properties:{key:"1.0.0"}});g1=z("clearStorage",{implement(){return g(this,null,function*(){let e=I.mpId,{response:t}=yield X(`/api/games/user-storage/${e}/clear`,{method:"POST",appendHostCookie:!0});de("clearLocalStorageAsync");let{data:{code:r,message:n}}=t;return r==="SUCCESS"?{code:r,message:n}:{code:r,message:`${n}.fallback to native`}})}});fs.registerCommand("StorageSDK.clear",g1);D("storage.clear",{version:"1.0.0"});Q6=z("getStorageInfo",{implement(){return g(this,null,function*(){let{data:e}=yield de("getStorageInfoAsync");return e})}});D("getStorageInfo",{version:"1.0.0",success:{keys:"1.0.0",currentSize:"1.0.0",limitSize:"1.0.0"}});Z6=Q("getStorageInfoSync",{implement(){return L("getStorageInfoSync")}}),v1=["string","number","boolean","object",""];Vr=z("getGlobalStorage",{paramsSchema:S.tuple(S.string()),implement(e){return g(this,null,function*(){try{let{data:{data:t,dataType:r}}=yield de("getGlobalStorageAsync",{key:e});return{code:"SUCCESS",message:"success",data:iv(t,r)}}catch(t){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] get global storage failed",data:null}}})}}),St=z("setGlobalStorage",{paramsSchema:S.tuple(S.string(),S.or(S.string(),S.boolean(),S.number(),S.array())),implement(e,t){return g(this,null,function*(){try{let r=nv(t),n=ov(t,r);return yield de("setGlobalStorageAsync",{key:e,data:n,dataType:r}),{code:"SUCCESS",message:"success"}}catch(r){return{code:"INTERNAL_ERROR",message:"[Jolibox SDK] set global storage failed"}}})}})});var av,ms,sv=T(()=>{"use strict";$();Kg();R();ft();ce();uo();ps();av="REPORT_FIRST_OPEN_GAME",ms=class extends $a{constructor(r,n,i){super(n,i);this.started=!1;this.gameId=I.mpId,this.sessionId=I.sessionId,this.track=r,this.taskUrl=Qn(I.testMode)+"/api/base/app-event"}reporter(r){return g(this,null,function*(){let{event:n,params:i,extraParams:o}=r,a={eventType:n,gameInfo:P({gameId:this.gameId,sessionId:this.sessionId},i)};o&&Object.assign(a,o),yield this.createTask(a)})}reportToNative(r){return g(this,null,function*(){let{event:n,params:i}=r;yield de("userTrackAsync",{event:n,params:P({},i),gameId:this.gameId})})}tracker(r,n=null){this.track(r,n)}start(r){if(this.started){console.info("[JoliboxSDK] taskTrakcer has started");return}super.start(r),this.tryReportOpenGamePlus(),this.started=!0}tryReportOpenGamePlus(){Vr(av).then(r=>{Jr(r.data)&&r.data&&this.tracker("OpenGame_2Plus"),St(av,!0)})}createTask(r){return ye("sendServerEventAsync")?de("sendServerEventAsync",{payload:r}):I.platform==="android"?X("/api/base/app-event",{method:"POST",data:r}):de("trackAppEventAsync",{url:this.taskUrl,body:JSON.stringify(r)})}}});var pv={};Bh(pv,{nativeTaskEmitter:()=>po,taskTracker:()=>It,track:()=>j,trackPerformance:()=>uv});var y1,cv,lv,j,uv,dv,po,It,wt=T(()=>{"use strict";Bg();R();Ru();zg();$();sv();ce();y1=(e,t,r)=>{var l,d,u,p,f,m,v;let n=t,i=vn(n.extra)?n.extra:io(n.extra)?JSON.parse(n.extra):{},{mpName:o,mpVersion:a}=(l=I.mpInfo)!=null?l:{},s=P(P(B(P({},i),{mp_id:(d=n.mp_id)!=null?d:"",mp_version:(u=n.mp_version)!=null?u:"",session_id:I.sessionId,user_id:(f=(p=I.hostUserInfo)==null?void 0:p.uid)!=null?f:""}),o?{mp_name:o}:{}),a?{mp_info_version:a}:{}),c=(m=n.eventType)!=null?m:K.Other;L("trackAsync",{event:(v=t.tag)!=null?v:e,data:s,webviewId:r,eventType:c})},{track:j,trackPerformance:uv}=Vg(y1,{type:Su.AppSDK,platform:"native",jssdk_version:(lv=(cv=I.sdkInfo)==null?void 0:cv.jssdkVersion)!=null?lv:"1.0.0",mp_id:I.mpId,mp_version:I.mpVersion}),dv=Y();dv.registerCommand("ReportSDK.traceSystemTimeline",({event:e,duration:t,extra:r})=>{uv(e,t,r)});dv.registerCommand("ReportSDK.traceSystem",({event:e,info:t})=>{j(e,t)});po=new Yt,It=new ms(j,po)});function fv(){let e=null,t=null,r=window.fetch,n=()=>{t=document.createElement("meta"),t.setAttribute("name","viewport"),t.setAttribute("content","viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"),t.setAttribute("data-jolibox-sdk","viewport-meta"),e=document.createElement("style"),e.setAttribute("data-jolibox-sdk","default-styles");let s=`
4
4
  html[data-jolibox-root] {
@@ -866,7 +866,7 @@ If multiple caches share the same key they might "fight" for each other's style
866
866
  width: 100%;
867
867
  height: 100%;
868
868
  }
869
- `,RP=e=>{let{state:t}=e,{afterAd:r,adDismissed:n,adViewed:i,adBreakDone:o,adLoaded:a,adLinkClicked:s,visible:c,src:l}=t,[d,u]=Sr(!1),p=m=>{var v,b,y,_;u(!1),c.value=!1,m==="dismiss"?(v=n.value)==null||v.call(n):m==="viewed"&&((b=i.value)==null||b.call(i)),(y=r.value)==null||y.call(r),(_=o.value)==null||_.call(o)},f=()=>{var m;(m=a.value)==null||m.call(a)};return Ui("appsrockets_ad_dismissed",()=>p("dismiss")),Ui("appsrockets_ad_rewarded",()=>p("viewed")),Ui("appsrockets_ad_completed",()=>p("viewed")),Ui("appsrockets_ad_skipped",()=>p("viewed")),Ui("appsrockets_ad_clicked",m=>{var v;return(v=s.value)==null?void 0:v.call(s,m)}),Ui("appsrockets_ad_loaded",()=>u(!0)),c.value?G("div",{className:D9,style:{display:d?"flex":"none"},children:c.value&&G("iframe",{src:l.value,onLoad:f,allowFullScreen:!0,allow:"autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-modals allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation allow-top-navigation allow-top-navigation-by-user-activation allow-top-navigation-to-custom-protocols"})}):null};Jm=class{constructor(t,r){Lr(this,"name","APPSROCKETS"),Lr(this,"initialized",!1),Lr(this,"initCompleter",null),Lr(this,"context",void 0),Lr(this,"adsOverlay",null),Lr(this,"adsIsShowing",!1),Lr(this,"lastUnDisplayedAdBreak",null),Lr(this,"state",OP()),Lr(this,"processUrl",(n,i)=>{var o;let a=this.context.getContextInfo(),s=new URL(n),c=new URLSearchParams(s.search);return c.has("joliSource")||c.set("joliSource",a.joliSource),c.get("osType")||c.set("osType",a.osType),c.get("runtimeType")||c.set("runtimeType",a.runtimeType),c.get("mode")||c.set("mode","AFG"),c.get("deviceId")||c.set("deviceId",a.deviceId),c.get("statusBarHeight")||c.set("statusBarHeight",((o=this.context.getWindowInfo().statusBarHeight)!=null?o:0).toString()),c.get("adsType")||c.set("adsType",i),s.search=c.toString(),s.toString()}),this.context=t}init(){return g(this,null,function*(){var t;this.adsOverlay=document.createElement("div"),this.adsOverlay.setAttribute("data-placement-info","afg-appsrockets"),Qt(G(RP,{state:this.state}),this.adsOverlay),document.documentElement.appendChild(this.adsOverlay),this.initialized=!0,(t=this.initCompleter)==null||t.call(this)})}adConfig(t){var r;if(this.initialized){(r=t.onReady)==null||r.call(t);return}this.initCompleter=()=>{var n;(n=t.onReady)==null||n.call(t)}}adBreak(t,r){var n,i,o,a,s,c,l,d;if(!this.initialized||!this.adsOverlay||!r.params.url){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"});return}if(this.adsIsShowing){(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}let u=f=>{var m,v;(v=(m=this.context).handleLinkClicked)==null||v.call(m,f)},p=t.type==="reward"?"REWARD":"INTERSTITIAL";switch(t.type){case"preroll":{(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"start":case"browse":case"next":case"pause":{(a=t.beforeAd)==null||a.call(t);let f=()=>{var b;this.adsIsShowing=!1,(b=t.afterAd)==null||b.call(t)},m=()=>{var b;this.adsIsShowing=!1,(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"})},v=()=>{var b;this.adsIsShowing=!1,(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"noAdPreloaded"})};Ce(()=>{this.adsIsShowing=!0,this.state.afterAd.value=f,this.state.adBreakDone.value=m,this.state.src.value=this.processUrl(r.params.url,p),this.state.adLinkClicked.value=u,this.state.adError.value=v,this.state.visible.value=!0});break}case"reward":{this.lastUnDisplayedAdBreak&&((c=(s=this.lastUnDisplayedAdBreak).adBreakDone)==null||c.call(s,{breakType:this.lastUnDisplayedAdBreak.type,breakName:this.lastUnDisplayedAdBreak.type==="preroll"?"":this.lastUnDisplayedAdBreak.name,breakFormat:this.lastUnDisplayedAdBreak.type==="reward"?"reward":"interstitial",breakStatus:"ignored"}),this.lastUnDisplayedAdBreak=null),(l=t.beforeAd)==null||l.call(t);let f=()=>{var C;this.adsIsShowing=!1,(C=t.afterAd)==null||C.call(t)},m={breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"ignored"},v=()=>{var C;this.adsIsShowing=!1,m.breakStatus="dismissed",(C=t.adDismissed)==null||C.call(t)},b=()=>{var C;this.adsIsShowing=!1,m.breakStatus="viewed",(C=t.adViewed)==null||C.call(t)},y=()=>{var C;this.adsIsShowing=!1,(C=t.adBreakDone)==null||C.call(t,m)},_=()=>{this.adsIsShowing=!1,m.breakStatus="noAdPreloaded"};Ce(()=>{this.state.afterAd.value=f,this.state.adDismissed.value=v,this.state.adViewed.value=b,this.state.adBreakDone.value=y,this.state.adLinkClicked.value=u,this.state.adError.value=_});let E=()=>{var C;if(this.lastUnDisplayedAdBreak=null,!this.adsOverlay){(C=t.adBreakDone)==null||C.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"notReady"});return}this.adsIsShowing=!0,Ce(()=>{this.state.src.value=this.processUrl(r.params.url,p),this.state.visible.value=!0})};this.lastUnDisplayedAdBreak=t,(d=t.beforeReward)==null||d.call(t,E);break}}}},NP=()=>{window.googletag=window.googletag||{cmd:[]},window.googletag.pubadsReady||window.googletag.cmd.push(()=>{window.googletag.enableServices()})};DP=class{constructor(e,t,r){it(this,"adUnit",void 0),it(this,"project",void 0),it(this,"keyValue",void 0),it(this,"adsContext",null),it(this,"rewardedSlot",null),it(this,"rewardedPayload",null),it(this,"readyEvent",null),it(this,"withCommand",function(){googletag.cmd.push(...arguments)}),it(this,"init",()=>{var n;this.rewardedSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.REWARDED),this.rewardedSlot&&(this.rewardedSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().addEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().addEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.keyValue&&(Object.keys(this.keyValue).forEach(i=>{var o;(o=this.rewardedSlot)==null||o.setTargeting(i,this.keyValue[i])}),Object.keys(this.keyValue).includes("project")||(n=this.rewardedSlot)==null||n.setTargeting("project",this.project)),googletag.display(this.rewardedSlot))}),it(this,"destroy",n=>{var i,o;this.rewardedPayload=null,this.readyEvent=null,googletag.pubads().removeEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().removeEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().removeEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().removeEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.rewardedSlot&&(googletag.destroySlots([this.rewardedSlot]),this.rewardedSlot=null),(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),it(this,"reinit",n=>{this.destroy(n),this.init()}),it(this,"handleSlotReady",n=>{n.slot===this.rewardedSlot&&(this.readyEvent=n)}),it(this,"handleSlotClosed",n=>{var i,o;if(this.adsContext&&n.slot===this.rewardedSlot){let a=this.rewardedPayload?"viewed":"dismissed";a==="viewed"?this.adsContext.adViewed():this.adsContext.adDismissed(),(o=(i=this.adsContext).afterAd)==null||o.call(i),this.withCommand(()=>{this.reinit(a)})}}),it(this,"handleSlotGranted",n=>{this.adsContext&&n.slot===this.rewardedSlot&&(this.rewardedPayload=n.payload)}),it(this,"handleSlotRenderEnded",n=>{n.slot===this.rewardedSlot&&n.isEmpty&&this.adsContext&&this.withCommand(()=>{this.reinit("frequencyCapped")})}),it(this,"requestAds",n=>{this.withCommand(()=>{if(this.adsContext){this.destroy("ignored");return}if(this.rewardedSlot||this.init(),this.adsContext=n,!this.rewardedSlot){this.reinit("notReady");return}if(this.readyEvent)this.adsContext.beforeReward(()=>{var i,o,a;(o=(i=this.adsContext)==null?void 0:i.beforeAd)==null||o.call(i),(a=this.readyEvent)==null||a.makeRewardedVisible()});else{let i=o=>{o.slot===this.rewardedSlot&&this.adsContext&&(googletag.pubads().removeEventListener("rewardedSlotReady",i),this.readyEvent=o,this.adsContext.beforeReward(()=>{var a,s,c;(s=(a=this.adsContext)==null?void 0:a.beforeAd)==null||s.call(a),(c=this.readyEvent)==null||c.makeRewardedVisible()}))};googletag.pubads().addEventListener("rewardedSlotReady",i),window.setTimeout(()=>{this.readyEvent||(this.reinit("timeout"),googletag.pubads().removeEventListener("rewardedSlotReady",i))},500)}})}),this.adUnit=e,this.project=t,this.keyValue=r,NP(),this.withCommand(()=>{this.init()})}};Hm=class{constructor(t,r,n){var i=this;vt(this,"adUnit",void 0),vt(this,"project",void 0),vt(this,"keyValue",void 0),vt(this,"adsContext",null),vt(this,"gamingInterstitialSlot",null),vt(this,"readyEvent",null),vt(this,"isRetrying",!1),vt(this,"withCommand",function(){googletag.cmd.push(...arguments)}),vt(this,"init",()=>{var o;this.gamingInterstitialSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL),this.gamingInterstitialSlot&&(this.gamingInterstitialSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("gameManualInterstitialSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("gameManualInterstitialSlotClosed",this.handleSlotClosed),this.keyValue&&(Object.keys(this.keyValue).forEach(a=>{var s;(s=this.gamingInterstitialSlot)==null||s.setTargeting(a,this.keyValue[a])}),Object.keys(this.keyValue).includes("project")||(o=this.gamingInterstitialSlot)==null||o.setTargeting("project",this.project)),googletag.display(this.gamingInterstitialSlot))}),vt(this,"destroy",function(o){var a,s;(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1])&&((s=(a=i.adsContext)==null?void 0:a.onEnd)==null||s.call(a,o),o!=="ignored"&&(i.adsContext=null)),googletag.pubads().removeEventListener("gameManualInterstitialSlotReady",i.handleSlotReady),googletag.pubads().removeEventListener("gameManualInterstitialSlotClosed",i.handleSlotClosed),i.gamingInterstitialSlot&&(googletag.destroySlots([i.gamingInterstitialSlot]),i.gamingInterstitialSlot=null,i.readyEvent=null)}),vt(this,"reinit",function(o){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;i.destroy(o,a),i.init()}),vt(this,"handleSlotReady",o=>{this.gamingInterstitialSlot===o.slot&&(this.readyEvent=o)}),vt(this,"handleSlotClosed",o=>{var a,s;this.adsContext&&this.gamingInterstitialSlot===o.slot&&((s=(a=this.adsContext).afterAd)==null||s.call(a),this.withCommand(()=>{this.reinit("viewed")}))}),vt(this,"requestAds",o=>{this.withCommand(()=>{var a,s,c;if(this.adsContext){this.destroy("ignored");return}if(this.gamingInterstitialSlot||this.init(),this.adsContext=o,!this.gamingInterstitialSlot){this.reinit("notReady");return}this.readyEvent?((a=o.beforeAd)==null||a.call(o),this.readyEvent.makeGameManualInterstitialVisible()):((c=(s=this.adsContext).onEnd)==null||c.call(s,"frequencyCapped"),this.adsContext=null,this.isRetrying||(this.isRetrying=!0,window.setTimeout(()=>{this.readyEvent||this.withCommand(()=>{this.reinit("frequencyCapped",!1)}),this.isRetrying=!1},31e3)))})}),NP(),this.adUnit=t,this.project=r,this.keyValue=n,this.withCommand(()=>{this.init()})}};Vm=class{constructor(t,r){Gn(this,"name","GOOGLE_GPT"),Gn(this,"context",void 0),Gn(this,"contextInfo",void 0),Gn(this,"initParams",void 0),Gn(this,"rewardAdManager",void 0),Gn(this,"interstitialManager",void 0),Gn(this,"insertScript",()=>{let n="jolibox-google-gpt",i=document.getElementById(n);i||(i=window.document.createElement("script"),i.id=n,i.async=!0,i.src="https://securepubads.g.doubleclick.net/tag/js/gpt.js",i.crossOrigin="anonymous",document.head.appendChild(i))}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.initParams=r,this.insertScript()}init(){return g(this,null,function*(){let t=this.contextInfo.testAdsMode?"/22639388115/rewarded_web_example":this.initParams.rewardedSlot,r=this.contextInfo.testAdsMode?"/6355419/Travel/Europe/France/Paris":this.initParams.interstitialSlot,n=`minigame-${this.contextInfo.runtimeType==="APP"?"app":"h5"}`;t&&(this.rewardAdManager=new DP(t,n,this.initParams.keyValue)),r&&(this.interstitialManager=new Hm(r,n,this.initParams.keyValue))})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:a})}});break}default:{if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}this.interstitialManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,onEnd:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:a})}});break}}}};$m=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GAME";Im(this,"context",void 0),Im(this,"placement","GAME"),Im(this,"contextInfo",void 0),this.context=t,this.placement=r,this.contextInfo=this.context.getContextInfo()}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:this.placement==="GAME"?"GamePage":"DramaPage",params:r}}getDevice(){var t,r,n,i;return{platform:(t=this.contextInfo.platform)!=null?t:aP.WebSDK,os:this.contextInfo.osType+"_"+this.contextInfo.runtimeType,appVersion:"1.0.0",appId:(r=this.contextInfo.hostAppId)!=null?r:"1",model:(n=this.contextInfo.deviceModel)!=null?n:"UnknownModel",brand:(i=this.contextInfo.deviceBrand)!=null?i:"UnknownBrand",uuid:this.contextInfo.deviceId,jsSdkVersion:"1.0.0",extra:{}}}serialize(t,r){var n;let i={protocolVersion:"1.0.0",events:[{name:t,type:iP.System,location:this.getLocation(),target:null,extra:r,timestamp:Date.now(),userId:(n=this.contextInfo.userId)!=null?n:null}],device:this.getDevice(),project:oP.WebSDK};return zV(i)}};Ia=class{constructor(t){dt(this,"context",void 0),dt(this,"adsTrackSerializer",void 0),dt(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo(),this.adsTrackSerializer=new $m(this.context)}getRequestContextData(t){var r,n;this.contextInfo=this.context.getContextInfo();let{width:i,height:o}=this.context.getWindowInfo();return{report:JSON.stringify(this.adsTrackSerializer.serialize(t,{sessionId:this.contextInfo.sessionId,objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId,testAdsMode:this.contextInfo.testAdsMode})),osType:this.contextInfo.osType,runtimeType:this.contextInfo.runtimeType,sessionId:this.contextInfo.sessionId,deviceId:this.contextInfo.deviceId,adId:this.contextInfo.adId,deviceModel:(r=this.contextInfo.deviceModel)!=null?r:"UnknownModel",deviceBrand:(n=this.contextInfo.deviceBrand)!=null?n:"UnknownBrand",dimension:{width:i,height:o}}}getRequestBizParams(){return{objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId}}},Nl=class{constructor(t,r){var n=this;dt(this,"context",void 0),dt(this,"contextInfo",void 0),dt(this,"requestContext",void 0),dt(this,"pendingAFGAdsInfo",{REWARD:Promise.resolve(null),INTERSTITIAL:Promise.resolve(null)}),dt(this,"pendingAFVAdsInfo",Promise.resolve(null)),dt(this,"doFetchAdsInfo",i=>g(this,null,function*(){let o=i==="afv"?"AdsAFVSDKRequest":"AdsAFGSDKAdBreak",a=[];switch(i){case"afv":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}case"reward":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}default:{a=["INTERSTITIAL"];break}}let s=i==="afv"?void 0:"cached",{data:c,code:l}=yield this.context.httpClient.post("/api/ads/info",{data:{contextData:this.requestContext.getRequestContextData(o),bizParams:this.requestContext.getRequestBizParams(),adsTypes:a,testAdsMode:this.contextInfo.testAdsMode,name:s}});return l==="SUCCESS"||l==="BYPASS_ADS"?{code:l,data:c}:null})),dt(this,"cacheRewardInfo",()=>{this.pendingAFGAdsInfo.REWARD=this.doFetchAdsInfo("reward").catch(()=>null)}),dt(this,"cacheInterstitialInfo",i=>{this.pendingAFGAdsInfo.INTERSTITIAL=this.doFetchAdsInfo(i).catch(()=>null)}),dt(this,"cacheAFVInfo",()=>{this.pendingAFVAdsInfo=this.doFetchAdsInfo("afv").catch(()=>null)}),dt(this,"cacheNextAFGAdsInfo",i=>g(this,null,function*(){i==="reward"?this.cacheRewardInfo():this.cacheInterstitialInfo(i)})),dt(this,"getAFGAdsInfo",i=>g(this,null,function*(){let o=yield i==="reward"?this.pendingAFGAdsInfo.REWARD:this.pendingAFGAdsInfo.INTERSTITIAL;return this.cacheNextAFGAdsInfo(i),o})),dt(this,"getAFVAdsInfo",function(){return g(this,arguments,function*(){if(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0]){let i=yield n.pendingAFVAdsInfo;return n.cacheAFVInfo(),i}else return n.cacheAFVInfo(),yield n.pendingAFVAdsInfo})}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.requestContext=new Ia(t),r!=null&&r.reward&&this.cacheRewardInfo(),r!=null&&r.interstitial&&this.cacheInterstitialInfo("start"),r!=null&&r.afv&&this.cacheAFVInfo()}};Y9=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(e)try{e(...r)}catch(i){console.error("[JoliboxSDK] Callback error:",i)}},Dl=class{constructor(t){this.context=t,W9(this,"canIUseHelper",void 0),this.context=t;let{canIUseNative:r}=ja(()=>this.context.getContextInfo().deviceInfo.nativeSDKVersionCode||1e6,()=>this.context.getContextInfo().deviceInfo.platform||"h5");this.canIUseHelper=r}loadAdsAsync(t){return g(this,null,function*(){try{let{errNo:r,errMsg:n}=yield L("loadAdsAsync",{params:{providers:t.providers}});return r!==0||n.length>0?{code:"FAILURE",message:n||"Failed to load ads"}:{code:"SUCCESS",message:"Ads loaded successfully"}}catch(r){return{code:"FAILURE",message:`Failed to load ads: ${r instanceof Error?r.message:String(r)}`}}})}canIUse(){return xl()&&this.canIUseHelper("loadAdsAsync")&&this.canIUseHelper("showAdAsync")}showAdAsync(t){return g(this,null,function*(){try{let r=yield L("showAdAsync",{params:{providers:t.providers}});if(r.errNo!==0)return{code:"FAILURE",message:r.errMsg||"Failed to show ad"};let n=r.data.UUID;if(t.callbacks){let i=t.timeout!==void 0?t.timeout:-1,o=null,a=()=>{lg("onAdsStateChange",s),o&&(clearTimeout(o),o=null)},s=c=>{var l;if(c.UUID!==n)return;let d=(l=t.callbacks)==null?void 0:l[c.event];d&&Y9(d,c.data),["onAdClosed","onAdError","onAdDismissed"].includes(c.event)&&a()};we("onAdsStateChange",s),i>0&&(o=setTimeout(()=>{a(),console.warn(`[JoliboxSDK] Event listener for ad ${n} auto-cleaned after ${i}ms timeout`)},i))}return{code:"SUCCESS",message:"Ad shown successfully"}}catch(r){return{code:"FAILURE",message:`Failed to show ad: ${r instanceof Error?r.message:String(r)}`}}})}isAdsReadySync(t){try{let{errNo:r,data:n}=L("isAdsReadySync",{params:{providers:t.providers}});return r!==0||!n?(console.warn("[Jolibox SDK]isAdsReadySync returned an error or no data"),!1):!0}catch(r){return console.warn("[Jolibox SDK]isAdsReadySync invocation failed:",r),!1}}};Wm=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){qr(this,"providers",void 0),qr(this,"helper",void 0),qr(this,"adsContext",null),qr(this,"_isAdsReady",!1),qr(this,"init",()=>g(this,null,function*(){this.helper.canIUse()?(yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1:this._isAdsReady=!1})),qr(this,"destroy",n=>{var i,o;this._isAdsReady=!1,(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),qr(this,"reinit",n=>g(this,null,function*(){this.destroy(n),yield this.init()})),qr(this,"requestAds",(n,i)=>g(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=n,i&&i.length>0&&(this.providers=i);try{this.isAdsReady?this.showAd():yield this.reinit("frequencyCapped")}catch(o){this.destroy("notReady")}})),qr(this,"showAd",()=>{if(!this.adsContext){this.destroy("error");return}let n=!1,i=!1;this.adsContext.beforeReward(()=>g(this,null,function*(){var o,a;(a=(o=this.adsContext)==null?void 0:o.beforeAd)==null||a.call(o);let s=l=>{var d,u,p;i||(i=!0,l==="dismissed"&&((d=this.adsContext)==null||d.adDismissed()),(p=(u=this.adsContext)==null?void 0:u.afterAd)==null||p.call(u),this.reinit(l))},c={onAdShow:()=>{},onAdError:()=>{s("error")},onAdRewarded:()=>{var l;n=!0,(l=this.adsContext)==null||l.adViewed()},onAdDismissed:()=>{s(n?"viewed":"dismissed")},onAdClosed:()=>{s(n?"viewed":"dismissed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:c})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")}))}),this.providers=r,this.helper=new Dl(t),this.init()}};zm=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){var n=this;Ur(this,"providers",void 0),Ur(this,"helper",void 0),Ur(this,"adsContext",null),Ur(this,"_isAdsReady",!1),Ur(this,"init",()=>g(this,null,function*(){this.helper.canIUse()&&((yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1)})),Ur(this,"destroy",function(i){var o,a;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n._isAdsReady=!1,s&&((a=(o=n.adsContext)==null?void 0:o.onEnd)==null||a.call(o,i),i!=="ignored"&&(n.adsContext=null))}),Ur(this,"reinit",function(o){return g(this,arguments,function*(i){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n.destroy(i,a),yield n.init()})}),Ur(this,"requestAds",(i,o)=>g(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=i,o&&o.length>0&&(this.providers=o);try{this.isAdsReady?yield this.showAd():yield this.reinit("frequencyCapped")}catch(a){this.destroy("notReady")}})),Ur(this,"showAd",()=>g(this,null,function*(){var i,o;if(!this.adsContext){this.destroy("error");return}let a=!1;(o=(i=this.adsContext).beforeAd)==null||o.call(i);let s=l=>{var d,u;a||(a=!0,(u=(d=this.adsContext)==null?void 0:d.afterAd)==null||u.call(d),this.reinit(l))},c={onAdShow:()=>{},onAdError:()=>{s("error")},onAdDismissed:()=>{s("dismissed")},onAdClosed:()=>{s("viewed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:c})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")})),this.providers=r,this.helper=new Dl(t),this.init()}};Km=class{constructor(t,r){va(this,"name","INTERNAL_NATIVE"),va(this,"context",void 0),va(this,"rewardAdManager",void 0),va(this,"interstitialManager",void 0),va(this,"initProviders",void 0),this.context=t,this.initProviders=r.providers;let n=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],r.providers),i=this.getConfigsByTypes(["INTERSTITIAL"],r.providers);n.length>0&&(this.rewardAdManager=new Wm(this.context,n)),i.length>0&&(this.interstitialManager=new zm(this.context,i))}getConfigsByTypes(t,r,n){let i=[];return(n?n.map(o=>r.find(a=>a.provider===o.provider)).filter(o=>!!o):r).forEach(o=>{t.forEach(a=>{let s="";a==="REWARD"&&(s=o.params.adUnitId.reward),a==="REWARD_INTERSTITIAL"&&(s=o.params.adUnitId.rewardInterstitial),a==="INTERSTITIAL"&&(s=o.params.adUnitId.interstitial),a==="NATIVE"&&(s=o.params.adUnitId.nativeAds),s&&i.push({provider:o.provider,params:{placementId:s,adsType:a,extra:o.params.extra}})})}),i}init(){return g(this,null,function*(){})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}let a=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],this.initProviders,r.params);this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:s=>{var c;(c=t.adBreakDone)==null||c.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:s})}},a);break}default:{let a=t;if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}let s=this.getConfigsByTypes(["INTERSTITIAL"],this.initProviders,r.params);this.interstitialManager.requestAds({beforeAd:a.beforeAd,afterAd:a.afterAd,onEnd:c=>{var l;(l=t.adBreakDone)==null||l.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:c})}},s);break}}}},Em="jolibox-nb-proxy",nW=0;Al=()=>{try{if(window.parent&&window.parent!==window)return oW("GameSDK")}catch(e){}};Ym=class{constructor(){Mi(this,"adsContext",null),Mi(this,"init",()=>g(this,null,function*(){console.log("[JoliboxSDK] NewsBreak init");let t=Al();if(t)try{let r=yield t.createRewardAd({platform:"jolibox"});console.log("[JoliboxSDK] NewsBreak init createRewardAd result:",r)}catch(r){console.log("[JoliboxSDK] NewsBreak init createRewardAd error:",r)}})),Mi(this,"destroy",t=>{var r,n;(n=(r=this.adsContext)==null?void 0:r.adBreakDone)==null||n.call(r,t),t!=="ignored"&&(this.adsContext=null)}),Mi(this,"reinit",t=>g(this,null,function*(){console.log("[JoliboxSDK] NewsBreak reinit breakStatus:",t),this.destroy(t),yield this.init()})),Mi(this,"requestAds",t=>g(this,null,function*(){if(console.log("[JoliboxSDK] NewsBreak newsbreak this.adsContext",this.adsContext),this.adsContext){this.destroy("ignored");return}this.adsContext=t;let r=Al();if(console.log("[JoliboxSDK] NewsBreak newsbreak sdk",r),!r){this.destroy("notReady");return}this.showAd()})),Mi(this,"showAd",()=>{if(console.log("[JoliboxSDK] NewsBreak showAd"),!this.adsContext){this.destroy("error");return}this.adsContext.beforeReward(()=>g(this,null,function*(){var t,r,n,i,o,a,s,c,l,d,u,p,f,m;(r=(t=this.adsContext)==null?void 0:t.beforeAd)==null||r.call(t);let v=Al();if(!v){(i=(n=this.adsContext)==null?void 0:n.afterAd)==null||i.call(n),this.reinit("error");return}try{let b=yield v.showRewardAd();if(console.log("[JoliboxSDK] NewsBreak showRewardAd result:",b),!b.success){(a=(o=this.adsContext)==null?void 0:o.afterAd)==null||a.call(o),this.reinit("error");return}b.rewardGranted?((s=this.adsContext)==null||s.adViewed(),(l=(c=this.adsContext)==null?void 0:c.afterAd)==null||l.call(c),this.reinit("viewed")):((d=this.adsContext)==null||d.adDismissed(),(p=(u=this.adsContext)==null?void 0:u.afterAd)==null||p.call(u),this.reinit("dismissed"))}catch(b){console.error("[JoliboxSDK] NewsBreak showRewardAd failed:",b),(m=(f=this.adsContext)==null?void 0:f.afterAd)==null||m.call(f),this.reinit("error")}}))}),this.init()}};Xm=class{constructor(){XT(this,"name","NEWSBREAK"),XT(this,"rewardAdManager",void 0)}init(){return g(this,null,function*(){let t=Al();if(!t){console.warn("[JoliboxSDK] NewsBreak GameSDK is not available on window");return}t.onEnter(),this.rewardAdManager=new Ym})}adConfig(t,r){}adBreak(t,r){var n,i;if(t.type!=="reward"){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:o=>{var a;(a=t.adBreakDone)==null||a.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:o})}})}};Ji=class{constructor(t){if($t(this,"context",void 0),$t(this,"contextInfo",void 0),$t(this,"providers",{}),$t(this,"channelPolicy",void 0),$t(this,"adsActionDetection",void 0),$t(this,"requestContext",void 0),$t(this,"adsRequest",void 0),$t(this,"initialized",!1),$t(this,"adsIsShowing",!1),$t(this,"lastAdBreak",void 0),$t(this,"initializedTimeStamp",Date.now()),t)this.context=t,this.channelPolicy=new Rm(this.context),this.adsActionDetection=new Om(this.context),this.contextInfo=this.context.getContextInfo(),this.adsRequest=new Nl(t),this.requestContext=new Ia(t);else throw new Error("JoliboxAdsForGame requires a configuration object")}init(t){return g(this,null,function*(){window.adsbygoogle=window.adsbygoogle||[];let{data:r}=yield this.context.httpClient.post("/api/ads/init",{data:{contextData:this.requestContext.getRequestContextData("AdsAFGSDKInit"),bizParams:this.requestContext.getRequestBizParams(),testAdsMode:this.contextInfo.testAdsMode}});if((r==null?void 0:r.length)>0){let n=r.filter(s=>s.isNative),i=r.filter(s=>!s.isNative),o={provider:"INTERNAL_NATIVE",params:{providers:n}},a=i.concat([o]);for(let s of a)switch(s.provider){case"GOOGLE_GPT":{let c=new Vm(this.context,s.params);yield c.init(),this.providers[s.provider]=c;break}case"ADSENSE":case"ADSENSE_ADMOB":{let c=new Nm(this.context,s.params);yield c.init(),this.providers[s.provider]=c;break}case"OKSPIN":{let c=new Bm(this.context,s.params);yield c.init(),this.providers.OKSPIN=c;break}case"APPSROCKETS":{let c=new Jm(this.context,s.params);yield c.init(),this.providers.APPSROCKETS=c;break}case"ADSENSE_BANNER_AS_AFG":{let c=new Gm(this.context,s.params);yield c.init(),this.providers.ADSENSE_BANNER_AS_AFG=c;break}case"INTERNAL_NATIVE":{let c=new Km(this.context,s.params);yield c.init(),this.providers.INTERNAL_NATIVE=c;break}case"NEWSBREAK":{console.log("[JoliboxSDK] NewsBreak Provider",s);let c=new Xm;yield c.init(),this.providers.NEWSBREAK=c;break}}}this.adsRequest.cacheInterstitialInfo("start"),this.adsRequest.cacheRewardInfo(),this.initialized=!0})}adConfig(t){this.providers.ADSENSE?this.providers.ADSENSE.adConfig(t):window.adsbygoogle.push(t)}adBreak(t){return g(this,null,function*(){var r,n,i,o,a,s,c,l,d,u,p,f,m,v,b,y;let _=Date.now();if(_-this.initializedTimeStamp<3e3){(r=t.adBreakDone)==null||r.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}if(this.lastAdBreak&&_-this.lastAdBreak<500){console.warn("[Jolibox SDK Ads] You can't call adBreak too frequently"),(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.lastAdBreak=_,this.adsIsShowing){console.warn("[Jolibox SDK Ads] You can't call adBreak while ad is showing"),(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.initialized||(yield this.init()),t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}if(!this.context.checkNetwork()&&!this.providers.NEWSBREAK){(a=t.adBreakDone)==null||a.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}try{let E=yield this.adsRequest.getAFGAdsInfo(t.type),C=E==null?void 0:E.data,x=E==null?void 0:E.code;if(x==="BYPASS_ADS"){switch(t.type){case"preroll":{(s=t.adBreakDone)==null||s.call(t,{breakType:t.type,breakFormat:"interstitial",breakStatus:"viewed"});break}case"reward":{t.beforeReward(()=>{var k,A,H,ue;(k=t.beforeAd)==null||k.call(t),(A=t.adViewed)==null||A.call(t),(H=t.afterAd)==null||H.call(t),(ue=t.adBreakDone)==null||ue.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"viewed"})});break}default:{(c=t.beforeAd)==null||c.call(t),(l=t.afterAd)==null||l.call(t),(d=t.adBreakDone)==null||d.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"});break}}return}if(!C||x!=="SUCCESS"){(u=t.adBreakDone)==null||u.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}else{if(C.length===0){(p=t.adBreakDone)==null||p.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}let k=!0,A=null,H=new Pm(this.context);this.adsActionDetection.adBreakIsShowing=!0;let ue=C.filter(J=>J.isNative).sort((J,V)=>J.seq-V.seq),N=C.filter(J=>!J.isNative).sort((J,V)=>J.seq-V.seq),O={seq:(m=(f=ue[0])==null?void 0:f.seq)!=null?m:0,provider:"INTERNAL_NATIVE",params:ue},F;for(ue.length>0?F=[O].concat(N):F=N,F=F.sort((J,V)=>J.seq-V.seq).map((J,V)=>CV(eP({},J),{seq:V}));F.length>0;){let J=F.shift(),V=this.providers[J.provider];if(V){let[Mt,Mh]=yield H.callAdBreakAndContinue(V,t,J,Wl=>{var Oa;this.adsIsShowing=Wl,(Oa=this.context.eventEmitter)==null||Oa.emit("isAdShowing",Wl)});k=Mt,A=Mh}else k=!0,A={breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"};if(!k)break}k&&A&&((v=t.adBreakDone)==null||v.call(t,A))}}catch(E){(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}finally{this.adsIsShowing=!1,(y=this.context.eventEmitter)==null||y.emit("isAdShowing",!1),this.adsActionDetection.adBreakIsShowing=!1}})}adUnit(t){console.warn("This method has been deprecated. We will not support AdSense AdUnit in the future.")}};Qm=class{constructor(t){yl(this,"context",void 0),yl(this,"currentProvider",void 0),yl(this,"continueCallback",void 0),yl(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo()}get paramsToTrack(){var t,r;return{provider:(r=(t=this.currentProvider)==null?void 0:t.name)!=null?r:null}}wrapAdRequested(t){return()=>{this.context.track("CallAFVRequest",this.paramsToTrack),t==null||t()}}wrapAdLoaded(t){return r=>{this.context.track("CallAFVLoad",this.paramsToTrack),t==null||t(r)}}wrapAdPlaying(t){return r=>{var n,i;this.context.track("CallAFVPlaying",this.paramsToTrack),xl()&&this.context.track("mmp_ad_impression",{ad_network:(i=(n=this.currentProvider)==null?void 0:n.name)!=null?i:"",ad_format:"AFV",module:"drama",game_id:this.contextInfo.objectId}),t==null||t(r)}}wrapAdCompleted(t){return r=>{var n;this.context.track("CallAFVCompleted",this.paramsToTrack),t==null||t(r),(n=this.continueCallback)==null||n.call(this,[!1,null])}}wrapAdError(t){return r=>{var n;this.context.track("CallAFVError",this.paramsToTrack),(n=this.continueCallback)==null||n.call(this,[!0,r])}}callAdRequestAndContinue(t,r,n){return g(this,null,function*(){return this.currentProvider=t,new Promise(i=>{this.continueCallback=i;let o=Object.assign({},r);o.onAdRequested=this.wrapAdRequested(r.onAdRequested),o.onAdLoaded=this.wrapAdLoaded(r.onAdLoaded),o.onAdPlaying=this.wrapAdPlaying(r.onAdPlaying),o.onAdCompleted=this.wrapAdCompleted(r.onAdCompleted),o.onAdError=this.wrapAdError(r.onAdError),t.requestAd(o,n)})})}};at=class e extends Error{constructor(t,r){super(t.message),Am(this,"name",void 0),Am(this,"type",void 0),Am(this,"raw",void 0),this.name="AFVRequestError",this.type=r,this.raw=t,this.stack=t.stack,this.message=t.message}static from(t,r){switch(r){case"GOOGLE_IMA_ERROR":return new e(t,r);case"JOLIBOX_IMA_ERROR":return new e(t,r)}}};Zm=class{constructor(t,r,n){me(this,"adsLoader",void 0),me(this,"adDisplayContainer",void 0),me(this,"isAdPlaying",!1),me(this,"isContentFinished",!1),me(this,"videoContent",void 0),me(this,"adContainer",void 0),me(this,"adsManager",void 0),me(this,"intervalTimer",void 0),me(this,"completed",!1),me(this,"adTagUrl",void 0),me(this,"notifyRequestAd",void 0),me(this,"notifyLoaded",void 0),me(this,"notifyPlayingAd",void 0),me(this,"notifyCompleted",void 0),me(this,"notifyError",void 0),me(this,"destroy",()=>{var i,o,a,s,c,l,d,u,p,f,m;this.intervalTimer&&clearInterval(this.intervalTimer),(i=this.adsManager)==null||i.stop(),(o=this.adDisplayContainer)==null||o.destroy(),(a=this.adsLoader)==null||a.removeEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded),(s=this.adsLoader)==null||s.removeEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),(c=this.adsManager)==null||c.removeEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),(l=this.adsManager)==null||l.removeEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested),(d=this.adsManager)==null||d.removeEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested),(u=this.adsManager)==null||u.removeEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAdEvent),(p=this.adsManager)==null||p.removeEventListener(window.google.ima.AdEvent.Type.LOADED,this.onAdEvent),(f=this.adsManager)==null||f.removeEventListener(window.google.ima.AdEvent.Type.STARTED,this.onAdEvent),(m=this.adsManager)==null||m.removeEventListener(window.google.ima.AdEvent.Type.COMPLETE,this.onAdEvent)}),me(this,"requestAds",(i,o)=>g(this,null,function*(){var a;this.createAdDisplayContainer(),this.notifyRequestAd=i.onAdRequested,this.notifyLoaded=i.onAdLoaded,this.notifyPlayingAd=i.onAdPlaying,this.notifyCompleted=i.onAdCompleted,this.notifyError=u=>{var p;return(p=i.onAdError)==null?void 0:p.call(i,at.from(u,"GOOGLE_IMA_ERROR"))},this.adsLoader=new window.google.ima.AdsLoader(this.adDisplayContainer),this.adsLoader.addEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded,!1),this.adsLoader.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1);let s=()=>{var u;this.isAdPlaying||(this.isContentFinished=!0,(u=this.adsLoader)==null||u.contentComplete())};this.videoContent.onended=s;let c=new window.google.ima.AdsRequest;c.vastLoadTimeout=1e4;let l="";Object.keys(o.params).forEach(u=>{let p=window.encodeURIComponent(o.params[u]);l+=`&${u}=${p}`});let d=`${this.adTagUrl}${l}`;c.adTagUrl=d,c.linearAdSlotWidth=640,c.linearAdSlotHeight=400,c.nonLinearAdSlotWidth=640,c.nonLinearAdSlotHeight=150,this.adsLoader.requestAds(c),(a=this.notifyRequestAd)==null||a.call(this)})),me(this,"createAdDisplayContainer",()=>{this.adDisplayContainer=new window.google.ima.AdDisplayContainer(this.adContainer,this.videoContent)}),me(this,"playAds",()=>{var i,o;this.videoContent.load(),this.adDisplayContainer.initialize(),this.completed=!1;try{(i=this.adsManager)==null||i.init(window.document.body.clientWidth,window.document.body.clientHeight,window.google.ima.ViewMode.NORMAL),(o=this.adsManager)==null||o.start()}catch(a){console.error("[JoliboxAFV] Google IMA Error: ",a),this.videoContent.play()}}),me(this,"onAdsManagerLoaded",i=>{let o=new window.google.ima.AdsRenderingSettings;o.restoreCustomPlaybackStateOnAdBreakComplete=!0,o.loadVideoTimeout=1e4,this.adsManager=i.getAdsManager(this.videoContent,o),this.adsManager.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.LOADED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.STARTED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.COMPLETE,this.onAdEvent),i.type==="adsManagerLoaded"&&this.playAds()}),me(this,"onAdEvent",i=>{var o,a,s,c;let l=i.getAd();switch(i.type){case window.google.ima.AdEvent.Type.LOADED:l!=null&&l.isLinear()||this.videoContent.play(),(o=this.notifyLoaded)==null||o.call(this,i);break;case window.google.ima.AdEvent.Type.STARTED:l!=null&&l.isLinear()&&(this.intervalTimer=window.setInterval(function(){},300)),(a=this.notifyPlayingAd)==null||a.call(this,i);break;case window.google.ima.AdEvent.Type.COMPLETE:l!=null&&l.isLinear()&&clearInterval(this.intervalTimer),this.completed||(this.completed=!0,(s=this.notifyCompleted)==null||s.call(this,i));break;case window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED:l!=null&&l.isLinear()&&clearInterval(this.intervalTimer),this.completed||(this.completed=!0,(c=this.notifyCompleted)==null||c.call(this,i));break}}),me(this,"onAdError",i=>{var o,a;(o=this.notifyError)==null||o.call(this,i.getError()),(a=this.adsManager)==null||a.destroy()}),me(this,"onContentPauseRequested",()=>{this.isAdPlaying=!0,this.videoContent.pause()}),me(this,"onContentResumeRequested",()=>{this.isAdPlaying=!1}),this.adTagUrl=t,this.videoContent=r,this.adContainer=n}},Cl=(e=>(e[e.ADS_REQUEST_NETWORK_ERROR=1012]="ADS_REQUEST_NETWORK_ERROR",e[e.ASSET_FALLBACK_FAILED=1021]="ASSET_FALLBACK_FAILED",e[e.AUTOPLAY_DISALLOWED=1205]="AUTOPLAY_DISALLOWED",e[e.COMPANION_AD_LOADING_FAILED=603]="COMPANION_AD_LOADING_FAILED",e[e.COMPANION_REQUIRED_ERROR=602]="COMPANION_REQUIRED_ERROR",e[e.FAILED_TO_REQUEST_ADS=1005]="FAILED_TO_REQUEST_ADS",e[e.INVALID_AD_TAG=1013]="INVALID_AD_TAG",e[e.INVALID_ADX_EXTENSION=1105]="INVALID_ADX_EXTENSION",e[e.INVALID_ARGUMENTS=1101]="INVALID_ARGUMENTS",e[e.NONLINEAR_DIMENSIONS_ERROR=501]="NONLINEAR_DIMENSIONS_ERROR",e[e.OVERLAY_AD_LOADING_FAILED=502]="OVERLAY_AD_LOADING_FAILED",e[e.OVERLAY_AD_PLAYING_FAILED=500]="OVERLAY_AD_PLAYING_FAILED",e[e.STREAM_INITIALIZATION_FAILED=1020]="STREAM_INITIALIZATION_FAILED",e[e.UNKNOWN_AD_RESPONSE=1010]="UNKNOWN_AD_RESPONSE",e[e.UNKNOWN_ERROR=900]="UNKNOWN_ERROR",e[e.UNSUPPORTED_LOCALE=1011]="UNSUPPORTED_LOCALE",e[e.VAST_ASSET_NOT_FOUND=1007]="VAST_ASSET_NOT_FOUND",e[e.VAST_EMPTY_RESPONSE=1009]="VAST_EMPTY_RESPONSE",e[e.VAST_LINEAR_ASSET_MISMATCH=403]="VAST_LINEAR_ASSET_MISMATCH",e[e.VAST_LOAD_TIMEOUT=301]="VAST_LOAD_TIMEOUT",e[e.VAST_MALFORMED_RESPONSE=100]="VAST_MALFORMED_RESPONSE",e[e.VAST_MEDIA_LOAD_TIMEOUT=402]="VAST_MEDIA_LOAD_TIMEOUT",e[e.VAST_NO_ADS_AFTER_WRAPPER=303]="VAST_NO_ADS_AFTER_WRAPPER",e[e.VAST_NONLINEAR_ASSET_MISMATCH=503]="VAST_NONLINEAR_ASSET_MISMATCH",e[e.VAST_PROBLEM_DISPLAYING_MEDIA_FILE=405]="VAST_PROBLEM_DISPLAYING_MEDIA_FILE",e[e.VAST_SCHEMA_VALIDATION_ERROR=101]="VAST_SCHEMA_VALIDATION_ERROR",e[e.VAST_TOO_MANY_REDIRECTS=302]="VAST_TOO_MANY_REDIRECTS",e[e.VAST_TRAFFICKING_ERROR=200]="VAST_TRAFFICKING_ERROR",e[e.VAST_UNEXPECTED_DURATION_ERROR=202]="VAST_UNEXPECTED_DURATION_ERROR",e[e.VAST_UNEXPECTED_LINEARITY=201]="VAST_UNEXPECTED_LINEARITY",e[e.VAST_UNSUPPORTED_VERSION=102]="VAST_UNSUPPORTED_VERSION",e[e.VAST_WRAPPER_ERROR=300]="VAST_WRAPPER_ERROR",e[e.VIDEO_PLAY_ERROR=400]="VIDEO_PLAY_ERROR",e[e.VPAID_ERROR=901]="VPAID_ERROR",e))(Cl||{}),yW=()=>{let e=W(!1),t=W(!1),r=W(null),n=ho(),i=ho();return{visible:e,canRetry:t,retry:r,videoRef:n,adContainerRef:i}},bW=st`
869
+ `,RP=e=>{let{state:t}=e,{afterAd:r,adDismissed:n,adViewed:i,adBreakDone:o,adLoaded:a,adLinkClicked:s,visible:c,src:l}=t,[d,u]=Sr(!1),p=m=>{var v,b,y,_;u(!1),c.value=!1,m==="dismiss"?(v=n.value)==null||v.call(n):m==="viewed"&&((b=i.value)==null||b.call(i)),(y=r.value)==null||y.call(r),(_=o.value)==null||_.call(o)},f=()=>{var m;(m=a.value)==null||m.call(a)};return Ui("appsrockets_ad_dismissed",()=>p("dismiss")),Ui("appsrockets_ad_rewarded",()=>p("viewed")),Ui("appsrockets_ad_completed",()=>p("viewed")),Ui("appsrockets_ad_skipped",()=>p("viewed")),Ui("appsrockets_ad_clicked",m=>{var v;return(v=s.value)==null?void 0:v.call(s,m)}),Ui("appsrockets_ad_loaded",()=>u(!0)),c.value?G("div",{className:D9,style:{display:d?"flex":"none"},children:c.value&&G("iframe",{src:l.value,onLoad:f,allowFullScreen:!0,allow:"autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-modals allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation allow-top-navigation allow-top-navigation-by-user-activation allow-top-navigation-to-custom-protocols"})}):null};Jm=class{constructor(t,r){Lr(this,"name","APPSROCKETS"),Lr(this,"initialized",!1),Lr(this,"initCompleter",null),Lr(this,"context",void 0),Lr(this,"adsOverlay",null),Lr(this,"adsIsShowing",!1),Lr(this,"lastUnDisplayedAdBreak",null),Lr(this,"state",OP()),Lr(this,"processUrl",(n,i)=>{var o;let a=this.context.getContextInfo(),s=new URL(n),c=new URLSearchParams(s.search);return c.has("joliSource")||c.set("joliSource",a.joliSource),c.get("osType")||c.set("osType",a.osType),c.get("runtimeType")||c.set("runtimeType",a.runtimeType),c.get("mode")||c.set("mode","AFG"),c.get("deviceId")||c.set("deviceId",a.deviceId),c.get("statusBarHeight")||c.set("statusBarHeight",((o=this.context.getWindowInfo().statusBarHeight)!=null?o:0).toString()),c.get("adsType")||c.set("adsType",i),s.search=c.toString(),s.toString()}),this.context=t}init(){return g(this,null,function*(){var t;this.adsOverlay=document.createElement("div"),this.adsOverlay.setAttribute("data-placement-info","afg-appsrockets"),Qt(G(RP,{state:this.state}),this.adsOverlay),document.documentElement.appendChild(this.adsOverlay),this.initialized=!0,(t=this.initCompleter)==null||t.call(this)})}adConfig(t){var r;if(this.initialized){(r=t.onReady)==null||r.call(t);return}this.initCompleter=()=>{var n;(n=t.onReady)==null||n.call(t)}}adBreak(t,r){var n,i,o,a,s,c,l,d;if(!this.initialized||!this.adsOverlay||!r.params.url){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"});return}if(this.adsIsShowing){(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?"":t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}let u=f=>{var m,v;(v=(m=this.context).handleLinkClicked)==null||v.call(m,f)},p=t.type==="reward"?"REWARD":"INTERSTITIAL";switch(t.type){case"preroll":{(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"start":case"browse":case"next":case"pause":{(a=t.beforeAd)==null||a.call(t);let f=()=>{var b;this.adsIsShowing=!1,(b=t.afterAd)==null||b.call(t)},m=()=>{var b;this.adsIsShowing=!1,(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"})},v=()=>{var b;this.adsIsShowing=!1,(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"noAdPreloaded"})};Ce(()=>{this.adsIsShowing=!0,this.state.afterAd.value=f,this.state.adBreakDone.value=m,this.state.src.value=this.processUrl(r.params.url,p),this.state.adLinkClicked.value=u,this.state.adError.value=v,this.state.visible.value=!0});break}case"reward":{this.lastUnDisplayedAdBreak&&((c=(s=this.lastUnDisplayedAdBreak).adBreakDone)==null||c.call(s,{breakType:this.lastUnDisplayedAdBreak.type,breakName:this.lastUnDisplayedAdBreak.type==="preroll"?"":this.lastUnDisplayedAdBreak.name,breakFormat:this.lastUnDisplayedAdBreak.type==="reward"?"reward":"interstitial",breakStatus:"ignored"}),this.lastUnDisplayedAdBreak=null),(l=t.beforeAd)==null||l.call(t);let f=()=>{var C;this.adsIsShowing=!1,(C=t.afterAd)==null||C.call(t)},m={breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"ignored"},v=()=>{var C;this.adsIsShowing=!1,m.breakStatus="dismissed",(C=t.adDismissed)==null||C.call(t)},b=()=>{var C;this.adsIsShowing=!1,m.breakStatus="viewed",(C=t.adViewed)==null||C.call(t)},y=()=>{var C;this.adsIsShowing=!1,(C=t.adBreakDone)==null||C.call(t,m)},_=()=>{this.adsIsShowing=!1,m.breakStatus="noAdPreloaded"};Ce(()=>{this.state.afterAd.value=f,this.state.adDismissed.value=v,this.state.adViewed.value=b,this.state.adBreakDone.value=y,this.state.adLinkClicked.value=u,this.state.adError.value=_});let E=()=>{var C;if(this.lastUnDisplayedAdBreak=null,!this.adsOverlay){(C=t.adBreakDone)==null||C.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"notReady"});return}this.adsIsShowing=!0,Ce(()=>{this.state.src.value=this.processUrl(r.params.url,p),this.state.visible.value=!0})};this.lastUnDisplayedAdBreak=t,(d=t.beforeReward)==null||d.call(t,E);break}}}},NP=()=>{window.googletag=window.googletag||{cmd:[]},window.googletag.pubadsReady||window.googletag.cmd.push(()=>{window.googletag.enableServices()})};DP=class{constructor(e,t,r){it(this,"adUnit",void 0),it(this,"project",void 0),it(this,"keyValue",void 0),it(this,"adsContext",null),it(this,"rewardedSlot",null),it(this,"rewardedPayload",null),it(this,"readyEvent",null),it(this,"withCommand",function(){googletag.cmd.push(...arguments)}),it(this,"init",()=>{var n;this.rewardedSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.REWARDED),this.rewardedSlot&&(this.rewardedSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().addEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().addEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.keyValue&&(Object.keys(this.keyValue).forEach(i=>{var o;(o=this.rewardedSlot)==null||o.setTargeting(i,this.keyValue[i])}),Object.keys(this.keyValue).includes("project")||(n=this.rewardedSlot)==null||n.setTargeting("project",this.project)),googletag.display(this.rewardedSlot))}),it(this,"destroy",n=>{var i,o;this.rewardedPayload=null,this.readyEvent=null,googletag.pubads().removeEventListener("rewardedSlotReady",this.handleSlotReady),googletag.pubads().removeEventListener("rewardedSlotClosed",this.handleSlotClosed),googletag.pubads().removeEventListener("rewardedSlotGranted",this.handleSlotGranted),googletag.pubads().removeEventListener("slotRenderEnded",this.handleSlotRenderEnded),this.rewardedSlot&&(googletag.destroySlots([this.rewardedSlot]),this.rewardedSlot=null),(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),it(this,"reinit",n=>{this.destroy(n),this.init()}),it(this,"handleSlotReady",n=>{n.slot===this.rewardedSlot&&(this.readyEvent=n)}),it(this,"handleSlotClosed",n=>{var i,o;if(this.adsContext&&n.slot===this.rewardedSlot){let a=this.rewardedPayload?"viewed":"dismissed";a==="viewed"?this.adsContext.adViewed():this.adsContext.adDismissed(),(o=(i=this.adsContext).afterAd)==null||o.call(i),this.withCommand(()=>{this.reinit(a)})}}),it(this,"handleSlotGranted",n=>{this.adsContext&&n.slot===this.rewardedSlot&&(this.rewardedPayload=n.payload)}),it(this,"handleSlotRenderEnded",n=>{n.slot===this.rewardedSlot&&n.isEmpty&&this.adsContext&&this.withCommand(()=>{this.reinit("frequencyCapped")})}),it(this,"requestAds",n=>{this.withCommand(()=>{if(this.adsContext){this.destroy("ignored");return}if(this.rewardedSlot||this.init(),this.adsContext=n,!this.rewardedSlot){this.reinit("notReady");return}if(this.readyEvent)this.adsContext.beforeReward(()=>{var i,o,a;(o=(i=this.adsContext)==null?void 0:i.beforeAd)==null||o.call(i),(a=this.readyEvent)==null||a.makeRewardedVisible()});else{let i=o=>{o.slot===this.rewardedSlot&&this.adsContext&&(googletag.pubads().removeEventListener("rewardedSlotReady",i),this.readyEvent=o,this.adsContext.beforeReward(()=>{var a,s,c;(s=(a=this.adsContext)==null?void 0:a.beforeAd)==null||s.call(a),(c=this.readyEvent)==null||c.makeRewardedVisible()}))};googletag.pubads().addEventListener("rewardedSlotReady",i),window.setTimeout(()=>{this.readyEvent||(this.reinit("timeout"),googletag.pubads().removeEventListener("rewardedSlotReady",i))},500)}})}),this.adUnit=e,this.project=t,this.keyValue=r,NP(),this.withCommand(()=>{this.init()})}};Hm=class{constructor(t,r,n){var i=this;vt(this,"adUnit",void 0),vt(this,"project",void 0),vt(this,"keyValue",void 0),vt(this,"adsContext",null),vt(this,"gamingInterstitialSlot",null),vt(this,"readyEvent",null),vt(this,"isRetrying",!1),vt(this,"withCommand",function(){googletag.cmd.push(...arguments)}),vt(this,"init",()=>{var o;this.gamingInterstitialSlot=googletag.defineOutOfPageSlot(this.adUnit,googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL),this.gamingInterstitialSlot&&(this.gamingInterstitialSlot.addService(googletag.pubads()),googletag.pubads().addEventListener("gameManualInterstitialSlotReady",this.handleSlotReady),googletag.pubads().addEventListener("gameManualInterstitialSlotClosed",this.handleSlotClosed),this.keyValue&&(Object.keys(this.keyValue).forEach(a=>{var s;(s=this.gamingInterstitialSlot)==null||s.setTargeting(a,this.keyValue[a])}),Object.keys(this.keyValue).includes("project")||(o=this.gamingInterstitialSlot)==null||o.setTargeting("project",this.project)),googletag.display(this.gamingInterstitialSlot))}),vt(this,"destroy",function(o){var a,s;(!(arguments.length>1&&arguments[1]!==void 0)||arguments[1])&&((s=(a=i.adsContext)==null?void 0:a.onEnd)==null||s.call(a,o),o!=="ignored"&&(i.adsContext=null)),googletag.pubads().removeEventListener("gameManualInterstitialSlotReady",i.handleSlotReady),googletag.pubads().removeEventListener("gameManualInterstitialSlotClosed",i.handleSlotClosed),i.gamingInterstitialSlot&&(googletag.destroySlots([i.gamingInterstitialSlot]),i.gamingInterstitialSlot=null,i.readyEvent=null)}),vt(this,"reinit",function(o){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;i.destroy(o,a),i.init()}),vt(this,"handleSlotReady",o=>{this.gamingInterstitialSlot===o.slot&&(this.readyEvent=o)}),vt(this,"handleSlotClosed",o=>{var a,s;this.adsContext&&this.gamingInterstitialSlot===o.slot&&((s=(a=this.adsContext).afterAd)==null||s.call(a),this.withCommand(()=>{this.reinit("viewed")}))}),vt(this,"requestAds",o=>{this.withCommand(()=>{var a,s,c;if(this.adsContext){this.destroy("ignored");return}if(this.gamingInterstitialSlot||this.init(),this.adsContext=o,!this.gamingInterstitialSlot){this.reinit("notReady");return}this.readyEvent?((a=o.beforeAd)==null||a.call(o),this.readyEvent.makeGameManualInterstitialVisible()):((c=(s=this.adsContext).onEnd)==null||c.call(s,"frequencyCapped"),this.adsContext=null,this.isRetrying||(this.isRetrying=!0,window.setTimeout(()=>{this.readyEvent||this.withCommand(()=>{this.reinit("frequencyCapped",!1)}),this.isRetrying=!1},31e3)))})}),NP(),this.adUnit=t,this.project=r,this.keyValue=n,this.withCommand(()=>{this.init()})}};Vm=class{constructor(t,r){Gn(this,"name","GOOGLE_GPT"),Gn(this,"context",void 0),Gn(this,"contextInfo",void 0),Gn(this,"initParams",void 0),Gn(this,"rewardAdManager",void 0),Gn(this,"interstitialManager",void 0),Gn(this,"insertScript",()=>{let n="jolibox-google-gpt",i=document.getElementById(n);i||(i=window.document.createElement("script"),i.id=n,i.async=!0,i.src="https://securepubads.g.doubleclick.net/tag/js/gpt.js",i.crossOrigin="anonymous",document.head.appendChild(i))}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.initParams=r,this.insertScript()}init(){return g(this,null,function*(){let t=this.contextInfo.testAdsMode?"/22639388115/rewarded_web_example":this.initParams.rewardedSlot,r=this.contextInfo.testAdsMode?"/6355419/Travel/Europe/France/Paris":this.initParams.interstitialSlot,n=`minigame-${this.contextInfo.runtimeType==="APP"?"app":"h5"}`;t&&(this.rewardAdManager=new DP(t,n,this.initParams.keyValue)),r&&(this.interstitialManager=new Hm(r,n,this.initParams.keyValue))})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:a})}});break}default:{if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}this.interstitialManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,onEnd:a=>{var s;(s=t.adBreakDone)==null||s.call(t,{breakName:t.name,breakType:t.type,breakFormat:"interstitial",breakStatus:a})}});break}}}};$m=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GAME";Im(this,"context",void 0),Im(this,"placement","GAME"),Im(this,"contextInfo",void 0),this.context=t,this.placement=r,this.contextInfo=this.context.getContextInfo()}getLocation(){let t=new URLSearchParams(window.location.search),r={};return t.forEach((n,i)=>{r[i]=n}),{name:this.placement==="GAME"?"GamePage":"DramaPage",params:r}}getDevice(){var t,r,n,i;return{platform:(t=this.contextInfo.platform)!=null?t:aP.WebSDK,os:this.contextInfo.osType+"_"+this.contextInfo.runtimeType,appVersion:"1.0.0",appId:(r=this.contextInfo.hostAppId)!=null?r:"1",model:(n=this.contextInfo.deviceModel)!=null?n:"UnknownModel",brand:(i=this.contextInfo.deviceBrand)!=null?i:"UnknownBrand",uuid:this.contextInfo.deviceId,jsSdkVersion:"1.0.0",extra:{}}}serialize(t,r){var n;let i={protocolVersion:"1.0.0",events:[{name:t,type:iP.System,location:this.getLocation(),target:null,extra:r,timestamp:Date.now(),userId:(n=this.contextInfo.userId)!=null?n:null}],device:this.getDevice(),project:oP.WebSDK};return zV(i)}};Ia=class{constructor(t){dt(this,"context",void 0),dt(this,"adsTrackSerializer",void 0),dt(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo(),this.adsTrackSerializer=new $m(this.context)}getRequestContextData(t){var r,n;this.contextInfo=this.context.getContextInfo();let{width:i,height:o}=this.context.getWindowInfo();return{report:JSON.stringify(this.adsTrackSerializer.serialize(t,{sessionId:this.contextInfo.sessionId,objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId,testAdsMode:this.contextInfo.testAdsMode})),osType:this.contextInfo.osType,runtimeType:this.contextInfo.runtimeType,sessionId:this.contextInfo.sessionId,deviceId:this.contextInfo.deviceId,adId:this.contextInfo.adId,deviceModel:(r=this.contextInfo.deviceModel)!=null?r:"UnknownModel",deviceBrand:(n=this.contextInfo.deviceBrand)!=null?n:"UnknownBrand",dimension:{width:i,height:o}}}getRequestBizParams(){return{objectType:this.contextInfo.objectType,objectId:this.contextInfo.objectId}}},Nl=class{constructor(t,r){var n=this;dt(this,"context",void 0),dt(this,"contextInfo",void 0),dt(this,"requestContext",void 0),dt(this,"pendingAFGAdsInfo",{REWARD:Promise.resolve(null),INTERSTITIAL:Promise.resolve(null)}),dt(this,"pendingAFVAdsInfo",Promise.resolve(null)),dt(this,"doFetchAdsInfo",i=>g(this,null,function*(){let o=i==="afv"?"AdsAFVSDKRequest":"AdsAFGSDKAdBreak",a=[];switch(i){case"afv":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}case"reward":{a=["REWARD_INTERSTITIAL","REWARD","NATIVE"];break}default:{a=["INTERSTITIAL"];break}}let s=i==="afv"?void 0:"cached",{data:c,code:l}=yield this.context.httpClient.post("/api/ads/info",{data:{contextData:this.requestContext.getRequestContextData(o),bizParams:this.requestContext.getRequestBizParams(),adsTypes:a,testAdsMode:this.contextInfo.testAdsMode,name:s}});return l==="SUCCESS"||l==="BYPASS_ADS"?{code:l,data:c}:null})),dt(this,"cacheRewardInfo",()=>{this.pendingAFGAdsInfo.REWARD=this.doFetchAdsInfo("reward").catch(()=>null)}),dt(this,"cacheInterstitialInfo",i=>{this.pendingAFGAdsInfo.INTERSTITIAL=this.doFetchAdsInfo(i).catch(()=>null)}),dt(this,"cacheAFVInfo",()=>{this.pendingAFVAdsInfo=this.doFetchAdsInfo("afv").catch(()=>null)}),dt(this,"cacheNextAFGAdsInfo",i=>g(this,null,function*(){i==="reward"?this.cacheRewardInfo():this.cacheInterstitialInfo(i)})),dt(this,"getAFGAdsInfo",i=>g(this,null,function*(){let o=yield i==="reward"?this.pendingAFGAdsInfo.REWARD:this.pendingAFGAdsInfo.INTERSTITIAL;return this.cacheNextAFGAdsInfo(i),o})),dt(this,"getAFVAdsInfo",function(){return g(this,arguments,function*(){if(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0]){let i=yield n.pendingAFVAdsInfo;return n.cacheAFVInfo(),i}else return n.cacheAFVInfo(),yield n.pendingAFVAdsInfo})}),this.context=t,this.contextInfo=this.context.getContextInfo(),this.requestContext=new Ia(t),r!=null&&r.reward&&this.cacheRewardInfo(),r!=null&&r.interstitial&&this.cacheInterstitialInfo("start"),r!=null&&r.afv&&this.cacheAFVInfo()}};Y9=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(e)try{e(...r)}catch(i){console.error("[JoliboxSDK] Callback error:",i)}},Dl=class{constructor(t){this.context=t,W9(this,"canIUseHelper",void 0),this.context=t;let{canIUseNative:r}=ja(()=>this.context.getContextInfo().deviceInfo.nativeSDKVersionCode||1e6,()=>this.context.getContextInfo().deviceInfo.platform||"h5");this.canIUseHelper=r}loadAdsAsync(t){return g(this,null,function*(){try{let{errNo:r,errMsg:n}=yield L("loadAdsAsync",{params:{providers:t.providers}});return r!==0||n.length>0?{code:"FAILURE",message:n||"Failed to load ads"}:{code:"SUCCESS",message:"Ads loaded successfully"}}catch(r){return{code:"FAILURE",message:`Failed to load ads: ${r instanceof Error?r.message:String(r)}`}}})}canIUse(){return xl()&&this.canIUseHelper("loadAdsAsync")&&this.canIUseHelper("showAdAsync")}showAdAsync(t){return g(this,null,function*(){try{let r=yield L("showAdAsync",{params:{providers:t.providers}});if(r.errNo!==0)return{code:"FAILURE",message:r.errMsg||"Failed to show ad"};let n=r.data.UUID;if(t.callbacks){let i=t.timeout!==void 0?t.timeout:-1,o=null,a=()=>{lg("onAdsStateChange",s),o&&(clearTimeout(o),o=null)},s=c=>{var l;if(c.UUID!==n)return;let d=(l=t.callbacks)==null?void 0:l[c.event];d&&Y9(d,c.data),["onAdClosed","onAdError","onAdDismissed"].includes(c.event)&&a()};we("onAdsStateChange",s),i>0&&(o=setTimeout(()=>{a(),console.warn(`[JoliboxSDK] Event listener for ad ${n} auto-cleaned after ${i}ms timeout`)},i))}return{code:"SUCCESS",message:"Ad shown successfully"}}catch(r){return{code:"FAILURE",message:`Failed to show ad: ${r instanceof Error?r.message:String(r)}`}}})}isAdsReadySync(t){try{let{errNo:r,data:n}=L("isAdsReadySync",{params:{providers:t.providers}});return r!==0||!n?(console.warn("[Jolibox SDK]isAdsReadySync returned an error or no data"),!1):!0}catch(r){return console.warn("[Jolibox SDK]isAdsReadySync invocation failed:",r),!1}}};Wm=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){qr(this,"providers",void 0),qr(this,"helper",void 0),qr(this,"adsContext",null),qr(this,"_isAdsReady",!1),qr(this,"init",()=>g(this,null,function*(){this.helper.canIUse()?(yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1:this._isAdsReady=!1})),qr(this,"destroy",n=>{var i,o;this._isAdsReady=!1,(o=(i=this.adsContext)==null?void 0:i.adBreakDone)==null||o.call(i,n),n!=="ignored"&&(this.adsContext=null)}),qr(this,"reinit",n=>g(this,null,function*(){this.destroy(n),yield this.init()})),qr(this,"requestAds",(n,i)=>g(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=n,i&&i.length>0&&(this.providers=i);try{this.isAdsReady?this.showAd():yield this.reinit("frequencyCapped")}catch(o){this.destroy("notReady")}})),qr(this,"showAd",()=>{if(!this.adsContext){this.destroy("error");return}let n=!1,i=!1;this.adsContext.beforeReward(()=>g(this,null,function*(){var o,a;(a=(o=this.adsContext)==null?void 0:o.beforeAd)==null||a.call(o);let s=l=>{var d,u,p;i||(i=!0,l==="dismissed"&&((d=this.adsContext)==null||d.adDismissed()),(p=(u=this.adsContext)==null?void 0:u.afterAd)==null||p.call(u),this.reinit(l))},c={onAdShow:()=>{},onAdError:()=>{s("error")},onAdRewarded:()=>{var l;n=!0,(l=this.adsContext)==null||l.adViewed()},onAdDismissed:()=>{s(n?"viewed":"dismissed")},onAdClosed:()=>{s(n?"viewed":"dismissed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:c})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")}))}),this.providers=r,this.helper=new Dl(t),this.init()}};zm=class{get isAdsReady(){return this._isAdsReady}constructor(t,r){var n=this;Ur(this,"providers",void 0),Ur(this,"helper",void 0),Ur(this,"adsContext",null),Ur(this,"_isAdsReady",!1),Ur(this,"init",()=>g(this,null,function*(){this.helper.canIUse()&&((yield this.helper.loadAdsAsync({providers:this.providers})).code==="SUCCESS"?this._isAdsReady=!0:this._isAdsReady=!1)})),Ur(this,"destroy",function(i){var o,a;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n._isAdsReady=!1,s&&((a=(o=n.adsContext)==null?void 0:o.onEnd)==null||a.call(o,i),i!=="ignored"&&(n.adsContext=null))}),Ur(this,"reinit",function(o){return g(this,arguments,function*(i){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;n.destroy(i,a),yield n.init()})}),Ur(this,"requestAds",(i,o)=>g(this,null,function*(){if(this.adsContext){this.destroy("ignored");return}this.adsContext=i,o&&o.length>0&&(this.providers=o);try{this.isAdsReady?yield this.showAd():yield this.reinit("frequencyCapped")}catch(a){this.destroy("notReady")}})),Ur(this,"showAd",()=>g(this,null,function*(){var i,o;if(!this.adsContext){this.destroy("error");return}let a=!1;(o=(i=this.adsContext).beforeAd)==null||o.call(i);let s=l=>{var d,u;a||(a=!0,(u=(d=this.adsContext)==null?void 0:d.afterAd)==null||u.call(d),this.reinit(l))},c={onAdShow:()=>{},onAdError:()=>{s("error")},onAdDismissed:()=>{s("dismissed")},onAdClosed:()=>{s("viewed")}};(yield this.helper.showAdAsync({providers:this.providers,callbacks:c})).code!=="SUCCESS"&&this.reinit("noAdPreloaded")})),this.providers=r,this.helper=new Dl(t),this.init()}};Km=class{constructor(t,r){va(this,"name","INTERNAL_NATIVE"),va(this,"context",void 0),va(this,"rewardAdManager",void 0),va(this,"interstitialManager",void 0),va(this,"initProviders",void 0),this.context=t,this.initProviders=r.providers;let n=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],r.providers),i=this.getConfigsByTypes(["INTERSTITIAL"],r.providers);n.length>0&&(this.rewardAdManager=new Wm(this.context,n)),i.length>0&&(this.interstitialManager=new zm(this.context,i))}getConfigsByTypes(t,r,n){let i=[];return(n?n.map(o=>r.find(a=>a.provider===o.provider)).filter(o=>!!o):r).forEach(o=>{t.forEach(a=>{let s="";a==="REWARD"&&(s=o.params.adUnitId.reward),a==="REWARD_INTERSTITIAL"&&(s=o.params.adUnitId.rewardInterstitial),a==="INTERSTITIAL"&&(s=o.params.adUnitId.interstitial),a==="NATIVE"&&(s=o.params.adUnitId.nativeAds),s&&i.push({provider:o.provider,params:{placementId:s,adsType:a,extra:o.params.extra}})})}),i}init(){return g(this,null,function*(){})}adConfig(t,r){}adBreak(t,r){var n,i,o;switch(t.type){case"preroll":{(n=t.adBreakDone)==null||n.call(t,{breakType:"preroll",breakFormat:"interstitial",breakStatus:"noAdPreloaded"});break}case"reward":{if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}let a=this.getConfigsByTypes(["REWARD","REWARD_INTERSTITIAL","NATIVE"],this.initProviders,r.params);this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:s=>{var c;(c=t.adBreakDone)==null||c.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:s})}},a);break}default:{let a=t;if(!this.interstitialManager){(o=t.adBreakDone)==null||o.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:"noAdPreloaded"});return}let s=this.getConfigsByTypes(["INTERSTITIAL"],this.initProviders,r.params);this.interstitialManager.requestAds({beforeAd:a.beforeAd,afterAd:a.afterAd,onEnd:c=>{var l;(l=t.adBreakDone)==null||l.call(t,{breakName:a.name,breakType:t.type,breakFormat:"interstitial",breakStatus:c})}},s);break}}}},Em="jolibox-nb-proxy",nW=0;Al=()=>{try{if(window.parent&&window.parent!==window)return oW("GameSDK")}catch(e){}};Ym=class{constructor(){Mi(this,"adsContext",null),Mi(this,"init",()=>g(this,null,function*(){console.log("[JoliboxSDK] NewsBreak init");let t=Al();if(t)try{let r=yield t.createRewardAd({platform:"jolibox"});console.log("[JoliboxSDK] NewsBreak init createRewardAd result:",r)}catch(r){console.log("[JoliboxSDK] NewsBreak init createRewardAd error:",r)}})),Mi(this,"destroy",t=>{var r,n;(n=(r=this.adsContext)==null?void 0:r.adBreakDone)==null||n.call(r,t),t!=="ignored"&&(this.adsContext=null)}),Mi(this,"reinit",t=>g(this,null,function*(){console.log("[JoliboxSDK] NewsBreak reinit breakStatus:",t),this.destroy(t),yield this.init()})),Mi(this,"requestAds",t=>g(this,null,function*(){if(console.log("[JoliboxSDK] NewsBreak newsbreak this.adsContext",this.adsContext),this.adsContext){this.destroy("ignored");return}this.adsContext=t;let r=Al();if(console.log("[JoliboxSDK] NewsBreak newsbreak sdk",r),!r){this.destroy("notReady");return}this.showAd()})),Mi(this,"showAd",()=>{if(console.log("[JoliboxSDK] NewsBreak showAd"),!this.adsContext){this.destroy("error");return}this.adsContext.beforeReward(()=>g(this,null,function*(){var t,r,n,i,o,a,s,c,l,d,u,p,f,m;(r=(t=this.adsContext)==null?void 0:t.beforeAd)==null||r.call(t);let v=Al();if(!v){(i=(n=this.adsContext)==null?void 0:n.afterAd)==null||i.call(n),this.reinit("error");return}try{let b=yield v.showRewardAd();if(console.log("[JoliboxSDK] NewsBreak showRewardAd result:",b),!b.success){(a=(o=this.adsContext)==null?void 0:o.afterAd)==null||a.call(o),this.reinit("error");return}b.rewardGranted?((s=this.adsContext)==null||s.adViewed(),(l=(c=this.adsContext)==null?void 0:c.afterAd)==null||l.call(c),this.reinit("viewed")):((d=this.adsContext)==null||d.adDismissed(),(p=(u=this.adsContext)==null?void 0:u.afterAd)==null||p.call(u),this.reinit("dismissed"))}catch(b){console.error("[JoliboxSDK] NewsBreak showRewardAd failed:",b),(m=(f=this.adsContext)==null?void 0:f.afterAd)==null||m.call(f),this.reinit("error")}}))}),this.init()}};Xm=class{constructor(){XT(this,"name","NEWSBREAK"),XT(this,"rewardAdManager",void 0)}init(){return g(this,null,function*(){let t=Al();if(!t){console.warn("[JoliboxSDK] NewsBreak GameSDK is not available on window");return}t.onEnter(),this.rewardAdManager=new Ym})}adConfig(t,r){}adBreak(t,r){var n,i;if(t.type!=="reward"){(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}if(!this.rewardAdManager){(i=t.adBreakDone)==null||i.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:"noAdPreloaded"});return}this.rewardAdManager.requestAds({beforeAd:t.beforeAd,afterAd:t.afterAd,adDismissed:t.adDismissed,adViewed:t.adViewed,beforeReward:t.beforeReward,adBreakDone:o=>{var a;(a=t.adBreakDone)==null||a.call(t,{breakName:t.name,breakType:t.type,breakFormat:"reward",breakStatus:o})}})}};Ji=class{constructor(t){if($t(this,"context",void 0),$t(this,"contextInfo",void 0),$t(this,"providers",{}),$t(this,"channelPolicy",void 0),$t(this,"adsActionDetection",void 0),$t(this,"requestContext",void 0),$t(this,"adsRequest",void 0),$t(this,"initialized",!1),$t(this,"adsIsShowing",!1),$t(this,"lastAdBreak",void 0),$t(this,"initializedTimeStamp",Date.now()),t)this.context=t,this.channelPolicy=new Rm(this.context),this.adsActionDetection=new Om(this.context),this.contextInfo=this.context.getContextInfo(),this.adsRequest=new Nl(t),this.requestContext=new Ia(t);else throw new Error("JoliboxAdsForGame requires a configuration object")}init(t){return g(this,null,function*(){window.adsbygoogle=window.adsbygoogle||[];let{data:r}=yield this.context.httpClient.post("/api/ads/init",{data:{contextData:this.requestContext.getRequestContextData("AdsAFGSDKInit"),bizParams:this.requestContext.getRequestBizParams(),testAdsMode:this.contextInfo.testAdsMode}});if((r==null?void 0:r.length)>0){let n=r.filter(s=>s.isNative),i=r.filter(s=>!s.isNative),o={provider:"INTERNAL_NATIVE",params:{providers:n}},a=i.concat([o]);for(let s of a)switch(s.provider){case"GOOGLE_GPT":{let c=new Vm(this.context,s.params);yield c.init(),this.providers[s.provider]=c;break}case"ADSENSE":case"ADSENSE_ADMOB":{let c=new Nm(this.context,s.params);yield c.init(),this.providers[s.provider]=c;break}case"OKSPIN":{let c=new Bm(this.context,s.params);yield c.init(),this.providers.OKSPIN=c;break}case"APPSROCKETS":{let c=new Jm(this.context,s.params);yield c.init(),this.providers.APPSROCKETS=c;break}case"ADSENSE_BANNER_AS_AFG":{let c=new Gm(this.context,s.params);yield c.init(),this.providers.ADSENSE_BANNER_AS_AFG=c;break}case"INTERNAL_NATIVE":{let c=new Km(this.context,s.params);yield c.init(),this.providers.INTERNAL_NATIVE=c;break}case"NEWSBREAK":{console.log("[JoliboxSDK] NewsBreak Provider",s);let c=new Xm;yield c.init(),this.providers.NEWSBREAK=c;break}}}this.adsRequest.cacheInterstitialInfo("start"),this.adsRequest.cacheRewardInfo(),this.initialized=!0})}adConfig(t){this.providers.ADSENSE?this.providers.ADSENSE.adConfig(t):window.adsbygoogle.push(t)}adBreak(t){return g(this,null,function*(){var r,n,i,o,a,s,c,l,d,u,p,f,m,v,b,y;let _=Date.now();if(_-this.initializedTimeStamp<3e3){console.log("[Jolibox SDK Ads] too soon"),(r=t.adBreakDone)==null||r.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}if(this.lastAdBreak&&_-this.lastAdBreak<500){console.warn("[Jolibox SDK Ads] You can't call adBreak too frequently"),(n=t.adBreakDone)==null||n.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.lastAdBreak=_,this.adsIsShowing){console.warn("[Jolibox SDK Ads] You can't call adBreak while ad is showing"),(i=t.adBreakDone)==null||i.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"frequencyCapped"});return}if(this.initialized||(yield this.init()),t.type!=="reward"&&!this.channelPolicy.shouldBypassCallingInterstitial()){(o=t.adBreakDone)==null||o.call(t,{breakType:t.type,breakName:"skipInterstitials",breakFormat:"interstitial",breakStatus:"viewed"});return}if(!this.context.checkNetwork()&&!this.providers.NEWSBREAK){console.log("[Jolibox SDK Ads] net not ready"),(a=t.adBreakDone)==null||a.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}try{let E=yield this.adsRequest.getAFGAdsInfo(t.type),C=E==null?void 0:E.data,x=E==null?void 0:E.code;if(x==="BYPASS_ADS"){switch(t.type){case"preroll":{(s=t.adBreakDone)==null||s.call(t,{breakType:t.type,breakFormat:"interstitial",breakStatus:"viewed"});break}case"reward":{t.beforeReward(()=>{var k,A,H,ue;(k=t.beforeAd)==null||k.call(t),(A=t.adViewed)==null||A.call(t),(H=t.afterAd)==null||H.call(t),(ue=t.adBreakDone)==null||ue.call(t,{breakType:t.type,breakName:t.name,breakFormat:"reward",breakStatus:"viewed"})});break}default:{(c=t.beforeAd)==null||c.call(t),(l=t.afterAd)==null||l.call(t),(d=t.adBreakDone)==null||d.call(t,{breakType:t.type,breakName:t.name,breakFormat:"interstitial",breakStatus:"viewed"});break}}return}if(!C||x!=="SUCCESS"){console.log("[Jolibox SDK Ads] not SUCCESS"),(u=t.adBreakDone)==null||u.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}else{if(C.length===0){console.log("[Jolibox SDK Ads] ads info empty"),(p=t.adBreakDone)==null||p.call(t,{breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"});return}let k=!0,A=null,H=new Pm(this.context);this.adsActionDetection.adBreakIsShowing=!0;let ue=C.filter(J=>J.isNative).sort((J,V)=>J.seq-V.seq),N=C.filter(J=>!J.isNative).sort((J,V)=>J.seq-V.seq),O={seq:(m=(f=ue[0])==null?void 0:f.seq)!=null?m:0,provider:"INTERNAL_NATIVE",params:ue},F;for(ue.length>0?F=[O].concat(N):F=N,F=F.sort((J,V)=>J.seq-V.seq).map((J,V)=>CV(eP({},J),{seq:V}));F.length>0;){let J=F.shift(),V=this.providers[J.provider];if(V){let[Mt,Mh]=yield H.callAdBreakAndContinue(V,t,J,Wl=>{var Oa;this.adsIsShowing=Wl,(Oa=this.context.eventEmitter)==null||Oa.emit("isAdShowing",Wl)});k=Mt,A=Mh}else k=!0,A={breakType:t.type,breakName:t.type==="preroll"?void 0:t.name,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"notReady"};if(!k)break}k&&A&&((v=t.adBreakDone)==null||v.call(t,A))}}catch(E){console.log("[Jolibox SDK Ads] error:",E),(b=t.adBreakDone)==null||b.call(t,{breakType:t.type,breakFormat:t.type==="reward"?"reward":"interstitial",breakStatus:"noAdPreloaded"})}finally{this.adsIsShowing=!1,(y=this.context.eventEmitter)==null||y.emit("isAdShowing",!1),this.adsActionDetection.adBreakIsShowing=!1}})}adUnit(t){console.warn("This method has been deprecated. We will not support AdSense AdUnit in the future.")}};Qm=class{constructor(t){yl(this,"context",void 0),yl(this,"currentProvider",void 0),yl(this,"continueCallback",void 0),yl(this,"contextInfo",void 0),this.context=t,this.contextInfo=t.getContextInfo()}get paramsToTrack(){var t,r;return{provider:(r=(t=this.currentProvider)==null?void 0:t.name)!=null?r:null}}wrapAdRequested(t){return()=>{this.context.track("CallAFVRequest",this.paramsToTrack),t==null||t()}}wrapAdLoaded(t){return r=>{this.context.track("CallAFVLoad",this.paramsToTrack),t==null||t(r)}}wrapAdPlaying(t){return r=>{var n,i;this.context.track("CallAFVPlaying",this.paramsToTrack),xl()&&this.context.track("mmp_ad_impression",{ad_network:(i=(n=this.currentProvider)==null?void 0:n.name)!=null?i:"",ad_format:"AFV",module:"drama",game_id:this.contextInfo.objectId}),t==null||t(r)}}wrapAdCompleted(t){return r=>{var n;this.context.track("CallAFVCompleted",this.paramsToTrack),t==null||t(r),(n=this.continueCallback)==null||n.call(this,[!1,null])}}wrapAdError(t){return r=>{var n;this.context.track("CallAFVError",this.paramsToTrack),(n=this.continueCallback)==null||n.call(this,[!0,r])}}callAdRequestAndContinue(t,r,n){return g(this,null,function*(){return this.currentProvider=t,new Promise(i=>{this.continueCallback=i;let o=Object.assign({},r);o.onAdRequested=this.wrapAdRequested(r.onAdRequested),o.onAdLoaded=this.wrapAdLoaded(r.onAdLoaded),o.onAdPlaying=this.wrapAdPlaying(r.onAdPlaying),o.onAdCompleted=this.wrapAdCompleted(r.onAdCompleted),o.onAdError=this.wrapAdError(r.onAdError),t.requestAd(o,n)})})}};at=class e extends Error{constructor(t,r){super(t.message),Am(this,"name",void 0),Am(this,"type",void 0),Am(this,"raw",void 0),this.name="AFVRequestError",this.type=r,this.raw=t,this.stack=t.stack,this.message=t.message}static from(t,r){switch(r){case"GOOGLE_IMA_ERROR":return new e(t,r);case"JOLIBOX_IMA_ERROR":return new e(t,r)}}};Zm=class{constructor(t,r,n){me(this,"adsLoader",void 0),me(this,"adDisplayContainer",void 0),me(this,"isAdPlaying",!1),me(this,"isContentFinished",!1),me(this,"videoContent",void 0),me(this,"adContainer",void 0),me(this,"adsManager",void 0),me(this,"intervalTimer",void 0),me(this,"completed",!1),me(this,"adTagUrl",void 0),me(this,"notifyRequestAd",void 0),me(this,"notifyLoaded",void 0),me(this,"notifyPlayingAd",void 0),me(this,"notifyCompleted",void 0),me(this,"notifyError",void 0),me(this,"destroy",()=>{var i,o,a,s,c,l,d,u,p,f,m;this.intervalTimer&&clearInterval(this.intervalTimer),(i=this.adsManager)==null||i.stop(),(o=this.adDisplayContainer)==null||o.destroy(),(a=this.adsLoader)==null||a.removeEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded),(s=this.adsLoader)==null||s.removeEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),(c=this.adsManager)==null||c.removeEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),(l=this.adsManager)==null||l.removeEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested),(d=this.adsManager)==null||d.removeEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested),(u=this.adsManager)==null||u.removeEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAdEvent),(p=this.adsManager)==null||p.removeEventListener(window.google.ima.AdEvent.Type.LOADED,this.onAdEvent),(f=this.adsManager)==null||f.removeEventListener(window.google.ima.AdEvent.Type.STARTED,this.onAdEvent),(m=this.adsManager)==null||m.removeEventListener(window.google.ima.AdEvent.Type.COMPLETE,this.onAdEvent)}),me(this,"requestAds",(i,o)=>g(this,null,function*(){var a;this.createAdDisplayContainer(),this.notifyRequestAd=i.onAdRequested,this.notifyLoaded=i.onAdLoaded,this.notifyPlayingAd=i.onAdPlaying,this.notifyCompleted=i.onAdCompleted,this.notifyError=u=>{var p;return(p=i.onAdError)==null?void 0:p.call(i,at.from(u,"GOOGLE_IMA_ERROR"))},this.adsLoader=new window.google.ima.AdsLoader(this.adDisplayContainer),this.adsLoader.addEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded,!1),this.adsLoader.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1);let s=()=>{var u;this.isAdPlaying||(this.isContentFinished=!0,(u=this.adsLoader)==null||u.contentComplete())};this.videoContent.onended=s;let c=new window.google.ima.AdsRequest;c.vastLoadTimeout=1e4;let l="";Object.keys(o.params).forEach(u=>{let p=window.encodeURIComponent(o.params[u]);l+=`&${u}=${p}`});let d=`${this.adTagUrl}${l}`;c.adTagUrl=d,c.linearAdSlotWidth=640,c.linearAdSlotHeight=400,c.nonLinearAdSlotWidth=640,c.nonLinearAdSlotHeight=150,this.adsLoader.requestAds(c),(a=this.notifyRequestAd)==null||a.call(this)})),me(this,"createAdDisplayContainer",()=>{this.adDisplayContainer=new window.google.ima.AdDisplayContainer(this.adContainer,this.videoContent)}),me(this,"playAds",()=>{var i,o;this.videoContent.load(),this.adDisplayContainer.initialize(),this.completed=!1;try{(i=this.adsManager)==null||i.init(window.document.body.clientWidth,window.document.body.clientHeight,window.google.ima.ViewMode.NORMAL),(o=this.adsManager)==null||o.start()}catch(a){console.error("[JoliboxAFV] Google IMA Error: ",a),this.videoContent.play()}}),me(this,"onAdsManagerLoaded",i=>{let o=new window.google.ima.AdsRenderingSettings;o.restoreCustomPlaybackStateOnAdBreakComplete=!0,o.loadVideoTimeout=1e4,this.adsManager=i.getAdsManager(this.videoContent,o),this.adsManager.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.LOADED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.STARTED,this.onAdEvent),this.adsManager.addEventListener(window.google.ima.AdEvent.Type.COMPLETE,this.onAdEvent),i.type==="adsManagerLoaded"&&this.playAds()}),me(this,"onAdEvent",i=>{var o,a,s,c;let l=i.getAd();switch(i.type){case window.google.ima.AdEvent.Type.LOADED:l!=null&&l.isLinear()||this.videoContent.play(),(o=this.notifyLoaded)==null||o.call(this,i);break;case window.google.ima.AdEvent.Type.STARTED:l!=null&&l.isLinear()&&(this.intervalTimer=window.setInterval(function(){},300)),(a=this.notifyPlayingAd)==null||a.call(this,i);break;case window.google.ima.AdEvent.Type.COMPLETE:l!=null&&l.isLinear()&&clearInterval(this.intervalTimer),this.completed||(this.completed=!0,(s=this.notifyCompleted)==null||s.call(this,i));break;case window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED:l!=null&&l.isLinear()&&clearInterval(this.intervalTimer),this.completed||(this.completed=!0,(c=this.notifyCompleted)==null||c.call(this,i));break}}),me(this,"onAdError",i=>{var o,a;(o=this.notifyError)==null||o.call(this,i.getError()),(a=this.adsManager)==null||a.destroy()}),me(this,"onContentPauseRequested",()=>{this.isAdPlaying=!0,this.videoContent.pause()}),me(this,"onContentResumeRequested",()=>{this.isAdPlaying=!1}),this.adTagUrl=t,this.videoContent=r,this.adContainer=n}},Cl=(e=>(e[e.ADS_REQUEST_NETWORK_ERROR=1012]="ADS_REQUEST_NETWORK_ERROR",e[e.ASSET_FALLBACK_FAILED=1021]="ASSET_FALLBACK_FAILED",e[e.AUTOPLAY_DISALLOWED=1205]="AUTOPLAY_DISALLOWED",e[e.COMPANION_AD_LOADING_FAILED=603]="COMPANION_AD_LOADING_FAILED",e[e.COMPANION_REQUIRED_ERROR=602]="COMPANION_REQUIRED_ERROR",e[e.FAILED_TO_REQUEST_ADS=1005]="FAILED_TO_REQUEST_ADS",e[e.INVALID_AD_TAG=1013]="INVALID_AD_TAG",e[e.INVALID_ADX_EXTENSION=1105]="INVALID_ADX_EXTENSION",e[e.INVALID_ARGUMENTS=1101]="INVALID_ARGUMENTS",e[e.NONLINEAR_DIMENSIONS_ERROR=501]="NONLINEAR_DIMENSIONS_ERROR",e[e.OVERLAY_AD_LOADING_FAILED=502]="OVERLAY_AD_LOADING_FAILED",e[e.OVERLAY_AD_PLAYING_FAILED=500]="OVERLAY_AD_PLAYING_FAILED",e[e.STREAM_INITIALIZATION_FAILED=1020]="STREAM_INITIALIZATION_FAILED",e[e.UNKNOWN_AD_RESPONSE=1010]="UNKNOWN_AD_RESPONSE",e[e.UNKNOWN_ERROR=900]="UNKNOWN_ERROR",e[e.UNSUPPORTED_LOCALE=1011]="UNSUPPORTED_LOCALE",e[e.VAST_ASSET_NOT_FOUND=1007]="VAST_ASSET_NOT_FOUND",e[e.VAST_EMPTY_RESPONSE=1009]="VAST_EMPTY_RESPONSE",e[e.VAST_LINEAR_ASSET_MISMATCH=403]="VAST_LINEAR_ASSET_MISMATCH",e[e.VAST_LOAD_TIMEOUT=301]="VAST_LOAD_TIMEOUT",e[e.VAST_MALFORMED_RESPONSE=100]="VAST_MALFORMED_RESPONSE",e[e.VAST_MEDIA_LOAD_TIMEOUT=402]="VAST_MEDIA_LOAD_TIMEOUT",e[e.VAST_NO_ADS_AFTER_WRAPPER=303]="VAST_NO_ADS_AFTER_WRAPPER",e[e.VAST_NONLINEAR_ASSET_MISMATCH=503]="VAST_NONLINEAR_ASSET_MISMATCH",e[e.VAST_PROBLEM_DISPLAYING_MEDIA_FILE=405]="VAST_PROBLEM_DISPLAYING_MEDIA_FILE",e[e.VAST_SCHEMA_VALIDATION_ERROR=101]="VAST_SCHEMA_VALIDATION_ERROR",e[e.VAST_TOO_MANY_REDIRECTS=302]="VAST_TOO_MANY_REDIRECTS",e[e.VAST_TRAFFICKING_ERROR=200]="VAST_TRAFFICKING_ERROR",e[e.VAST_UNEXPECTED_DURATION_ERROR=202]="VAST_UNEXPECTED_DURATION_ERROR",e[e.VAST_UNEXPECTED_LINEARITY=201]="VAST_UNEXPECTED_LINEARITY",e[e.VAST_UNSUPPORTED_VERSION=102]="VAST_UNSUPPORTED_VERSION",e[e.VAST_WRAPPER_ERROR=300]="VAST_WRAPPER_ERROR",e[e.VIDEO_PLAY_ERROR=400]="VIDEO_PLAY_ERROR",e[e.VPAID_ERROR=901]="VPAID_ERROR",e))(Cl||{}),yW=()=>{let e=W(!1),t=W(!1),r=W(null),n=ho(),i=ho();return{visible:e,canRetry:t,retry:r,videoRef:n,adContainerRef:i}},bW=st`
870
870
  ${Ge}
871
871
  position: fixed;
872
872
  left: 0;
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.4.13 clean
3
+ > @jolibox/implement@1.4.14 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.4.13 build:esm
7
+ > @jolibox/implement@1.4.14 build:esm
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
9
9
 
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.4.13",
4
+ "version": "1.4.14",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.4.13",
10
- "@jolibox/types": "1.4.13",
11
- "@jolibox/native-bridge": "1.4.13",
12
- "@jolibox/ads": "1.4.13",
9
+ "@jolibox/common": "1.4.14",
10
+ "@jolibox/types": "1.4.14",
11
+ "@jolibox/native-bridge": "1.4.14",
12
+ "@jolibox/ads": "1.4.14",
13
13
  "localforage": "1.10.0",
14
- "@jolibox/ui": "1.4.13",
14
+ "@jolibox/ui": "1.4.14",
15
15
  "web-vitals": "4.2.4"
16
16
  },
17
17
  "devDependencies": {