handler-playable-sdk 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-E26K3244.js → chunk-XGJ2QPBX.js} +32 -34
- package/dist/cli/brand-dna.mjs +1 -1
- package/dist/cli/canva-import.mjs +1 -1
- package/dist/cli/cleanup-assets.mjs +1 -1
- package/dist/cli/fix-scales.mjs +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/screen-helper.mjs +1 -1
- package/dist/cli/setup-library.mjs +1 -1
- package/dist/cli/student-helper.mjs +1 -1
- package/dist/cli/sync-screens.mjs +1 -1
- package/dist/cli/validate-assets.mjs +1 -1
- package/dist/cli/validate.mjs +1 -1
- package/dist/index.cjs +61 -63
- package/dist/index.css +23 -3
- package/dist/index.js +1 -1
- package/dist/pixi/index.cjs +7 -7
- package/dist/pixi/index.css +23 -3
- package/dist/pixi/index.js +1 -1
- package/dist/three/index.cjs +1 -1
- package/dist/three/index.css +23 -3
- package/dist/three/index.js +1 -1
- package/package.json +1 -1
package/dist/pixi/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ba=Object.create;var ht=Object.defineProperty;var ya=Object.getOwnPropertyDescriptor;var va=Object.getOwnPropertyNames;var xa=Object.getPrototypeOf,wa=Object.prototype.hasOwnProperty;var ne=(i,e)=>()=>(i&&(e=i(i=0)),e);var Vi=(i,e)=>{for(var t in e)ht(i,t,{get:e[t],enumerable:!0})},Wi=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of va(e))!wa.call(i,a)&&a!==t&&ht(i,a,{get:()=>e[a],enumerable:!(n=ya(e,a))||n.enumerable});return i};var ft=(i,e,t)=>(t=i!=null?ba(xa(i)):{},Wi(e||!i||!i.__esModule?ht(t,"default",{value:i,enumerable:!0}):t,i)),Ea=i=>Wi(ht({},"__esModule",{value:!0}),i);var ka,ue=ne(()=>{"use strict";ka="handler_preview_override_mode";if(typeof window!="undefined"){let i=window.localStorage.getItem(ka);window.__enableConfigOverrides=i===null?!0:i==="true"}});var Tn,xe,Zr,Yt=ne(()=>{"use strict";ue();Tn=null,xe="dev";if(typeof window!="undefined"){let i=window.__BUILD_SETTINGS__;if(i!=null&&i.buildMode)Tn=i,xe=i.buildMode,console.log("[CONFIG] Loaded inline build settings:",i,"buildMode:",xe);else try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);Tn=t,xe=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",xe)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",xe)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",xe);Zr=xe==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var Kt=ne(()=>{"use strict"});var kn=ne(()=>{"use strict";Kt();Yt()});var Xt=ne(()=>{"use strict";Yt();Kt();kn()});var Q,Qt=ne(()=>{"use strict";Q=class{static get(e){var t;return(t=this.store.get(e))==null?void 0:t.data}static set(e,t){this.store.set(e,{data:t})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};Q.store=new Map});function Fa(){var i,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(i=document.querySelector("script"))==null?void 0:i.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),n=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!n)}catch{return!1}}async function Ua(){try{if(typeof window!="undefined"){let i=await fetch("./build-settings.json");if(i.ok){let e=await i.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Ga(){try{if(typeof window!="undefined"){let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}async function qa(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${_}`),Object.keys(ae).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(ae)),ae;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),ae={...window.INLINE_ASSETS},ae;if(!(_==="publish"&&ee!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),ae;if(!ei){let e=typeof window!="undefined"?new URL("inline-assets.js",window.location.href).href:"./inline-assets.js";console.log("[AssetLoader] Loading inline assets from:",e),ei=(async()=>{try{try{let r=await import(e+"?t="+Date.now());if(r.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(r.INLINE_ASSETS)),r.INLINE_ASSETS}catch(r){console.warn("[AssetLoader] ES module import failed, trying text parse:",r)}let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.text();console.log("[AssetLoader] Received JS code, length:",n.length);let a=n.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)try{let r=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let o=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(o)),o}catch(r){return console.warn("[AssetLoader] Failed to parse inline assets:",r),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",n.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return ae=await ei,console.log("[AssetLoader] Final inline assets cache:",Object.keys(ae)),ae}function ti(i){return i===null||typeof i!="object"||(Object.freeze(i),Object.values(i).forEach(e=>ti(e))),i}function Va(i=64,e=64,t=16711680){let n=document.createElement("canvas");n.width=i,n.height=e;let a=n.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,i,e),a.strokeStyle="#000",a.strokeRect(0,0,i,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",i/2,e/2),re.Texture.from(n)}function wt(i,e){Rn.set(i,e)}var re,In,jn,we,_,ee,ge,ae,ei,Rn,he,Et=ne(()=>{"use strict";re=require("pixi.js");Qt();In=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",jn=Fa(),we=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,_=jn?"publish":In,ee=we==null?void 0:we.assetsInlined;we!=null&&we.buildMode&&(_=we.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${_}`));ge=Ga();ge!=null&&ge.buildMode&&(_=ge.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${_}`));(ge==null?void 0:ge.assetsInlined)!==void 0&&(ee=ge.assetsInlined);Ua().then(i=>{i!=null&&i.buildMode&&i.buildMode!==_&&(_=i.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${_}`)),(i==null?void 0:i.assetsInlined)!==void 0&&(ee=i.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${In}, Runtime: ${jn?"publish":"dev"}, Effective: ${_}`);ae={},ei=null;Rn=new Map;he=class{static async load(e,t,n,a){let r=`${e}:${t.path}`,o=Q.get(r);if(o!==void 0)return o;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${_}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let s=await qa(),d=s[e];if(!d&&a&&(d=s[a],d&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${a}`)),!d&&t.path){let l=t.path.split("/");if(l.length>=2){let p=l[l.length-1].split(".")[0];s[p]&&(d=s[p],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${p}`))}}if(console.log("[AssetLoader] Inline data for",e,":",d?"FOUND":"NOT FOUND"),_==="publish"&&ee!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!d))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${t.path}`);let u=Rn.get(t.type);if(u)try{let l=await u(t.path,d,e,n);return Q.set(r,l),l}catch(l){return this.handleFailure(e,t.type,l)}try{let l;switch(t.type){case"image":l=await this.loadImage(t.path,d);break;case"json":l=await this.loadJSON(t.path,d),l=ti(l);break;default:throw new Error(`Unknown asset type: ${t.type}`)}return Q.set(r,l),l}catch(l){return this.handleFailure(e,t.type,l)}}static async loadImage(e,t){let n=_==="publish",a=n&&ee!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${_}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof t!="string"||!t.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof t}`);try{return await re.Assets.load(t)}catch(r){throw console.error("[AssetLoader] Failed to load texture from data URI:",r),r}}if(t&&typeof t=="string"&&t.startsWith("data:"))try{return await re.Assets.load(t)}catch(r){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",r),await re.Assets.load(e)}return await re.Assets.load(e)}static async loadJSON(e,t){let n=_==="publish",a=n&&ee!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${_}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let o=atob(t.split(",")[1]);return JSON.parse(o)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let o=atob(t.split(",")[1]);return JSON.parse(o)}return JSON.parse(t)}let r=await fetch(e);if(!r.ok)throw new Error(`JSON fetch failed: ${e}`);return r.json()}static handleFailure(e,t,n){if(_==="dev"){let r=t==="image"?Va():ti({__placeholder:!0,type:t});return Q.set(e+":"+((n==null?void 0:n.path)||"missing"),r),r}throw n}};wt("image",async(i,e)=>{let t=_==="publish",n=t&&ee!==!1,a=_==="brand",r=t&&ee===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${_}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${i}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return re.Assets.load(e)}let o=i;return(a||r)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(o=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${o}"`))),re.Assets.load(e||o)});wt("json",async(i,e)=>{let t=_==="publish",n=t&&ee!==!1,a=_==="brand",r=t&&ee===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${_}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${i}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let o=i;if((a||r)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(o=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${o}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let s=await fetch(o);if(!s.ok)throw new Error(`JSON fetch failed: ${i}`);return s.json()})});function At(i,e){Dn.init(i,e),typeof window!="undefined"&&(window.__AssetTextures=fe)}var ii,Dn,fe,Xe=ne(()=>{"use strict";Et();ii=class{constructor(){this.textures=new Map;this.readyPromise=null;this.priorityReadyPromise=null;this.priorityReadyResolve=null;this.config=null;this.app=null;this.attempted=new Set;this.waiters=new Set}init(e,t){if(this.config===e&&this.app===t&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.attempted.clear(),this.waiters.clear(),this.priorityReadyPromise=new Promise(n=>{this.priorityReadyResolve=n}),this.config=e,this.app=t,console.log("[AssetTextures] Initialized with config, cleared previous textures")}async ready(){if(this.readyPromise){await this.readyPromise;return}if(!this.config)throw new Error("[AssetTextures] Must call init() before ready() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before ready() - app is null");let e=this.config,t=this.app;return this.readyPromise=(async()=>{var o;console.log("[AssetTextures] Loading all assets...");let n=new Set(["background_loading_1"]),a=[],r=[];for(let[s,d]of e.objects.entries()){let c=(o=d.render)==null?void 0:o.asset;if(!c)continue;let u=async()=>{var l;try{let p=(l=d.identity)==null?void 0:l.id;console.log(`[AssetTextures] Loading ${c.type}: ${s} (${p})`);let g=await he.load(s,c,t,p);this.textures.set(s,g),console.log(`[AssetTextures] \u2713 Loaded: ${s}`)}catch(p){console.error(`[AssetTextures] \u2717 Failed to load: ${s}`,p)}finally{this.attempted.add(s);try{for(let p of Array.from(this.waiters))p()}catch{}}};n.has(s)?a.push(u()):r.push(u())}a.length>0&&(console.log("[AssetTextures] Phase 1: Loading priority assets (loading screen)..."),await Promise.all(a),console.log("[AssetTextures] Phase 1: Priority assets ready")),this.priorityReadyResolve&&this.priorityReadyResolve(),console.log("[AssetTextures] Phase 2: Loading remaining assets..."),await Promise.all(r),console.log("[AssetTextures] All textures loaded:",Array.from(this.textures.keys()))})(),this.readyPromise}async priorityReady(){return this.priorityReadyPromise?this.priorityReadyPromise:Promise.resolve()}async waitFor(e,t={}){if(!this.config)throw new Error("[AssetTextures] Must call init() before waitFor() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before waitFor() - app is null");let a=Array.from(new Set((e||[]).filter(s=>typeof s=="string"&&s))).filter(s=>{var d,c,u,l;try{let p=(u=(c=(d=this.config)==null?void 0:d.objects)==null?void 0:c.get)==null?void 0:u.call(c,s);return!!((l=p==null?void 0:p.render)!=null&&l.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let r=()=>a.every(s=>this.textures.has(s)||this.attempted.has(s));if(r())return;let o=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(s=>{let d=!1,c=()=>{d||r()&&(d=!0,this.waiters.delete(c),s())};this.waiters.add(c),c(),o>0&&setTimeout(()=>{d||(d=!0,this.waiters.delete(c),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),s())},o)})}get(e){return this.textures.get(e)}set(e,t){this.textures.set(e,t),console.log(`[AssetTextures] Updated texture: ${e}`)}clear(){this.textures.clear(),this.readyPromise=null,console.log("[AssetTextures] Cleared all textures")}getAllIds(){return Array.from(this.textures.keys())}},Dn=new ii,fe=new Proxy(Dn,{get(i,e){return e in i&&typeof i[e]=="function"?i[e].bind(i):i.get(e)},set(i,e,t){return i.set(e,t),!0}})});var Hn={};Vi(Hn,{AssetEditorModal:()=>si});var si,li=ne(()=>{"use strict";si=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,n,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=n,this.onApplyCallback=a,this.createModal(e,n),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let n=document.createElement("div");n.className="asset-editor-modal",n.innerHTML=`
|
|
1
|
+
"use strict";var ba=Object.create;var ft=Object.defineProperty;var ya=Object.getOwnPropertyDescriptor;var va=Object.getOwnPropertyNames;var xa=Object.getPrototypeOf,wa=Object.prototype.hasOwnProperty;var ne=(i,e)=>()=>(i&&(e=i(i=0)),e);var Vi=(i,e)=>{for(var t in e)ft(i,t,{get:e[t],enumerable:!0})},Wi=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of va(e))!wa.call(i,a)&&a!==t&&ft(i,a,{get:()=>e[a],enumerable:!(n=ya(e,a))||n.enumerable});return i};var ht=(i,e,t)=>(t=i!=null?ba(xa(i)):{},Wi(e||!i||!i.__esModule?ft(t,"default",{value:i,enumerable:!0}):t,i)),Ea=i=>Wi(ft({},"__esModule",{value:!0}),i);var ka,ue=ne(()=>{"use strict";ka="handler_preview_override_mode";if(typeof window!="undefined"){let i=window.localStorage.getItem(ka);window.__enableConfigOverrides=i===null?!0:i==="true"}});var Tn,xe,Zr,Yt=ne(()=>{"use strict";ue();Tn=null,xe="dev";if(typeof window!="undefined"){let i=window.__BUILD_SETTINGS__;if(i!=null&&i.buildMode)Tn=i,xe=i.buildMode,console.log("[CONFIG] Loaded inline build settings:",i,"buildMode:",xe);else try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);Tn=t,xe=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",xe)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",xe)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",xe);Zr=xe==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var Kt=ne(()=>{"use strict"});var kn=ne(()=>{"use strict";Kt();Yt()});var Xt=ne(()=>{"use strict";Yt();Kt();kn()});var Q,Qt=ne(()=>{"use strict";Q=class{static get(e){var t;return(t=this.store.get(e))==null?void 0:t.data}static set(e,t){this.store.set(e,{data:t})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};Q.store=new Map});function Fa(){var i,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(i=document.querySelector("script"))==null?void 0:i.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),n=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!n)}catch{return!1}}async function Ua(){try{if(typeof window!="undefined"){let i=await fetch("./build-settings.json");if(i.ok){let e=await i.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Ga(){try{if(typeof window!="undefined"){let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}async function qa(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${_}`),Object.keys(ae).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(ae)),ae;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),ae={...window.INLINE_ASSETS},ae;if(!(_==="publish"&&ee!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),ae;if(!ei){let e=typeof window!="undefined"?new URL("inline-assets.js",window.location.href).href:"./inline-assets.js";console.log("[AssetLoader] Loading inline assets from:",e),ei=(async()=>{try{try{let r=await import(e+"?t="+Date.now());if(r.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(r.INLINE_ASSETS)),r.INLINE_ASSETS}catch(r){console.warn("[AssetLoader] ES module import failed, trying text parse:",r)}let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.text();console.log("[AssetLoader] Received JS code, length:",n.length);let a=n.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)try{let r=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let o=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(o)),o}catch(r){return console.warn("[AssetLoader] Failed to parse inline assets:",r),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",n.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return ae=await ei,console.log("[AssetLoader] Final inline assets cache:",Object.keys(ae)),ae}function ti(i){return i===null||typeof i!="object"||(Object.freeze(i),Object.values(i).forEach(e=>ti(e))),i}function Va(i=64,e=64,t=16711680){let n=document.createElement("canvas");n.width=i,n.height=e;let a=n.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,i,e),a.strokeStyle="#000",a.strokeRect(0,0,i,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",i/2,e/2),re.Texture.from(n)}function wt(i,e){Rn.set(i,e)}var re,In,jn,we,_,ee,ge,ae,ei,Rn,fe,Et=ne(()=>{"use strict";re=require("pixi.js");Qt();In=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",jn=Fa(),we=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,_=jn?"publish":In,ee=we==null?void 0:we.assetsInlined;we!=null&&we.buildMode&&(_=we.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${_}`));ge=Ga();ge!=null&&ge.buildMode&&(_=ge.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${_}`));(ge==null?void 0:ge.assetsInlined)!==void 0&&(ee=ge.assetsInlined);Ua().then(i=>{i!=null&&i.buildMode&&i.buildMode!==_&&(_=i.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${_}`)),(i==null?void 0:i.assetsInlined)!==void 0&&(ee=i.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${In}, Runtime: ${jn?"publish":"dev"}, Effective: ${_}`);ae={},ei=null;Rn=new Map;fe=class{static async load(e,t,n,a){let r=`${e}:${t.path}`,o=Q.get(r);if(o!==void 0)return o;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${_}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let s=await qa(),d=s[e];if(!d&&a&&(d=s[a],d&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${a}`)),!d&&t.path){let l=t.path.split("/");if(l.length>=2){let p=l[l.length-1].split(".")[0];s[p]&&(d=s[p],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${p}`))}}if(console.log("[AssetLoader] Inline data for",e,":",d?"FOUND":"NOT FOUND"),_==="publish"&&ee!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!d))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${t.path}`);let u=Rn.get(t.type);if(u)try{let l=await u(t.path,d,e,n);return Q.set(r,l),l}catch(l){return this.handleFailure(e,t.type,l)}try{let l;switch(t.type){case"image":l=await this.loadImage(t.path,d);break;case"json":l=await this.loadJSON(t.path,d),l=ti(l);break;default:throw new Error(`Unknown asset type: ${t.type}`)}return Q.set(r,l),l}catch(l){return this.handleFailure(e,t.type,l)}}static async loadImage(e,t){let n=_==="publish",a=n&&ee!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${_}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof t!="string"||!t.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof t}`);try{return await re.Assets.load(t)}catch(r){throw console.error("[AssetLoader] Failed to load texture from data URI:",r),r}}if(t&&typeof t=="string"&&t.startsWith("data:"))try{return await re.Assets.load(t)}catch(r){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",r),await re.Assets.load(e)}return await re.Assets.load(e)}static async loadJSON(e,t){let n=_==="publish",a=n&&ee!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${_}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let o=atob(t.split(",")[1]);return JSON.parse(o)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let o=atob(t.split(",")[1]);return JSON.parse(o)}return JSON.parse(t)}let r=await fetch(e);if(!r.ok)throw new Error(`JSON fetch failed: ${e}`);return r.json()}static handleFailure(e,t,n){if(_==="dev"){let r=t==="image"?Va():ti({__placeholder:!0,type:t});return Q.set(e+":"+((n==null?void 0:n.path)||"missing"),r),r}throw n}};wt("image",async(i,e)=>{let t=_==="publish",n=t&&ee!==!1,a=_==="brand",r=t&&ee===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${_}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${i}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return re.Assets.load(e)}let o=i;return(a||r)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(o=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${o}"`))),re.Assets.load(e||o)});wt("json",async(i,e)=>{let t=_==="publish",n=t&&ee!==!1,a=_==="brand",r=t&&ee===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${_}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${i}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let o=i;if((a||r)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(o=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${o}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let s=await fetch(o);if(!s.ok)throw new Error(`JSON fetch failed: ${i}`);return s.json()})});function At(i,e){Dn.init(i,e),typeof window!="undefined"&&(window.__AssetTextures=he)}var ii,Dn,he,Xe=ne(()=>{"use strict";Et();ii=class{constructor(){this.textures=new Map;this.readyPromise=null;this.priorityReadyPromise=null;this.priorityReadyResolve=null;this.config=null;this.app=null;this.attempted=new Set;this.waiters=new Set}init(e,t){if(this.config===e&&this.app===t&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.attempted.clear(),this.waiters.clear(),this.priorityReadyPromise=new Promise(n=>{this.priorityReadyResolve=n}),this.config=e,this.app=t,console.log("[AssetTextures] Initialized with config, cleared previous textures")}async ready(){if(this.readyPromise){await this.readyPromise;return}if(!this.config)throw new Error("[AssetTextures] Must call init() before ready() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before ready() - app is null");let e=this.config,t=this.app;return this.readyPromise=(async()=>{var o;console.log("[AssetTextures] Loading all assets...");let n=new Set(["background_loading_1"]),a=[],r=[];for(let[s,d]of e.objects.entries()){let c=(o=d.render)==null?void 0:o.asset;if(!c)continue;let u=async()=>{var l;try{let p=(l=d.identity)==null?void 0:l.id;console.log(`[AssetTextures] Loading ${c.type}: ${s} (${p})`);let g=await fe.load(s,c,t,p);this.textures.set(s,g),console.log(`[AssetTextures] \u2713 Loaded: ${s}`)}catch(p){console.error(`[AssetTextures] \u2717 Failed to load: ${s}`,p)}finally{this.attempted.add(s);try{for(let p of Array.from(this.waiters))p()}catch{}}};n.has(s)?a.push(u()):r.push(u())}a.length>0&&(console.log("[AssetTextures] Phase 1: Loading priority assets (loading screen)..."),await Promise.all(a),console.log("[AssetTextures] Phase 1: Priority assets ready")),this.priorityReadyResolve&&this.priorityReadyResolve(),console.log("[AssetTextures] Phase 2: Loading remaining assets..."),await Promise.all(r),console.log("[AssetTextures] All textures loaded:",Array.from(this.textures.keys()))})(),this.readyPromise}async priorityReady(){return this.priorityReadyPromise?this.priorityReadyPromise:Promise.resolve()}async waitFor(e,t={}){if(!this.config)throw new Error("[AssetTextures] Must call init() before waitFor() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before waitFor() - app is null");let a=Array.from(new Set((e||[]).filter(s=>typeof s=="string"&&s))).filter(s=>{var d,c,u,l;try{let p=(u=(c=(d=this.config)==null?void 0:d.objects)==null?void 0:c.get)==null?void 0:u.call(c,s);return!!((l=p==null?void 0:p.render)!=null&&l.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let r=()=>a.every(s=>this.textures.has(s)||this.attempted.has(s));if(r())return;let o=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(s=>{let d=!1,c=()=>{d||r()&&(d=!0,this.waiters.delete(c),s())};this.waiters.add(c),c(),o>0&&setTimeout(()=>{d||(d=!0,this.waiters.delete(c),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),s())},o)})}get(e){return this.textures.get(e)}set(e,t){this.textures.set(e,t),console.log(`[AssetTextures] Updated texture: ${e}`)}clear(){this.textures.clear(),this.readyPromise=null,console.log("[AssetTextures] Cleared all textures")}getAllIds(){return Array.from(this.textures.keys())}},Dn=new ii,he=new Proxy(Dn,{get(i,e){return e in i&&typeof i[e]=="function"?i[e].bind(i):i.get(e)},set(i,e,t){return i.set(e,t),!0}})});var Hn={};Vi(Hn,{AssetEditorModal:()=>si});var si,li=ne(()=>{"use strict";si=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,n,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=n,this.onApplyCallback=a,this.createModal(e,n),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let n=document.createElement("div");n.className="asset-editor-modal",n.innerHTML=`
|
|
2
2
|
<div class="asset-editor-card">
|
|
3
3
|
<div class="asset-editor-header">
|
|
4
4
|
<div>
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
<button class="debug-btn primary" data-modal-apply>Apply</button>
|
|
44
44
|
</div>
|
|
45
45
|
</div>
|
|
46
|
-
`,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(o=>{o.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(o=>{o.addEventListener("click",s=>{let c=s.target.dataset.tab;c&&this.switchTab(c)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let a=this.modal.querySelector("[data-ai-edit]");a==null||a.addEventListener("click",()=>{this.openAiEditor("edit")});let r=this.modal.querySelector("[data-modal-apply]");r==null||r.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",o=>{o.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let t=window.__openAiEditor;if(typeof t!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";e==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:a=>{this.onApplyCallback&&this.onApplyCallback(a),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var Hr={};Vi(Hr,{AssetCache:()=>Q,AssetLoader:()=>he,AssetSystem:()=>It,AssetTextures:()=>fe,Assets:()=>pa,BaseSystem:()=>He,GameEngine:()=>Ot,GameObject:()=>st,GameObjectManager:()=>$e,ObjectFactory:()=>me,Renderer:()=>ot,RuntimeObjectRegistry:()=>Ne,Transform:()=>rt,applyScreenAnchor:()=>Dt,basePixi:()=>sa,clearResponsiveElements:()=>ga,createPixiBase:()=>Pt,getRegisteredFontIds:()=>na,globalResponsiveMultipliers:()=>ct,initAssetTextures:()=>At,initAssets:()=>ua,layout:()=>fa,playLottieOverlay:()=>ra,registerFont:()=>ia,registerType:()=>wt,resolveAnchorVec2:()=>Ce,resolveFont:()=>ea,resolveFontWeight:()=>ta,resolveScreenAnchorPoint:()=>Be,resolveScreenRatioPoint:()=>Fe,runInitSequence:()=>ma,setLottieInstance:()=>St,spawnSceneFromConfig:()=>ca,updateScreenState:()=>Rt});module.exports=Ea(Hr);var Qn=require("pixi.js");var pe={};function mt(i,e,t=!1){pe[i]||(pe[i]=[]),pe[i].push({fn:e,once:t})}function Gt(i,e){if(pe[i]){if(!e){delete pe[i];return}pe[i]=pe[i].filter(t=>t.fn!==e)}}function bt(i,...e){let t=pe[i];if(t)for(let n of[...t])n.fn(...e),n.once&&Gt(i,n.fn)}function q(i,e){mt(i,e,!0)}var D=null,Y=[],Te=null;function Xi(i){D=i,Y=[],Te!==null&&(clearTimeout(Te),Te=null)}function Ji(){var i,e,t;return{endpoint:(D==null?void 0:D.endpoint)||"",transport:(D==null?void 0:D.transport)||"beacon",batchSize:(i=D==null?void 0:D.batchSize)!=null?i:10,flushIntervalMs:(e=D==null?void 0:D.flushIntervalMs)!=null?e:300,maxQueue:(t=D==null?void 0:D.maxQueue)!=null?t:200,debug:!!(D!=null&&D.debug)}}async function Yi(i,e,t,n){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(i,new Blob([a],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",e)}catch(r){n&&console.warn("[handler.telemetry] fetch failed",r)}}function qt(i,e){let t=Ji();if(e&&t.endpoint){if(Y.push(i),Y.length>t.maxQueue&&(Y=Y.slice(Y.length-t.maxQueue)),Y.length>=t.batchSize){Ki();return}Te===null&&(Te=window.setTimeout(()=>{Te=null,Ki()},t.flushIntervalMs))}}async function Ki(){let i=Ji();if(!i.endpoint||Y.length===0)return;let e=Y.splice(0,i.batchSize);await Yi(i.endpoint,{events:e},i.transport,i.debug),Y.length>0&&await Yi(i.endpoint,{events:Y.splice(0,i.batchSize)},i.transport,i.debug)}function Zi(i){return Math.max(0,Math.min(1,i))}function Aa(i){let e=String(i!=null?i:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),n=t?Number(t[1]):1.8;return a=>1+(n+1)*Math.pow(a-1,3)+n*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function Ke(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Sa(i,e){let t=i==null?void 0:i[e];return typeof t=="number"?t:0}function Qi(i,e,t){try{i[e]=t}catch{}}function Ca(i){let e=i==null?void 0:i.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,n=typeof e.y=="number"?e.y:1;return{x:t,y:n}}function en(i,e){let t=i==null?void 0:i.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function tn(i,e){let t=Ca(i);if(!t)return{from:null,to:null};let n=null,a=null;return typeof e.scale=="number"?(n=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(n=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(n=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),n===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:n!=null?n:t.x,y:a!=null?a:t.y}}}function nn(){let i=new Set,e=new WeakMap,t=null,n=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,s(),i.size>0&&n()})},a=u=>{var p;i.add(u);let l=(p=e.get(u.target))!=null?p:new Set;l.add(u),e.set(u.target,l),n()},r=u=>{i.delete(u);let l=e.get(u.target);l&&(l.delete(u),l.size===0&&e.delete(u.target))},o=u=>{u.killed||(u.killed=!0,r(u))},s=()=>{var l,p;let u=Ke();for(let g of Array.from(i)){if(g.killed||g.paused)continue;let m=u-g.startMs-g.delayMs;if(m<0)continue;let f=g.durationMs>0?m/g.durationMs:1,A=Zi(f),b=g.repeat>=0?g.repeat+1:1,h=g.repeat>0?Math.min(Math.floor(f),b-1):0;if(g.repeat>0&&f>=1){let y=f-h;A=Zi(y)}let x=g.ease(A);g.yoyo&&h%2===1&&(x=1-x);for(let y of g.props)Qi(g.target,y.key,y.from+(y.to-y.from)*x);g.scaleFrom&&g.scaleTo&&en(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*x,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*x});try{(l=g.onUpdate)==null||l.call(g)}catch{}if(f>=b){o(g);try{(p=g.onComplete)==null||p.call(g)}catch{}}}},d=(u,l,p)=>{var y;let g=Math.max(0,(typeof l.duration=="number"?l.duration:.5)*1e3),m=Math.max(0,(typeof l.delay=="number"?l.delay:0)*1e3+((y=p==null?void 0:p.delayMsOverride)!=null?y:0)),f=Aa(l.ease),A=typeof l.repeat=="number"?Math.max(0,l.repeat|0):0,b=l.yoyo===!0,h=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),x=[];for(let I of Object.keys(l)){if(h.has(I))continue;let R=l[I];typeof R=="number"&&x.push({key:I,from:Sa(u,I),to:R})}let w=tn(u,l);return{target:u,startMs:Ke(),delayMs:m,durationMs:g,ease:f,props:x,scaleFrom:w.from,scaleTo:w.to,repeat:A,yoyo:b,onUpdate:typeof l.onUpdate=="function"?l.onUpdate:void 0,onComplete:typeof l.onComplete=="function"?l.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(u,l){let p=d(u,l);return a(p),{kill:()=>o(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=Ke())},resume:()=>{var f;if(!p.paused)return;let g=(f=p.pauseAtMs)!=null?f:Ke(),m=Ke()-g;p.startMs+=m,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(u,l,p){return c.set(u,l),c.to(u,p)},set(u,l){if(!u||!l)return;for(let g of Object.keys(l)){let m=l[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof m=="number"&&Qi(u,g,m)}let p=tn(u,l);p.to&&en(u,p.to)},killTweensOf(u){let l=e.get(u);if(l)for(let p of Array.from(l))o(p)},timeline(u={}){let l=[],p=0,g=!1,m=[],f=h=>{if(typeof h=="number")return Math.max(0,h*1e3);let x=typeof h=="string"?h.trim():"";return x.startsWith("+=")?p+Math.max(0,Number(x.slice(2))*1e3||0):x?Math.max(0,Number(x)*1e3||0):p},A=h=>{l.push(h);let x=Math.max(0,(typeof h.vars.duration=="number"?h.vars.duration:.5)*1e3);p=Math.max(p,h.atMs+x)},b={to(h,x,w){return A({kind:"to",target:h,vars:x,atMs:f(w)}),b},fromTo(h,x,w,y){return A({kind:"fromTo",target:h,vars:w,from:x,atMs:f(y)}),b},play(){var h,x;if(g)return b;g=!0,m=[];for(let w of l)w.kind==="fromTo"&&c.set(w.target,(h=w.from)!=null?h:{}),m.push(c.to(w.target,{...w.vars,delay:w.atMs/1e3+((x=w.vars.delay)!=null?x:0)}));return b},pause(){for(let h of m)h.pause();return b},kill(){for(let h of m)h.kill();m=[],g=!1}};return u.paused||b.play(),b}};return c}function an(){if(typeof window=="undefined")return;let i=window;if(!i.gsap)try{i.gsap=nn()}catch{}}var rn={name:"handler-playable-sdk",version:"0.4.0",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && chmod +x dist/cli/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var V=0,La=V++,on=V++,sn=V++,ln=V++,cn=V++,dn=V++,pn=V++,un=V++,gn=V++,hn=V++,fn=V++,mn=V++,M=La;function bn(){return M===on}function yn(){return M===sn}function vn(){return M===ln}function xn(){return M===cn}function Le(){return M===dn}function ke(){return M===pn}function wn(){return M===un}function En(){return M===gn}function An(){return M===hn}function Vt(){return M===fn}function Wt(){return M===mn}function Sn(){let i=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(i==="mraid")try{mraid.getState(),M=on;return}catch{}else if(i==="dapi")try{dapi.isReady(),M=sn;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(M=ln)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(M=cn)}catch{}else if(e==="mintegral")window.gameReady&&(M=dn);else if(e==="tapjoy")window.TJ_API&&(M=pn);else if(e==="tiktok")window.openAppStore&&(M=un);else if(e==="smadex")try{window.smxTracking&&(M=gn)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(M=hn)}catch{}else e==="vungle"?M=fn:(i==="nucleo"||e==="nucleo")&&(M=mn)}var yt=ft(require("lottie-web"),1),Cn=yt.default;typeof window!="undefined"&&(window.lottie=yt.default,window.__baseLottie=yt.default);Xt();function $(i,e){let t=(a,r)=>r===0?a:t(r,a%r),n=t(i,e);return`${i/n}:${e/n}`}var vo=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:$(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:$(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:$(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:$(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:$(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:$(360,780)}],xo=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:$(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:$(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:$(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:$(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:$(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:$(412,915)}],wo=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:$(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:$(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:$(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:$(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:$(800,1280)}],_n=[{id:"playable-portrait",label:"Playable Portrait",width:320,height:480,category:"playable",ratio:"2:3",mraidScale:1},{id:"mraid-320x480",label:"MRAID 320\xD7480",width:320,height:480,category:"playable",ratio:"2:3",mraidScale:1},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"playable",ratio:$(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:$(768,1024),mraidScale:.7}];var Eo=[..._n];var Ra=_n[0];ue();var Ba=ft(require("jszip"),1);function za(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Ha(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}async function Na(i){return await new Promise(e=>{let t=new Image;t.onload=()=>e({width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}),t.onerror=()=>e(null),t.src=i})}async function Jt(i){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",i);let n=await fetch(i);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,i),null;let a=await n.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let r=await za(a),o=await Na(r),s=Ha(r);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",s.mimeType),{base64:s.base64,mimeType:s.mimeType,dataUrl:r,width:(e=o==null?void 0:o.width)!=null?e:0,height:(t=o==null?void 0:o.height)!=null?t:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function vt(i,e=30){try{console.log("[ImageUtils] Removing background color...");let t=await new Promise((l,p)=>{let g=new Image;g.onload=()=>l(g),g.onerror=()=>p(new Error("Failed to load image")),g.src=i}),n=document.createElement("canvas");n.width=t.width,n.height=t.height;let a=n.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),i;a.drawImage(t,0,0);let r=a.getImageData(0,0,n.width,n.height),o=r.data,d=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(l=>({r:o[l.offset],g:o[l.offset+1],b:o[l.offset+2]})),c=0;for(let l=0;l<o.length;l+=4){let p=o[l],g=o[l+1],m=o[l+2],f=!1;for(let A of d)if(Math.sqrt(Math.pow(p-A.r,2)+Math.pow(g-A.g,2)+Math.pow(m-A.b,2))<e){f=!0;break}f&&(o[l+3]=0,c++)}return console.log(`[ImageUtils] Removed background from ${c} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),n.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),i}}var Pn=require("@google/genai");async function Zt(i,e,t=[],n={}){var a,r,o,s,d,c,u;try{if(!(i!=null&&i.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let b=0;b<t.length;b++){let h=t[b];if(!h.base64||!h.mimeType)throw new Error(`Image ${b+1} is missing required data`);if(h.base64.length<1e3&&console.warn(`Image ${b+1} data appears very small, may be corrupted`),!h.mimeType.startsWith("image/"))throw new Error(`Image ${b+1} has invalid MIME type: ${h.mimeType}`)}let l=new Pn.GoogleGenAI({apiKey:i}),p="gemini-2.5-flash",g=[e];t.length>0&&t.forEach((b,h)=>{g.push({inlineData:{data:b.base64,mimeType:b.mimeType}}),console.log(`[Gemini] Added image ${h+1}: ${b.mimeType}, size: ${Math.round(b.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${t.length} images and prompt length: ${e.length}`);let m=await l.models.generateContent({model:p,contents:g}),f="",A=(o=(r=(a=m.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:o.parts;if(A)for(let b of A)b.text&&(f+=b.text);if(!f.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${f.length}`),f}catch(l){throw console.error("[Gemini] API error:",l),(s=l.message)!=null&&s.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(d=l.message)!=null&&d.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(c=l.message)!=null&&c.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(u=l.message)!=null&&u.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):l}}var Mn=require("@google/genai");async function xt(i,e,t=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Mn.GoogleGenAI({apiKey:i}),r=[{text:e}];t.length>0&&t.forEach((s,d)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${d}`),r.push({inlineData:{mimeType:s.mimeType,data:s.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let s of o.candidates[0].content.parts)if(s.text)console.log(s.text);else if(s.inlineData){let d=s.inlineData.data,c=s.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${c};base64,${d}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(a){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(a,Object.getOwnPropertyNames(a),2)),a}}var Wa=require("pixi.js");Xe();ue();var $n=require("pixi.js");var Ya=require("pixi.js");ue();function tr(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function ir(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}function nr(i){return`
|
|
46
|
+
`,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(o=>{o.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(o=>{o.addEventListener("click",s=>{let c=s.target.dataset.tab;c&&this.switchTab(c)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let a=this.modal.querySelector("[data-ai-edit]");a==null||a.addEventListener("click",()=>{this.openAiEditor("edit")});let r=this.modal.querySelector("[data-modal-apply]");r==null||r.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",o=>{o.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let t=window.__openAiEditor;if(typeof t!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";e==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:a=>{this.onApplyCallback&&this.onApplyCallback(a),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var Hr={};Vi(Hr,{AssetCache:()=>Q,AssetLoader:()=>fe,AssetSystem:()=>It,AssetTextures:()=>he,Assets:()=>pa,BaseSystem:()=>He,GameEngine:()=>Ot,GameObject:()=>st,GameObjectManager:()=>$e,ObjectFactory:()=>me,Renderer:()=>ot,RuntimeObjectRegistry:()=>Ne,Transform:()=>rt,applyScreenAnchor:()=>Dt,basePixi:()=>sa,clearResponsiveElements:()=>ga,createPixiBase:()=>Pt,getRegisteredFontIds:()=>na,globalResponsiveMultipliers:()=>ct,initAssetTextures:()=>At,initAssets:()=>ua,layout:()=>ha,playLottieOverlay:()=>ra,registerFont:()=>ia,registerType:()=>wt,resolveAnchorVec2:()=>Ce,resolveFont:()=>ea,resolveFontWeight:()=>ta,resolveScreenAnchorPoint:()=>Be,resolveScreenRatioPoint:()=>Fe,runInitSequence:()=>ma,setLottieInstance:()=>St,spawnSceneFromConfig:()=>ca,updateScreenState:()=>Rt});module.exports=Ea(Hr);var Qn=require("pixi.js");var pe={};function mt(i,e,t=!1){pe[i]||(pe[i]=[]),pe[i].push({fn:e,once:t})}function Gt(i,e){if(pe[i]){if(!e){delete pe[i];return}pe[i]=pe[i].filter(t=>t.fn!==e)}}function bt(i,...e){let t=pe[i];if(t)for(let n of[...t])n.fn(...e),n.once&&Gt(i,n.fn)}function q(i,e){mt(i,e,!0)}var D=null,Y=[],Te=null;function Xi(i){D=i,Y=[],Te!==null&&(clearTimeout(Te),Te=null)}function Ji(){var i,e,t;return{endpoint:(D==null?void 0:D.endpoint)||"",transport:(D==null?void 0:D.transport)||"beacon",batchSize:(i=D==null?void 0:D.batchSize)!=null?i:10,flushIntervalMs:(e=D==null?void 0:D.flushIntervalMs)!=null?e:300,maxQueue:(t=D==null?void 0:D.maxQueue)!=null?t:200,debug:!!(D!=null&&D.debug)}}async function Yi(i,e,t,n){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(i,new Blob([a],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",e)}catch(r){n&&console.warn("[handler.telemetry] fetch failed",r)}}function qt(i,e){let t=Ji();if(e&&t.endpoint){if(Y.push(i),Y.length>t.maxQueue&&(Y=Y.slice(Y.length-t.maxQueue)),Y.length>=t.batchSize){Ki();return}Te===null&&(Te=window.setTimeout(()=>{Te=null,Ki()},t.flushIntervalMs))}}async function Ki(){let i=Ji();if(!i.endpoint||Y.length===0)return;let e=Y.splice(0,i.batchSize);await Yi(i.endpoint,{events:e},i.transport,i.debug),Y.length>0&&await Yi(i.endpoint,{events:Y.splice(0,i.batchSize)},i.transport,i.debug)}function Zi(i){return Math.max(0,Math.min(1,i))}function Aa(i){let e=String(i!=null?i:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),n=t?Number(t[1]):1.8;return a=>1+(n+1)*Math.pow(a-1,3)+n*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function Ke(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Sa(i,e){let t=i==null?void 0:i[e];return typeof t=="number"?t:0}function Qi(i,e,t){try{i[e]=t}catch{}}function Ca(i){let e=i==null?void 0:i.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,n=typeof e.y=="number"?e.y:1;return{x:t,y:n}}function en(i,e){let t=i==null?void 0:i.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function tn(i,e){let t=Ca(i);if(!t)return{from:null,to:null};let n=null,a=null;return typeof e.scale=="number"?(n=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(n=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(n=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),n===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:n!=null?n:t.x,y:a!=null?a:t.y}}}function nn(){let i=new Set,e=new WeakMap,t=null,n=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,s(),i.size>0&&n()})},a=u=>{var p;i.add(u);let l=(p=e.get(u.target))!=null?p:new Set;l.add(u),e.set(u.target,l),n()},r=u=>{i.delete(u);let l=e.get(u.target);l&&(l.delete(u),l.size===0&&e.delete(u.target))},o=u=>{u.killed||(u.killed=!0,r(u))},s=()=>{var l,p;let u=Ke();for(let g of Array.from(i)){if(g.killed||g.paused)continue;let m=u-g.startMs-g.delayMs;if(m<0)continue;let h=g.durationMs>0?m/g.durationMs:1,A=Zi(h),b=g.repeat>=0?g.repeat+1:1,f=g.repeat>0?Math.min(Math.floor(h),b-1):0;if(g.repeat>0&&h>=1){let y=h-f;A=Zi(y)}let x=g.ease(A);g.yoyo&&f%2===1&&(x=1-x);for(let y of g.props)Qi(g.target,y.key,y.from+(y.to-y.from)*x);g.scaleFrom&&g.scaleTo&&en(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*x,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*x});try{(l=g.onUpdate)==null||l.call(g)}catch{}if(h>=b){o(g);try{(p=g.onComplete)==null||p.call(g)}catch{}}}},d=(u,l,p)=>{var y;let g=Math.max(0,(typeof l.duration=="number"?l.duration:.5)*1e3),m=Math.max(0,(typeof l.delay=="number"?l.delay:0)*1e3+((y=p==null?void 0:p.delayMsOverride)!=null?y:0)),h=Aa(l.ease),A=typeof l.repeat=="number"?Math.max(0,l.repeat|0):0,b=l.yoyo===!0,f=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),x=[];for(let I of Object.keys(l)){if(f.has(I))continue;let R=l[I];typeof R=="number"&&x.push({key:I,from:Sa(u,I),to:R})}let w=tn(u,l);return{target:u,startMs:Ke(),delayMs:m,durationMs:g,ease:h,props:x,scaleFrom:w.from,scaleTo:w.to,repeat:A,yoyo:b,onUpdate:typeof l.onUpdate=="function"?l.onUpdate:void 0,onComplete:typeof l.onComplete=="function"?l.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(u,l){let p=d(u,l);return a(p),{kill:()=>o(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=Ke())},resume:()=>{var h;if(!p.paused)return;let g=(h=p.pauseAtMs)!=null?h:Ke(),m=Ke()-g;p.startMs+=m,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(u,l,p){return c.set(u,l),c.to(u,p)},set(u,l){if(!u||!l)return;for(let g of Object.keys(l)){let m=l[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof m=="number"&&Qi(u,g,m)}let p=tn(u,l);p.to&&en(u,p.to)},killTweensOf(u){let l=e.get(u);if(l)for(let p of Array.from(l))o(p)},timeline(u={}){let l=[],p=0,g=!1,m=[],h=f=>{if(typeof f=="number")return Math.max(0,f*1e3);let x=typeof f=="string"?f.trim():"";return x.startsWith("+=")?p+Math.max(0,Number(x.slice(2))*1e3||0):x?Math.max(0,Number(x)*1e3||0):p},A=f=>{l.push(f);let x=Math.max(0,(typeof f.vars.duration=="number"?f.vars.duration:.5)*1e3);p=Math.max(p,f.atMs+x)},b={to(f,x,w){return A({kind:"to",target:f,vars:x,atMs:h(w)}),b},fromTo(f,x,w,y){return A({kind:"fromTo",target:f,vars:w,from:x,atMs:h(y)}),b},play(){var f,x;if(g)return b;g=!0,m=[];for(let w of l)w.kind==="fromTo"&&c.set(w.target,(f=w.from)!=null?f:{}),m.push(c.to(w.target,{...w.vars,delay:w.atMs/1e3+((x=w.vars.delay)!=null?x:0)}));return b},pause(){for(let f of m)f.pause();return b},kill(){for(let f of m)f.kill();m=[],g=!1}};return u.paused||b.play(),b}};return c}function an(){if(typeof window=="undefined")return;let i=window;if(!i.gsap)try{i.gsap=nn()}catch{}}var rn={name:"handler-playable-sdk",version:"0.4.2",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && chmod +x dist/cli/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var V=0,La=V++,on=V++,sn=V++,ln=V++,cn=V++,dn=V++,pn=V++,un=V++,gn=V++,fn=V++,hn=V++,mn=V++,M=La;function bn(){return M===on}function yn(){return M===sn}function vn(){return M===ln}function xn(){return M===cn}function Le(){return M===dn}function ke(){return M===pn}function wn(){return M===un}function En(){return M===gn}function An(){return M===fn}function Vt(){return M===hn}function Wt(){return M===mn}function Sn(){let i=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(i==="mraid")try{mraid.getState(),M=on;return}catch{}else if(i==="dapi")try{dapi.isReady(),M=sn;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(M=ln)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(M=cn)}catch{}else if(e==="mintegral")window.gameReady&&(M=dn);else if(e==="tapjoy")window.TJ_API&&(M=pn);else if(e==="tiktok")window.openAppStore&&(M=un);else if(e==="smadex")try{window.smxTracking&&(M=gn)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(M=fn)}catch{}else e==="vungle"?M=hn:(i==="nucleo"||e==="nucleo")&&(M=mn)}var yt=ht(require("lottie-web"),1),Cn=yt.default;typeof window!="undefined"&&(window.lottie=yt.default,window.__baseLottie=yt.default);Xt();function $(i,e){let t=(a,r)=>r===0?a:t(r,a%r),n=t(i,e);return`${i/n}:${e/n}`}var vo=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:$(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:$(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:$(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:$(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:$(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:$(360,780)}],xo=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:$(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:$(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:$(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:$(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:$(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:$(412,915)}],wo=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:$(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:$(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:$(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:$(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:$(800,1280)}],_n=[{id:"playable-portrait",label:"Playable Portrait",width:320,height:480,category:"playable",ratio:"2:3",mraidScale:1},{id:"mraid-320x480",label:"MRAID 320\xD7480",width:320,height:480,category:"playable",ratio:"2:3",mraidScale:1},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"playable",ratio:$(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:$(768,1024),mraidScale:.7}];var Eo=[..._n];var Ra=_n[0];ue();var Ba=ht(require("jszip"),1);function za(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Ha(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}async function Na(i){return await new Promise(e=>{let t=new Image;t.onload=()=>e({width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}),t.onerror=()=>e(null),t.src=i})}async function Jt(i){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",i);let n=await fetch(i);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,i),null;let a=await n.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let r=await za(a),o=await Na(r),s=Ha(r);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",s.mimeType),{base64:s.base64,mimeType:s.mimeType,dataUrl:r,width:(e=o==null?void 0:o.width)!=null?e:0,height:(t=o==null?void 0:o.height)!=null?t:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function vt(i,e=30){try{console.log("[ImageUtils] Removing background color...");let t=await new Promise((l,p)=>{let g=new Image;g.onload=()=>l(g),g.onerror=()=>p(new Error("Failed to load image")),g.src=i}),n=document.createElement("canvas");n.width=t.width,n.height=t.height;let a=n.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),i;a.drawImage(t,0,0);let r=a.getImageData(0,0,n.width,n.height),o=r.data,d=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(l=>({r:o[l.offset],g:o[l.offset+1],b:o[l.offset+2]})),c=0;for(let l=0;l<o.length;l+=4){let p=o[l],g=o[l+1],m=o[l+2],h=!1;for(let A of d)if(Math.sqrt(Math.pow(p-A.r,2)+Math.pow(g-A.g,2)+Math.pow(m-A.b,2))<e){h=!0;break}h&&(o[l+3]=0,c++)}return console.log(`[ImageUtils] Removed background from ${c} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),n.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),i}}var Pn=require("@google/genai");async function Zt(i,e,t=[],n={}){var a,r,o,s,d,c,u;try{if(!(i!=null&&i.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let b=0;b<t.length;b++){let f=t[b];if(!f.base64||!f.mimeType)throw new Error(`Image ${b+1} is missing required data`);if(f.base64.length<1e3&&console.warn(`Image ${b+1} data appears very small, may be corrupted`),!f.mimeType.startsWith("image/"))throw new Error(`Image ${b+1} has invalid MIME type: ${f.mimeType}`)}let l=new Pn.GoogleGenAI({apiKey:i}),p="gemini-2.5-flash",g=[e];t.length>0&&t.forEach((b,f)=>{g.push({inlineData:{data:b.base64,mimeType:b.mimeType}}),console.log(`[Gemini] Added image ${f+1}: ${b.mimeType}, size: ${Math.round(b.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${t.length} images and prompt length: ${e.length}`);let m=await l.models.generateContent({model:p,contents:g}),h="",A=(o=(r=(a=m.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:o.parts;if(A)for(let b of A)b.text&&(h+=b.text);if(!h.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${h.length}`),h}catch(l){throw console.error("[Gemini] API error:",l),(s=l.message)!=null&&s.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(d=l.message)!=null&&d.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(c=l.message)!=null&&c.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(u=l.message)!=null&&u.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):l}}var Mn=require("@google/genai");async function xt(i,e,t=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Mn.GoogleGenAI({apiKey:i}),r=[{text:e}];t.length>0&&t.forEach((s,d)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${d}`),r.push({inlineData:{mimeType:s.mimeType,data:s.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let s of o.candidates[0].content.parts)if(s.text)console.log(s.text);else if(s.inlineData){let d=s.inlineData.data,c=s.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${c};base64,${d}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(a){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(a,Object.getOwnPropertyNames(a),2)),a}}var Wa=require("pixi.js");Xe();ue();var $n=require("pixi.js");var Ya=require("pixi.js");ue();function tr(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function ir(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}function nr(i){return`
|
|
47
47
|
Analyze these screenshots of a brand or game and extract its "Brand DNA".
|
|
48
48
|
|
|
49
49
|
Provide a concise summary (2-3 sentences) covering:
|
|
@@ -226,7 +226,7 @@ Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
226
226
|
<button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
|
|
227
227
|
</div>
|
|
228
228
|
</div>
|
|
229
|
-
`,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var n;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(n=this.options)!=null&&n.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,n=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,n-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,n=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,n,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,n,a),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+n-r,t],[e,t+a-r],[e+n-r,t+a-r]].forEach(([s,d])=>{var c;(c=this.ctx)==null||c.fillRect(s,d,r,r)})}updatePreview(){if(!this.modal||!this.image)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let n=150;e.width=n,e.height=n;let a=n/this.cropWidth,r=n/this.cropHeight,o=Math.min(a,r),s=this.cropWidth*o,d=this.cropHeight*o,c=(n-s)/2,u=(n-d)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,c,u,s,d)}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",n=>{let a=parseFloat(n.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",n=>{let a=n.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",n=>{switch(n.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",n=>{n.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,n=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,n=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let n=e.toDataURL("image/png");this.options.onCrop(n),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(i){new di().open(i)};ue();var Je=require("pixi.js");Et();var rr=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",pi=rr;if(typeof window!="undefined")try{let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);e!=null&&e.buildMode&&(pi=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${pi}`))}}catch{}function or(i){var t,n,a,r,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(i);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(i))return{x:(t=i[0])!=null?t:.5,y:(n=i[1])!=null?n:.5};if(i&&typeof i=="object"&&"x"in i&&"y"in i)return{x:(a=i.x)!=null?a:.5,y:(r=i.y)!=null?r:.5};if(typeof i=="string"){let s=i.trim().toLowerCase();return(o=e[s])!=null?o:{x:.5,y:.5}}return null}var me=class{static async create(e,t,n){var d,c,u,l,p,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${pi}`);let a=(d=t==null?void 0:t.render)==null?void 0:d.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let f=new Je.Container;return this.applyTransform(f,t==null?void 0:t.transform,t),f}let r=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${a.type}, path: ${a.path}`);let o=await he.load(e,a,n,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=o==null?void 0:o.constructor)==null?void 0:u.name}`);let s;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),s=new Je.Sprite(o),console.log("[ObjectFactory] Created object:",s,"type:",(l=s==null?void 0:s.constructor)==null?void 0:l.name),this.applyTransform(s,t==null?void 0:t.transform,t);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(p=o==null?void 0:o.constructor)==null?void 0:p.name,o),o&&(((g=o.constructor)==null?void 0:g.name)==="Container"||o instanceof Je.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let f=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],A=!1;for(let b of f)try{let h=await fetch(b);if(h.ok){s=await h.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=s==null?void 0:s.constructor)==null?void 0:m.name),A=!0;break}}catch{continue}A||(console.error("[ObjectFactory] Failed to reload JSON from any path"),s=o)}else s=o;else s=o,s&&typeof s=="object"&&("x"in s||"position"in s)&&this.applyTransform(s,t==null?void 0:t.transform,t);return s}static applyTransform(e,t,n){var a,r,o,s;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(a=t.position.x)!=null?a:0,e.y=(r=t.position.y)!=null?r:0):"position"in e&&e.position&&e.position.set((o=t.position.x)!=null?o:0,(s=t.position.y)!=null?s:0)),t.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(t.scale):e.scale=t.scale),t.rotation!==void 0&&"rotation"in e&&(e.rotation=t.rotation),t.anchor&&"anchor"in e&&e.anchor)){let d=or(t.anchor);d&&("set"in e.anchor?e.anchor.set(d.x,d.y):(e.anchor.x=d.x,e.anchor.y=d.y))}}};ue();var Nn=ft(require("lottie-web"),1);St(Cn);typeof window!="undefined"&&!window.lottie&&(window.lottie=Nn.default);Xt();ue();var ui=rn.version,lr=new Set(["init","boot","view","ready","start","pause","resume","complete","error","engagement","first_interaction","retry","cta_show","cta_click","cta_dismiss","clickout","conversion","session_time","level_time","load_time","level_start","level_complete","level_fail","checkpoint","reward","tutorial_start","tutorial_complete","tutorial_skip","ab_assign","fps","memory","asset_load_start","asset_load_complete"]);an();var Wn={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Yn=Math.random().toString(36).slice(2),Oe=null,Pe={...Wn},Kn="web_embed",mi={},et,gi=!1,Qe=!1,it=!1,Xn=!1,xi=1,Tt=0,_t=!1,oe=!1,Me="",Ie=Math.floor(window.innerWidth),je=Math.floor(window.innerHeight),bi=Ie>je,se=!1,tt=!1,Bn=!1,Fn=!1,hi=!1,Lt=null,Ae=null,yi=!1,vi=!1,Ct=new Map;function Jn(){if(!Ae)return null;let i=Date.now()-Ae;return!Number.isFinite(i)||i<0?null:i}function fi(i){if(yi)return;let e=Jn();e!==null&&(yi=!0,v("session_time",{duration_ms:e,reason:i}))}function Un(){if(Oe)return Oe;let i=document.createElement("div");return i.id="handler-root",i.setAttribute("data-handler-root","true"),document.body.appendChild(i),Oe=i,i}function kt(i){switch(i){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return i}}function Zn(i,e){return{event_name:i,ts:Date.now(),session_id:Yn,deployment_id:Pe.deployment_id,variant_id:Pe.variant_id,export_profile_id:Pe.profile_id,instance_id:Pe.instance_id||"default",env:Kn==="mraid"?"mraid":"web",attribution:et,payload:e}}function v(i,e){let t=kt(i),n=Zn(t,e);qt(n,!!mi.analytics),bt(t,n),t!==i&&bt(i,n)}function nt(){Lt&&(Lt(Ie,je),Lt=null)}function Re(i){xi=i,v("volume",i)}function De(i){i&&(Xn=!0),!it&&(it=!0,v("pause"),Re(0))}function at(i){!i&&Xn||it&&(it=!1,v("resume"),Re(xi))}function be(i,e){Ie=Math.floor(i||window.innerWidth),je=Math.floor(e||window.innerHeight),bi=Ie>je,v("resize",{width:Ie,height:je})}function cr(){if(bn())try{let i=mraid.getMaxSize();be(i.width,i.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?at():De()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let t=mraid.getMaxSize();be(t.width,t.height)}),mraid.getAudioVolume){let t=mraid.getAudioVolume();Re(t?1:0)}if(mraid.addEventListener("audioVolumeChange",t=>{t!==null&&Re(t>0?1:0)}),mraid.addEventListener("error",(t,n)=>{console.warn("mraid error:",t,"action:",n)}),_t=!0,mraid.isViewable()&&mraid.getState()!=="hidden")se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt();else{let t=()=>{se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt()};mraid.addEventListener("ready",t)}}catch(i){console.warn("MRAID hook skipped",i)}}function dr(){if(yn())try{let i=dapi.getScreenSize();be(i.width,i.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?at():De()}),dapi.addEventListener("adResized",t=>{let n=dapi.getScreenSize();be(t.width||n.width,t.height||n.height)});let e=dapi.getAudioVolume();if(Re(e?1:0),dapi.addEventListener("audioVolumeChange",t=>Re(t?1:0)),_t=!0,dapi.isViewable())se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt();else{let t=()=>{se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt()};dapi.addEventListener("ready",t)}}catch(i){console.warn("DAPI hook skipped",i)}}function Gn(){let i=()=>{se||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt(),tt&&(tt=!1,te.start()))};window.addEventListener("resize",()=>be()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(at(),i()):De()}),document.readyState==="complete"||document.readyState==="interactive"?i():window.addEventListener("load",i),_t=!0}function pr(){let i=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(Bn=!0),!(Bn&&e instanceof MouseEvent)&&(Tt+=1,vi||(vi=!0,v("first_interaction",{count:Tt})),v("interaction",Tt))};document.addEventListener("mousedown",i),document.addEventListener("touchstart",i)}function qn(i){var n,a,r,o,s,d,c,u,l,p,g,m;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(n=window.ExitApi)==null||n.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(i||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ke())(r=(a=window.TJ_API)==null?void 0:a.click)==null||r.call(a);else if(vn())(s=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||s.call(o);else if(An())(c=(d=window.ScPlayableAd)==null?void 0:d.onCTAClick)==null||c.call(d);else if(En())try{(l=(u=window.smxTracking)==null?void 0:u.redirect)==null||l.call(u)}catch(f){console.warn("Smadex redirect failed",f)}else if(xn()){let f=window.ExitApi;f&&typeof f.exit=="function"?f.exit(i||Me||""):i&&window.open(i)}else Le()?(p=window.install)==null||p.call(window):wn()?(g=window.openAppStore)==null||g.call(window):Vt()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):i&&window.open(i)}function ur(){let i=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let n=new Image;n.src=t};if(i==="bigabid"){let t=window.BIGABID_BIDTIMEMACROS;if(!t)return;q("view",()=>e(t.mraid_viewable)),q("start",()=>e(t.game_viewable)),q("engagement",()=>e(t.engagement));let n=()=>e(t.complete);q("complete",n),mt("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.count)>3&&n()}),q("cta_click",()=>e(t.click))}else if(i==="inmobi"){let t=window.INMOBI_DSPMACROS;if(!t)return;q("view",()=>e(t.Ad_Load_Start)),q("start",()=>e(t.Ad_Viewable)),q("engagement",()=>e(t.First_Engagement)),q("complete",()=>e(t.Gameplay_Complete)),q("cta_click",()=>e(t.DSP_Click)),q("start",()=>{[5,10,15,20,25,30].forEach(n=>setTimeout(()=>e(t[`Spent_${n}_Seconds`]),n*1e3))})}}function gr(){if(!ke())return;let i=window.TJ_API;i&&i.setPlayableAPI&&i.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function Vn(){var e,t,n;let i=window.TJ_API;(e=i==null?void 0:i.objectiveComplete)==null||e.call(i),(t=i==null?void 0:i.playableFinished)==null||t.call(i),(n=i==null?void 0:i.gameplayFinished)==null||n.call(i)}function hr(){Le()&&(window.mintGameStart=()=>{at(!0),be()},window.mintGameClose=()=>{De(!0)})}function fr(){if(!Wt())return;let i=window.NUC;!i||!i.trigger||(te.on("cta_click",()=>{var e,t;return(t=(e=i.trigger).convert)==null?void 0:t.call(e,Me)}),te.on("complete",()=>{var e,t;return(t=(e=i.trigger).tryAgain)==null?void 0:t.call(e)}))}var te={init(i={},e){var t;if(Kn=i.profile||"web_embed",mi=i.consent||{},Pe={...Wn,...i.ids||{}},Oe=i.rootEl||Oe,et=void 0,Xi((t=i.telemetry)!=null&&t.endpoint?i.telemetry:null),Ae=null,yi=!1,vi=!1,Ct.clear(),Me=i.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Lt=e),v("init"),document.body.oncontextmenu=()=>!1,Un(),br(Oe),Sn(),cr(),dr(),!_t){if(document.readyState==="complete")Gn();else if(!Fn){Fn=!0;let n=()=>{Gn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}pr(),ur(),gr(),hr(),fr(),console.log(`%c @handler/playable-sdk %c v${ui} `,"background: var(--ui-console-info); color: var(--ui-white); font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: var(--ui-console-bg); color: var(--ui-console-text); font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),se&&!oe&&(v("boot"),v("view"),v("ready"),tt&&(tt=!1,te.start()),oe=!0),oe=se},getRoot(){return Un()},get version(){return ui},get maxWidth(){return Ie},get maxHeight(){return je},get isLandscape(){return bi},get isReady(){return oe},get isStarted(){return gi},get isPaused(){return it},get isFinished(){return Qe},get volume(){return xi},get interactions(){return Tt},on(i,e){mt(kt(i),e)},off(i,e){Gt(kt(i),e)},start(){var i,e;if(!gi){if(!se){tt=!0;return}if(gi=!0,Ae||(Ae=Date.now()),v("start"),be(),Le())De(),(i=window.gameReady)==null||i.call(window);else if(ke()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:bi?"landscape":"portrait",buildID:ui})}}},finish(){var i,e;Qe||(Qe=!0,v("complete"),fi("complete"),Le()?(i=window.gameEnd)==null||i.call(window):Vt()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):ke()&&Vn())},install(i){if(!Qe){Qe=!0,ke()?(Vn(),setTimeout(()=>te.install(i),300)):(v("complete"),setTimeout(()=>te.install(i),0));return}hi||(hi=!0,setTimeout(()=>hi=!1,500),v("cta_click"),v("conversion"),fi("cta"),qn(i||Me))},emit(i,e){let t=kt(i);if(!lr.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${i} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let n=Zn(t,e);qt(n,!!mi.analytics),bt(t,n)},gameStart(){te.start()},gameEnd(){te.finish()},ctaClick(i,e){v("cta_click",{url:i||Me,manual:!0}),(e==null?void 0:e.open)!==!1&&qn(i||Me)},ctaShow(i){v("cta_show",i)},ctaDismiss(i){v("cta_dismiss",i)},getGameTimeMs(){return Jn()},endSession(i="manual"){fi(i)},setAttribution(i){et=i},abTest(i,e){if(!i)throw new Error("abTest requires experimentId");if(!Array.isArray(e)||e.length<2)throw new Error("abTest requires at least 2 variants");let t=Math.abs(mr(`${Yn}:${i}`))%e.length,n=e[t];return et={...et||{},experiment_id:i},Pe.variant_id=n,v("ab_assign",{experiment_id:i,variant_id:n}),n},levelStart(i,e){Ae||(Ae=Date.now()),v("level_start",{level_id:i,...e})},levelComplete(i,e){v("level_complete",{level_id:i,...e})},levelFail(i,e){v("level_fail",{level_id:i,...e})},checkpoint(i,e){v("checkpoint",{checkpoint_id:i,...e})},reward(i,e){v("reward",{reward_id:i,...e})},tutorialStart(i,e){v("tutorial_start",{step_id:i,...e})},tutorialComplete(i,e){v("tutorial_complete",{step_id:i,...e})},tutorialSkip(i,e){v("tutorial_skip",{step_id:i,...e})},timerStart(i){i&&Ct.set(i,Date.now())},timerEnd(i,e="custom",t){if(!i)return;let n=Ct.get(i);if(!n)return;Ct.delete(i);let a=Date.now()-n;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){v("engagement",{action:"timer",key:i,duration_ms:a,...t});return}v(e,{key:i,duration_ms:a,...t})}},fps(i,e){v("fps",{value:i,...e})},memory(i,e){v("memory",{bytes:i,...e})},assetLoadStart(i,e){v("asset_load_start",{asset_id:i,...e})},assetLoadComplete(i,e){v("asset_load_complete",{asset_id:i,...e})},reportError(i,e,t){v("error",{code:i,message:e,...t})},retry(){var i,e,t;if(Le())(i=window.gameRetry)==null||i.call(window);else if(Wt()){let n=window.NUC;(t=(e=n==null?void 0:n.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}v("engagement",{action:"retry"})},pause(){De(!0)},resume(){at(!0)},resize(i,e){be(i,e)}},Ze=te;function mr(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function br(i){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
|
|
229
|
+
`,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var n;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(n=this.options)!=null&&n.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,n=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,n-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,n=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,n,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,n,a),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+n-r,t],[e,t+a-r],[e+n-r,t+a-r]].forEach(([s,d])=>{var c;(c=this.ctx)==null||c.fillRect(s,d,r,r)})}updatePreview(){if(!this.modal||!this.image)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let n=150;e.width=n,e.height=n;let a=n/this.cropWidth,r=n/this.cropHeight,o=Math.min(a,r),s=this.cropWidth*o,d=this.cropHeight*o,c=(n-s)/2,u=(n-d)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,c,u,s,d)}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",n=>{let a=parseFloat(n.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",n=>{let a=n.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",n=>{switch(n.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",n=>{n.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,n=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,n=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let n=e.toDataURL("image/png");this.options.onCrop(n),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(i){new di().open(i)};ue();var Je=require("pixi.js");Et();var rr=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",pi=rr;if(typeof window!="undefined")try{let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);e!=null&&e.buildMode&&(pi=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${pi}`))}}catch{}function or(i){var t,n,a,r,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(i);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(i))return{x:(t=i[0])!=null?t:.5,y:(n=i[1])!=null?n:.5};if(i&&typeof i=="object"&&"x"in i&&"y"in i)return{x:(a=i.x)!=null?a:.5,y:(r=i.y)!=null?r:.5};if(typeof i=="string"){let s=i.trim().toLowerCase();return(o=e[s])!=null?o:{x:.5,y:.5}}return null}var me=class{static async create(e,t,n){var d,c,u,l,p,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${pi}`);let a=(d=t==null?void 0:t.render)==null?void 0:d.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let h=new Je.Container;return this.applyTransform(h,t==null?void 0:t.transform,t),h}let r=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${a.type}, path: ${a.path}`);let o=await fe.load(e,a,n,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=o==null?void 0:o.constructor)==null?void 0:u.name}`);let s;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),s=new Je.Sprite(o),console.log("[ObjectFactory] Created object:",s,"type:",(l=s==null?void 0:s.constructor)==null?void 0:l.name),this.applyTransform(s,t==null?void 0:t.transform,t);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(p=o==null?void 0:o.constructor)==null?void 0:p.name,o),o&&(((g=o.constructor)==null?void 0:g.name)==="Container"||o instanceof Je.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],A=!1;for(let b of h)try{let f=await fetch(b);if(f.ok){s=await f.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=s==null?void 0:s.constructor)==null?void 0:m.name),A=!0;break}}catch{continue}A||(console.error("[ObjectFactory] Failed to reload JSON from any path"),s=o)}else s=o;else s=o,s&&typeof s=="object"&&("x"in s||"position"in s)&&this.applyTransform(s,t==null?void 0:t.transform,t);return s}static applyTransform(e,t,n){var a,r,o,s;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(a=t.position.x)!=null?a:0,e.y=(r=t.position.y)!=null?r:0):"position"in e&&e.position&&e.position.set((o=t.position.x)!=null?o:0,(s=t.position.y)!=null?s:0)),t.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(t.scale):e.scale=t.scale),t.rotation!==void 0&&"rotation"in e&&(e.rotation=t.rotation),t.anchor&&"anchor"in e&&e.anchor)){let d=or(t.anchor);d&&("set"in e.anchor?e.anchor.set(d.x,d.y):(e.anchor.x=d.x,e.anchor.y=d.y))}}};ue();var Nn=ht(require("lottie-web"),1);St(Cn);typeof window!="undefined"&&!window.lottie&&(window.lottie=Nn.default);Xt();ue();var ui=rn.version,lr=new Set(["init","boot","view","ready","start","pause","resume","complete","error","engagement","first_interaction","retry","cta_show","cta_click","cta_dismiss","clickout","conversion","session_time","level_time","load_time","level_start","level_complete","level_fail","checkpoint","reward","tutorial_start","tutorial_complete","tutorial_skip","ab_assign","fps","memory","asset_load_start","asset_load_complete"]);an();var Wn={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Yn=Math.random().toString(36).slice(2),Oe=null,Pe={...Wn},Kn="web_embed",mi={},et,gi=!1,Qe=!1,it=!1,Xn=!1,xi=1,Tt=0,_t=!1,oe=!1,Me="",Ie=Math.floor(window.innerWidth),je=Math.floor(window.innerHeight),bi=Ie>je,se=!1,tt=!1,Bn=!1,Fn=!1,fi=!1,Lt=null,Ae=null,yi=!1,vi=!1,Ct=new Map;function Jn(){if(!Ae)return null;let i=Date.now()-Ae;return!Number.isFinite(i)||i<0?null:i}function hi(i){if(yi)return;let e=Jn();e!==null&&(yi=!0,v("session_time",{duration_ms:e,reason:i}))}function Un(){if(Oe)return Oe;let i=document.createElement("div");return i.id="handler-root",i.setAttribute("data-handler-root","true"),document.body.appendChild(i),Oe=i,i}function kt(i){switch(i){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return i}}function Zn(i,e){return{event_name:i,ts:Date.now(),session_id:Yn,deployment_id:Pe.deployment_id,variant_id:Pe.variant_id,export_profile_id:Pe.profile_id,instance_id:Pe.instance_id||"default",env:Kn==="mraid"?"mraid":"web",attribution:et,payload:e}}function v(i,e){let t=kt(i),n=Zn(t,e);qt(n,!!mi.analytics),bt(t,n),t!==i&&bt(i,n)}function nt(){Lt&&(Lt(Ie,je),Lt=null)}function Re(i){xi=i,v("volume",i)}function De(i){i&&(Xn=!0),!it&&(it=!0,v("pause"),Re(0))}function at(i){!i&&Xn||it&&(it=!1,v("resume"),Re(xi))}function be(i,e){Ie=Math.floor(i||window.innerWidth),je=Math.floor(e||window.innerHeight),bi=Ie>je,v("resize",{width:Ie,height:je})}function cr(){if(bn())try{let i=mraid.getMaxSize();be(i.width,i.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?at():De()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let t=mraid.getMaxSize();be(t.width,t.height)}),mraid.getAudioVolume){let t=mraid.getAudioVolume();Re(t?1:0)}if(mraid.addEventListener("audioVolumeChange",t=>{t!==null&&Re(t>0?1:0)}),mraid.addEventListener("error",(t,n)=>{console.warn("mraid error:",t,"action:",n)}),_t=!0,mraid.isViewable()&&mraid.getState()!=="hidden")se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt();else{let t=()=>{se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt()};mraid.addEventListener("ready",t)}}catch(i){console.warn("MRAID hook skipped",i)}}function dr(){if(yn())try{let i=dapi.getScreenSize();be(i.width,i.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?at():De()}),dapi.addEventListener("adResized",t=>{let n=dapi.getScreenSize();be(t.width||n.width,t.height||n.height)});let e=dapi.getAudioVolume();if(Re(e?1:0),dapi.addEventListener("audioVolumeChange",t=>Re(t?1:0)),_t=!0,dapi.isViewable())se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt();else{let t=()=>{se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt()};dapi.addEventListener("ready",t)}}catch(i){console.warn("DAPI hook skipped",i)}}function Gn(){let i=()=>{se||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt(),tt&&(tt=!1,te.start()))};window.addEventListener("resize",()=>be()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(at(),i()):De()}),document.readyState==="complete"||document.readyState==="interactive"?i():window.addEventListener("load",i),_t=!0}function pr(){let i=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(Bn=!0),!(Bn&&e instanceof MouseEvent)&&(Tt+=1,vi||(vi=!0,v("first_interaction",{count:Tt})),v("interaction",Tt))};document.addEventListener("mousedown",i),document.addEventListener("touchstart",i)}function qn(i){var n,a,r,o,s,d,c,u,l,p,g,m;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(n=window.ExitApi)==null||n.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(i||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ke())(r=(a=window.TJ_API)==null?void 0:a.click)==null||r.call(a);else if(vn())(s=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||s.call(o);else if(An())(c=(d=window.ScPlayableAd)==null?void 0:d.onCTAClick)==null||c.call(d);else if(En())try{(l=(u=window.smxTracking)==null?void 0:u.redirect)==null||l.call(u)}catch(h){console.warn("Smadex redirect failed",h)}else if(xn()){let h=window.ExitApi;h&&typeof h.exit=="function"?h.exit(i||Me||""):i&&window.open(i)}else Le()?(p=window.install)==null||p.call(window):wn()?(g=window.openAppStore)==null||g.call(window):Vt()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):i&&window.open(i)}function ur(){let i=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let n=new Image;n.src=t};if(i==="bigabid"){let t=window.BIGABID_BIDTIMEMACROS;if(!t)return;q("view",()=>e(t.mraid_viewable)),q("start",()=>e(t.game_viewable)),q("engagement",()=>e(t.engagement));let n=()=>e(t.complete);q("complete",n),mt("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.count)>3&&n()}),q("cta_click",()=>e(t.click))}else if(i==="inmobi"){let t=window.INMOBI_DSPMACROS;if(!t)return;q("view",()=>e(t.Ad_Load_Start)),q("start",()=>e(t.Ad_Viewable)),q("engagement",()=>e(t.First_Engagement)),q("complete",()=>e(t.Gameplay_Complete)),q("cta_click",()=>e(t.DSP_Click)),q("start",()=>{[5,10,15,20,25,30].forEach(n=>setTimeout(()=>e(t[`Spent_${n}_Seconds`]),n*1e3))})}}function gr(){if(!ke())return;let i=window.TJ_API;i&&i.setPlayableAPI&&i.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function Vn(){var e,t,n;let i=window.TJ_API;(e=i==null?void 0:i.objectiveComplete)==null||e.call(i),(t=i==null?void 0:i.playableFinished)==null||t.call(i),(n=i==null?void 0:i.gameplayFinished)==null||n.call(i)}function fr(){Le()&&(window.mintGameStart=()=>{at(!0),be()},window.mintGameClose=()=>{De(!0)})}function hr(){if(!Wt())return;let i=window.NUC;!i||!i.trigger||(te.on("cta_click",()=>{var e,t;return(t=(e=i.trigger).convert)==null?void 0:t.call(e,Me)}),te.on("complete",()=>{var e,t;return(t=(e=i.trigger).tryAgain)==null?void 0:t.call(e)}))}var te={init(i={},e){var t;if(Kn=i.profile||"web_embed",mi=i.consent||{},Pe={...Wn,...i.ids||{}},Oe=i.rootEl||Oe,et=void 0,Xi((t=i.telemetry)!=null&&t.endpoint?i.telemetry:null),Ae=null,yi=!1,vi=!1,Ct.clear(),Me=i.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Lt=e),v("init"),document.body.oncontextmenu=()=>!1,Un(),br(Oe),Sn(),cr(),dr(),!_t){if(document.readyState==="complete")Gn();else if(!Fn){Fn=!0;let n=()=>{Gn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}pr(),ur(),gr(),fr(),hr(),console.log(`%c @handler/playable-sdk %c v${ui} `,"background: var(--ui-console-info); color: var(--ui-white); font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: var(--ui-console-bg); color: var(--ui-console-text); font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),se&&!oe&&(v("boot"),v("view"),v("ready"),tt&&(tt=!1,te.start()),oe=!0),oe=se},getRoot(){return Un()},get version(){return ui},get maxWidth(){return Ie},get maxHeight(){return je},get isLandscape(){return bi},get isReady(){return oe},get isStarted(){return gi},get isPaused(){return it},get isFinished(){return Qe},get volume(){return xi},get interactions(){return Tt},on(i,e){mt(kt(i),e)},off(i,e){Gt(kt(i),e)},start(){var i,e;if(!gi){if(!se){tt=!0;return}if(gi=!0,Ae||(Ae=Date.now()),v("start"),be(),Le())De(),(i=window.gameReady)==null||i.call(window);else if(ke()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:bi?"landscape":"portrait",buildID:ui})}}},finish(){var i,e;Qe||(Qe=!0,v("complete"),hi("complete"),Le()?(i=window.gameEnd)==null||i.call(window):Vt()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):ke()&&Vn())},install(i){if(!Qe){Qe=!0,ke()?(Vn(),setTimeout(()=>te.install(i),300)):(v("complete"),setTimeout(()=>te.install(i),0));return}fi||(fi=!0,setTimeout(()=>fi=!1,500),v("cta_click"),v("conversion"),hi("cta"),qn(i||Me))},emit(i,e){let t=kt(i);if(!lr.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${i} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let n=Zn(t,e);qt(n,!!mi.analytics),bt(t,n)},gameStart(){te.start()},gameEnd(){te.finish()},ctaClick(i,e){v("cta_click",{url:i||Me,manual:!0}),(e==null?void 0:e.open)!==!1&&qn(i||Me)},ctaShow(i){v("cta_show",i)},ctaDismiss(i){v("cta_dismiss",i)},getGameTimeMs(){return Jn()},endSession(i="manual"){hi(i)},setAttribution(i){et=i},abTest(i,e){if(!i)throw new Error("abTest requires experimentId");if(!Array.isArray(e)||e.length<2)throw new Error("abTest requires at least 2 variants");let t=Math.abs(mr(`${Yn}:${i}`))%e.length,n=e[t];return et={...et||{},experiment_id:i},Pe.variant_id=n,v("ab_assign",{experiment_id:i,variant_id:n}),n},levelStart(i,e){Ae||(Ae=Date.now()),v("level_start",{level_id:i,...e})},levelComplete(i,e){v("level_complete",{level_id:i,...e})},levelFail(i,e){v("level_fail",{level_id:i,...e})},checkpoint(i,e){v("checkpoint",{checkpoint_id:i,...e})},reward(i,e){v("reward",{reward_id:i,...e})},tutorialStart(i,e){v("tutorial_start",{step_id:i,...e})},tutorialComplete(i,e){v("tutorial_complete",{step_id:i,...e})},tutorialSkip(i,e){v("tutorial_skip",{step_id:i,...e})},timerStart(i){i&&Ct.set(i,Date.now())},timerEnd(i,e="custom",t){if(!i)return;let n=Ct.get(i);if(!n)return;Ct.delete(i);let a=Date.now()-n;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){v("engagement",{action:"timer",key:i,duration_ms:a,...t});return}v(e,{key:i,duration_ms:a,...t})}},fps(i,e){v("fps",{value:i,...e})},memory(i,e){v("memory",{bytes:i,...e})},assetLoadStart(i,e){v("asset_load_start",{asset_id:i,...e})},assetLoadComplete(i,e){v("asset_load_complete",{asset_id:i,...e})},reportError(i,e,t){v("error",{code:i,message:e,...t})},retry(){var i,e,t;if(Le())(i=window.gameRetry)==null||i.call(window);else if(Wt()){let n=window.NUC;(t=(e=n==null?void 0:n.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}v("engagement",{action:"retry"})},pause(){De(!0)},resume(){at(!0)},resize(i,e){be(i,e)}},Ze=te;function mr(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function br(i){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
|
|
230
230
|
(function(){
|
|
231
231
|
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
232
232
|
function unlock(){
|
|
@@ -242,14 +242,14 @@ Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
242
242
|
}
|
|
243
243
|
events.forEach(function(e){ document.addEventListener(e, unlock, false); });
|
|
244
244
|
})();
|
|
245
|
-
`,i.appendChild(e)}async function Pt(i,e={}){let t=new Qn.Application;await t.init({resizeTo:i,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let n=o=>{var l,p,g,m;if(!t.renderer)return;let s=(l=o==null?void 0:o.width)!=null?l:i.clientWidth,d=(p=o==null?void 0:o.height)!=null?p:i.clientHeight,c=s&&s>0?s:(g=window.innerWidth)!=null?g:320,u=d&&d>0?d:(m=window.innerHeight)!=null?m:480;t.renderer.resize(c,u)};i.appendChild(t.canvas),i.style.position="relative",i.style.display="flex",i.style.flexDirection="column",i.style.alignItems="stretch",i.style.width="100%",i.style.height="100dvh",i.style.minHeight="100vh",i.style.maxWidth="100%",i.style.maxHeight="100%",i.style.boxSizing="border-box",i.style.overflow="hidden",e.background&&(i.style.background=e.background),n();let a=document.createElement("div");return a.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),i.appendChild(a),Ze.on("pause",()=>{t.ticker.stop(),document.querySelectorAll("audio").forEach(s=>s.pause())}),Ze.on("resume",()=>{t.ticker.start(),document.querySelectorAll("audio").forEach(s=>{s.currentTime>0&&!s.ended&&s.play().catch(()=>{})})}),Ze.on("resize",({payload:o})=>{n({width:o==null?void 0:o.width,height:o==null?void 0:o.height})}),window.addEventListener("resize",()=>n()),requestAnimationFrame(()=>n()),new ResizeObserver(o=>{let s=o[0];if(s&&s.contentRect.width>0&&s.contentRect.height>0){let d=Math.round(s.contentRect.width),c=Math.round(s.contentRect.height);if(n({width:d,height:c}),typeof window!="undefined"&&window.gameApp&&window.gameObjectManager){let u={width:d,height:c,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:"auto-resize",isLandscape:d>c};window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:u}))}}}).observe(i),{app:t,stage:t.stage,overlay:a,applySize:n}}var U=require("pixi.js"),rt=class{constructor(e){var a,r;let t=e==null?void 0:e.position,n=e==null?void 0:e.offset;this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0},this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0},this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y},this.scale=(a=e==null?void 0:e.scale)!=null?a:1,this.rotation=(r=e==null?void 0:e.rotation)!=null?r:0}update(e){let t=e.position,n=e.offset;t!==void 0&&(this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0}),n!==void 0&&(this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0}),(t!==void 0||n!==void 0)&&(this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y}),e.scale!==void 0&&(this.scale=e.scale),e.rotation!==void 0&&(this.rotation=e.rotation)}syncToPixi(e){e&&(e.position.set(this.position.x,this.position.y),e.scale.set(this.scale),e.rotation=this.rotation)}},ot=class{constructor(e){var t,n,a,r;this.z_index=(t=e==null?void 0:e.z_index)!=null?t:0,this.alpha=(n=e==null?void 0:e.alpha)!=null?n:1,this.visible=(a=e==null?void 0:e.visible)!=null?a:!0,this.tint=(r=e==null?void 0:e.tint)!=null?r:null}update(e){e.z_index!==void 0&&(this.z_index=e.z_index),e.alpha!==void 0&&(this.alpha=e.alpha),e.visible!==void 0&&(this.visible=e.visible),e.tint!==void 0&&(this.tint=e.tint)}syncToPixi(e,t){if(!e)return;if(e.zIndex=this.z_index,t!=null&&t.startsWith("ui_endgame_")||(e.alpha=this.alpha),e.visible=this.visible,this.tint!==null&&"tint"in e&&(e.tint=this.tint),t&&"texture"in e)try{let{AssetTextures:a}=require("handler-playable-sdk/pixi");if(a&&a[t]){let r=a[t];r&&(e.texture=r)}}catch{}}},st=class{constructor(e,t,n,a){this._tickerCleanup=null;this.onRebuildRequired=null;this.instanceId=e,this.objectConfig=t,this.pixiObject=n,this._config=a,this.transform=new rt(a.transform),this.renderer=new ot(a.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject,this.instanceId),this.applyAnchor(),this.applyEffectsScale(),this.applyEffects(),this.syncTextProperties(),(!this._initialized||this._shouldReplayIntro)&&(this.applyIntro(),this._initialized=!0,this._shouldReplayIntro=!1),this.applyMotion()}syncTextProperties(){var t;if(!this.pixiObject||!("text"in this.pixiObject))return;let e=(t=this._config)==null?void 0:t.ui;e&&(e.text!==void 0&&this.pixiObject.text!==e.text&&(this.pixiObject.text=e.text),this.pixiObject.style&&(e.fontSize!==void 0&&(this.pixiObject.style.fontSize=e.fontSize),e.color!==void 0&&(this.pixiObject.style.fill=e.color),e.align!==void 0&&(this.pixiObject.style.align=e.align)))}destroy(){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null),this._introTicker&&(U.Ticker.shared.remove(this._introTicker),this._introTicker=null),this.pixiObject&&this.pixiObject.parent&&this.pixiObject.parent.removeChild(this.pixiObject)}updateConfig(e){var d,c,u,l,p,g,m,f,A,b,h;let t=(c=(d=this._config)==null?void 0:d.motion)==null?void 0:c.intro,n=(u=e==null?void 0:e.motion)==null?void 0:u.intro;n!=null&&n.enabled&&JSON.stringify(t)!==JSON.stringify(n)&&(this._shouldReplayIntro=!0);let a=(g=(p=(l=this._config)==null?void 0:l.render)==null?void 0:p.asset)==null?void 0:g.type,r=(f=(m=e==null?void 0:e.render)==null?void 0:m.asset)==null?void 0:f.type,o=(b=(A=this._config)==null?void 0:A.ui)==null?void 0:b.renderMode,s=(h=e==null?void 0:e.ui)==null?void 0:h.renderMode;if((a!==r||o!==s)&&(console.log(`[GameObject] Rebuild required for ${this.instanceId}: type changed from ${a}/${o} to ${r}/${s}`),this.onRebuildRequired)){this.onRebuildRequired(this,e);return}this._config=e,e.transform&&this.transform.update(e.transform),e.render&&this.renderer.update(e.render),this.sync()}applyAnchor(){var a,r,o,s;if(!this.pixiObject||!("anchor"in this.pixiObject)||!this.pixiObject.anchor)return;let e=(r=(a=this._config)==null?void 0:a.render)==null?void 0:r.anchor,t=(s=(o=this._config)==null?void 0:o.transform)==null?void 0:s.anchor,n=e&&typeof e=="object"?e:t&&typeof t=="object"?t:null;n&&typeof n.x=="number"&&typeof n.y=="number"&&this.pixiObject.anchor.set(n.x,n.y)}applyEffectsScale(){var r,o,s;if(!((r=this.pixiObject)!=null&&r.scale))return;let e=(o=this._config)==null?void 0:o.effects,t=typeof(e==null?void 0:e.scale_x)=="number"?e.scale_x:1,n=typeof(e==null?void 0:e.scale_y)=="number"?e.scale_y:1;if(t===1&&n===1)return;let a=(s=this.transform.scale)!=null?s:1;typeof this.pixiObject.scale.set=="function"?this.pixiObject.scale.set(a*t,a*n):(this.pixiObject.scale.x=a*t,this.pixiObject.scale.y=a*n)}applyEffects(){var n,a,r,o,s,d,c,u,l;if(!this.pixiObject)return;let e=(n=this._config)==null?void 0:n.effects;if(!e||e.enabled===!1){this.pixiObject.filters=null;return}let t=[];if((a=e.blur)!=null&&a.enabled){let p=new U.BlurFilter;p.blur=(r=e.blur.strength)!=null?r:4,t.push(p)}if((o=e.shadow)!=null&&o.enabled){let p=e.shadow,g=new U.BlurFilter;g.blur=(s=p.blur)!=null?s:4,g.blendMode="multiply",t.push(g),(p.offsetX!==0||p.offsetY!==0)&&console.warn("[Effects] Drop shadow offset requires pixi-filters. Install: npm install pixi-filters")}if((d=e.glow)!=null&&d.enabled){let p=e.glow,g=new U.BlurFilter;if(g.blur=(c=p.blur)!=null?c:8,t.push(g),p.color){let m=new U.ColorMatrixFilter,f=typeof p.color=="string"?parseInt(p.color.replace("#",""),16):p.color;m.tint(f),t.push(m)}}(u=e.stroke)!=null&&u.enabled&&console.warn("[Effects] Stroke/outline effect requires pixi-filters. Install: npm install pixi-filters"),(l=e.distortion)!=null&&l.enabled&&console.warn("[Effects] Distortion effect requires pixi-filters or a displacement map. Install: npm install pixi-filters"),this.pixiObject.filters=t.length>0?t:null}applyIntro(){var u,l,p,g,m,f,A;let e=(u=this._config)==null?void 0:u.motion;if(!e||!((l=e.intro)!=null&&l.enabled)||!this.pixiObject)return;let t=e.intro,n=(t.duration||0)/1e3,a=(t.delay||0)/1e3,r=this.transform.position.y,o=this.transform.scale*(((g=(p=this._config)==null?void 0:p.effects)==null?void 0:g.scale_x)||1),s=this.transform.scale*(((f=(m=this._config)==null?void 0:m.effects)==null?void 0:f.scale_y)||1);if(this.pixiObject.alpha=(A=t.startAlpha)!=null?A:0,t.startScale!==void 0&&this.pixiObject.scale.set(o*t.startScale,s*t.startScale),t.startYOffset!==void 0&&(this.pixiObject.y=r+(t.startYOffset||0)),this._introTicker&&U.Ticker.shared.remove(this._introTicker),n<=0&&a<=0){this.pixiObject.alpha=this.renderer.alpha,this.pixiObject.y=this.transform.position.y,this.pixiObject.scale.set(o,s);return}let d=0,c=b=>{var z,N,j,C,E,S;if(d+=b.deltaTime/60,d<a)return;let h=n>0?Math.min(1,(d-a)/n):1,x=1-Math.pow(1-h,3),w=this.renderer.alpha,y=this.transform.scale*(((N=(z=this._config)==null?void 0:z.effects)==null?void 0:N.scale_x)||1),I=this.transform.scale*(((C=(j=this._config)==null?void 0:j.effects)==null?void 0:C.scale_y)||1),R=this.transform.position.y,H=this.transform.position.x;if(this.pixiObject.alpha=((E=t.startAlpha)!=null?E:0)+(w-((S=t.startAlpha)!=null?S:0))*x,t.startScale!==void 0){let T=t.startScale+(1-t.startScale)*x;this.pixiObject.scale.set(y*T,I*T)}t.startYOffset!==void 0&&(this.pixiObject.y=R+t.startYOffset+(R-(R+t.startYOffset))*x),h>=1&&(U.Ticker.shared.remove(c),this._introTicker=null,this.pixiObject.alpha=w,this.pixiObject.x=H,this.pixiObject.y=R,this.pixiObject.scale.set(y,I))};this._introTicker=c,U.Ticker.shared.add(c)}applyMotion(){var a,r,o;let e=(a=this._config)==null?void 0:a.motion,t=e&&e.enabled!==!1,n=JSON.stringify(e);if(!(this._lastMotionStr===n&&this._tickerCleanup)){if(this._lastMotionStr=n,!t){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null);return}if(this._tickerCleanup&&this._tickerCleanup(),(r=e.pulse)!=null&&r.enabled||(o=e.swing)!=null&&o.enabled){let s=0,d=c=>{var f,A,b,h,x,w,y,I,R,H,z;s+=c.deltaTime*.05;let u=this.transform.scale,l=u*(((A=(f=this._config)==null?void 0:f.effects)==null?void 0:A.scale_x)||1),p=u*(((h=(b=this._config)==null?void 0:b.effects)==null?void 0:h.scale_y)||1),g=this.transform.position.x,m=this.transform.position.y;if((x=e.pulse)!=null&&x.enabled){let N=(w=e.pulse.intensity)!=null?w:.1,j=(y=e.pulse.speed)!=null?y:1,E=1+Math.sin(s*j)*N;(I=this.pixiObject.scale)!=null&&I.set?this.pixiObject.scale.set(l*E,p*E):this.pixiObject.scale&&(this.pixiObject.scale.x=l*E,this.pixiObject.scale.y=p*E)}if((R=e.swing)!=null&&R.enabled){let N=(H=e.swing.amplitude)!=null?H:10,j=(z=e.swing.speed)!=null?z:1,C=Math.sin(s*j)*N;e.swing.axis==="vertical"?this.pixiObject.y=m+C:e.swing.axis==="both"?(this.pixiObject.x=g+C,this.pixiObject.y=m+C):this.pixiObject.x=g+C}};U.Ticker.shared.add(d),this._tickerCleanup=()=>{var c,u,l,p,g;if(U.Ticker.shared.remove(d),this.pixiObject){let m=this.transform.scale*(((u=(c=this._config)==null?void 0:c.effects)==null?void 0:u.scale_x)||1),f=this.transform.scale*(((p=(l=this._config)==null?void 0:l.effects)==null?void 0:p.scale_y)||1);this.pixiObject.x=this.transform.position.x,this.pixiObject.y=this.transform.position.y,(g=this.pixiObject.scale)!=null&&g.set?this.pixiObject.scale.set(m,f):this.pixiObject.scale&&(this.pixiObject.scale.x=m,this.pixiObject.scale.y=f)}}}}}getComponent(e){return this._config[e]}getPosition(){return{...this.transform.position}}setPosition(e,t){this.transform.position={x:e,y:t},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(e){this.renderer.alpha=e,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(e){this.renderer.visible=e,this.renderer.syncToPixi(this.pixiObject)}},$e=class{constructor(e){this.objects=new Map;this.onObjectRebuildRequired=null;this.config=e}create(e,t){let n=this.config.objects.get(e);if(!n)throw new Error(`Object config not found: ${e}`);let a=new st(e,n.object_config||e,t,n);return this.objects.set(e,a),a.onRebuildRequired=async(r,o)=>{if(this.onObjectRebuildRequired){console.log(`[GameObjectManager] Triggering rebuild for ${e}`);let s=await this.onObjectRebuildRequired(e,o);s&&this.objects.get(e)===s&&console.log(`[GameObjectManager] \u2705 Rebuilt ${e} successfully`)}else console.warn(`[GameObjectManager] Rebuild required for ${e} but no factory provided`),r.updateConfig(o)},a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[t,n]of this.objects.entries()){let a=e.objects.get(t);a&&n.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(e){let t=this.objects.get(e);t&&t.destroy(),this.objects.delete(e)}clear(){for(let e of this.objects.values())e.destroy();this.objects.clear()}};var Mt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function ea(i){let e=Mt[i];return e?e.family:(console.warn(`Font ID "${i}" not found in registry, using fallback`),"Arial, sans-serif")}function ta(i){var t;let e=Mt[i];return e&&(t=e.weight)!=null?t:"400"}function ia(i,e){Mt[i]=e}function na(){return Object.keys(Mt)}var ze=null;function yr(){return console.log("[LottieOverlay] getLottie called, lottieLib cached?",!!ze),console.log("[LottieOverlay] window.lottie exists?",typeof window!="undefined"&&!!window.lottie),ze||(typeof window!="undefined"&&window.lottie?(ze=window.lottie,console.log("[LottieOverlay] \u2705 Found window.lottie, cached it")):(console.warn("[LottieOverlay] \u274C lottie-web is not available globally. Make sure it is loaded before using Lottie animations."),console.log("[LottieOverlay] window keys:",typeof window!="undefined"?Object.keys(window).filter(i=>i.toLowerCase().includes("lottie")):"no window"),ze=null)),ze}function vr(i){return!i||i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`}function xr(i){try{let e=new XMLHttpRequest;return e.open("GET",vr(i),!1),e.send(null),e.status<200||e.status>=300||!e.responseText?null:JSON.parse(e.responseText)}catch{return null}}function aa(i){return!i||typeof i!="object"||!Array.isArray(i.layers)?null:(Array.isArray(i.assets)||(i.assets=[]),Array.isArray(i.chars)||(i.chars=[]),i)}function St(i){ze=i}function ra(i,e,t,n){var I,R,H,z,N,j,C,E,S,T,k,X,ye,Ue,Ge,qe,Ve,We,Ye;let a=t.objects.get(i);if(!a)return console.warn(`[LottieOverlay] Object config not found: ${i}`),null;let r=((I=a.effects)==null?void 0:I.lottie)||{},o=a.transform||{},s=a.render||{};if(r.enabled===!1||s.visible===!1)return null;let d=n==null?void 0:n[i],c=aa(d);if(!c){let J=(H=(R=a.render)==null?void 0:R.asset)==null?void 0:H.path;if(typeof J=="string"&&J.toLowerCase().endsWith(".json")){let dt=xr(J);if(c=aa(dt),c)try{n[i]=c}catch{}}}if(!c){let J=d&&typeof d=="object"?Object.prototype.toString.call(d):typeof d;return console.warn(`[LottieOverlay] Lottie JSON invalid for: ${i}`,{kind:J}),null}let u=yr();if(!u)return console.warn(`[LottieOverlay] lottie-web is not available. Cannot play animation: ${i}`),null;let l=(z=r.width)!=null?z:300,p=(N=r.height)!=null?N:300,g=(j=o.scale)!=null?j:1,m=((E=(C=o.position)==null?void 0:C.x)!=null?E:0)+((T=(S=o.offset)==null?void 0:S.x)!=null?T:0),f=((X=(k=o.position)==null?void 0:k.y)!=null?X:0)+((Ue=(ye=o.offset)==null?void 0:ye.y)!=null?Ue:0),A=(Ge=o.rotation)!=null?Ge:0,b=(qe=s.z_index)!=null?qe:100,h=(Ve=s.alpha)!=null?Ve:1,x=document.createElement("div");x.style.cssText=`
|
|
245
|
+
`,i.appendChild(e)}async function Pt(i,e={}){let t=new Qn.Application;await t.init({resizeTo:i,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let n=o=>{var l,p,g,m;if(!t.renderer)return;let s=(l=o==null?void 0:o.width)!=null?l:i.clientWidth,d=(p=o==null?void 0:o.height)!=null?p:i.clientHeight,c=s&&s>0?s:(g=window.innerWidth)!=null?g:320,u=d&&d>0?d:(m=window.innerHeight)!=null?m:480;t.renderer.resize(c,u)};i.appendChild(t.canvas),i.style.position="relative",i.style.display="flex",i.style.flexDirection="column",i.style.alignItems="stretch",i.style.width="100%",i.style.height="100dvh",i.style.minHeight="100vh",i.style.maxWidth="100%",i.style.maxHeight="100%",i.style.boxSizing="border-box",i.style.overflow="hidden",e.background&&(i.style.background=e.background),n();let a=document.createElement("div");return a.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),i.appendChild(a),Ze.on("pause",()=>{t.ticker.stop(),document.querySelectorAll("audio").forEach(s=>s.pause())}),Ze.on("resume",()=>{t.ticker.start(),document.querySelectorAll("audio").forEach(s=>{s.currentTime>0&&!s.ended&&s.play().catch(()=>{})})}),Ze.on("resize",({payload:o})=>{n({width:o==null?void 0:o.width,height:o==null?void 0:o.height})}),window.addEventListener("resize",()=>n()),requestAnimationFrame(()=>n()),new ResizeObserver(o=>{let s=o[0];if(s&&s.contentRect.width>0&&s.contentRect.height>0){let d=Math.round(s.contentRect.width),c=Math.round(s.contentRect.height);if(n({width:d,height:c}),typeof window!="undefined"&&window.gameApp&&window.gameObjectManager){let u={width:d,height:c,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:"auto-resize",isLandscape:d>c};window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:u}))}}}).observe(i),{app:t,stage:t.stage,overlay:a,applySize:n}}var U=require("pixi.js"),rt=class{constructor(e){var a,r;let t=e==null?void 0:e.position,n=e==null?void 0:e.offset;this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0},this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0},this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y},this.scale=(a=e==null?void 0:e.scale)!=null?a:1,this.rotation=(r=e==null?void 0:e.rotation)!=null?r:0}update(e){let t=e.position,n=e.offset;t!==void 0&&(this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0}),n!==void 0&&(this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0}),(t!==void 0||n!==void 0)&&(this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y}),e.scale!==void 0&&(this.scale=e.scale),e.rotation!==void 0&&(this.rotation=e.rotation)}syncToPixi(e){e&&(e.position.set(this.position.x,this.position.y),e.scale.set(this.scale),e.rotation=this.rotation)}},ot=class{constructor(e){var t,n,a,r;this.z_index=(t=e==null?void 0:e.z_index)!=null?t:0,this.alpha=(n=e==null?void 0:e.alpha)!=null?n:1,this.visible=(a=e==null?void 0:e.visible)!=null?a:!0,this.tint=(r=e==null?void 0:e.tint)!=null?r:null}update(e){e.z_index!==void 0&&(this.z_index=e.z_index),e.alpha!==void 0&&(this.alpha=e.alpha),e.visible!==void 0&&(this.visible=e.visible),e.tint!==void 0&&(this.tint=e.tint)}syncToPixi(e,t){if(!e)return;if(e.zIndex=this.z_index,t!=null&&t.startsWith("ui_endgame_")||(e.alpha=this.alpha),e.visible=this.visible,this.tint!==null&&"tint"in e&&(e.tint=this.tint),t&&"texture"in e)try{let{AssetTextures:a}=require("handler-playable-sdk/pixi");if(a&&a[t]){let r=a[t];r&&(e.texture=r)}}catch{}}},st=class{constructor(e,t,n,a){this._tickerCleanup=null;this.onRebuildRequired=null;this.instanceId=e,this.objectConfig=t,this.pixiObject=n,this._config=a,this.transform=new rt(a.transform),this.renderer=new ot(a.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject,this.instanceId),this.applyAnchor(),this.applyEffectsScale(),this.applyEffects(),this.syncTextProperties(),(!this._initialized||this._shouldReplayIntro)&&(this.applyIntro(),this._initialized=!0,this._shouldReplayIntro=!1),this.applyMotion()}syncTextProperties(){var t;if(!this.pixiObject||!("text"in this.pixiObject))return;let e=(t=this._config)==null?void 0:t.ui;e&&(e.text!==void 0&&this.pixiObject.text!==e.text&&(this.pixiObject.text=e.text),this.pixiObject.style&&(e.fontSize!==void 0&&(this.pixiObject.style.fontSize=e.fontSize),e.color!==void 0&&(this.pixiObject.style.fill=e.color),e.align!==void 0&&(this.pixiObject.style.align=e.align)))}destroy(){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null),this._introTicker&&(U.Ticker.shared.remove(this._introTicker),this._introTicker=null),this.pixiObject&&this.pixiObject.parent&&this.pixiObject.parent.removeChild(this.pixiObject)}updateConfig(e){var d,c,u,l,p,g,m,h,A,b,f;let t=(c=(d=this._config)==null?void 0:d.motion)==null?void 0:c.intro,n=(u=e==null?void 0:e.motion)==null?void 0:u.intro;n!=null&&n.enabled&&JSON.stringify(t)!==JSON.stringify(n)&&(this._shouldReplayIntro=!0);let a=(g=(p=(l=this._config)==null?void 0:l.render)==null?void 0:p.asset)==null?void 0:g.type,r=(h=(m=e==null?void 0:e.render)==null?void 0:m.asset)==null?void 0:h.type,o=(b=(A=this._config)==null?void 0:A.ui)==null?void 0:b.renderMode,s=(f=e==null?void 0:e.ui)==null?void 0:f.renderMode;if((a!==r||o!==s)&&(console.log(`[GameObject] Rebuild required for ${this.instanceId}: type changed from ${a}/${o} to ${r}/${s}`),this.onRebuildRequired)){this.onRebuildRequired(this,e);return}this._config=e,e.transform&&this.transform.update(e.transform),e.render&&this.renderer.update(e.render),this.sync()}applyAnchor(){var a,r,o,s;if(!this.pixiObject||!("anchor"in this.pixiObject)||!this.pixiObject.anchor)return;let e=(r=(a=this._config)==null?void 0:a.render)==null?void 0:r.anchor,t=(s=(o=this._config)==null?void 0:o.transform)==null?void 0:s.anchor,n=e&&typeof e=="object"?e:t&&typeof t=="object"?t:null;n&&typeof n.x=="number"&&typeof n.y=="number"&&this.pixiObject.anchor.set(n.x,n.y)}applyEffectsScale(){var r,o,s;if(!((r=this.pixiObject)!=null&&r.scale))return;let e=(o=this._config)==null?void 0:o.effects,t=typeof(e==null?void 0:e.scale_x)=="number"?e.scale_x:1,n=typeof(e==null?void 0:e.scale_y)=="number"?e.scale_y:1;if(t===1&&n===1)return;let a=(s=this.transform.scale)!=null?s:1;typeof this.pixiObject.scale.set=="function"?this.pixiObject.scale.set(a*t,a*n):(this.pixiObject.scale.x=a*t,this.pixiObject.scale.y=a*n)}applyEffects(){var n,a,r,o,s,d,c,u,l;if(!this.pixiObject)return;let e=(n=this._config)==null?void 0:n.effects;if(!e||e.enabled===!1){this.pixiObject.filters=null;return}let t=[];if((a=e.blur)!=null&&a.enabled){let p=new U.BlurFilter;p.blur=(r=e.blur.strength)!=null?r:4,t.push(p)}if((o=e.shadow)!=null&&o.enabled){let p=e.shadow,g=new U.BlurFilter;g.blur=(s=p.blur)!=null?s:4,g.blendMode="multiply",t.push(g),(p.offsetX!==0||p.offsetY!==0)&&console.warn("[Effects] Drop shadow offset requires pixi-filters. Install: npm install pixi-filters")}if((d=e.glow)!=null&&d.enabled){let p=e.glow,g=new U.BlurFilter;if(g.blur=(c=p.blur)!=null?c:8,t.push(g),p.color){let m=new U.ColorMatrixFilter,h=typeof p.color=="string"?parseInt(p.color.replace("#",""),16):p.color;m.tint(h),t.push(m)}}(u=e.stroke)!=null&&u.enabled&&console.warn("[Effects] Stroke/outline effect requires pixi-filters. Install: npm install pixi-filters"),(l=e.distortion)!=null&&l.enabled&&console.warn("[Effects] Distortion effect requires pixi-filters or a displacement map. Install: npm install pixi-filters"),this.pixiObject.filters=t.length>0?t:null}applyIntro(){var u,l,p,g,m,h,A;let e=(u=this._config)==null?void 0:u.motion;if(!e||!((l=e.intro)!=null&&l.enabled)||!this.pixiObject)return;let t=e.intro,n=(t.duration||0)/1e3,a=(t.delay||0)/1e3,r=this.transform.position.y,o=this.transform.scale*(((g=(p=this._config)==null?void 0:p.effects)==null?void 0:g.scale_x)||1),s=this.transform.scale*(((h=(m=this._config)==null?void 0:m.effects)==null?void 0:h.scale_y)||1);if(this.pixiObject.alpha=(A=t.startAlpha)!=null?A:0,t.startScale!==void 0&&this.pixiObject.scale.set(o*t.startScale,s*t.startScale),t.startYOffset!==void 0&&(this.pixiObject.y=r+(t.startYOffset||0)),this._introTicker&&U.Ticker.shared.remove(this._introTicker),n<=0&&a<=0){this.pixiObject.alpha=this.renderer.alpha,this.pixiObject.y=this.transform.position.y,this.pixiObject.scale.set(o,s);return}let d=0,c=b=>{var z,N,j,C,E,S;if(d+=b.deltaTime/60,d<a)return;let f=n>0?Math.min(1,(d-a)/n):1,x=1-Math.pow(1-f,3),w=this.renderer.alpha,y=this.transform.scale*(((N=(z=this._config)==null?void 0:z.effects)==null?void 0:N.scale_x)||1),I=this.transform.scale*(((C=(j=this._config)==null?void 0:j.effects)==null?void 0:C.scale_y)||1),R=this.transform.position.y,H=this.transform.position.x;if(this.pixiObject.alpha=((E=t.startAlpha)!=null?E:0)+(w-((S=t.startAlpha)!=null?S:0))*x,t.startScale!==void 0){let T=t.startScale+(1-t.startScale)*x;this.pixiObject.scale.set(y*T,I*T)}t.startYOffset!==void 0&&(this.pixiObject.y=R+t.startYOffset+(R-(R+t.startYOffset))*x),f>=1&&(U.Ticker.shared.remove(c),this._introTicker=null,this.pixiObject.alpha=w,this.pixiObject.x=H,this.pixiObject.y=R,this.pixiObject.scale.set(y,I))};this._introTicker=c,U.Ticker.shared.add(c)}applyMotion(){var a,r,o;let e=(a=this._config)==null?void 0:a.motion,t=e&&e.enabled!==!1,n=JSON.stringify(e);if(!(this._lastMotionStr===n&&this._tickerCleanup)){if(this._lastMotionStr=n,!t){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null);return}if(this._tickerCleanup&&this._tickerCleanup(),(r=e.pulse)!=null&&r.enabled||(o=e.swing)!=null&&o.enabled){let s=0,d=c=>{var h,A,b,f,x,w,y,I,R,H,z;s+=c.deltaTime*.05;let u=this.transform.scale,l=u*(((A=(h=this._config)==null?void 0:h.effects)==null?void 0:A.scale_x)||1),p=u*(((f=(b=this._config)==null?void 0:b.effects)==null?void 0:f.scale_y)||1),g=this.transform.position.x,m=this.transform.position.y;if((x=e.pulse)!=null&&x.enabled){let N=(w=e.pulse.intensity)!=null?w:.1,j=(y=e.pulse.speed)!=null?y:1,E=1+Math.sin(s*j)*N;(I=this.pixiObject.scale)!=null&&I.set?this.pixiObject.scale.set(l*E,p*E):this.pixiObject.scale&&(this.pixiObject.scale.x=l*E,this.pixiObject.scale.y=p*E)}if((R=e.swing)!=null&&R.enabled){let N=(H=e.swing.amplitude)!=null?H:10,j=(z=e.swing.speed)!=null?z:1,C=Math.sin(s*j)*N;e.swing.axis==="vertical"?this.pixiObject.y=m+C:e.swing.axis==="both"?(this.pixiObject.x=g+C,this.pixiObject.y=m+C):this.pixiObject.x=g+C}};U.Ticker.shared.add(d),this._tickerCleanup=()=>{var c,u,l,p,g;if(U.Ticker.shared.remove(d),this.pixiObject){let m=this.transform.scale*(((u=(c=this._config)==null?void 0:c.effects)==null?void 0:u.scale_x)||1),h=this.transform.scale*(((p=(l=this._config)==null?void 0:l.effects)==null?void 0:p.scale_y)||1);this.pixiObject.x=this.transform.position.x,this.pixiObject.y=this.transform.position.y,(g=this.pixiObject.scale)!=null&&g.set?this.pixiObject.scale.set(m,h):this.pixiObject.scale&&(this.pixiObject.scale.x=m,this.pixiObject.scale.y=h)}}}}}getComponent(e){return this._config[e]}getPosition(){return{...this.transform.position}}setPosition(e,t){this.transform.position={x:e,y:t},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(e){this.renderer.alpha=e,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(e){this.renderer.visible=e,this.renderer.syncToPixi(this.pixiObject)}},$e=class{constructor(e){this.objects=new Map;this.onObjectRebuildRequired=null;this.config=e}create(e,t){let n=this.config.objects.get(e);if(!n)throw new Error(`Object config not found: ${e}`);let a=new st(e,n.object_config||e,t,n);return this.objects.set(e,a),a.onRebuildRequired=async(r,o)=>{if(this.onObjectRebuildRequired){console.log(`[GameObjectManager] Triggering rebuild for ${e}`);let s=await this.onObjectRebuildRequired(e,o);s&&this.objects.get(e)===s&&console.log(`[GameObjectManager] \u2705 Rebuilt ${e} successfully`)}else console.warn(`[GameObjectManager] Rebuild required for ${e} but no factory provided`),r.updateConfig(o)},a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[t,n]of this.objects.entries()){let a=e.objects.get(t);a&&n.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(e){let t=this.objects.get(e);t&&t.destroy(),this.objects.delete(e)}clear(){for(let e of this.objects.values())e.destroy();this.objects.clear()}};var Mt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function ea(i){let e=Mt[i];return e?e.family:(console.warn(`Font ID "${i}" not found in registry, using fallback`),"Arial, sans-serif")}function ta(i){var t;let e=Mt[i];return e&&(t=e.weight)!=null?t:"400"}function ia(i,e){Mt[i]=e}function na(){return Object.keys(Mt)}var ze=null;function yr(){return console.log("[LottieOverlay] getLottie called, lottieLib cached?",!!ze),console.log("[LottieOverlay] window.lottie exists?",typeof window!="undefined"&&!!window.lottie),ze||(typeof window!="undefined"&&window.lottie?(ze=window.lottie,console.log("[LottieOverlay] \u2705 Found window.lottie, cached it")):(console.warn("[LottieOverlay] \u274C lottie-web is not available globally. Make sure it is loaded before using Lottie animations."),console.log("[LottieOverlay] window keys:",typeof window!="undefined"?Object.keys(window).filter(i=>i.toLowerCase().includes("lottie")):"no window"),ze=null)),ze}function vr(i){return!i||i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`}function xr(i){try{let e=new XMLHttpRequest;return e.open("GET",vr(i),!1),e.send(null),e.status<200||e.status>=300||!e.responseText?null:JSON.parse(e.responseText)}catch{return null}}function aa(i){return!i||typeof i!="object"||!Array.isArray(i.layers)?null:(Array.isArray(i.assets)||(i.assets=[]),Array.isArray(i.chars)||(i.chars=[]),i)}function St(i){ze=i}function ra(i,e,t,n){var I,R,H,z,N,j,C,E,S,T,k,X,ye,Ue,Ge,qe,Ve,We,Ye;let a=t.objects.get(i);if(!a)return console.warn(`[LottieOverlay] Object config not found: ${i}`),null;let r=((I=a.effects)==null?void 0:I.lottie)||{},o=a.transform||{},s=a.render||{};if(r.enabled===!1||s.visible===!1)return null;let d=n==null?void 0:n[i],c=aa(d);if(!c){let J=(H=(R=a.render)==null?void 0:R.asset)==null?void 0:H.path;if(typeof J=="string"&&J.toLowerCase().endsWith(".json")){let dt=xr(J);if(c=aa(dt),c)try{n[i]=c}catch{}}}if(!c){let J=d&&typeof d=="object"?Object.prototype.toString.call(d):typeof d;return console.warn(`[LottieOverlay] Lottie JSON invalid for: ${i}`,{kind:J}),null}let u=yr();if(!u)return console.warn(`[LottieOverlay] lottie-web is not available. Cannot play animation: ${i}`),null;let l=(z=r.width)!=null?z:300,p=(N=r.height)!=null?N:300,g=(j=o.scale)!=null?j:1,m=((E=(C=o.position)==null?void 0:C.x)!=null?E:0)+((T=(S=o.offset)==null?void 0:S.x)!=null?T:0),h=((X=(k=o.position)==null?void 0:k.y)!=null?X:0)+((Ue=(ye=o.offset)==null?void 0:ye.y)!=null?Ue:0),A=(Ge=o.rotation)!=null?Ge:0,b=(qe=s.z_index)!=null?qe:100,f=(Ve=s.alpha)!=null?Ve:1,x=document.createElement("div");x.style.cssText=`
|
|
246
246
|
position: absolute;
|
|
247
|
-
top: calc(50% + ${
|
|
247
|
+
top: calc(50% + ${h}px);
|
|
248
248
|
left: calc(50% + ${m}px);
|
|
249
249
|
transform: translate(-50%, -50%) scale(${g}) rotate(${A}deg);
|
|
250
250
|
width: ${l}px;
|
|
251
251
|
height: ${p}px;
|
|
252
252
|
pointer-events: none;
|
|
253
253
|
z-index: ${b};
|
|
254
|
-
opacity: ${
|
|
255
|
-
`,e.appendChild(x);let w;try{w=u.loadAnimation({container:x,renderer:r.renderer||"svg",loop:(We=r.loop)!=null?We:!1,autoplay:(Ye=r.autoplay)!=null?Ye:!0,animationData:c})}catch(J){return x.parentNode&&x.parentNode.removeChild(x),console.warn(`[LottieOverlay] Failed to start animation: ${i}`,J),null}r.speed!==void 0&&w.setSpeed(r.speed);let y=()=>{w.destroy(),x.parentNode&&x.parentNode.removeChild(x)};return r.loop||w.addEventListener("complete",y),{animation:w,cleanup:y}}Et();Qt();var Ot=class{constructor(e,t,n){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=n}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:n}=await Pt(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=n,this.gameObjectManager=new $e(this.config),this.stage.eventMode="passive",this.stage.interactive=!1,this.stage.interactiveChildren=!0,this.stage.sortableChildren=!0,this.context={app:this.app,stage:this.stage,config:this.config,gameObjectManager:this.gameObjectManager,destinationUrl:this.destinationUrl,root:this.root,engine:this};for(let a of this.systems)a.setContext(this.context);return{app:this.app,gameObjectManager:this.gameObjectManager}}async initSystems(){if(!this.context)throw new Error("[GameEngine] createApp() must be called before initSystems()");for(let e of this.systems)e.init&&await e.init()}async init(e){return await this.createApp(e),await this.initSystems(),{app:this.app,gameObjectManager:this.gameObjectManager}}registerSystems(e){this.systems.push(...e)}async start(){for(let e of this.systems)e.onStart&&await e.onStart();this.app.ticker.add(this.update.bind(this)),window.addEventListener("handler-preview:screen",e=>{let{width:t,height:n}=e.detail;this.resize(t,n)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let n of this.systems)n.update&&n.update(t,this.totalTime)}resize(e,t){for(let n of this.systems)n.onResize&&n.onResize(e,t)}updateConfig(e){this.config=e;for(let t of this.systems)t.context.config=e,t.onConfigUpdate&&t.onConfigUpdate(e)}destroy(){for(let e of this.systems)e.onDestroy&&e.onDestroy();this.app.ticker.remove(this.update.bind(this)),this.app.destroy(!0,{children:!0,texture:!1})}getApp(){return this.app}getGameObjectManager(){return this.gameObjectManager}getTotalTime(){return this.totalTime}getSystem(e){let t=this.systems.find(n=>n instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var He=class{setContext(e){this.context=e}};var Ne=class{constructor(){this.config=null}init(e){this.config=e}get(e){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(e)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(e){return this.config?this.config.objects.has(e):!1}};var oa=ft(require("pixi.js"),1),sa=oa;typeof window!="undefined"&&(window.__basePixi=oa);Xe();var le=require("pixi.js");Xe();var la=i=>i*Math.PI/180;function wr(i,e){var o,s,d,c,u;let t=e.ui;if(!(t!=null&&t.text))return null;let n="#ffffff";(o=e.render)!=null&&o.tint&&(n=e.render.tint);let a=new le.TextStyle({fontFamily:(s=t.font)!=null?s:"Arial",fontSize:(d=t.fontSize)!=null?d:16,fill:n,align:(c=t.align)!=null?c:"center",letterSpacing:(u=t.letterSpacing)!=null?u:0}),r=new le.Text({text:t.text,style:a});return r.label=i,r}function ca(i){var u,l,p,g,m,f,A,b,h,x;let{stage:e,mainContainer:t,activeConfig:n,gameObjectManager:a,allowList:r,denyList:o}=i,s={},d={},c={};t.sortableChildren=!0;for(let[w,y]of n.objects.entries()){if(o!=null&&o.has(w)||r&&!r.has(w)||(y==null?void 0:y.enabled)===!1)continue;let I=(l=(u=y==null?void 0:y.render)==null?void 0:u.asset)==null?void 0:l.path,R=(g=(p=y==null?void 0:y.render)==null?void 0:p.asset)==null?void 0:g.type,H=!!(I&&R==="image"),z=!!((m=y==null?void 0:y.ui)!=null&&m.text),N=z?(f=y==null?void 0:y.ui)==null?void 0:f.renderMode:void 0,j;if(N==="png"&&H?j="png":N==="text"&&z?j="text":H?j="png":z?j="text":j="skip",j!=="skip"){if(j==="text"){let C=wr(w,y);if(!C)continue;let E=y.render;C.alpha=typeof(E==null?void 0:E.alpha)=="number"?E.alpha:1,C.visible=(E==null?void 0:E.visible)!==!1,C.zIndex=typeof(E==null?void 0:E.z_index)=="number"?E.z_index:0,E!=null&&E.anchor&&typeof E.anchor.x=="number"&&typeof E.anchor.y=="number"?C.anchor.set(E.anchor.x,E.anchor.y):C.anchor.set(.5,.5);let S=y.transform,T=(S==null?void 0:S.position)||(S==null?void 0:S.offset);T&&C.position.set((A=T.x)!=null?A:0,(b=T.y)!=null?b:0);let k=typeof(S==null?void 0:S.scale)=="number"?S.scale:1;C.scale.set(k,k);let X=typeof(S==null?void 0:S.rotation)=="number"?S.rotation:0;C.rotation=la(X),C.parent||t.addChild(C);try{a.create(w,C)}catch{}s[w]=C,c[w]=C}else if(j==="png"){let C=fe[w]||(typeof le.Texture!="undefined"?le.Texture.EMPTY:void 0),E=new le.Sprite(C);E.label=w;let S=y.render;E.alpha=typeof(S==null?void 0:S.alpha)=="number"?S.alpha:1,E.visible=(S==null?void 0:S.visible)!==!1,E.zIndex=typeof(S==null?void 0:S.z_index)=="number"?S.z_index:0,S!=null&&S.anchor&&typeof S.anchor.x=="number"&&typeof S.anchor.y=="number"&&E.anchor.set(S.anchor.x,S.anchor.y);let T=y.transform,k=(T==null?void 0:T.position)||(T==null?void 0:T.offset);k&&E.position.set((h=k.x)!=null?h:0,(x=k.y)!=null?x:0);let X=typeof(T==null?void 0:T.scale)=="number"?T.scale:1;E.scale.set(X,X);let ye=typeof(T==null?void 0:T.rotation)=="number"?T.rotation:0;E.rotation=la(ye),E.parent||t.addChild(E);try{a.create(w,E)}catch{}s[w]=E,d[w]=E}}}return t.parent||e.addChild(t),{objects:s,sprites:d,texts:c}}var wi=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Ne}init(e,t){this.registry.init(e),this.app=t}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let t=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(t.length===0)return;let n=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async r=>{var s;let o=this.registry.get(r);if(!o){console.warn("[Assets] No config found for object:",r);return}try{let d=await me.create(r,o,this.app);this.instanceCache.set(r,d),console.log("[Assets] Loaded object:",r,(s=d==null?void 0:d.constructor)==null?void 0:s.name)}catch(d){console.error("[Assets] Failed to load object:",r,d)}})))};return this.readyPromise=(async()=>{await n(t);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await n(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let t=this.registry.get(e);if(t){let n=await me.create(e,t,this.app);this.instanceCache.set(e,n)}}get(e){return this.instanceCache.get(e)}},da=new wi,pa=new Proxy(da,{get(i,e){if(e in i&&typeof i[e]=="function")return i[e].bind(i);if(i.get(e))return i.get(e)}});function ua(i,e){da.init(i,e)}Xe();var It=class extends He{async init(){At(this.context.config,this.context.app),await fe.ready(),console.log("[AssetSystem] All assets preloaded and ready")}async onStart(){}onConfigUpdate(){console.log("[AssetSystem] Config updated - systems will refresh textures")}};var $t=require("pixi.js"),ce={width:400,height:600,designWidth:400,scaleFactor:1},ct={scale:1,position:1},zt=[];function Er(i,e,t,n,a,r,o){zt.push({element:i,originalScale:r,positionHelper:e,heightPercent:a}),e(i,t,n,a,r,o,!1)}function Ar(){zt.forEach(({element:i,originalScale:e,positionHelper:t,heightPercent:n})=>{let a=e*ce.scaleFactor;t(i,ce.width,ce.height,n,a,!0,!1)})}function ga(){zt.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Rt(i,e){console.log(`[SCREEN] updateScreenState called: ${i}x${e}`),ce.width=i,ce.height=e,ce.scaleFactor=Math.min(i/ce.designWidth,1.15),ct.scale=ce.scaleFactor,ct.position=1,console.log(`[SCREEN] Global multipliers - scale: ${ct.scale.toFixed(3)}`),Ar()}var O={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Sr(i,e,t){let n=O[i];n&&n[e]!==void 0&&(n[e]=t,console.log(`Updated ${i}.${e} = ${t}`))}function Cr(){return O}var Tr={center:{x:.5,y:.5},"center-center":{x:.5,y:.5},middle:{x:.5,y:.5},"middle-center":{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},"left-center":{x:0,y:.5},"right-center":{x:1,y:.5},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};function jt(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function Ce(i,e={x:.5,y:.5}){var t;if(Array.isArray(i))return{x:jt(i[0],e.x),y:jt(i[1],e.y)};if(i&&typeof i=="object"){let n=i;return{x:jt(n.x,e.x),y:jt(n.y,e.y)}}if(typeof i=="string"){let n=i.trim().toLowerCase();return(t=Tr[n])!=null?t:e}return e}function Be(i,e,t,n={}){var g,m,f,A,b,h;let a=Ce(t),r=(g=n.inset)!=null?g:{},o=(m=n.padding)!=null?m:{x:0,y:0},s=((f=r.left)!=null?f:0)+o.x,d=((A=r.right)!=null?A:0)+o.x,c=((b=r.top)!=null?b:0)+o.y,u=((h=r.bottom)!=null?h:0)+o.y,l=Math.max(0,i-s-d),p=Math.max(0,e-c-u);return{x:s+l*a.x,y:c+p*a.y}}function Fe(i,e,t,n={}){var f,A,b,h,x,w;let a=(f=n.inset)!=null?f:{},r=(A=n.padding)!=null?A:{x:0,y:0},o=((b=a.left)!=null?b:0)+r.x,s=((h=a.right)!=null?h:0)+r.x,d=((x=a.top)!=null?x:0)+r.y,c=((w=a.bottom)!=null?w:0)+r.y,u=Math.max(0,i-o-s),l=Math.max(0,e-d-c),p=Ce(t,{x:.5,y:.5}),g=Math.min(Math.max(p.x,0),1),m=Math.min(Math.max(p.y,0),1);return{x:o+u*g,y:d+l*m}}function Dt(i,e,t,n={}){var u,l,p;if(!i)return;let a=n.positionRatio?Fe(e,t,n.positionRatio,{inset:n.inset,padding:n.screenPadding}):Be(e,t,n.anchor,{inset:n.inset,padding:n.screenPadding}),r=(u=n.offset)!=null?u:{x:0,y:0},o=a.x+r.x,s=a.y+r.y;i.anchor&&n.renderAnchor&&i.anchor.set(n.renderAnchor.x,n.renderAnchor.y),K(i,o,s);let d=(l=n.scale)!=null?l:1,c=(p=n.scaleMultiplier)!=null?p:1;(n.scale!==void 0||n.scaleMultiplier!==void 0)&&ie(i,d*c)}if(typeof window!="undefined"){let i=window.innerWidth,e=window.innerHeight,t=()=>{let n=window.innerWidth,a=window.innerHeight;(n!==i||a!==e)&&(i=n,e=a,Rt(n,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Rt(window.innerWidth,window.innerHeight),window.updateDebugConfig=Sr,window.getDebugConfig=Cr,window.copyConfig=$r,window.applyConfig=lt,window.applyConfigForRatio=zr,window.positionAtBottom=ha,window.positionAtTop=_r,window.positionAtCenter=Pr,window.positionAtLeft=Mr,window.positionAtRight=Or,window.positionAtBottomLeft=Ir,window.positionAtBottomRight=jr,window.positionAtTopLeft=Rr,window.positionAtTopRight=Dr,window.applyPositionContract=kr,console.log("\u{1F3AE} Debug Config Functions Available:"),console.log("\u2022 updateDebugConfig(category, key, value)"),console.log("\u2022 getDebugConfig()"),console.log("\u2022 copyConfig(presetName)"),console.log("\u2022 applyConfig(config)"),console.log("\u2022 applyConfigForRatio(width, height)"),console.log("\u{1F4CD} Positioning Helpers Available (with scale):"),console.log("\u2022 positionAtBottom(element, w, h, percent, scale)"),console.log("\u2022 positionAtTop(element, w, h, percent, scale)"),console.log("\u2022 positionAtCenter(element, w, h, offsetX, offsetY, scale)"),console.log("\u2022 positionAtLeft/Right(element, w, h, percent, scale)"),console.log("\u2022 Corner positions: BottomLeft/Right, TopLeft/Right (all with scale)"),console.log("\u2022 applyPositionContract(element, w, h, contract)"),console.log("Example: positionAtCenter(mySprite, 400, 600, 0, -50, 1.2)")}function Ht(i,e,t=0){return i*e+t}function Nt(i,e,t=0){return i*(1-e)+t}function Bt(i,e,t=0){return i*e+t}function Ft(i,e,t=0){return i*(1-e)+t}function W(i,e=0){return i/2+e}function Lr(i,e){return i*e}function kr(i,e,t,n){var o,s,d,c,u,l,p,g,m,f,A,b,h,x,w,y,I,R,H,z;let a=0,r=0;switch(n.type){case"top":a=W(e,(s=(o=n.offset)==null?void 0:o.x)!=null?s:0),r=Ht(t,n.percent,(c=(d=n.offset)==null?void 0:d.y)!=null?c:0);break;case"bottom":a=W(e,(l=(u=n.offset)==null?void 0:u.x)!=null?l:0),r=Nt(t,n.percent,(g=(p=n.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=Bt(e,n.percent,(f=(m=n.offset)==null?void 0:m.x)!=null?f:0),r=W(t,(b=(A=n.offset)==null?void 0:A.y)!=null?b:0);break;case"right":a=Ft(e,n.percent,(x=(h=n.offset)==null?void 0:h.x)!=null?x:0),r=W(t,(y=(w=n.offset)==null?void 0:w.y)!=null?y:0);break;case"center":a=W(e,(R=(I=n.offset)==null?void 0:I.x)!=null?R:0),r=W(t,(z=(H=n.offset)==null?void 0:H.y)!=null?z:0);break}i.position?i.position.set(a,r):(i.x=a,i.y=r),n.scale!==void 0&&n.scale!==1&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(n.scale,n.scale):(i.scale.x=n.scale,i.scale.y=n.scale))}function ha(i,e,t,n=.2,a=1,r=!0,o=!1){let s=Lr(t,n),d=Nt(t,n/2);K(i,W(e),d);let c=r?a*ce.scaleFactor:a;ie(i,c),o&&!zt.find(u=>u.element===i)&&Er(i,ha,e,t,n,a,r)}function _r(i,e,t,n=.1,a=1){K(i,W(e),Ht(t,n)),ie(i,a)}function Pr(i,e,t,n=0,a=0,r=1){K(i,W(e,n),W(t,a)),ie(i,r)}function Mr(i,e,t,n=.1,a=1){K(i,Bt(e,n),W(t)),ie(i,a)}function Or(i,e,t,n=.1,a=1){K(i,Ft(e,n),W(t)),ie(i,a)}function Ir(i,e,t,n=.05,a=.05,r=1){K(i,Bt(e,a),Nt(t,n)),ie(i,r)}function jr(i,e,t,n=.05,a=.05,r=1){K(i,Ft(e,a),Nt(t,n)),ie(i,r)}function Rr(i,e,t,n=.05,a=.05,r=1){K(i,Bt(e,a),Ht(t,n)),ie(i,r)}function Dr(i,e,t,n=.05,a=.05,r=1){K(i,Ft(e,a),Ht(t,n)),ie(i,r)}function K(i,e,t){i&&i.position?typeof i.position.set=="function"?i.position.set(e,t):(i.position.x=e,i.position.y=t):i&&(i.x=e,i.y=t)}function ie(i,e){e!==1&&i&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(e,e):i.scale.x!==void 0&&i.scale.y!==void 0&&(i.scale.x=e,i.scale.y=e))}var Se={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function $r(i){return i&&Se[i]?JSON.parse(JSON.stringify(Se[i])):JSON.parse(JSON.stringify(O))}function lt(i){Object.keys(i).forEach(e=>{let t=e;O[t]&&i[t]&&Object.assign(O[t],i[t])}),console.log("Config applied:",i)}function zr(i,e){let t=i/e;t>1.6?(lt(Se.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(lt(Se.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(lt(Se.square),console.log("Applied SQUARE config for ratio:",t)):(lt(Se.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let i=window;i.configPresets=Se,i.resolveAnchorVec2=i.resolveAnchorVec2||Ce,i.resolveScreenAnchorPoint=i.resolveScreenAnchorPoint||Be,i.resolveScreenRatioPoint=i.resolveScreenRatioPoint||Fe}var G=null;function fa(i,e,t,n,a,r={}){var X,ye,Ue,Ge,qe,Ve,We,Ye,J,dt,Ei,Ai,Si,Ci,Ti,Li,ki,_i,Pi,Mi,Oi,Ii,ji,Ri,Di,$i,zi,Hi,Ni,Bi,Fi,Ui,Gi,qi;let o=(X=r.enableDebugLogs)!=null?X:!1;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:n.width,height:n.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",r));let{mainContainer:s,label:d,background:c,backgroundTexture:u,app:l}=i;if(!l||!l.renderer){o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:l.renderer.width,height:l.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:l.screen.width,height:l.screen.height}));let p=n.width,g=n.height;o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:p,baseHeight:g});let m=p*O.layout.screen_scale_x,f=g*O.layout.screen_scale_y,A=p/2,b=e.engine.runtime||{},h=b.layout||{};o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:O.layout.screen_scale_x,screen_scale_y:O.layout.screen_scale_y}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Calculated dimensions:",{width:m,height:f,midX:A}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",b),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",h));let x=h.design_width_portrait||400,w=m/x;w=Math.min(w,1.15);let y=w*((ye=O.engine.scale)!=null?ye:1),I=(Ue=r.skipMainContainerTransform)!=null?Ue:!1;!I&&s&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(y):(s.scale.x=y,s.scale.y=y));let R=(Ge=h.main_container_anchor)!=null?Ge:"center",H=(qe=h.main_container_position_ratio)!=null?qe:{x:.5,y:.5},z=(Ve=h.main_container_offset)!=null?Ve:{x:0,y:0},N=h.main_container_position_ratio?Fe(p,g,H):Be(p,g,R),j=N.x+z.x+O.layout.position_offset.x,C=N.y+z.y+O.layout.position_offset.y;if(!I&&s&&s.position&&(typeof s.position.set=="function"?s.position.set(j,C):(s.position.x=j,s.position.y=C)),a&&(s!=null&&s.toLocal))for(let[F,B]of e.objects.entries()){let P=B==null?void 0:B.transform;if(!P||((We=P.position_mode)!=null?We:"static")!=="static")continue;let L=(Ye=a.get)==null?void 0:Ye.call(a,F),Z=((J=L==null?void 0:L.getDisplayObject)==null?void 0:J.call(L))||(L==null?void 0:L.pixiObject)||L;if(!Z||Z.parent!==s)continue;let pt=P.position_ratio!=null?Fe(p,g,P.position_ratio):Be(p,g,(dt=P.anchor)!=null?dt:"center"),ut=s.toLocal(new $t.Point(pt.x,pt.y)),gt=(Ei=P.position)!=null?Ei:{x:0,y:0},ve=ut.x+gt.x,Ut=ut.y+gt.y;typeof(L==null?void 0:L.setPosition)=="function"?L.setPosition(ve,Ut):(K(Z,ve,Ut),(Ai=L==null?void 0:L.transform)!=null&&Ai.position&&(L.transform.position.x=ve,L.transform.position.y=Ut))}let E=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,T=((E==null?void 0:E.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(O.layout.debug_rect_visible&&T){(!G||G.parent!==l.stage)&&(G==null||G.destroy(),G=new $t.Graphics,G.zIndex=9999,l.stage.addChild(G)),G.clear();let F=O.layout.debug_rect_scale_x,B=O.layout.debug_rect_scale_y,P=(p-4)*F,de=(g-4)*B,L=(p-P)/2,Z=(g-de)/2;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:P,rectH:de,offsetX:L,offsetY:Z}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+L,y:2+Z,width:P,height:de})),G.rect(2+L,2+Z,P,de).stroke({width:O.layout.debug_rect_thickness,color:O.layout.debug_rect_color})}else G&&(G.destroy(),G=null);let k=((Si=i.label)==null?void 0:Si.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(d&&d.position&&k){let F=(Ti=(Ci=k==null?void 0:k.transform)==null?void 0:Ci.anchor)!=null?Ti:"center",B=(Li=k==null?void 0:k.transform)==null?void 0:Li.position_ratio,P=((ki=k==null?void 0:k.transform)==null?void 0:ki.offset)||{x:0,y:0};Dt(d,p,g,{anchor:F,positionRatio:B,offset:{x:P.x*y,y:P.y*y},renderAnchor:Ce(F)})}if(d&&d.alpha>0){let F=1+Math.sin(t*O.engine.label_pulse_speed)*O.engine.label_pulse_intensity,B=(Pi=(_i=k==null?void 0:k.transform)==null?void 0:_i.scale)!=null?Pi:1,P=F*y*B;d.scale&&(typeof d.scale.set=="function"?d.scale.set(P):(d.scale.x=P,d.scale.y=P))}if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),c){o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!c),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(Mi=c.constructor)==null?void 0:Mi.name)),c.alpha=((Ii=(Oi=b.background)==null?void 0:Oi.alpha)!=null?Ii:.98)*O.engine.background_alpha,o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",c.alpha);let F=e.objects.get("background_1");o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",F);let B=(F==null?void 0:F.transform)||{};o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",B);let P=B.offset||{x:0,y:0},de=((Ri=(ji=b.background)==null?void 0:ji.offset_y)!=null?Ri:0)+O.engine.background_offset_y,L=(Di=B.anchor)!=null?Di:"center",Z=B.position_ratio;if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:P,bgRuntimeOffsetY:de,bgScreenAnchor:L,bgPositionRatio:Z,baseWidth:p,baseHeight:g,finalScale:y}),Dt(c,p,g,{anchor:L,positionRatio:Z,offset:{x:P.x*y,y:P.y*y+de},renderAnchor:Ce(L)}),o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:c.x,y:c.y,scaleX:($i=c.scale)==null?void 0:$i.x,scaleY:(zi=c.scale)==null?void 0:zi.y,anchorX:(Hi=c.anchor)==null?void 0:Hi.x,anchorY:(Ni=c.anchor)==null?void 0:Ni.y,pivotX:(Bi=c.pivot)==null?void 0:Bi.x,pivotY:(Fi=c.pivot)==null?void 0:Fi.y,width:c.width,height:c.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background texture dimensions:",{textureWidth:u==null?void 0:u.width,textureHeight:u==null?void 0:u.height})),u){let pt=Math.max(m/u.width,f/u.height),ut=(Gi=(Ui=b.background)==null?void 0:Ui.scale_multiplier)!=null?Gi:1.05,gt=(qi=B.scale)!=null?qi:1,ve=pt*ut*O.engine.background_scale*gt;c.scale&&(typeof c.scale.set=="function"?c.scale.set(ve):(c.scale.x=ve,c.scale.y=ve))}else c&&typeof c.clear=="function"&&(c.clear(),c.rect(-m/2,-f/2,m,f).fill({color:1444375}))}}function ma(i){var s,d,c;let{setState:e,updateLabelAlpha:t,updateHandAlpha:n,config:a,states:r}=i,o=((d=(s=a.engine)==null?void 0:s.runtime)==null?void 0:d.timeline)||{};e(r.showHook),setTimeout(()=>{t(1),n(1),e(r.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(c=o.tutorial_delay_ms)!=null?c:1500)}0&&(module.exports={AssetCache,AssetLoader,AssetSystem,AssetTextures,Assets,BaseSystem,GameEngine,GameObject,GameObjectManager,ObjectFactory,Renderer,RuntimeObjectRegistry,Transform,applyScreenAnchor,basePixi,clearResponsiveElements,createPixiBase,getRegisteredFontIds,globalResponsiveMultipliers,initAssetTextures,initAssets,layout,playLottieOverlay,registerFont,registerType,resolveAnchorVec2,resolveFont,resolveFontWeight,resolveScreenAnchorPoint,resolveScreenRatioPoint,runInitSequence,setLottieInstance,spawnSceneFromConfig,updateScreenState});
|
|
254
|
+
opacity: ${f};
|
|
255
|
+
`,e.appendChild(x);let w;try{w=u.loadAnimation({container:x,renderer:r.renderer||"svg",loop:(We=r.loop)!=null?We:!1,autoplay:(Ye=r.autoplay)!=null?Ye:!0,animationData:c})}catch(J){return x.parentNode&&x.parentNode.removeChild(x),console.warn(`[LottieOverlay] Failed to start animation: ${i}`,J),null}r.speed!==void 0&&w.setSpeed(r.speed);let y=()=>{w.destroy(),x.parentNode&&x.parentNode.removeChild(x)};return r.loop||w.addEventListener("complete",y),{animation:w,cleanup:y}}Et();Qt();var Ot=class{constructor(e,t,n){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=n}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:n}=await Pt(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=n,this.gameObjectManager=new $e(this.config),this.stage.eventMode="passive",this.stage.interactive=!1,this.stage.interactiveChildren=!0,this.stage.sortableChildren=!0,this.context={app:this.app,stage:this.stage,config:this.config,gameObjectManager:this.gameObjectManager,destinationUrl:this.destinationUrl,root:this.root,engine:this};for(let a of this.systems)a.setContext(this.context);return{app:this.app,gameObjectManager:this.gameObjectManager}}async initSystems(){if(!this.context)throw new Error("[GameEngine] createApp() must be called before initSystems()");for(let e of this.systems)e.init&&await e.init()}async init(e){return await this.createApp(e),await this.initSystems(),{app:this.app,gameObjectManager:this.gameObjectManager}}registerSystems(e){this.systems.push(...e)}async start(){for(let e of this.systems)e.onStart&&await e.onStart();this.app.ticker.add(this.update.bind(this)),window.addEventListener("handler-preview:screen",e=>{let{width:t,height:n}=e.detail;this.resize(t,n)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let n of this.systems)n.update&&n.update(t,this.totalTime)}resize(e,t){for(let n of this.systems)n.onResize&&n.onResize(e,t)}updateConfig(e){this.config=e;for(let t of this.systems)t.context.config=e,t.onConfigUpdate&&t.onConfigUpdate(e)}destroy(){for(let e of this.systems)e.onDestroy&&e.onDestroy();this.app.ticker.remove(this.update.bind(this)),this.app.destroy(!0,{children:!0,texture:!1})}getApp(){return this.app}getGameObjectManager(){return this.gameObjectManager}getTotalTime(){return this.totalTime}getSystem(e){let t=this.systems.find(n=>n instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var He=class{setContext(e){this.context=e}};var Ne=class{constructor(){this.config=null}init(e){this.config=e}get(e){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(e)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(e){return this.config?this.config.objects.has(e):!1}};var oa=ht(require("pixi.js"),1),sa=oa;typeof window!="undefined"&&(window.__basePixi=oa);Xe();var le=require("pixi.js");Xe();var la=i=>i*Math.PI/180;function wr(i,e){var o,s,d,c,u;let t=e.ui;if(!(t!=null&&t.text))return null;let n="#ffffff";(o=e.render)!=null&&o.tint&&(n=e.render.tint);let a=new le.TextStyle({fontFamily:(s=t.font)!=null?s:"Arial",fontSize:(d=t.fontSize)!=null?d:16,fill:n,align:(c=t.align)!=null?c:"center",letterSpacing:(u=t.letterSpacing)!=null?u:0}),r=new le.Text({text:t.text,style:a});return r.label=i,r}function ca(i){var u,l,p,g,m,h,A,b,f,x;let{stage:e,mainContainer:t,activeConfig:n,gameObjectManager:a,allowList:r,denyList:o}=i,s={},d={},c={};t.sortableChildren=!0;for(let[w,y]of n.objects.entries()){if(o!=null&&o.has(w)||r&&!r.has(w)||(y==null?void 0:y.enabled)===!1)continue;let I=(l=(u=y==null?void 0:y.render)==null?void 0:u.asset)==null?void 0:l.path,R=(g=(p=y==null?void 0:y.render)==null?void 0:p.asset)==null?void 0:g.type,H=!!(I&&R==="image"),z=!!((m=y==null?void 0:y.ui)!=null&&m.text),N=z?(h=y==null?void 0:y.ui)==null?void 0:h.renderMode:void 0,j;if(N==="png"&&H?j="png":N==="text"&&z?j="text":H?j="png":z?j="text":j="skip",j!=="skip"){if(j==="text"){let C=wr(w,y);if(!C)continue;let E=y.render;C.alpha=typeof(E==null?void 0:E.alpha)=="number"?E.alpha:1,C.visible=(E==null?void 0:E.visible)!==!1,C.zIndex=typeof(E==null?void 0:E.z_index)=="number"?E.z_index:0,E!=null&&E.anchor&&typeof E.anchor.x=="number"&&typeof E.anchor.y=="number"?C.anchor.set(E.anchor.x,E.anchor.y):C.anchor.set(.5,.5);let S=y.transform,T=(S==null?void 0:S.position)||(S==null?void 0:S.offset);T&&C.position.set((A=T.x)!=null?A:0,(b=T.y)!=null?b:0);let k=typeof(S==null?void 0:S.scale)=="number"?S.scale:1;C.scale.set(k,k);let X=typeof(S==null?void 0:S.rotation)=="number"?S.rotation:0;C.rotation=la(X),C.parent||t.addChild(C);try{a.create(w,C)}catch{}s[w]=C,c[w]=C}else if(j==="png"){let C=he[w]||(typeof le.Texture!="undefined"?le.Texture.EMPTY:void 0),E=new le.Sprite(C);E.label=w;let S=y.render;E.alpha=typeof(S==null?void 0:S.alpha)=="number"?S.alpha:1,E.visible=(S==null?void 0:S.visible)!==!1,E.zIndex=typeof(S==null?void 0:S.z_index)=="number"?S.z_index:0,S!=null&&S.anchor&&typeof S.anchor.x=="number"&&typeof S.anchor.y=="number"&&E.anchor.set(S.anchor.x,S.anchor.y);let T=y.transform,k=(T==null?void 0:T.position)||(T==null?void 0:T.offset);k&&E.position.set((f=k.x)!=null?f:0,(x=k.y)!=null?x:0);let X=typeof(T==null?void 0:T.scale)=="number"?T.scale:1;E.scale.set(X,X);let ye=typeof(T==null?void 0:T.rotation)=="number"?T.rotation:0;E.rotation=la(ye),E.parent||t.addChild(E);try{a.create(w,E)}catch{}s[w]=E,d[w]=E}}}return t.parent||e.addChild(t),{objects:s,sprites:d,texts:c}}var wi=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Ne}init(e,t){this.registry.init(e),this.app=t}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let t=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(t.length===0)return;let n=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async r=>{var s;let o=this.registry.get(r);if(!o){console.warn("[Assets] No config found for object:",r);return}try{let d=await me.create(r,o,this.app);this.instanceCache.set(r,d),console.log("[Assets] Loaded object:",r,(s=d==null?void 0:d.constructor)==null?void 0:s.name)}catch(d){console.error("[Assets] Failed to load object:",r,d)}})))};return this.readyPromise=(async()=>{await n(t);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await n(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let t=this.registry.get(e);if(t){let n=await me.create(e,t,this.app);this.instanceCache.set(e,n)}}get(e){return this.instanceCache.get(e)}},da=new wi,pa=new Proxy(da,{get(i,e){if(e in i&&typeof i[e]=="function")return i[e].bind(i);if(i.get(e))return i.get(e)}});function ua(i,e){da.init(i,e)}Xe();var It=class extends He{async init(){At(this.context.config,this.context.app),await he.ready(),console.log("[AssetSystem] All assets preloaded and ready")}async onStart(){}onConfigUpdate(){console.log("[AssetSystem] Config updated - systems will refresh textures")}};var $t=require("pixi.js"),ce={width:400,height:600,designWidth:400,scaleFactor:1},ct={scale:1,position:1},zt=[];function Er(i,e,t,n,a,r,o){zt.push({element:i,originalScale:r,positionHelper:e,heightPercent:a}),e(i,t,n,a,r,o,!1)}function Ar(){zt.forEach(({element:i,originalScale:e,positionHelper:t,heightPercent:n})=>{let a=e*ce.scaleFactor;t(i,ce.width,ce.height,n,a,!0,!1)})}function ga(){zt.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Rt(i,e){console.log(`[SCREEN] updateScreenState called: ${i}x${e}`),ce.width=i,ce.height=e,ce.scaleFactor=Math.min(i/ce.designWidth,1.15),ct.scale=ce.scaleFactor,ct.position=1,console.log(`[SCREEN] Global multipliers - scale: ${ct.scale.toFixed(3)}`),Ar()}var O={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Sr(i,e,t){let n=O[i];n&&n[e]!==void 0&&(n[e]=t,console.log(`Updated ${i}.${e} = ${t}`))}function Cr(){return O}var Tr={center:{x:.5,y:.5},"center-center":{x:.5,y:.5},middle:{x:.5,y:.5},"middle-center":{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},"left-center":{x:0,y:.5},"right-center":{x:1,y:.5},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};function jt(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function Ce(i,e={x:.5,y:.5}){var t;if(Array.isArray(i))return{x:jt(i[0],e.x),y:jt(i[1],e.y)};if(i&&typeof i=="object"){let n=i;return{x:jt(n.x,e.x),y:jt(n.y,e.y)}}if(typeof i=="string"){let n=i.trim().toLowerCase();return(t=Tr[n])!=null?t:e}return e}function Be(i,e,t,n={}){var g,m,h,A,b,f;let a=Ce(t),r=(g=n.inset)!=null?g:{},o=(m=n.padding)!=null?m:{x:0,y:0},s=((h=r.left)!=null?h:0)+o.x,d=((A=r.right)!=null?A:0)+o.x,c=((b=r.top)!=null?b:0)+o.y,u=((f=r.bottom)!=null?f:0)+o.y,l=Math.max(0,i-s-d),p=Math.max(0,e-c-u);return{x:s+l*a.x,y:c+p*a.y}}function Fe(i,e,t,n={}){var h,A,b,f,x,w;let a=(h=n.inset)!=null?h:{},r=(A=n.padding)!=null?A:{x:0,y:0},o=((b=a.left)!=null?b:0)+r.x,s=((f=a.right)!=null?f:0)+r.x,d=((x=a.top)!=null?x:0)+r.y,c=((w=a.bottom)!=null?w:0)+r.y,u=Math.max(0,i-o-s),l=Math.max(0,e-d-c),p=Ce(t,{x:.5,y:.5}),g=Math.min(Math.max(p.x,0),1),m=Math.min(Math.max(p.y,0),1);return{x:o+u*g,y:d+l*m}}function Dt(i,e,t,n={}){var u,l,p;if(!i)return;let a=n.positionRatio?Fe(e,t,n.positionRatio,{inset:n.inset,padding:n.screenPadding}):Be(e,t,n.anchor,{inset:n.inset,padding:n.screenPadding}),r=(u=n.offset)!=null?u:{x:0,y:0},o=a.x+r.x,s=a.y+r.y;i.anchor&&n.renderAnchor&&i.anchor.set(n.renderAnchor.x,n.renderAnchor.y),K(i,o,s);let d=(l=n.scale)!=null?l:1,c=(p=n.scaleMultiplier)!=null?p:1;(n.scale!==void 0||n.scaleMultiplier!==void 0)&&ie(i,d*c)}if(typeof window!="undefined"){let i=window.innerWidth,e=window.innerHeight,t=()=>{let n=window.innerWidth,a=window.innerHeight;(n!==i||a!==e)&&(i=n,e=a,Rt(n,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Rt(window.innerWidth,window.innerHeight),window.updateDebugConfig=Sr,window.getDebugConfig=Cr,window.copyConfig=$r,window.applyConfig=lt,window.applyConfigForRatio=zr,window.positionAtBottom=fa,window.positionAtTop=_r,window.positionAtCenter=Pr,window.positionAtLeft=Mr,window.positionAtRight=Or,window.positionAtBottomLeft=Ir,window.positionAtBottomRight=jr,window.positionAtTopLeft=Rr,window.positionAtTopRight=Dr,window.applyPositionContract=kr,console.log("\u{1F3AE} Debug Config Functions Available:"),console.log("\u2022 updateDebugConfig(category, key, value)"),console.log("\u2022 getDebugConfig()"),console.log("\u2022 copyConfig(presetName)"),console.log("\u2022 applyConfig(config)"),console.log("\u2022 applyConfigForRatio(width, height)"),console.log("\u{1F4CD} Positioning Helpers Available (with scale):"),console.log("\u2022 positionAtBottom(element, w, h, percent, scale)"),console.log("\u2022 positionAtTop(element, w, h, percent, scale)"),console.log("\u2022 positionAtCenter(element, w, h, offsetX, offsetY, scale)"),console.log("\u2022 positionAtLeft/Right(element, w, h, percent, scale)"),console.log("\u2022 Corner positions: BottomLeft/Right, TopLeft/Right (all with scale)"),console.log("\u2022 applyPositionContract(element, w, h, contract)"),console.log("Example: positionAtCenter(mySprite, 400, 600, 0, -50, 1.2)")}function Ht(i,e,t=0){return i*e+t}function Nt(i,e,t=0){return i*(1-e)+t}function Bt(i,e,t=0){return i*e+t}function Ft(i,e,t=0){return i*(1-e)+t}function W(i,e=0){return i/2+e}function Lr(i,e){return i*e}function kr(i,e,t,n){var o,s,d,c,u,l,p,g,m,h,A,b,f,x,w,y,I,R,H,z;let a=0,r=0;switch(n.type){case"top":a=W(e,(s=(o=n.offset)==null?void 0:o.x)!=null?s:0),r=Ht(t,n.percent,(c=(d=n.offset)==null?void 0:d.y)!=null?c:0);break;case"bottom":a=W(e,(l=(u=n.offset)==null?void 0:u.x)!=null?l:0),r=Nt(t,n.percent,(g=(p=n.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=Bt(e,n.percent,(h=(m=n.offset)==null?void 0:m.x)!=null?h:0),r=W(t,(b=(A=n.offset)==null?void 0:A.y)!=null?b:0);break;case"right":a=Ft(e,n.percent,(x=(f=n.offset)==null?void 0:f.x)!=null?x:0),r=W(t,(y=(w=n.offset)==null?void 0:w.y)!=null?y:0);break;case"center":a=W(e,(R=(I=n.offset)==null?void 0:I.x)!=null?R:0),r=W(t,(z=(H=n.offset)==null?void 0:H.y)!=null?z:0);break}i.position?i.position.set(a,r):(i.x=a,i.y=r),n.scale!==void 0&&n.scale!==1&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(n.scale,n.scale):(i.scale.x=n.scale,i.scale.y=n.scale))}function fa(i,e,t,n=.2,a=1,r=!0,o=!1){let s=Lr(t,n),d=Nt(t,n/2);K(i,W(e),d);let c=r?a*ce.scaleFactor:a;ie(i,c),o&&!zt.find(u=>u.element===i)&&Er(i,fa,e,t,n,a,r)}function _r(i,e,t,n=.1,a=1){K(i,W(e),Ht(t,n)),ie(i,a)}function Pr(i,e,t,n=0,a=0,r=1){K(i,W(e,n),W(t,a)),ie(i,r)}function Mr(i,e,t,n=.1,a=1){K(i,Bt(e,n),W(t)),ie(i,a)}function Or(i,e,t,n=.1,a=1){K(i,Ft(e,n),W(t)),ie(i,a)}function Ir(i,e,t,n=.05,a=.05,r=1){K(i,Bt(e,a),Nt(t,n)),ie(i,r)}function jr(i,e,t,n=.05,a=.05,r=1){K(i,Ft(e,a),Nt(t,n)),ie(i,r)}function Rr(i,e,t,n=.05,a=.05,r=1){K(i,Bt(e,a),Ht(t,n)),ie(i,r)}function Dr(i,e,t,n=.05,a=.05,r=1){K(i,Ft(e,a),Ht(t,n)),ie(i,r)}function K(i,e,t){i&&i.position?typeof i.position.set=="function"?i.position.set(e,t):(i.position.x=e,i.position.y=t):i&&(i.x=e,i.y=t)}function ie(i,e){e!==1&&i&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(e,e):i.scale.x!==void 0&&i.scale.y!==void 0&&(i.scale.x=e,i.scale.y=e))}var Se={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function $r(i){return i&&Se[i]?JSON.parse(JSON.stringify(Se[i])):JSON.parse(JSON.stringify(O))}function lt(i){Object.keys(i).forEach(e=>{let t=e;O[t]&&i[t]&&Object.assign(O[t],i[t])}),console.log("Config applied:",i)}function zr(i,e){let t=i/e;t>1.6?(lt(Se.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(lt(Se.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(lt(Se.square),console.log("Applied SQUARE config for ratio:",t)):(lt(Se.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let i=window;i.configPresets=Se,i.resolveAnchorVec2=i.resolveAnchorVec2||Ce,i.resolveScreenAnchorPoint=i.resolveScreenAnchorPoint||Be,i.resolveScreenRatioPoint=i.resolveScreenRatioPoint||Fe}var G=null;function ha(i,e,t,n,a,r={}){var X,ye,Ue,Ge,qe,Ve,We,Ye,J,dt,Ei,Ai,Si,Ci,Ti,Li,ki,_i,Pi,Mi,Oi,Ii,ji,Ri,Di,$i,zi,Hi,Ni,Bi,Fi,Ui,Gi,qi;let o=(X=r.enableDebugLogs)!=null?X:!1;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:n.width,height:n.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",r));let{mainContainer:s,label:d,background:c,backgroundTexture:u,app:l}=i;if(!l||!l.renderer){o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:l.renderer.width,height:l.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:l.screen.width,height:l.screen.height}));let p=n.width,g=n.height;o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:p,baseHeight:g});let m=p*O.layout.screen_scale_x,h=g*O.layout.screen_scale_y,A=p/2,b=e.engine.runtime||{},f=b.layout||{};o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:O.layout.screen_scale_x,screen_scale_y:O.layout.screen_scale_y}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Calculated dimensions:",{width:m,height:h,midX:A}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",b),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",f));let x=f.design_width_portrait||400,w=m/x;w=Math.min(w,1.15);let y=w*((ye=O.engine.scale)!=null?ye:1),I=(Ue=r.skipMainContainerTransform)!=null?Ue:!1;!I&&s&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(y):(s.scale.x=y,s.scale.y=y));let R=(Ge=f.main_container_anchor)!=null?Ge:"center",H=(qe=f.main_container_position_ratio)!=null?qe:{x:.5,y:.5},z=(Ve=f.main_container_offset)!=null?Ve:{x:0,y:0},N=f.main_container_position_ratio?Fe(p,g,H):Be(p,g,R),j=N.x+z.x+O.layout.position_offset.x,C=N.y+z.y+O.layout.position_offset.y;if(!I&&s&&s.position&&(typeof s.position.set=="function"?s.position.set(j,C):(s.position.x=j,s.position.y=C)),a&&(s!=null&&s.toLocal))for(let[F,B]of e.objects.entries()){let P=B==null?void 0:B.transform;if(!P||((We=P.position_mode)!=null?We:"static")!=="static")continue;let L=(Ye=a.get)==null?void 0:Ye.call(a,F),Z=((J=L==null?void 0:L.getDisplayObject)==null?void 0:J.call(L))||(L==null?void 0:L.pixiObject)||L;if(!Z||Z.parent!==s)continue;let pt=P.position_ratio!=null?Fe(p,g,P.position_ratio):Be(p,g,(dt=P.anchor)!=null?dt:"center"),ut=s.toLocal(new $t.Point(pt.x,pt.y)),gt=(Ei=P.position)!=null?Ei:{x:0,y:0},ve=ut.x+gt.x,Ut=ut.y+gt.y;typeof(L==null?void 0:L.setPosition)=="function"?L.setPosition(ve,Ut):(K(Z,ve,Ut),(Ai=L==null?void 0:L.transform)!=null&&Ai.position&&(L.transform.position.x=ve,L.transform.position.y=Ut))}let E=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,T=((E==null?void 0:E.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(O.layout.debug_rect_visible&&T){(!G||G.parent!==l.stage)&&(G==null||G.destroy(),G=new $t.Graphics,G.zIndex=9999,l.stage.addChild(G)),G.clear();let F=O.layout.debug_rect_scale_x,B=O.layout.debug_rect_scale_y,P=(p-4)*F,de=(g-4)*B,L=(p-P)/2,Z=(g-de)/2;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:P,rectH:de,offsetX:L,offsetY:Z}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+L,y:2+Z,width:P,height:de})),G.rect(2+L,2+Z,P,de).stroke({width:O.layout.debug_rect_thickness,color:O.layout.debug_rect_color})}else G&&(G.destroy(),G=null);let k=((Si=i.label)==null?void 0:Si.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(d&&d.position&&k){let F=(Ti=(Ci=k==null?void 0:k.transform)==null?void 0:Ci.anchor)!=null?Ti:"center",B=(Li=k==null?void 0:k.transform)==null?void 0:Li.position_ratio,P=((ki=k==null?void 0:k.transform)==null?void 0:ki.offset)||{x:0,y:0};Dt(d,p,g,{anchor:F,positionRatio:B,offset:{x:P.x*y,y:P.y*y},renderAnchor:Ce(F)})}if(d&&d.alpha>0){let F=1+Math.sin(t*O.engine.label_pulse_speed)*O.engine.label_pulse_intensity,B=(Pi=(_i=k==null?void 0:k.transform)==null?void 0:_i.scale)!=null?Pi:1,P=F*y*B;d.scale&&(typeof d.scale.set=="function"?d.scale.set(P):(d.scale.x=P,d.scale.y=P))}if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),c){o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!c),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(Mi=c.constructor)==null?void 0:Mi.name)),c.alpha=((Ii=(Oi=b.background)==null?void 0:Oi.alpha)!=null?Ii:.98)*O.engine.background_alpha,o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",c.alpha);let F=e.objects.get("background_1");o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",F);let B=(F==null?void 0:F.transform)||{};o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",B);let P=B.offset||{x:0,y:0},de=((Ri=(ji=b.background)==null?void 0:ji.offset_y)!=null?Ri:0)+O.engine.background_offset_y,L=(Di=B.anchor)!=null?Di:"center",Z=B.position_ratio;if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:P,bgRuntimeOffsetY:de,bgScreenAnchor:L,bgPositionRatio:Z,baseWidth:p,baseHeight:g,finalScale:y}),Dt(c,p,g,{anchor:L,positionRatio:Z,offset:{x:P.x*y,y:P.y*y+de},renderAnchor:Ce(L)}),o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:c.x,y:c.y,scaleX:($i=c.scale)==null?void 0:$i.x,scaleY:(zi=c.scale)==null?void 0:zi.y,anchorX:(Hi=c.anchor)==null?void 0:Hi.x,anchorY:(Ni=c.anchor)==null?void 0:Ni.y,pivotX:(Bi=c.pivot)==null?void 0:Bi.x,pivotY:(Fi=c.pivot)==null?void 0:Fi.y,width:c.width,height:c.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background texture dimensions:",{textureWidth:u==null?void 0:u.width,textureHeight:u==null?void 0:u.height})),u){let pt=Math.max(m/u.width,h/u.height),ut=(Gi=(Ui=b.background)==null?void 0:Ui.scale_multiplier)!=null?Gi:1.05,gt=(qi=B.scale)!=null?qi:1,ve=pt*ut*O.engine.background_scale*gt;c.scale&&(typeof c.scale.set=="function"?c.scale.set(ve):(c.scale.x=ve,c.scale.y=ve))}else c&&typeof c.clear=="function"&&(c.clear(),c.rect(-m/2,-h/2,m,h).fill({color:1444375}))}}function ma(i){var s,d,c;let{setState:e,updateLabelAlpha:t,updateHandAlpha:n,config:a,states:r}=i,o=((d=(s=a.engine)==null?void 0:s.runtime)==null?void 0:d.timeline)||{};e(r.showHook),setTimeout(()=>{t(1),n(1),e(r.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(c=o.tutorial_delay_ms)!=null?c:1500)}0&&(module.exports={AssetCache,AssetLoader,AssetSystem,AssetTextures,Assets,BaseSystem,GameEngine,GameObject,GameObjectManager,ObjectFactory,Renderer,RuntimeObjectRegistry,Transform,applyScreenAnchor,basePixi,clearResponsiveElements,createPixiBase,getRegisteredFontIds,globalResponsiveMultipliers,initAssetTextures,initAssets,layout,playLottieOverlay,registerFont,registerType,resolveAnchorVec2,resolveFont,resolveFontWeight,resolveScreenAnchorPoint,resolveScreenRatioPoint,runInitSequence,setLottieInstance,spawnSceneFromConfig,updateScreenState});
|