handler-playable-sdk 0.3.48 → 0.3.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var xa=Object.create;var ht=Object.defineProperty;var wa=Object.getOwnPropertyDescriptor;var Ea=Object.getOwnPropertyNames;var Aa=Object.getPrototypeOf,Sa=Object.prototype.hasOwnProperty;var ae=(n,e)=>()=>(n&&(e=n(n=0)),e);var Xn=(n,e)=>{for(var t in e)ht(n,t,{get:e[t],enumerable:!0})},Jn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ea(e))!Sa.call(n,a)&&a!==t&&ht(n,a,{get:()=>e[a],enumerable:!(i=wa(e,a))||i.enumerable});return n};var mt=(n,e,t)=>(t=n!=null?xa(Aa(n)):{},Jn(e||!n||!n.__esModule?ht(t,"default",{value:n,enumerable:!0}):t,n)),Ca=n=>Jn(ht({},"__esModule",{value:!0}),n);var ka,ue=ae(()=>{"use strict";ka="handler_preview_override_mode";if(typeof window!="undefined"){let n=window.localStorage.getItem(ka);window.__enableConfigOverrides=n===null?!0:n==="true"}});var Pi,xe,es,Yt=ae(()=>{"use strict";ue();Pi=null,xe="dev";if(typeof window!="undefined"){let n=window.__BUILD_SETTINGS__;if(n!=null&&n.buildMode)Pi=n,xe=n.buildMode,console.log("[CONFIG] Loaded inline build settings:",n,"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);Pi=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);es=xe==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var Kt=ae(()=>{"use strict"});var ki=ae(()=>{"use strict";Kt();Yt()});var Xt=ae(()=>{"use strict";Yt();Kt();ki()});var ee,Qt=ae(()=>{"use strict";ee=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()}};ee.store=new Map});function qa(){var n,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(n=document.querySelector("script"))==null?void 0:n.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),i=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!i)}catch{return!1}}async function Va(){try{if(typeof window!="undefined"){let n=await fetch("./build-settings.json");if(n.ok){let e=await n.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Wa(){try{if(typeof window!="undefined"){let n=new XMLHttpRequest;if(n.open("GET","./build-settings.json",!1),n.send(),n.status===200&&n.responseText){let e=JSON.parse(n.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}async function Ya(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${P}`),Object.keys(re).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(re)),re;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),re={...window.INLINE_ASSETS},re;if(!(P==="publish"&&te!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),re;if(!en){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),en=(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 i=await t.text();console.log("[AssetLoader] Received JS code, length:",i.length);let a=i.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 s=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(s)),s}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:",i.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return re=await en,console.log("[AssetLoader] Final inline assets cache:",Object.keys(re)),re}function tn(n){return n===null||typeof n!="object"||(Object.freeze(n),Object.values(n).forEach(e=>tn(e))),n}function Ka(n=64,e=64,t=16711680){let i=document.createElement("canvas");i.width=n,i.height=e;let a=i.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,n,e),a.strokeStyle="#000",a.strokeRect(0,0,n,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",n/2,e/2),se.Texture.from(i)}function Et(n,e){zi.set(n,e)}var se,Di,$i,we,P,te,ge,re,en,zi,fe,At=ae(()=>{"use strict";se=require("pixi.js");Qt();Di=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",$i=qa(),we=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,P=$i?"publish":Di,te=we==null?void 0:we.assetsInlined;we!=null&&we.buildMode&&(P=we.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${P}`));ge=Wa();ge!=null&&ge.buildMode&&(P=ge.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${P}`));(ge==null?void 0:ge.assetsInlined)!==void 0&&(te=ge.assetsInlined);Va().then(n=>{n!=null&&n.buildMode&&n.buildMode!==P&&(P=n.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${P}`)),(n==null?void 0:n.assetsInlined)!==void 0&&(te=n.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${Di}, Runtime: ${$i?"publish":"dev"}, Effective: ${P}`);re={},en=null;zi=new Map;fe=class{static async load(e,t,i,a){let r=`${e}:${t.path}`,s=ee.get(r);if(s!==void 0)return s;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${P}`),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 o=await Ya(),d=o[e];if(!d&&a&&(d=o[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];o[p]&&(d=o[p],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${p}`))}}if(console.log("[AssetLoader] Inline data for",e,":",d?"FOUND":"NOT FOUND"),P==="publish"&&te!==!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=zi.get(t.type);if(u)try{let l=await u(t.path,d,e,i);return ee.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=tn(l);break;default:throw new Error(`Unknown asset type: ${t.type}`)}return ee.set(r,l),l}catch(l){return this.handleFailure(e,t.type,l)}}static async loadImage(e,t){let i=P==="publish",a=i&&te!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${P}, isPublishMode: ${i}, 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 se.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 se.Assets.load(t)}catch(r){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",r),await se.Assets.load(e)}return await se.Assets.load(e)}static async loadJSON(e,t){let i=P==="publish",a=i&&te!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${P}, isPublishMode: ${i}, 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 s=atob(t.split(",")[1]);return JSON.parse(s)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let s=atob(t.split(",")[1]);return JSON.parse(s)}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,i){if(P==="dev"){let r=t==="image"?Ka():tn({__placeholder:!0,type:t});return ee.set(e+":"+((i==null?void 0:i.path)||"missing"),r),r}throw i}};Et("image",async(n,e)=>{let t=P==="publish",i=t&&te!==!1,a=P==="brand",r=t&&te===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${P}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){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: ${n}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return se.Assets.load(e)}let s=n;return(a||r)&&n&&!n.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(s=n,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${n}" as-is`)):(s=`assets/${n}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${n}" -> "${s}"`))),se.Assets.load(e||s)});Et("json",async(n,e)=>{let t=P==="publish",i=t&&te!==!1,a=P==="brand",r=t&&te===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${P}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){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: ${n}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let s=n;if((a||r)&&n&&!n.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(s=n,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${n}" as-is`)):(s=`assets/${n}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${n}" -> "${s}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let o=await fetch(s);if(!o.ok)throw new Error(`JSON fetch failed: ${n}`);return o.json()})});function St(n,e){Ni.init(n,e),typeof window!="undefined"&&(window.__AssetTextures=he)}var nn,Ni,he,Je=ae(()=>{"use strict";At();nn=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(i=>{this.priorityReadyResolve=i}),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 s;console.log("[AssetTextures] Loading all assets...");let i=new Set(["background_loading_1"]),a=[],r=[];for(let[o,d]of e.objects.entries()){let c=(s=d.render)==null?void 0:s.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}: ${o} (${p})`);let g=await fe.load(o,c,t,p);this.textures.set(o,g),console.log(`[AssetTextures] \u2713 Loaded: ${o}`)}catch(p){console.error(`[AssetTextures] \u2717 Failed to load: ${o}`,p)}finally{this.attempted.add(o);try{for(let p of Array.from(this.waiters))p()}catch{}}};i.has(o)?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(o=>typeof o=="string"&&o))).filter(o=>{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,o);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(o=>this.textures.has(o)||this.attempted.has(o));if(r())return;let s=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(o=>{let d=!1,c=()=>{d||r()&&(d=!0,this.waiters.delete(c),o())};this.waiters.add(c),c(),s>0&&setTimeout(()=>{d||(d=!0,this.waiters.delete(c),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),o())},s)})}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())}},Ni=new nn,he=new Proxy(Ni,{get(n,e){return e in n&&typeof n[e]=="function"?n[e].bind(n):n.get(e)},set(n,e,t){return n.set(e,t),!0}})});var Fi={};Xn(Fi,{AssetEditorModal:()=>ln});var ln,cn=ae(()=>{"use strict";ln=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,i,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=i,this.onApplyCallback=a,this.createModal(e,i),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let i=document.createElement("div");i.className="asset-editor-modal",i.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 ie=(n,e)=>()=>(n&&(e=n(n=0)),e);var Wn=(n,e)=>{for(var t in e)ft(n,t,{get:e[t],enumerable:!0})},Yn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of va(e))!wa.call(n,a)&&a!==t&&ft(n,a,{get:()=>e[a],enumerable:!(i=ya(e,a))||i.enumerable});return n};var ht=(n,e,t)=>(t=n!=null?ba(xa(n)):{},Yn(e||!n||!n.__esModule?ft(t,"default",{value:n,enumerable:!0}):t,n)),Ea=n=>Yn(ft({},"__esModule",{value:!0}),n);var _a,ue=ie(()=>{"use strict";_a="handler_preview_override_mode";if(typeof window!="undefined"){let n=window.localStorage.getItem(_a);window.__enableConfigOverrides=n===null?!0:n==="true"}});var Li,xe,Zr,Yt=ie(()=>{"use strict";ue();Li=null,xe="dev";if(typeof window!="undefined"){let n=window.__BUILD_SETTINGS__;if(n!=null&&n.buildMode)Li=n,xe=n.buildMode,console.log("[CONFIG] Loaded inline build settings:",n,"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);Li=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=ie(()=>{"use strict"});var _i=ie(()=>{"use strict";Kt();Yt()});var Xt=ie(()=>{"use strict";Yt();Kt();_i()});var Q,Qt=ie(()=>{"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 n,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(n=document.querySelector("script"))==null?void 0:n.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),i=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!i)}catch{return!1}}async function Ua(){try{if(typeof window!="undefined"){let n=await fetch("./build-settings.json");if(n.ok){let e=await n.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Ga(){try{if(typeof window!="undefined"){let n=new XMLHttpRequest;if(n.open("GET","./build-settings.json",!1),n.send(),n.status===200&&n.responseText){let e=JSON.parse(n.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: ${P}`),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(!(P==="publish"&&ee!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),ae;if(!en){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),en=(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 i=await t.text();console.log("[AssetLoader] Received JS code, length:",i.length);let a=i.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 s=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(s)),s}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:",i.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return ae=await en,console.log("[AssetLoader] Final inline assets cache:",Object.keys(ae)),ae}function tn(n){return n===null||typeof n!="object"||(Object.freeze(n),Object.values(n).forEach(e=>tn(e))),n}function Va(n=64,e=64,t=16711680){let i=document.createElement("canvas");i.width=n,i.height=e;let a=i.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,n,e),a.strokeStyle="#000",a.strokeRect(0,0,n,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",n/2,e/2),re.Texture.from(i)}function wt(n,e){ji.set(n,e)}var re,Ii,Ri,we,P,ee,ge,ae,en,ji,fe,Et=ie(()=>{"use strict";re=require("pixi.js");Qt();Ii=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Ri=Fa(),we=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,P=Ri?"publish":Ii,ee=we==null?void 0:we.assetsInlined;we!=null&&we.buildMode&&(P=we.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${P}`));ge=Ga();ge!=null&&ge.buildMode&&(P=ge.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${P}`));(ge==null?void 0:ge.assetsInlined)!==void 0&&(ee=ge.assetsInlined);Ua().then(n=>{n!=null&&n.buildMode&&n.buildMode!==P&&(P=n.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${P}`)),(n==null?void 0:n.assetsInlined)!==void 0&&(ee=n.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${Ii}, Runtime: ${Ri?"publish":"dev"}, Effective: ${P}`);ae={},en=null;ji=new Map;fe=class{static async load(e,t,i,a){let r=`${e}:${t.path}`,s=Q.get(r);if(s!==void 0)return s;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${P}`),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 o=await qa(),d=o[e];if(!d&&a&&(d=o[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];o[p]&&(d=o[p],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${p}`))}}if(console.log("[AssetLoader] Inline data for",e,":",d?"FOUND":"NOT FOUND"),P==="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=ji.get(t.type);if(u)try{let l=await u(t.path,d,e,i);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=tn(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 i=P==="publish",a=i&&ee!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${P}, isPublishMode: ${i}, 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 i=P==="publish",a=i&&ee!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${P}, isPublishMode: ${i}, 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 s=atob(t.split(",")[1]);return JSON.parse(s)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let s=atob(t.split(",")[1]);return JSON.parse(s)}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,i){if(P==="dev"){let r=t==="image"?Va():tn({__placeholder:!0,type:t});return Q.set(e+":"+((i==null?void 0:i.path)||"missing"),r),r}throw i}};wt("image",async(n,e)=>{let t=P==="publish",i=t&&ee!==!1,a=P==="brand",r=t&&ee===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${P}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){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: ${n}`);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 s=n;return(a||r)&&n&&!n.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(s=n,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${n}" as-is`)):(s=`assets/${n}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${n}" -> "${s}"`))),re.Assets.load(e||s)});wt("json",async(n,e)=>{let t=P==="publish",i=t&&ee!==!1,a=P==="brand",r=t&&ee===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${P}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){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: ${n}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let s=n;if((a||r)&&n&&!n.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(s=n,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${n}" as-is`)):(s=`assets/${n}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${n}" -> "${s}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let o=await fetch(s);if(!o.ok)throw new Error(`JSON fetch failed: ${n}`);return o.json()})});function At(n,e){Di.init(n,e),typeof window!="undefined"&&(window.__AssetTextures=he)}var nn,Di,he,Xe=ie(()=>{"use strict";Et();nn=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(i=>{this.priorityReadyResolve=i}),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 s;console.log("[AssetTextures] Loading all assets...");let i=new Set(["background_loading_1"]),a=[],r=[];for(let[o,d]of e.objects.entries()){let c=(s=d.render)==null?void 0:s.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}: ${o} (${p})`);let g=await fe.load(o,c,t,p);this.textures.set(o,g),console.log(`[AssetTextures] \u2713 Loaded: ${o}`)}catch(p){console.error(`[AssetTextures] \u2717 Failed to load: ${o}`,p)}finally{this.attempted.add(o);try{for(let p of Array.from(this.waiters))p()}catch{}}};i.has(o)?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(o=>typeof o=="string"&&o))).filter(o=>{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,o);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(o=>this.textures.has(o)||this.attempted.has(o));if(r())return;let s=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(o=>{let d=!1,c=()=>{d||r()&&(d=!0,this.waiters.delete(c),o())};this.waiters.add(c),c(),s>0&&setTimeout(()=>{d||(d=!0,this.waiters.delete(c),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),o())},s)})}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())}},Di=new nn,he=new Proxy(Di,{get(n,e){return e in n&&typeof n[e]=="function"?n[e].bind(n):n.get(e)},set(n,e,t){return n.set(e,t),!0}})});var Ni={};Wn(Ni,{AssetEditorModal:()=>ln});var ln,cn=ie(()=>{"use strict";ln=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,i,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=i,this.onApplyCallback=a,this.createModal(e,i),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let i=document.createElement("div");i.className="asset-editor-modal",i.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=i}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let c=o.target.dataset.tab;c&&this.switchTab(c)})});let i=this.modal.querySelector("[data-ai-generate]");i==null||i.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",s=>{s.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 i="";e==="edit"&&this.currentAsset?i=`Edit this image: ${this.currentObjectId}`:i=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",i,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 Br={};Xn(Br,{AssetCache:()=>ee,AssetLoader:()=>fe,AssetSystem:()=>Rt,AssetTextures:()=>he,Assets:()=>fa,BaseSystem:()=>ze,GameEngine:()=>It,GameObject:()=>lt,GameObjectManager:()=>De,ObjectFactory:()=>me,Renderer:()=>ot,RuntimeObjectRegistry:()=>Ne,Transform:()=>st,applyScreenAnchor:()=>$t,basePixi:()=>da,clearResponsiveElements:()=>ma,createPixiBase:()=>kt,getRegisteredFontIds:()=>sa,globalResponsiveMultipliers:()=>dt,initAssetTextures:()=>St,initAssets:()=>ha,layout:()=>ya,playLottieOverlay:()=>la,registerFont:()=>ra,registerType:()=>Et,resolveAnchorVec2:()=>pt,resolveFont:()=>ia,resolveFontWeight:()=>aa,resolveScreenAnchorPoint:()=>He,resolveScreenRatioPoint:()=>Be,runInitSequence:()=>va,setLottieInstance:()=>Ct,spawnSceneFromConfig:()=>ua,updateScreenState:()=>Dt});module.exports=Ca(Br);var na=require("pixi.js");var pe={};function bt(n,e,t=!1){pe[n]||(pe[n]=[]),pe[n].push({fn:e,once:t})}function Gt(n,e){if(pe[n]){if(!e){delete pe[n];return}pe[n]=pe[n].filter(t=>t.fn!==e)}}function yt(n,...e){let t=pe[n];if(t)for(let i of[...t])i.fn(...e),i.once&&Gt(n,i.fn)}function q(n,e){bt(n,e,!0)}var D=null,K=[],Ce=null;function ei(n){D=n,K=[],Ce!==null&&(clearTimeout(Ce),Ce=null)}function ti(){var n,e,t;return{endpoint:(D==null?void 0:D.endpoint)||"",transport:(D==null?void 0:D.transport)||"beacon",batchSize:(n=D==null?void 0:D.batchSize)!=null?n: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 Zn(n,e,t,i){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(n,new Blob([a],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function qt(n,e){let t=ti();if(e&&t.endpoint){if(K.push(n),K.length>t.maxQueue&&(K=K.slice(K.length-t.maxQueue)),K.length>=t.batchSize){Qn();return}Ce===null&&(Ce=window.setTimeout(()=>{Ce=null,Qn()},t.flushIntervalMs))}}async function Qn(){let n=ti();if(!n.endpoint||K.length===0)return;let e=K.splice(0,n.batchSize);await Zn(n.endpoint,{events:e},n.transport,n.debug),K.length>0&&await Zn(n.endpoint,{events:K.splice(0,n.batchSize)},n.transport,n.debug)}function ni(n){return Math.max(0,Math.min(1,n))}function La(n){let e=String(n!=null?n:"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.]+)\)/),i=t?Number(t[1]):1.8;return a=>1+(i+1)*Math.pow(a-1,3)+i*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function Xe(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Ta(n,e){let t=n==null?void 0:n[e];return typeof t=="number"?t:0}function ii(n,e,t){try{n[e]=t}catch{}}function _a(n){let e=n==null?void 0:n.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:t,y:i}}function ai(n,e){let t=n==null?void 0:n.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 ri(n,e){let t=_a(n);if(!t)return{from:null,to:null};let i=null,a=null;return typeof e.scale=="number"?(i=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),i===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:i!=null?i:t.x,y:a!=null?a:t.y}}}function si(){let n=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),n.size>0&&i()})},a=u=>{var p;n.add(u);let l=(p=e.get(u.target))!=null?p:new Set;l.add(u),e.set(u.target,l),i()},r=u=>{n.delete(u);let l=e.get(u.target);l&&(l.delete(u),l.size===0&&e.delete(u.target))},s=u=>{u.killed||(u.killed=!0,r(u))},o=()=>{var l,p;let u=Xe();for(let g of Array.from(n)){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=ni(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=ni(y)}let x=g.ease(A);g.yoyo&&f%2===1&&(x=1-x);for(let y of g.props)ii(g.target,y.key,y.from+(y.to-y.from)*x);g.scaleFrom&&g.scaleTo&&ai(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){s(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=La(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 O of Object.keys(l)){if(f.has(O))continue;let j=l[O];typeof j=="number"&&x.push({key:O,from:Ta(u,O),to:j})}let w=ri(u,l);return{target:u,startMs:Xe(),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:()=>s(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=Xe())},resume:()=>{var h;if(!p.paused)return;let g=(h=p.pauseAtMs)!=null?h:Xe(),m=Xe()-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"&&ii(u,g,m)}let p=ri(u,l);p.to&&ai(u,p.to)},killTweensOf(u){let l=e.get(u);if(l)for(let p of Array.from(l))s(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 oi(){if(typeof window=="undefined")return;let n=window;if(!n.gsap)try{n.gsap=si()}catch{}}var li={name:"handler-playable-sdk",version:"0.3.48",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,Ma=V++,ci=V++,di=V++,pi=V++,ui=V++,gi=V++,fi=V++,hi=V++,mi=V++,bi=V++,yi=V++,vi=V++,M=Ma;function xi(){return M===ci}function wi(){return M===di}function Ei(){return M===pi}function Ai(){return M===ui}function Le(){return M===gi}function Te(){return M===fi}function Si(){return M===hi}function Ci(){return M===mi}function Li(){return M===bi}function Vt(){return M===yi}function Wt(){return M===vi}function Ti(){let n=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(n==="mraid")try{mraid.getState(),M=ci;return}catch{}else if(n==="dapi")try{dapi.isReady(),M=di;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(M=pi)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(M=ui)}catch{}else if(e==="mintegral")window.gameReady&&(M=gi);else if(e==="tapjoy")window.TJ_API&&(M=fi);else if(e==="tiktok")window.openAppStore&&(M=hi);else if(e==="smadex")try{window.smxTracking&&(M=mi)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(M=bi)}catch{}else e==="vungle"?M=yi:(n==="nucleo"||e==="nucleo")&&(M=vi)}var vt=mt(require("lottie-web"),1),_i=vt.default;typeof window!="undefined"&&(window.lottie=vt.default,window.__baseLottie=vt.default);Xt();function $(n,e){let t=(a,r)=>r===0?a:t(r,a%r),i=t(n,e);return`${n/i}:${e/i}`}var xs=[{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)}],ws=[{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)}],Es=[{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)}],Oi=[{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 As=[...Oi];var za=Oi[0];ue();var Ga=mt(require("jszip"),1);function Ba(n){return new Promise((e,t)=>{let i=new FileReader;i.onerror=()=>t(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(n)})}function Fa(n){var a;let[e,t]=n.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}async function Ua(n){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=n})}async function Jt(n){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",n);let i=await fetch(n);if(!i.ok)return console.warn("[ImageUtils] Fetch failed with status:",i.status,n),null;let a=await i.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let r=await Ba(a),s=await Ua(r),o=Fa(r);return console.log("[ImageUtils] Success resolution:",s==null?void 0:s.width,"x",s==null?void 0:s.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:r,width:(e=s==null?void 0:s.width)!=null?e:0,height:(t=s==null?void 0:s.height)!=null?t:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function xt(n,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=n}),i=document.createElement("canvas");i.width=t.width,i.height=t.height;let a=i.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),n;a.drawImage(t,0,0);let r=a.getImageData(0,0,i.width,i.height),s=r.data,d=[{name:"top-left",offset:0},{name:"top-right",offset:(i.width-1)*4},{name:"bottom-left",offset:(i.height-1)*i.width*4},{name:"bottom-right",offset:((i.height-1)*i.width+(i.width-1))*4}].map(l=>({r:s[l.offset],g:s[l.offset+1],b:s[l.offset+2]})),c=0;for(let l=0;l<s.length;l+=4){let p=s[l],g=s[l+1],m=s[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&&(s[l+3]=0,c++)}return console.log(`[ImageUtils] Removed background from ${c} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),i.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),n}}var Ii=require("@google/genai");async function Zt(n,e,t=[],i={}){var a,r,s,o,d,c,u;try{if(!(n!=null&&n.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 Ii.GoogleGenAI({apiKey:n}),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=(s=(r=(a=m.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:s.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),(o=l.message)!=null&&o.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 Ri=require("@google/genai");async function wt(n,e,t=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Ri.GoogleGenAI({apiKey:n}),r=[{text:e}];t.length>0&&t.forEach((o,d)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${d}`),r.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let s=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!s.candidates||!s.candidates[0]||!s.candidates[0].content||!s.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of s.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let d=o.inlineData.data,c=o.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 Xa=require("pixi.js");Je();ue();var Hi=require("pixi.js");var Ja=require("pixi.js");ue();function ar(n){return new Promise((e,t)=>{let i=new FileReader;i.onerror=()=>t(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(n)})}function rr(n){var a;let[e,t]=n.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}function sr(n){return`
46
+ `,this.modal=i}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let c=o.target.dataset.tab;c&&this.switchTab(c)})});let i=this.modal.querySelector("[data-ai-generate]");i==null||i.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",s=>{s.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 i="";e==="edit"&&this.currentAsset?i=`Edit this image: ${this.currentObjectId}`:i=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",i,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 Nr={};Wn(Nr,{AssetCache:()=>Q,AssetLoader:()=>fe,AssetSystem:()=>It,AssetTextures:()=>he,Assets:()=>pa,BaseSystem:()=>Ne,GameEngine:()=>Ot,GameObject:()=>ot,GameObjectManager:()=>$e,ObjectFactory:()=>me,Renderer:()=>st,RuntimeObjectRegistry:()=>He,Transform:()=>rt,applyScreenAnchor:()=>Dt,basePixi:()=>oa,clearResponsiveElements:()=>ga,createPixiBase:()=>Mt,getRegisteredFontIds:()=>ia,globalResponsiveMultipliers:()=>ct,initAssetTextures:()=>At,initAssets:()=>ua,layout:()=>ha,playLottieOverlay:()=>ra,registerFont:()=>na,registerType:()=>wt,resolveAnchorVec2:()=>Ce,resolveFont:()=>ea,resolveFontWeight:()=>ta,resolveScreenAnchorPoint:()=>Be,resolveScreenRatioPoint:()=>Fe,runInitSequence:()=>ma,setLottieInstance:()=>St,spawnSceneFromConfig:()=>ca,updateScreenState:()=>jt});module.exports=Ea(Nr);var Qi=require("pixi.js");var pe={};function mt(n,e,t=!1){pe[n]||(pe[n]=[]),pe[n].push({fn:e,once:t})}function Gt(n,e){if(pe[n]){if(!e){delete pe[n];return}pe[n]=pe[n].filter(t=>t.fn!==e)}}function bt(n,...e){let t=pe[n];if(t)for(let i of[...t])i.fn(...e),i.once&&Gt(n,i.fn)}function q(n,e){mt(n,e,!0)}var D=null,Y=[],Le=null;function Jn(n){D=n,Y=[],Le!==null&&(clearTimeout(Le),Le=null)}function Zn(){var n,e,t;return{endpoint:(D==null?void 0:D.endpoint)||"",transport:(D==null?void 0:D.transport)||"beacon",batchSize:(n=D==null?void 0:D.batchSize)!=null?n: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 Kn(n,e,t,i){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(n,new Blob([a],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function qt(n,e){let t=Zn();if(e&&t.endpoint){if(Y.push(n),Y.length>t.maxQueue&&(Y=Y.slice(Y.length-t.maxQueue)),Y.length>=t.batchSize){Xn();return}Le===null&&(Le=window.setTimeout(()=>{Le=null,Xn()},t.flushIntervalMs))}}async function Xn(){let n=Zn();if(!n.endpoint||Y.length===0)return;let e=Y.splice(0,n.batchSize);await Kn(n.endpoint,{events:e},n.transport,n.debug),Y.length>0&&await Kn(n.endpoint,{events:Y.splice(0,n.batchSize)},n.transport,n.debug)}function Qn(n){return Math.max(0,Math.min(1,n))}function Aa(n){let e=String(n!=null?n:"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.]+)\)/),i=t?Number(t[1]):1.8;return a=>1+(i+1)*Math.pow(a-1,3)+i*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(n,e){let t=n==null?void 0:n[e];return typeof t=="number"?t:0}function ei(n,e,t){try{n[e]=t}catch{}}function Ca(n){let e=n==null?void 0:n.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:t,y:i}}function ti(n,e){let t=n==null?void 0:n.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 ni(n,e){let t=Ca(n);if(!t)return{from:null,to:null};let i=null,a=null;return typeof e.scale=="number"?(i=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),i===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:i!=null?i:t.x,y:a!=null?a:t.y}}}function ii(){let n=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),n.size>0&&i()})},a=u=>{var p;n.add(u);let l=(p=e.get(u.target))!=null?p:new Set;l.add(u),e.set(u.target,l),i()},r=u=>{n.delete(u);let l=e.get(u.target);l&&(l.delete(u),l.size===0&&e.delete(u.target))},s=u=>{u.killed||(u.killed=!0,r(u))},o=()=>{var l,p;let u=Ke();for(let g of Array.from(n)){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=Qn(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=Qn(y)}let x=g.ease(A);g.yoyo&&f%2===1&&(x=1-x);for(let y of g.props)ei(g.target,y.key,y.from+(y.to-y.from)*x);g.scaleFrom&&g.scaleTo&&ti(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){s(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 j=l[I];typeof j=="number"&&x.push({key:I,from:Sa(u,I),to:j})}let w=ni(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:()=>s(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"&&ei(u,g,m)}let p=ni(u,l);p.to&&ti(u,p.to)},killTweensOf(u){let l=e.get(u);if(l)for(let p of Array.from(l))s(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 ai(){if(typeof window=="undefined")return;let n=window;if(!n.gsap)try{n.gsap=ii()}catch{}}var ri={name:"handler-playable-sdk",version:"0.3.49",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,Ta=V++,si=V++,oi=V++,li=V++,ci=V++,di=V++,pi=V++,ui=V++,gi=V++,fi=V++,hi=V++,mi=V++,k=Ta;function bi(){return k===si}function yi(){return k===oi}function vi(){return k===li}function xi(){return k===ci}function Te(){return k===di}function _e(){return k===pi}function wi(){return k===ui}function Ei(){return k===gi}function Ai(){return k===fi}function Vt(){return k===hi}function Wt(){return k===mi}function Si(){let n=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(n==="mraid")try{mraid.getState(),k=si;return}catch{}else if(n==="dapi")try{dapi.isReady(),k=oi;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(k=li)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(k=ci)}catch{}else if(e==="mintegral")window.gameReady&&(k=di);else if(e==="tapjoy")window.TJ_API&&(k=pi);else if(e==="tiktok")window.openAppStore&&(k=ui);else if(e==="smadex")try{window.smxTracking&&(k=gi)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(k=fi)}catch{}else e==="vungle"?k=hi:(n==="nucleo"||e==="nucleo")&&(k=mi)}var yt=ht(require("lottie-web"),1),Ci=yt.default;typeof window!="undefined"&&(window.lottie=yt.default,window.__baseLottie=yt.default);Xt();function $(n,e){let t=(a,r)=>r===0?a:t(r,a%r),i=t(n,e);return`${n/i}:${e/i}`}var ys=[{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)}],vs=[{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)}],xs=[{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)}],Pi=[{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 ws=[...Pi];var ja=Pi[0];ue();var Ba=ht(require("jszip"),1);function za(n){return new Promise((e,t)=>{let i=new FileReader;i.onerror=()=>t(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(n)})}function Na(n){var a;let[e,t]=n.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}async function Ha(n){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=n})}async function Jt(n){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",n);let i=await fetch(n);if(!i.ok)return console.warn("[ImageUtils] Fetch failed with status:",i.status,n),null;let a=await i.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let r=await za(a),s=await Ha(r),o=Na(r);return console.log("[ImageUtils] Success resolution:",s==null?void 0:s.width,"x",s==null?void 0:s.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:r,width:(e=s==null?void 0:s.width)!=null?e:0,height:(t=s==null?void 0:s.height)!=null?t:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function vt(n,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=n}),i=document.createElement("canvas");i.width=t.width,i.height=t.height;let a=i.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),n;a.drawImage(t,0,0);let r=a.getImageData(0,0,i.width,i.height),s=r.data,d=[{name:"top-left",offset:0},{name:"top-right",offset:(i.width-1)*4},{name:"bottom-left",offset:(i.height-1)*i.width*4},{name:"bottom-right",offset:((i.height-1)*i.width+(i.width-1))*4}].map(l=>({r:s[l.offset],g:s[l.offset+1],b:s[l.offset+2]})),c=0;for(let l=0;l<s.length;l+=4){let p=s[l],g=s[l+1],m=s[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&&(s[l+3]=0,c++)}return console.log(`[ImageUtils] Removed background from ${c} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),i.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),n}}var Mi=require("@google/genai");async function Zt(n,e,t=[],i={}){var a,r,s,o,d,c,u;try{if(!(n!=null&&n.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 Mi.GoogleGenAI({apiKey:n}),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=(s=(r=(a=m.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:s.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),(o=l.message)!=null&&o.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 ki=require("@google/genai");async function xt(n,e,t=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new ki.GoogleGenAI({apiKey:n}),r=[{text:e}];t.length>0&&t.forEach((o,d)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${d}`),r.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let s=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!s.candidates||!s.candidates[0]||!s.candidates[0].content||!s.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of s.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let d=o.inlineData.data,c=o.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 $i=require("pixi.js");var Ya=require("pixi.js");ue();function tr(n){return new Promise((e,t)=>{let i=new FileReader;i.onerror=()=>t(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(n)})}function nr(n){var a;let[e,t]=n.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}function ir(n){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:
@@ -60,9 +60,9 @@ Palette: [#RRGGBB, #RRGGBB, ...]
60
60
  ${n?`
61
61
  ADDITIONAL RULES/NOTES:
62
62
  ${n}`:""}
63
- `.trim()}function Bi(){let n=[],e="",t=null;return{async addSources(i){let a=[];for(let r of i){let s=await ar(r),o=rr(s),d={id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,name:r.name,base64:o.base64,mimeType:o.mimeType,dataUrl:s};n.push(d),a.push(d)}return a},getSources(){return n.slice()},async analyze(i,a,r){if(n.length===0)throw new Error("No screenshots to analyze.");let s=sr(a),o=n.map(p=>({base64:p.base64,mimeType:p.mimeType})),d=await Zt(i,s,o,{model:r}),c=e,u=[],l=d.split(`
63
+ `.trim()}function zi(){let n=[],e="",t=null;return{async addSources(i){let a=[];for(let r of i){let s=await tr(r),o=nr(s),d={id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,name:r.name,base64:o.base64,mimeType:o.mimeType,dataUrl:s};n.push(d),a.push(d)}return a},getSources(){return n.slice()},async analyze(i,a,r){if(n.length===0)throw new Error("No screenshots to analyze.");let s=ir(a),o=n.map(p=>({base64:p.base64,mimeType:p.mimeType})),d=await Zt(i,s,o,{model:r}),c=e,u=[],l=d.split(`
64
64
  `);for(let p of l)if(p.toLowerCase().startsWith("summary:"))c=p.slice(8).trim();else if(p.toLowerCase().includes("palette:")){let g=p.match(/#[0-9A-Fa-f]{6}/g);g&&g.forEach(m=>{u.includes(m.toUpperCase())||u.push(m.toUpperCase())})}return(!c||c===e)&&(c=d.split(`
65
- Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:c,palette:u.slice(0,10)},t},setSummary(i){e=i,t&&(t={...t,summary:i})},getResult(){return t}}}var Ee="handler_api_key_";var _e=class{static setKey(e,t,i){try{let a={key:this.encryptKey(t),created:Date.now(),lastUsed:Date.now(),label:i||e},r=`${Ee}${e}`;localStorage.setItem(r,JSON.stringify(a))}catch(a){console.error("[ApiKeyStorage] Failed to store API key:",a)}}static getKey(e){try{let t=`${Ee}${e}`,i=localStorage.getItem(t);if(!i)return null;let a=JSON.parse(i);return a.lastUsed=Date.now(),localStorage.setItem(t,JSON.stringify(a)),this.decryptKey(a.key)}catch(t){return console.error("[ApiKeyStorage] Failed to retrieve API key:",t),null}}static hasKey(e){let t=`${Ee}${e}`;return localStorage.getItem(t)!==null}static removeKey(e){try{let t=`${Ee}${e}`;localStorage.removeItem(t)}catch(t){console.error("[ApiKeyStorage] Failed to remove API key:",t)}}static getStoredServices(){let e=[];try{for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);if(i&&i.startsWith(Ee)){let a=i.substring(Ee.length),r=localStorage.getItem(i);if(r){let s=JSON.parse(r);e.push({service:a,label:s.label,created:s.created,lastUsed:s.lastUsed})}}}}catch(t){console.error("[ApiKeyStorage] Failed to get stored services:",t)}return e.sort((t,i)=>i.lastUsed-t.lastUsed)}static clearAll(){try{let e=[];for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);i&&i.startsWith(Ee)&&e.push(i)}e.forEach(t=>localStorage.removeItem(t))}catch(e){console.error("[ApiKeyStorage] Failed to clear API keys:",e)}}static encryptKey(e){try{let i="handler_preview_salt_2024"+e;return btoa(i)}catch(t){return console.warn("[ApiKeyStorage] Encryption failed, storing as-is:",t),e}}static decryptKey(e){try{let t=atob(e),i="handler_preview_salt_2024";return t.startsWith(i)?t.substring(i.length):t}catch(t){return console.warn("[ApiKeyStorage] Decryption failed, returning as-is:",t),e}}},an=()=>_e.getKey("gemini"),rn=(n,e)=>_e.setKey("gemini",n,e),or=()=>_e.hasKey("gemini");window.ApiKeyStorage=_e;window.getGeminiApiKey=an;window.setGeminiApiKey=rn;window.hasGeminiApiKey=or;var on=class{constructor(){this.modal=null;this.options=null;this.analyzer=Bi();this.currentPrompt="";this.isGenerating=!1;this.generatedImages=[];this.selectedImageIndex=-1;this.promptInput=null;this.generateBtn=null;this.loadingEl=null;this.galleryEl=null;this.previewEl=null}open(e){this.options=e,this.currentPrompt=e.initialPrompt||"",this.generatedImages=[],this.selectedImageIndex=-1,this.isGenerating=!1,this.createModal(),document.body.appendChild(this.modal),setTimeout(()=>{var t,i;(t=this.promptInput)==null||t.focus(),(i=this.promptInput)==null||i.select()},100)}createModal(){var t;let e=document.createElement("div");e.className="ai-modal",e.innerHTML=`
65
+ Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:c,palette:u.slice(0,10)},t},setSummary(i){e=i,t&&(t={...t,summary:i})},getResult(){return t}}}var Ee="handler_api_key_";var Pe=class{static setKey(e,t,i){try{let a={key:this.encryptKey(t),created:Date.now(),lastUsed:Date.now(),label:i||e},r=`${Ee}${e}`;localStorage.setItem(r,JSON.stringify(a))}catch(a){console.error("[ApiKeyStorage] Failed to store API key:",a)}}static getKey(e){try{let t=`${Ee}${e}`,i=localStorage.getItem(t);if(!i)return null;let a=JSON.parse(i);return a.lastUsed=Date.now(),localStorage.setItem(t,JSON.stringify(a)),this.decryptKey(a.key)}catch(t){return console.error("[ApiKeyStorage] Failed to retrieve API key:",t),null}}static hasKey(e){let t=`${Ee}${e}`;return localStorage.getItem(t)!==null}static removeKey(e){try{let t=`${Ee}${e}`;localStorage.removeItem(t)}catch(t){console.error("[ApiKeyStorage] Failed to remove API key:",t)}}static getStoredServices(){let e=[];try{for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);if(i&&i.startsWith(Ee)){let a=i.substring(Ee.length),r=localStorage.getItem(i);if(r){let s=JSON.parse(r);e.push({service:a,label:s.label,created:s.created,lastUsed:s.lastUsed})}}}}catch(t){console.error("[ApiKeyStorage] Failed to get stored services:",t)}return e.sort((t,i)=>i.lastUsed-t.lastUsed)}static clearAll(){try{let e=[];for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);i&&i.startsWith(Ee)&&e.push(i)}e.forEach(t=>localStorage.removeItem(t))}catch(e){console.error("[ApiKeyStorage] Failed to clear API keys:",e)}}static encryptKey(e){try{let i="handler_preview_salt_2024"+e;return btoa(i)}catch(t){return console.warn("[ApiKeyStorage] Encryption failed, storing as-is:",t),e}}static decryptKey(e){try{let t=atob(e),i="handler_preview_salt_2024";return t.startsWith(i)?t.substring(i.length):t}catch(t){return console.warn("[ApiKeyStorage] Decryption failed, returning as-is:",t),e}}},an=()=>Pe.getKey("gemini"),rn=(n,e)=>Pe.setKey("gemini",n,e),ar=()=>Pe.hasKey("gemini");window.ApiKeyStorage=Pe;window.getGeminiApiKey=an;window.setGeminiApiKey=rn;window.hasGeminiApiKey=ar;var on=class{constructor(){this.modal=null;this.options=null;this.analyzer=zi();this.currentPrompt="";this.isGenerating=!1;this.generatedImages=[];this.selectedImageIndex=-1;this.promptInput=null;this.generateBtn=null;this.loadingEl=null;this.galleryEl=null;this.previewEl=null}open(e){this.options=e,this.currentPrompt=e.initialPrompt||"",this.generatedImages=[],this.selectedImageIndex=-1,this.isGenerating=!1,this.createModal(),document.body.appendChild(this.modal),setTimeout(()=>{var t,i;(t=this.promptInput)==null||t.focus(),(i=this.promptInput)==null||i.select()},100)}createModal(){var t;let e=document.createElement("div");e.className="ai-modal",e.innerHTML=`
66
66
  <div class="ai-modal-card">
67
67
  <div class="ai-modal-header">
68
68
  <div class="ai-modal-actions">
@@ -143,7 +143,7 @@ Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:c,palette:u.slice(0
143
143
  </div>
144
144
  `,this.modal=e,this.attachEventListeners(),this.updatePromptFromDna()}attachEventListeners(){var i;if(!this.modal)return;this.promptInput=this.modal.querySelector(".ai-textarea"),this.generateBtn=this.modal.querySelector('[data-action="generate"]'),this.loadingEl=this.modal.querySelector("[data-loading]"),this.galleryEl=this.modal.querySelector("[data-gallery]"),this.previewEl=this.modal.querySelector("[data-preview]"),(i=this.promptInput)==null||i.addEventListener("input",()=>{var a;this.currentPrompt=((a=this.promptInput)==null?void 0:a.value)||"",this.updateGenerateButton()});let e=this.modal.querySelector('[data-strength="creativity"]'),t=this.modal.querySelector(".ai-strength-value");e==null||e.addEventListener("input",()=>{t.textContent=e.value}),this.modal.addEventListener("click",a=>{var o;let r=a.target;switch(r.dataset.action||((o=r.closest("[data-action]"))==null?void 0:o.getAttribute("data-action"))){case"generate":this.generateImage();break;case"apply":this.applySelectedImage();break;case"gallery":this.toggleGallery();break;case"close":case"cancel":this.close();break}}),this.modal.addEventListener("click",a=>{let r=a.target;if(r.classList.contains("ai-gallery-item")||r.closest(".ai-gallery-item")){let s=r.closest(".ai-gallery-item"),o=parseInt(s.dataset.index||"-1");o>=0&&this.selectImage(o)}}),this.modal.addEventListener("click",a=>{a.target===this.modal&&this.close()}),this.updateGenerateButton()}updateGenerateButton(){if(!this.generateBtn)return;let e=this.currentPrompt.trim().length>0;this.generateBtn.disabled=!e||this.isGenerating}async updatePromptFromDna(){var t;let e=(t=this.modal)==null?void 0:t.querySelector("#ai-use-dna");if(e!=null&&e.checked)try{let i=this.analyzer.getResult();if(i!=null&&i.summary&&this.promptInput){let a=`${this.currentPrompt}
145
145
 
146
- Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}catch(i){console.warn("[AiEditorModal] Failed to apply brand DNA:",i)}}async generateImage(){var e,t,i,a;if(!(!this.options||this.isGenerating)){this.isGenerating=!0,this.updateGenerateButton(),(e=this.loadingEl)==null||e.classList.remove("hidden"),(t=this.previewEl)==null||t.classList.add("hidden");try{let r=this.getApiKey();if(!r){alert("Please set your Gemini API key first. You can do this in the AI Creative Suite panel.");return}let s=[];if(this.options.currentValue&&this.options.currentValue.startsWith("data:"))try{let c=await Jt(this.options.currentValue);c&&(s=[{base64:c.base64,mimeType:c.mimeType}])}catch(c){console.warn("[AiEditorModal] Failed to load current image:",c)}let o=await wt(r,this.currentPrompt,s,{aspectRatio:"1:1"}),d=await xt(o);this.generatedImages.push(d||o),this.selectedImageIndex=this.generatedImages.length-1,this.updateGallery(),this.updatePreview(),this.updateApplyButton()}catch(r){console.error("[AiEditorModal] Generation failed:",r),alert(`Generation failed: ${r instanceof Error?r.message:"Unknown error"}`)}finally{this.isGenerating=!1,(i=this.loadingEl)==null||i.classList.add("hidden"),(a=this.previewEl)==null||a.classList.remove("hidden"),this.updateGenerateButton()}}}updateGallery(){if(!this.galleryEl)return;let e=this.galleryEl.querySelector("[data-gallery-grid]");e&&(e.innerHTML=this.generatedImages.map((t,i)=>`
146
+ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}catch(i){console.warn("[AiEditorModal] Failed to apply brand DNA:",i)}}async generateImage(){var e,t,i,a;if(!(!this.options||this.isGenerating)){this.isGenerating=!0,this.updateGenerateButton(),(e=this.loadingEl)==null||e.classList.remove("hidden"),(t=this.previewEl)==null||t.classList.add("hidden");try{let r=this.getApiKey();if(!r){alert("Please set your Gemini API key first. You can do this in the AI Creative Suite panel.");return}let s=[];if(this.options.currentValue&&this.options.currentValue.startsWith("data:"))try{let c=await Jt(this.options.currentValue);c&&(s=[{base64:c.base64,mimeType:c.mimeType}])}catch(c){console.warn("[AiEditorModal] Failed to load current image:",c)}let o=await xt(r,this.currentPrompt,s,{aspectRatio:"1:1"}),d=await vt(o);this.generatedImages.push(d||o),this.selectedImageIndex=this.generatedImages.length-1,this.updateGallery(),this.updatePreview(),this.updateApplyButton()}catch(r){console.error("[AiEditorModal] Generation failed:",r),alert(`Generation failed: ${r instanceof Error?r.message:"Unknown error"}`)}finally{this.isGenerating=!1,(i=this.loadingEl)==null||i.classList.add("hidden"),(a=this.previewEl)==null||a.classList.remove("hidden"),this.updateGenerateButton()}}}updateGallery(){if(!this.galleryEl)return;let e=this.galleryEl.querySelector("[data-gallery-grid]");e&&(e.innerHTML=this.generatedImages.map((t,i)=>`
147
147
  <div class="ai-gallery-item ${i===this.selectedImageIndex?"active":""}" data-index="${i}">
148
148
  <img class="ai-gallery-thumb" src="${t}" alt="Generated ${i+1}" />
149
149
  <div class="ai-gallery-label">#${i+1}</div>
@@ -175,7 +175,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
175
175
  <source src="${a}" type="audio/wav">
176
176
  Your browser does not support the audio element.
177
177
  </audio>
178
- `;case"text":return`<pre style="background: rgba(0,0,0,0.2); padding: 16px; border-radius: 8px; max-height: 300px; overflow-y: auto; white-space: pre-wrap;">${e}</pre>`;default:return`<div class="asset-preview-placeholder">Cannot preview ${t} assets</div>`}}resolveAssetUrl(e){return e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("/")?e:`/raw/${e}`}attachEventListeners(){if(!this.modal)return;this.modal.addEventListener("click",i=>{let a=i.target;(a.dataset.action==="close"||a===this.modal)&&this.close()});let e=this.modal.querySelector('[data-action="change"]');e&&e.addEventListener("click",()=>{this.openAssetEditor()});let t=this.modal.querySelector('[data-action="edit"]');t&&t.addEventListener("click",()=>{this.openAiEditor(),this.close()})}openAssetEditor(){this.options&&Promise.resolve().then(()=>(cn(),Fi)).then(({AssetEditorModal:e})=>{new e().show(this.options.objectId||"unknown",this.options.propertyPath||"",this.options.assetPath,i=>{var a;(a=this.options)!=null&&a.onChange&&this.options.onChange(i),this.close()})})}openAiEditor(){if(!this.options||this.options.assetType!=="image")return;let e=window.__openAiEditor;typeof e=="function"&&e(this.options.objectId||"asset","Edit this image asset",this.options.assetPath,{path:this.options.propertyPath,onApply:t=>{var i;(i=this.options)!=null&&i.onChange&&this.options.onChange(t)}})}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.options=null}};window.openAssetPreview=function(n){new dn().open(n)};var pn=class{constructor(){this.modal=null;this.canvas=null;this.ctx=null;this.image=null;this.options=null;this.cropX=0;this.cropY=0;this.cropWidth=100;this.cropHeight=100;this.scale=1;this.panX=0;this.panY=0;this.isDragging=!1;this.dragStartX=0;this.dragStartY=0;this.lastPanX=0;this.lastPanY=0}open(e){this.options=e,this.createModal(),this.loadImage(),document.body.appendChild(this.modal)}createModal(){let e=document.createElement("div");e.className="asset-crop-modal",e.innerHTML=`
178
+ `;case"text":return`<pre style="background: rgba(0,0,0,0.2); padding: 16px; border-radius: 8px; max-height: 300px; overflow-y: auto; white-space: pre-wrap;">${e}</pre>`;default:return`<div class="asset-preview-placeholder">Cannot preview ${t} assets</div>`}}resolveAssetUrl(e){return e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("/")?e:`/raw/${e}`}attachEventListeners(){if(!this.modal)return;this.modal.addEventListener("click",i=>{let a=i.target;(a.dataset.action==="close"||a===this.modal)&&this.close()});let e=this.modal.querySelector('[data-action="change"]');e&&e.addEventListener("click",()=>{this.openAssetEditor()});let t=this.modal.querySelector('[data-action="edit"]');t&&t.addEventListener("click",()=>{this.openAiEditor(),this.close()})}openAssetEditor(){this.options&&Promise.resolve().then(()=>(cn(),Ni)).then(({AssetEditorModal:e})=>{new e().show(this.options.objectId||"unknown",this.options.propertyPath||"",this.options.assetPath,i=>{var a;(a=this.options)!=null&&a.onChange&&this.options.onChange(i),this.close()})})}openAiEditor(){if(!this.options||this.options.assetType!=="image")return;let e=window.__openAiEditor;typeof e=="function"&&e(this.options.objectId||"asset","Edit this image asset",this.options.assetPath,{path:this.options.propertyPath,onApply:t=>{var i;(i=this.options)!=null&&i.onChange&&this.options.onChange(t)}})}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.options=null}};window.openAssetPreview=function(n){new dn().open(n)};var pn=class{constructor(){this.modal=null;this.canvas=null;this.ctx=null;this.image=null;this.options=null;this.cropX=0;this.cropY=0;this.cropWidth=100;this.cropHeight=100;this.scale=1;this.panX=0;this.panY=0;this.isDragging=!1;this.dragStartX=0;this.dragStartY=0;this.lastPanX=0;this.lastPanY=0}open(e){this.options=e,this.createModal(),this.loadImage(),document.body.appendChild(this.modal)}createModal(){let e=document.createElement("div");e.className="asset-crop-modal",e.innerHTML=`
179
179
  <div class="asset-crop-card">
180
180
  <div class="asset-crop-header">
181
181
  <div>
@@ -226,7 +226,7 @@ Style guidelines: ${i.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 i;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),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,i=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,i-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,i=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,i,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,i,a),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+i-r,t],[e,t+a-r],[e+i-r,t+a-r]].forEach(([o,d])=>{var c;(c=this.ctx)==null||c.fillRect(o,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 i=150;e.width=i,e.height=i;let a=i/this.cropWidth,r=i/this.cropHeight,s=Math.min(a,r),o=this.cropWidth*s,d=this.cropHeight*s,c=(i-o)/2,u=(i-d)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,c,u,o,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",i=>{let a=parseFloat(i.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",i=>{let a=i.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.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,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,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,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,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 i=e.toDataURL("image/png");this.options.onCrop(i),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(n){new pn().open(n)};ue();var Ze=require("pixi.js");At();var lr=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",un=lr;if(typeof window!="undefined")try{let n=new XMLHttpRequest;if(n.open("GET","./build-settings.json",!1),n.send(),n.status===200&&n.responseText){let e=JSON.parse(n.responseText);e!=null&&e.buildMode&&(un=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${un}`))}}catch{}var me=class{static async create(e,t,i){var d,c,u,l,p,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${un}`);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 Ze.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 s=await fe.load(e,a,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=s==null?void 0:s.constructor)==null?void 0:u.name}`);let o;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",e),o=new Ze.Sprite(s),console.log("[ObjectFactory] Created object:",o,"type:",(l=o==null?void 0:o.constructor)==null?void 0:l.name),this.applyTransform(o,t==null?void 0:t.transform,t);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name,s),s&&(((g=s.constructor)==null?void 0:g.name)==="Container"||s instanceof Ze.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){o=await f.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=o==null?void 0:o.constructor)==null?void 0:m.name),A=!0;break}}catch{continue}A||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=s)}else o=s;else o=s,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,t==null?void 0:t.transform,t);return o}static applyTransform(e,t,i){var a,r,s,o;!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((s=t.position.x)!=null?s:0,(o=t.position.y)!=null?o: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&&Array.isArray(t.anchor)&&("set"in e.anchor?e.anchor.set(t.anchor[0],t.anchor[1]):(e.anchor.x=t.anchor[0],e.anchor.y=t.anchor[1])))}};ue();var Ui=mt(require("lottie-web"),1);Ct(_i);typeof window!="undefined"&&!window.lottie&&(window.lottie=Ui.default);Xt();ue();var gn=li.version,dr=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"]);oi();var Xi={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"},Ji=Math.random().toString(36).slice(2),ke=null,Pe={...Xi},Zi="web_embed",bn={},tt,fn=!1,et=!1,it=!1,Qi=!1,wn=1,Tt=0,Mt=!1,oe=!1,Me="",Oe=Math.floor(window.innerWidth),Ie=Math.floor(window.innerHeight),yn=Oe>Ie,le=!1,nt=!1,Gi=!1,qi=!1,hn=!1,_t=null,Ae=null,vn=!1,xn=!1,Lt=new Map;function ea(){if(!Ae)return null;let n=Date.now()-Ae;return!Number.isFinite(n)||n<0?null:n}function mn(n){if(vn)return;let e=ea();e!==null&&(vn=!0,v("session_time",{duration_ms:e,reason:n}))}function Vi(){if(ke)return ke;let n=document.createElement("div");return n.id="handler-root",n.setAttribute("data-handler-root","true"),document.body.appendChild(n),ke=n,n}function Pt(n){switch(n){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return n}}function ta(n,e){return{event_name:n,ts:Date.now(),session_id:Ji,deployment_id:Pe.deployment_id,variant_id:Pe.variant_id,export_profile_id:Pe.profile_id,instance_id:Pe.instance_id||"default",env:Zi==="mraid"?"mraid":"web",attribution:tt,payload:e}}function v(n,e){let t=Pt(n),i=ta(t,e);qt(i,!!bn.analytics),yt(t,i),t!==n&&yt(n,i)}function at(){_t&&(_t(Oe,Ie),_t=null)}function Re(n){wn=n,v("volume",n)}function je(n){n&&(Qi=!0),!it&&(it=!0,v("pause"),Re(0))}function rt(n){!n&&Qi||it&&(it=!1,v("resume"),Re(wn))}function be(n,e){Oe=Math.floor(n||window.innerWidth),Ie=Math.floor(e||window.innerHeight),yn=Oe>Ie,v("resize",{width:Oe,height:Ie})}function pr(){if(xi())try{let n=mraid.getMaxSize();be(n.width,n.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?rt():je()};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,i)=>{console.warn("mraid error:",t,"action:",i)}),Mt=!0,mraid.isViewable()&&mraid.getState()!=="hidden")le=!0,v("boot"),v("view"),v("ready"),oe=!0,at();else{let t=()=>{le=!0,v("boot"),v("view"),v("ready"),oe=!0,at()};mraid.addEventListener("ready",t)}}catch(n){console.warn("MRAID hook skipped",n)}}function ur(){if(wi())try{let n=dapi.getScreenSize();be(n.width,n.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?rt():je()}),dapi.addEventListener("adResized",t=>{let i=dapi.getScreenSize();be(t.width||i.width,t.height||i.height)});let e=dapi.getAudioVolume();if(Re(e?1:0),dapi.addEventListener("audioVolumeChange",t=>Re(t?1:0)),Mt=!0,dapi.isViewable())le=!0,v("boot"),v("view"),v("ready"),oe=!0,at();else{let t=()=>{le=!0,v("boot"),v("view"),v("ready"),oe=!0,at()};dapi.addEventListener("ready",t)}}catch(n){console.warn("DAPI hook skipped",n)}}function Wi(){let n=()=>{le||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(le=!0,v("boot"),v("view"),v("ready"),oe=!0,at(),nt&&(nt=!1,ne.start()))};window.addEventListener("resize",()=>be()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(rt(),n()):je()}),document.readyState==="complete"||document.readyState==="interactive"?n():window.addEventListener("load",n),Mt=!0}function gr(){let n=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(Gi=!0),!(Gi&&e instanceof MouseEvent)&&(Tt+=1,xn||(xn=!0,v("first_interaction",{count:Tt})),v("interaction",Tt))};document.addEventListener("mousedown",n),document.addEventListener("touchstart",n)}function Yi(n){var i,a,r,s,o,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{(i=window.ExitApi)==null||i.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(n||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(Te())(r=(a=window.TJ_API)==null?void 0:a.click)==null||r.call(a);else if(Ei())(o=(s=window.FbPlayableAd)==null?void 0:s.onCTAClick)==null||o.call(s);else if(Li())(c=(d=window.ScPlayableAd)==null?void 0:d.onCTAClick)==null||c.call(d);else if(Ci())try{(l=(u=window.smxTracking)==null?void 0:u.redirect)==null||l.call(u)}catch(h){console.warn("Smadex redirect failed",h)}else if(Ai()){let h=window.ExitApi;h&&typeof h.exit=="function"?h.exit(n||Me||""):n&&window.open(n)}else Le()?(p=window.install)==null||p.call(window):Si()?(g=window.openAppStore)==null||g.call(window):Vt()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):n&&window.open(n)}function fr(){let n=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let i=new Image;i.src=t};if(n==="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 i=()=>e(t.complete);q("complete",i),bt("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.count)>3&&i()}),q("cta_click",()=>e(t.click))}else if(n==="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(i=>setTimeout(()=>e(t[`Spent_${i}_Seconds`]),i*1e3))})}}function hr(){if(!Te())return;let n=window.TJ_API;n&&n.setPlayableAPI&&n.setPlayableAPI({skipAd:()=>{try{ne.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function Ki(){var e,t,i;let n=window.TJ_API;(e=n==null?void 0:n.objectiveComplete)==null||e.call(n),(t=n==null?void 0:n.playableFinished)==null||t.call(n),(i=n==null?void 0:n.gameplayFinished)==null||i.call(n)}function mr(){Le()&&(window.mintGameStart=()=>{rt(!0),be()},window.mintGameClose=()=>{je(!0)})}function br(){if(!Wt())return;let n=window.NUC;!n||!n.trigger||(ne.on("cta_click",()=>{var e,t;return(t=(e=n.trigger).convert)==null?void 0:t.call(e,Me)}),ne.on("complete",()=>{var e,t;return(t=(e=n.trigger).tryAgain)==null?void 0:t.call(e)}))}var ne={init(n={},e){var t;if(Zi=n.profile||"web_embed",bn=n.consent||{},Pe={...Xi,...n.ids||{}},ke=n.rootEl||ke,tt=void 0,ei((t=n.telemetry)!=null&&t.endpoint?n.telemetry:null),Ae=null,vn=!1,xn=!1,Lt.clear(),Me=n.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(_t=e),v("init"),document.body.oncontextmenu=()=>!1,Vi(),vr(ke),Ti(),pr(),ur(),!Mt){if(document.readyState==="complete")Wi();else if(!qi){qi=!0;let i=()=>{Wi(),window.removeEventListener("load",i),document.removeEventListener("DOMContentLoaded",i)};window.addEventListener("load",i),document.addEventListener("DOMContentLoaded",i)}}gr(),fr(),hr(),mr(),br(),console.log(`%c @handler/playable-sdk %c v${gn} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),le&&!oe&&(v("boot"),v("view"),v("ready"),nt&&(nt=!1,ne.start()),oe=!0),oe=le},getRoot(){return Vi()},get version(){return gn},get maxWidth(){return Oe},get maxHeight(){return Ie},get isLandscape(){return yn},get isReady(){return oe},get isStarted(){return fn},get isPaused(){return it},get isFinished(){return et},get volume(){return wn},get interactions(){return Tt},on(n,e){bt(Pt(n),e)},off(n,e){Gt(Pt(n),e)},start(){var n,e;if(!fn){if(!le){nt=!0;return}if(fn=!0,Ae||(Ae=Date.now()),v("start"),be(),Le())je(),(n=window.gameReady)==null||n.call(window);else if(Te()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:yn?"landscape":"portrait",buildID:gn})}}},finish(){var n,e;et||(et=!0,v("complete"),mn("complete"),Le()?(n=window.gameEnd)==null||n.call(window):Vt()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Te()&&Ki())},install(n){if(!et){et=!0,Te()?(Ki(),setTimeout(()=>ne.install(n),300)):(v("complete"),setTimeout(()=>ne.install(n),0));return}hn||(hn=!0,setTimeout(()=>hn=!1,500),v("cta_click"),v("conversion"),mn("cta"),Yi(n||Me))},emit(n,e){let t=Pt(n);if(!dr.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${n} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=ta(t,e);qt(i,!!bn.analytics),yt(t,i)},gameStart(){ne.start()},gameEnd(){ne.finish()},ctaClick(n,e){v("cta_click",{url:n||Me,manual:!0}),(e==null?void 0:e.open)!==!1&&Yi(n||Me)},ctaShow(n){v("cta_show",n)},ctaDismiss(n){v("cta_dismiss",n)},getGameTimeMs(){return ea()},endSession(n="manual"){mn(n)},setAttribution(n){tt=n},abTest(n,e){if(!n)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(yr(`${Ji}:${n}`))%e.length,i=e[t];return tt={...tt||{},experiment_id:n},Pe.variant_id=i,v("ab_assign",{experiment_id:n,variant_id:i}),i},levelStart(n,e){Ae||(Ae=Date.now()),v("level_start",{level_id:n,...e})},levelComplete(n,e){v("level_complete",{level_id:n,...e})},levelFail(n,e){v("level_fail",{level_id:n,...e})},checkpoint(n,e){v("checkpoint",{checkpoint_id:n,...e})},reward(n,e){v("reward",{reward_id:n,...e})},tutorialStart(n,e){v("tutorial_start",{step_id:n,...e})},tutorialComplete(n,e){v("tutorial_complete",{step_id:n,...e})},tutorialSkip(n,e){v("tutorial_skip",{step_id:n,...e})},timerStart(n){n&&Lt.set(n,Date.now())},timerEnd(n,e="custom",t){if(!n)return;let i=Lt.get(n);if(!i)return;Lt.delete(n);let a=Date.now()-i;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){v("engagement",{action:"timer",key:n,duration_ms:a,...t});return}v(e,{key:n,duration_ms:a,...t})}},fps(n,e){v("fps",{value:n,...e})},memory(n,e){v("memory",{bytes:n,...e})},assetLoadStart(n,e){v("asset_load_start",{asset_id:n,...e})},assetLoadComplete(n,e){v("asset_load_complete",{asset_id:n,...e})},reportError(n,e,t){v("error",{code:n,message:e,...t})},retry(){var n,e,t;if(Le())(n=window.gameRetry)==null||n.call(window);else if(Wt()){let i=window.NUC;(t=(e=i==null?void 0:i.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}v("engagement",{action:"retry"})},pause(){je(!0)},resume(){rt(!0)},resize(n,e){be(n,e)}},Qe=ne;function yr(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function vr(n){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 i;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),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,i=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,i-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,i=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,i,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,i,a),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+i-r,t],[e,t+a-r],[e+i-r,t+a-r]].forEach(([o,d])=>{var c;(c=this.ctx)==null||c.fillRect(o,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 i=150;e.width=i,e.height=i;let a=i/this.cropWidth,r=i/this.cropHeight,s=Math.min(a,r),o=this.cropWidth*s,d=this.cropHeight*s,c=(i-o)/2,u=(i-d)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,c,u,o,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",i=>{let a=parseFloat(i.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",i=>{let a=i.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.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,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,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,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,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 i=e.toDataURL("image/png");this.options.onCrop(i),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(n){new pn().open(n)};ue();var Je=require("pixi.js");Et();var rr=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",un=rr;if(typeof window!="undefined")try{let n=new XMLHttpRequest;if(n.open("GET","./build-settings.json",!1),n.send(),n.status===200&&n.responseText){let e=JSON.parse(n.responseText);e!=null&&e.buildMode&&(un=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${un}`))}}catch{}function sr(n){var t,i,a,r,s;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(n);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(n))return{x:(t=n[0])!=null?t:.5,y:(i=n[1])!=null?i:.5};if(n&&typeof n=="object"&&"x"in n&&"y"in n)return{x:(a=n.x)!=null?a:.5,y:(r=n.y)!=null?r:.5};if(typeof n=="string"){let o=n.trim().toLowerCase();return(s=e[o])!=null?s:{x:.5,y:.5}}return null}var me=class{static async create(e,t,i){var d,c,u,l,p,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${un}`);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 s=await fe.load(e,a,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=s==null?void 0:s.constructor)==null?void 0:u.name}`);let o;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",e),o=new Je.Sprite(s),console.log("[ObjectFactory] Created object:",o,"type:",(l=o==null?void 0:o.constructor)==null?void 0:l.name),this.applyTransform(o,t==null?void 0:t.transform,t);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name,s),s&&(((g=s.constructor)==null?void 0:g.name)==="Container"||s 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){o=await f.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=o==null?void 0:o.constructor)==null?void 0:m.name),A=!0;break}}catch{continue}A||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=s)}else o=s;else o=s,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,t==null?void 0:t.transform,t);return o}static applyTransform(e,t,i){var a,r,s,o;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((s=t.position.x)!=null?s:0,(o=t.position.y)!=null?o: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=sr(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 Hi=ht(require("lottie-web"),1);St(Ci);typeof window!="undefined"&&!window.lottie&&(window.lottie=Hi.default);Xt();ue();var gn=ri.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"]);ai();var Wi={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"},Yi=Math.random().toString(36).slice(2),Oe=null,Me={...Wi},Ki="web_embed",bn={},et,fn=!1,Qe=!1,nt=!1,Xi=!1,wn=1,Lt=0,Pt=!1,se=!1,ke="",Ie=Math.floor(window.innerWidth),Re=Math.floor(window.innerHeight),yn=Ie>Re,oe=!1,tt=!1,Bi=!1,Fi=!1,hn=!1,Tt=null,Ae=null,vn=!1,xn=!1,Ct=new Map;function Ji(){if(!Ae)return null;let n=Date.now()-Ae;return!Number.isFinite(n)||n<0?null:n}function mn(n){if(vn)return;let e=Ji();e!==null&&(vn=!0,v("session_time",{duration_ms:e,reason:n}))}function Ui(){if(Oe)return Oe;let n=document.createElement("div");return n.id="handler-root",n.setAttribute("data-handler-root","true"),document.body.appendChild(n),Oe=n,n}function _t(n){switch(n){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return n}}function Zi(n,e){return{event_name:n,ts:Date.now(),session_id:Yi,deployment_id:Me.deployment_id,variant_id:Me.variant_id,export_profile_id:Me.profile_id,instance_id:Me.instance_id||"default",env:Ki==="mraid"?"mraid":"web",attribution:et,payload:e}}function v(n,e){let t=_t(n),i=Zi(t,e);qt(i,!!bn.analytics),bt(t,i),t!==n&&bt(n,i)}function it(){Tt&&(Tt(Ie,Re),Tt=null)}function je(n){wn=n,v("volume",n)}function De(n){n&&(Xi=!0),!nt&&(nt=!0,v("pause"),je(0))}function at(n){!n&&Xi||nt&&(nt=!1,v("resume"),je(wn))}function be(n,e){Ie=Math.floor(n||window.innerWidth),Re=Math.floor(e||window.innerHeight),yn=Ie>Re,v("resize",{width:Ie,height:Re})}function cr(){if(bi())try{let n=mraid.getMaxSize();be(n.width,n.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();je(t?1:0)}if(mraid.addEventListener("audioVolumeChange",t=>{t!==null&&je(t>0?1:0)}),mraid.addEventListener("error",(t,i)=>{console.warn("mraid error:",t,"action:",i)}),Pt=!0,mraid.isViewable()&&mraid.getState()!=="hidden")oe=!0,v("boot"),v("view"),v("ready"),se=!0,it();else{let t=()=>{oe=!0,v("boot"),v("view"),v("ready"),se=!0,it()};mraid.addEventListener("ready",t)}}catch(n){console.warn("MRAID hook skipped",n)}}function dr(){if(yi())try{let n=dapi.getScreenSize();be(n.width,n.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?at():De()}),dapi.addEventListener("adResized",t=>{let i=dapi.getScreenSize();be(t.width||i.width,t.height||i.height)});let e=dapi.getAudioVolume();if(je(e?1:0),dapi.addEventListener("audioVolumeChange",t=>je(t?1:0)),Pt=!0,dapi.isViewable())oe=!0,v("boot"),v("view"),v("ready"),se=!0,it();else{let t=()=>{oe=!0,v("boot"),v("view"),v("ready"),se=!0,it()};dapi.addEventListener("ready",t)}}catch(n){console.warn("DAPI hook skipped",n)}}function Gi(){let n=()=>{oe||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(oe=!0,v("boot"),v("view"),v("ready"),se=!0,it(),tt&&(tt=!1,te.start()))};window.addEventListener("resize",()=>be()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(at(),n()):De()}),document.readyState==="complete"||document.readyState==="interactive"?n():window.addEventListener("load",n),Pt=!0}function pr(){let n=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(Bi=!0),!(Bi&&e instanceof MouseEvent)&&(Lt+=1,xn||(xn=!0,v("first_interaction",{count:Lt})),v("interaction",Lt))};document.addEventListener("mousedown",n),document.addEventListener("touchstart",n)}function qi(n){var i,a,r,s,o,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{(i=window.ExitApi)==null||i.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(n||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(_e())(r=(a=window.TJ_API)==null?void 0:a.click)==null||r.call(a);else if(vi())(o=(s=window.FbPlayableAd)==null?void 0:s.onCTAClick)==null||o.call(s);else if(Ai())(c=(d=window.ScPlayableAd)==null?void 0:d.onCTAClick)==null||c.call(d);else if(Ei())try{(l=(u=window.smxTracking)==null?void 0:u.redirect)==null||l.call(u)}catch(h){console.warn("Smadex redirect failed",h)}else if(xi()){let h=window.ExitApi;h&&typeof h.exit=="function"?h.exit(n||ke||""):n&&window.open(n)}else Te()?(p=window.install)==null||p.call(window):wi()?(g=window.openAppStore)==null||g.call(window):Vt()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):n&&window.open(n)}function ur(){let n=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let i=new Image;i.src=t};if(n==="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 i=()=>e(t.complete);q("complete",i),mt("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.count)>3&&i()}),q("cta_click",()=>e(t.click))}else if(n==="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(i=>setTimeout(()=>e(t[`Spent_${i}_Seconds`]),i*1e3))})}}function gr(){if(!_e())return;let n=window.TJ_API;n&&n.setPlayableAPI&&n.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function Vi(){var e,t,i;let n=window.TJ_API;(e=n==null?void 0:n.objectiveComplete)==null||e.call(n),(t=n==null?void 0:n.playableFinished)==null||t.call(n),(i=n==null?void 0:n.gameplayFinished)==null||i.call(n)}function fr(){Te()&&(window.mintGameStart=()=>{at(!0),be()},window.mintGameClose=()=>{De(!0)})}function hr(){if(!Wt())return;let n=window.NUC;!n||!n.trigger||(te.on("cta_click",()=>{var e,t;return(t=(e=n.trigger).convert)==null?void 0:t.call(e,ke)}),te.on("complete",()=>{var e,t;return(t=(e=n.trigger).tryAgain)==null?void 0:t.call(e)}))}var te={init(n={},e){var t;if(Ki=n.profile||"web_embed",bn=n.consent||{},Me={...Wi,...n.ids||{}},Oe=n.rootEl||Oe,et=void 0,Jn((t=n.telemetry)!=null&&t.endpoint?n.telemetry:null),Ae=null,vn=!1,xn=!1,Ct.clear(),ke=n.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Tt=e),v("init"),document.body.oncontextmenu=()=>!1,Ui(),br(Oe),Si(),cr(),dr(),!Pt){if(document.readyState==="complete")Gi();else if(!Fi){Fi=!0;let i=()=>{Gi(),window.removeEventListener("load",i),document.removeEventListener("DOMContentLoaded",i)};window.addEventListener("load",i),document.addEventListener("DOMContentLoaded",i)}}pr(),ur(),gr(),fr(),hr(),console.log(`%c @handler/playable-sdk %c v${gn} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),oe&&!se&&(v("boot"),v("view"),v("ready"),tt&&(tt=!1,te.start()),se=!0),se=oe},getRoot(){return Ui()},get version(){return gn},get maxWidth(){return Ie},get maxHeight(){return Re},get isLandscape(){return yn},get isReady(){return se},get isStarted(){return fn},get isPaused(){return nt},get isFinished(){return Qe},get volume(){return wn},get interactions(){return Lt},on(n,e){mt(_t(n),e)},off(n,e){Gt(_t(n),e)},start(){var n,e;if(!fn){if(!oe){tt=!0;return}if(fn=!0,Ae||(Ae=Date.now()),v("start"),be(),Te())De(),(n=window.gameReady)==null||n.call(window);else if(_e()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:yn?"landscape":"portrait",buildID:gn})}}},finish(){var n,e;Qe||(Qe=!0,v("complete"),mn("complete"),Te()?(n=window.gameEnd)==null||n.call(window):Vt()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):_e()&&Vi())},install(n){if(!Qe){Qe=!0,_e()?(Vi(),setTimeout(()=>te.install(n),300)):(v("complete"),setTimeout(()=>te.install(n),0));return}hn||(hn=!0,setTimeout(()=>hn=!1,500),v("cta_click"),v("conversion"),mn("cta"),qi(n||ke))},emit(n,e){let t=_t(n);if(!lr.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${n} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Zi(t,e);qt(i,!!bn.analytics),bt(t,i)},gameStart(){te.start()},gameEnd(){te.finish()},ctaClick(n,e){v("cta_click",{url:n||ke,manual:!0}),(e==null?void 0:e.open)!==!1&&qi(n||ke)},ctaShow(n){v("cta_show",n)},ctaDismiss(n){v("cta_dismiss",n)},getGameTimeMs(){return Ji()},endSession(n="manual"){mn(n)},setAttribution(n){et=n},abTest(n,e){if(!n)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(`${Yi}:${n}`))%e.length,i=e[t];return et={...et||{},experiment_id:n},Me.variant_id=i,v("ab_assign",{experiment_id:n,variant_id:i}),i},levelStart(n,e){Ae||(Ae=Date.now()),v("level_start",{level_id:n,...e})},levelComplete(n,e){v("level_complete",{level_id:n,...e})},levelFail(n,e){v("level_fail",{level_id:n,...e})},checkpoint(n,e){v("checkpoint",{checkpoint_id:n,...e})},reward(n,e){v("reward",{reward_id:n,...e})},tutorialStart(n,e){v("tutorial_start",{step_id:n,...e})},tutorialComplete(n,e){v("tutorial_complete",{step_id:n,...e})},tutorialSkip(n,e){v("tutorial_skip",{step_id:n,...e})},timerStart(n){n&&Ct.set(n,Date.now())},timerEnd(n,e="custom",t){if(!n)return;let i=Ct.get(n);if(!i)return;Ct.delete(n);let a=Date.now()-i;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){v("engagement",{action:"timer",key:n,duration_ms:a,...t});return}v(e,{key:n,duration_ms:a,...t})}},fps(n,e){v("fps",{value:n,...e})},memory(n,e){v("memory",{bytes:n,...e})},assetLoadStart(n,e){v("asset_load_start",{asset_id:n,...e})},assetLoadComplete(n,e){v("asset_load_complete",{asset_id:n,...e})},reportError(n,e,t){v("error",{code:n,message:e,...t})},retry(){var n,e,t;if(Te())(n=window.gameRetry)==null||n.call(window);else if(Wt()){let i=window.NUC;(t=(e=i==null?void 0:i.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}v("engagement",{action:"retry"})},pause(){De(!0)},resume(){at(!0)},resize(n,e){be(n,e)}},Ze=te;function mr(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function br(n){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,7 +242,7 @@ Style guidelines: ${i.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
- `,n.appendChild(e)}async function kt(n,e={}){let t=new na.Application;await t.init({resizeTo:n,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let i=s=>{var l,p,g,m;if(!t.renderer)return;let o=(l=s==null?void 0:s.width)!=null?l:n.clientWidth,d=(p=s==null?void 0:s.height)!=null?p:n.clientHeight,c=o&&o>0?o:(g=window.innerWidth)!=null?g:320,u=d&&d>0?d:(m=window.innerHeight)!=null?m:480;t.renderer.resize(c,u)};n.appendChild(t.canvas),n.style.position="relative",n.style.display="flex",n.style.flexDirection="column",n.style.alignItems="stretch",n.style.width="100%",n.style.height="100dvh",n.style.minHeight="100vh",n.style.maxWidth="100%",n.style.maxHeight="100%",n.style.boxSizing="border-box",n.style.overflow="hidden",e.background&&(n.style.background=e.background),i();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(";")),n.appendChild(a),Qe.on("pause",()=>{t.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),Qe.on("resume",()=>{t.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),Qe.on("resize",({payload:s})=>{i({width:s==null?void 0:s.width,height:s==null?void 0:s.height})}),window.addEventListener("resize",()=>i()),requestAnimationFrame(()=>i()),new ResizeObserver(s=>{let o=s[0];if(o&&o.contentRect.width>0&&o.contentRect.height>0){let d=Math.round(o.contentRect.width),c=Math.round(o.contentRect.height);if(i({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(n),{app:t,stage:t.stage,overlay:a,applySize:i}}var U=require("pixi.js"),st=class{constructor(e){var a,r;let t=e==null?void 0:e.position,i=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(i==null?void 0:i.x)=="number"?i.x:0,y:typeof(i==null?void 0:i.y)=="number"?i.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,i=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}),i!==void 0&&(this._offset={x:typeof(i==null?void 0:i.x)=="number"?i.x:0,y:typeof(i==null?void 0:i.y)=="number"?i.y:0}),(t!==void 0||i!==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,i,a,r;this.z_index=(t=e==null?void 0:e.z_index)!=null?t:0,this.alpha=(i=e==null?void 0:e.alpha)!=null?i: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{}}},lt=class{constructor(e,t,i,a){this._tickerCleanup=null;this.onRebuildRequired=null;this.instanceId=e,this.objectConfig=t,this.pixiObject=i,this._config=a,this.transform=new st(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,i=(u=e==null?void 0:e.motion)==null?void 0:u.intro;i!=null&&i.enabled&&JSON.stringify(t)!==JSON.stringify(i)&&(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,s=(b=(A=this._config)==null?void 0:A.ui)==null?void 0:b.renderMode,o=(f=e==null?void 0:e.ui)==null?void 0:f.renderMode;if((a!==r||s!==o)&&(console.log(`[GameObject] Rebuild required for ${this.instanceId}: type changed from ${a}/${s} to ${r}/${o}`),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,s,o;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=(o=(s=this._config)==null?void 0:s.transform)==null?void 0:o.anchor,i=e&&typeof e=="object"?e:t&&typeof t=="object"?t:null;i&&typeof i.x=="number"&&typeof i.y=="number"&&this.pixiObject.anchor.set(i.x,i.y)}applyEffectsScale(){var r,s,o;if(!((r=this.pixiObject)!=null&&r.scale))return;let e=(s=this._config)==null?void 0:s.effects,t=typeof(e==null?void 0:e.scale_x)=="number"?e.scale_x:1,i=typeof(e==null?void 0:e.scale_y)=="number"?e.scale_y:1;if(t===1&&i===1)return;let a=(o=this.transform.scale)!=null?o:1;typeof this.pixiObject.scale.set=="function"?this.pixiObject.scale.set(a*t,a*i):(this.pixiObject.scale.x=a*t,this.pixiObject.scale.y=a*i)}applyEffects(){var i,a,r,s,o,d,c,u,l;if(!this.pixiObject)return;let e=(i=this._config)==null?void 0:i.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((s=e.shadow)!=null&&s.enabled){let p=e.shadow,g=new U.BlurFilter;g.blur=(o=p.blur)!=null?o: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,i=(t.duration||0)/1e3,a=(t.delay||0)/1e3,r=this.transform.position.y,s=this.transform.scale*(((g=(p=this._config)==null?void 0:p.effects)==null?void 0:g.scale_x)||1),o=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(s*t.startScale,o*t.startScale),t.startYOffset!==void 0&&(this.pixiObject.y=r+(t.startYOffset||0)),this._introTicker&&U.Ticker.shared.remove(this._introTicker),i<=0&&a<=0){this.pixiObject.alpha=this.renderer.alpha,this.pixiObject.y=this.transform.position.y,this.pixiObject.scale.set(s,o);return}let d=0,c=b=>{var z,H,I,C,E,S;if(d+=b.deltaTime/60,d<a)return;let f=i>0?Math.min(1,(d-a)/i):1,x=1-Math.pow(1-f,3),w=this.renderer.alpha,y=this.transform.scale*(((H=(z=this._config)==null?void 0:z.effects)==null?void 0:H.scale_x)||1),O=this.transform.scale*(((C=(I=this._config)==null?void 0:I.effects)==null?void 0:C.scale_y)||1),j=this.transform.position.y,N=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 L=t.startScale+(1-t.startScale)*x;this.pixiObject.scale.set(y*L,O*L)}t.startYOffset!==void 0&&(this.pixiObject.y=j+t.startYOffset+(j-(j+t.startYOffset))*x),f>=1&&(U.Ticker.shared.remove(c),this._introTicker=null,this.pixiObject.alpha=w,this.pixiObject.x=N,this.pixiObject.y=j,this.pixiObject.scale.set(y,O))};this._introTicker=c,U.Ticker.shared.add(c)}applyMotion(){var a,r,s;let e=(a=this._config)==null?void 0:a.motion,t=e&&e.enabled!==!1,i=JSON.stringify(e);if(!(this._lastMotionStr===i&&this._tickerCleanup)){if(this._lastMotionStr=i,!t){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null);return}if(this._tickerCleanup&&this._tickerCleanup(),(r=e.pulse)!=null&&r.enabled||(s=e.swing)!=null&&s.enabled){let o=0,d=c=>{var h,A,b,f,x,w,y,O,j,N,z;o+=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 H=(w=e.pulse.intensity)!=null?w:.1,I=(y=e.pulse.speed)!=null?y:1,E=1+Math.sin(o*I)*H;(O=this.pixiObject.scale)!=null&&O.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((j=e.swing)!=null&&j.enabled){let H=(N=e.swing.amplitude)!=null?N:10,I=(z=e.swing.speed)!=null?z:1,C=Math.sin(o*I)*H;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)}},De=class{constructor(e){this.objects=new Map;this.onObjectRebuildRequired=null;this.config=e}create(e,t){let i=this.config.objects.get(e);if(!i)throw new Error(`Object config not found: ${e}`);let a=new lt(e,i.object_config||e,t,i);return this.objects.set(e,a),a.onRebuildRequired=async(r,s)=>{if(this.onObjectRebuildRequired){console.log(`[GameObjectManager] Triggering rebuild for ${e}`);let o=await this.onObjectRebuildRequired(e,s);o&&this.objects.get(e)===o&&console.log(`[GameObjectManager] \u2705 Rebuilt ${e} successfully`)}else console.warn(`[GameObjectManager] Rebuild required for ${e} but no factory provided`),r.updateConfig(s)},a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[t,i]of this.objects.entries()){let a=e.objects.get(t);a&&i.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 Ot={"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 ia(n){let e=Ot[n];return e?e.family:(console.warn(`Font ID "${n}" not found in registry, using fallback`),"Arial, sans-serif")}function aa(n){var t;let e=Ot[n];return e&&(t=e.weight)!=null?t:"400"}function ra(n,e){Ot[n]=e}function sa(){return Object.keys(Ot)}var $e=null;function xr(){return console.log("[LottieOverlay] getLottie called, lottieLib cached?",!!$e),console.log("[LottieOverlay] window.lottie exists?",typeof window!="undefined"&&!!window.lottie),$e||(typeof window!="undefined"&&window.lottie?($e=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(n=>n.toLowerCase().includes("lottie")):"no window"),$e=null)),$e}function wr(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("/")?n:`/${n.replace(/^\.\//,"")}`}function Er(n){try{let e=new XMLHttpRequest;return e.open("GET",wr(n),!1),e.send(null),e.status<200||e.status>=300||!e.responseText?null:JSON.parse(e.responseText)}catch{return null}}function oa(n){return!n||typeof n!="object"||!Array.isArray(n.layers)?null:(Array.isArray(n.assets)||(n.assets=[]),Array.isArray(n.chars)||(n.chars=[]),n)}function Ct(n){$e=n}function la(n,e,t,i){var O,j,N,z,H,I,C,E,S,L,T,J,ye,Fe,Ue,Ge,qe,Ve,We;let a=t.objects.get(n);if(!a)return console.warn(`[LottieOverlay] Object config not found: ${n}`),null;let r=((O=a.effects)==null?void 0:O.lottie)||{},s=a.transform||{},o=a.render||{};if(r.enabled===!1||o.visible===!1)return null;let d=i==null?void 0:i[n],c=oa(d);if(!c){let Z=(N=(j=a.render)==null?void 0:j.asset)==null?void 0:N.path;if(typeof Z=="string"&&Z.toLowerCase().endsWith(".json")){let ut=Er(Z);if(c=oa(ut),c)try{i[n]=c}catch{}}}if(!c){let Z=d&&typeof d=="object"?Object.prototype.toString.call(d):typeof d;return console.warn(`[LottieOverlay] Lottie JSON invalid for: ${n}`,{kind:Z}),null}let u=xr();if(!u)return console.warn(`[LottieOverlay] lottie-web is not available. Cannot play animation: ${n}`),null;let l=(z=r.width)!=null?z:300,p=(H=r.height)!=null?H:300,g=(I=s.scale)!=null?I:1,m=((E=(C=s.position)==null?void 0:C.x)!=null?E:0)+((L=(S=s.offset)==null?void 0:S.x)!=null?L:0),h=((J=(T=s.position)==null?void 0:T.y)!=null?J:0)+((Fe=(ye=s.offset)==null?void 0:ye.y)!=null?Fe:0),A=(Ue=s.rotation)!=null?Ue:0,b=(Ge=o.z_index)!=null?Ge:100,f=(qe=o.alpha)!=null?qe:1,x=document.createElement("div");x.style.cssText=`
245
+ `,n.appendChild(e)}async function Mt(n,e={}){let t=new Qi.Application;await t.init({resizeTo:n,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let i=s=>{var l,p,g,m;if(!t.renderer)return;let o=(l=s==null?void 0:s.width)!=null?l:n.clientWidth,d=(p=s==null?void 0:s.height)!=null?p:n.clientHeight,c=o&&o>0?o:(g=window.innerWidth)!=null?g:320,u=d&&d>0?d:(m=window.innerHeight)!=null?m:480;t.renderer.resize(c,u)};n.appendChild(t.canvas),n.style.position="relative",n.style.display="flex",n.style.flexDirection="column",n.style.alignItems="stretch",n.style.width="100%",n.style.height="100dvh",n.style.minHeight="100vh",n.style.maxWidth="100%",n.style.maxHeight="100%",n.style.boxSizing="border-box",n.style.overflow="hidden",e.background&&(n.style.background=e.background),i();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(";")),n.appendChild(a),Ze.on("pause",()=>{t.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),Ze.on("resume",()=>{t.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),Ze.on("resize",({payload:s})=>{i({width:s==null?void 0:s.width,height:s==null?void 0:s.height})}),window.addEventListener("resize",()=>i()),requestAnimationFrame(()=>i()),new ResizeObserver(s=>{let o=s[0];if(o&&o.contentRect.width>0&&o.contentRect.height>0){let d=Math.round(o.contentRect.width),c=Math.round(o.contentRect.height);if(i({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(n),{app:t,stage:t.stage,overlay:a,applySize:i}}var U=require("pixi.js"),rt=class{constructor(e){var a,r;let t=e==null?void 0:e.position,i=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(i==null?void 0:i.x)=="number"?i.x:0,y:typeof(i==null?void 0:i.y)=="number"?i.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,i=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}),i!==void 0&&(this._offset={x:typeof(i==null?void 0:i.x)=="number"?i.x:0,y:typeof(i==null?void 0:i.y)=="number"?i.y:0}),(t!==void 0||i!==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)}},st=class{constructor(e){var t,i,a,r;this.z_index=(t=e==null?void 0:e.z_index)!=null?t:0,this.alpha=(i=e==null?void 0:e.alpha)!=null?i: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{}}},ot=class{constructor(e,t,i,a){this._tickerCleanup=null;this.onRebuildRequired=null;this.instanceId=e,this.objectConfig=t,this.pixiObject=i,this._config=a,this.transform=new rt(a.transform),this.renderer=new st(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,i=(u=e==null?void 0:e.motion)==null?void 0:u.intro;i!=null&&i.enabled&&JSON.stringify(t)!==JSON.stringify(i)&&(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,s=(b=(A=this._config)==null?void 0:A.ui)==null?void 0:b.renderMode,o=(f=e==null?void 0:e.ui)==null?void 0:f.renderMode;if((a!==r||s!==o)&&(console.log(`[GameObject] Rebuild required for ${this.instanceId}: type changed from ${a}/${s} to ${r}/${o}`),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,s,o;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=(o=(s=this._config)==null?void 0:s.transform)==null?void 0:o.anchor,i=e&&typeof e=="object"?e:t&&typeof t=="object"?t:null;i&&typeof i.x=="number"&&typeof i.y=="number"&&this.pixiObject.anchor.set(i.x,i.y)}applyEffectsScale(){var r,s,o;if(!((r=this.pixiObject)!=null&&r.scale))return;let e=(s=this._config)==null?void 0:s.effects,t=typeof(e==null?void 0:e.scale_x)=="number"?e.scale_x:1,i=typeof(e==null?void 0:e.scale_y)=="number"?e.scale_y:1;if(t===1&&i===1)return;let a=(o=this.transform.scale)!=null?o:1;typeof this.pixiObject.scale.set=="function"?this.pixiObject.scale.set(a*t,a*i):(this.pixiObject.scale.x=a*t,this.pixiObject.scale.y=a*i)}applyEffects(){var i,a,r,s,o,d,c,u,l;if(!this.pixiObject)return;let e=(i=this._config)==null?void 0:i.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((s=e.shadow)!=null&&s.enabled){let p=e.shadow,g=new U.BlurFilter;g.blur=(o=p.blur)!=null?o: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,i=(t.duration||0)/1e3,a=(t.delay||0)/1e3,r=this.transform.position.y,s=this.transform.scale*(((g=(p=this._config)==null?void 0:p.effects)==null?void 0:g.scale_x)||1),o=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(s*t.startScale,o*t.startScale),t.startYOffset!==void 0&&(this.pixiObject.y=r+(t.startYOffset||0)),this._introTicker&&U.Ticker.shared.remove(this._introTicker),i<=0&&a<=0){this.pixiObject.alpha=this.renderer.alpha,this.pixiObject.y=this.transform.position.y,this.pixiObject.scale.set(s,o);return}let d=0,c=b=>{var z,H,R,C,E,S;if(d+=b.deltaTime/60,d<a)return;let f=i>0?Math.min(1,(d-a)/i):1,x=1-Math.pow(1-f,3),w=this.renderer.alpha,y=this.transform.scale*(((H=(z=this._config)==null?void 0:z.effects)==null?void 0:H.scale_x)||1),I=this.transform.scale*(((C=(R=this._config)==null?void 0:R.effects)==null?void 0:C.scale_y)||1),j=this.transform.position.y,N=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 L=t.startScale+(1-t.startScale)*x;this.pixiObject.scale.set(y*L,I*L)}t.startYOffset!==void 0&&(this.pixiObject.y=j+t.startYOffset+(j-(j+t.startYOffset))*x),f>=1&&(U.Ticker.shared.remove(c),this._introTicker=null,this.pixiObject.alpha=w,this.pixiObject.x=N,this.pixiObject.y=j,this.pixiObject.scale.set(y,I))};this._introTicker=c,U.Ticker.shared.add(c)}applyMotion(){var a,r,s;let e=(a=this._config)==null?void 0:a.motion,t=e&&e.enabled!==!1,i=JSON.stringify(e);if(!(this._lastMotionStr===i&&this._tickerCleanup)){if(this._lastMotionStr=i,!t){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null);return}if(this._tickerCleanup&&this._tickerCleanup(),(r=e.pulse)!=null&&r.enabled||(s=e.swing)!=null&&s.enabled){let o=0,d=c=>{var h,A,b,f,x,w,y,I,j,N,z;o+=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 H=(w=e.pulse.intensity)!=null?w:.1,R=(y=e.pulse.speed)!=null?y:1,E=1+Math.sin(o*R)*H;(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((j=e.swing)!=null&&j.enabled){let H=(N=e.swing.amplitude)!=null?N:10,R=(z=e.swing.speed)!=null?z:1,C=Math.sin(o*R)*H;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 i=this.config.objects.get(e);if(!i)throw new Error(`Object config not found: ${e}`);let a=new ot(e,i.object_config||e,t,i);return this.objects.set(e,a),a.onRebuildRequired=async(r,s)=>{if(this.onObjectRebuildRequired){console.log(`[GameObjectManager] Triggering rebuild for ${e}`);let o=await this.onObjectRebuildRequired(e,s);o&&this.objects.get(e)===o&&console.log(`[GameObjectManager] \u2705 Rebuilt ${e} successfully`)}else console.warn(`[GameObjectManager] Rebuild required for ${e} but no factory provided`),r.updateConfig(s)},a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[t,i]of this.objects.entries()){let a=e.objects.get(t);a&&i.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 kt={"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(n){let e=kt[n];return e?e.family:(console.warn(`Font ID "${n}" not found in registry, using fallback`),"Arial, sans-serif")}function ta(n){var t;let e=kt[n];return e&&(t=e.weight)!=null?t:"400"}function na(n,e){kt[n]=e}function ia(){return Object.keys(kt)}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(n=>n.toLowerCase().includes("lottie")):"no window"),ze=null)),ze}function vr(n){return!n||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("/")?n:`/${n.replace(/^\.\//,"")}`}function xr(n){try{let e=new XMLHttpRequest;return e.open("GET",vr(n),!1),e.send(null),e.status<200||e.status>=300||!e.responseText?null:JSON.parse(e.responseText)}catch{return null}}function aa(n){return!n||typeof n!="object"||!Array.isArray(n.layers)?null:(Array.isArray(n.assets)||(n.assets=[]),Array.isArray(n.chars)||(n.chars=[]),n)}function St(n){ze=n}function ra(n,e,t,i){var I,j,N,z,H,R,C,E,S,L,_,X,ye,Ue,Ge,qe,Ve,We,Ye;let a=t.objects.get(n);if(!a)return console.warn(`[LottieOverlay] Object config not found: ${n}`),null;let r=((I=a.effects)==null?void 0:I.lottie)||{},s=a.transform||{},o=a.render||{};if(r.enabled===!1||o.visible===!1)return null;let d=i==null?void 0:i[n],c=aa(d);if(!c){let J=(N=(j=a.render)==null?void 0:j.asset)==null?void 0:N.path;if(typeof J=="string"&&J.toLowerCase().endsWith(".json")){let dt=xr(J);if(c=aa(dt),c)try{i[n]=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: ${n}`,{kind:J}),null}let u=yr();if(!u)return console.warn(`[LottieOverlay] lottie-web is not available. Cannot play animation: ${n}`),null;let l=(z=r.width)!=null?z:300,p=(H=r.height)!=null?H:300,g=(R=s.scale)!=null?R:1,m=((E=(C=s.position)==null?void 0:C.x)!=null?E:0)+((L=(S=s.offset)==null?void 0:S.x)!=null?L:0),h=((X=(_=s.position)==null?void 0:_.y)!=null?X:0)+((Ue=(ye=s.offset)==null?void 0:ye.y)!=null?Ue:0),A=(Ge=s.rotation)!=null?Ge:0,b=(qe=o.z_index)!=null?qe:100,f=(Ve=o.alpha)!=null?Ve:1,x=document.createElement("div");x.style.cssText=`
246
246
  position: absolute;
247
247
  top: calc(50% + ${h}px);
248
248
  left: calc(50% + ${m}px);
@@ -252,4 +252,4 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
252
252
  pointer-events: none;
253
253
  z-index: ${b};
254
254
  opacity: ${f};
255
- `,e.appendChild(x);let w;try{w=u.loadAnimation({container:x,renderer:r.renderer||"svg",loop:(Ve=r.loop)!=null?Ve:!1,autoplay:(We=r.autoplay)!=null?We:!0,animationData:c})}catch(Z){return x.parentNode&&x.parentNode.removeChild(x),console.warn(`[LottieOverlay] Failed to start animation: ${n}`,Z),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}}At();Qt();var It=class{constructor(e,t,i){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=i}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:i}=await kt(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=i,this.gameObjectManager=new De(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:i}=e.detail;this.resize(t,i)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let i of this.systems)i.update&&i.update(t,this.totalTime)}resize(e,t){for(let i of this.systems)i.onResize&&i.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(i=>i instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var ze=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 ca=mt(require("pixi.js"),1),da=ca;typeof window!="undefined"&&(window.__basePixi=ca);Je();var ce=require("pixi.js");Je();var pa=n=>n*Math.PI/180;function Ar(n,e){var s,o,d,c,u;let t=e.ui;if(!(t!=null&&t.text))return null;let i="#ffffff";(s=e.render)!=null&&s.tint&&(i=e.render.tint);let a=new ce.TextStyle({fontFamily:(o=t.font)!=null?o:"Arial",fontSize:(d=t.fontSize)!=null?d:16,fill:i,align:(c=t.align)!=null?c:"center",letterSpacing:(u=t.letterSpacing)!=null?u:0}),r=new ce.Text({text:t.text,style:a});return r.label=n,r}function ua(n){var u,l,p,g,m,h,A,b,f,x;let{stage:e,mainContainer:t,activeConfig:i,gameObjectManager:a,allowList:r,denyList:s}=n,o={},d={},c={};t.sortableChildren=!0;for(let[w,y]of i.objects.entries()){if(s!=null&&s.has(w)||r&&!r.has(w)||(y==null?void 0:y.enabled)===!1)continue;let O=(l=(u=y==null?void 0:y.render)==null?void 0:u.asset)==null?void 0:l.path,j=(g=(p=y==null?void 0:y.render)==null?void 0:p.asset)==null?void 0:g.type,N=!!(O&&j==="image"),z=!!((m=y==null?void 0:y.ui)!=null&&m.text),H=z?(h=y==null?void 0:y.ui)==null?void 0:h.renderMode:void 0,I;if(H==="png"&&N?I="png":H==="text"&&z?I="text":N?I="png":z?I="text":I="skip",I!=="skip"){if(I==="text"){let C=Ar(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,L=(S==null?void 0:S.position)||(S==null?void 0:S.offset);L&&C.position.set((A=L.x)!=null?A:0,(b=L.y)!=null?b:0);let T=typeof(S==null?void 0:S.scale)=="number"?S.scale:1;C.scale.set(T,T);let J=typeof(S==null?void 0:S.rotation)=="number"?S.rotation:0;C.rotation=pa(J),C.parent||t.addChild(C);try{a.create(w,C)}catch{}o[w]=C,c[w]=C}else if(I==="png"){let C=he[w]||(typeof ce.Texture!="undefined"?ce.Texture.EMPTY:void 0),E=new ce.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 L=y.transform,T=(L==null?void 0:L.position)||(L==null?void 0:L.offset);T&&E.position.set((f=T.x)!=null?f:0,(x=T.y)!=null?x:0);let J=typeof(L==null?void 0:L.scale)=="number"?L.scale:1;E.scale.set(J,J);let ye=typeof(L==null?void 0:L.rotation)=="number"?L.rotation:0;E.rotation=pa(ye),E.parent||t.addChild(E);try{a.create(w,E)}catch{}o[w]=E,d[w]=E}}}return t.parent||e.addChild(t),{objects:o,sprites:d,texts:c}}var En=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 i=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async r=>{var o;let s=this.registry.get(r);if(!s){console.warn("[Assets] No config found for object:",r);return}try{let d=await me.create(r,s,this.app);this.instanceCache.set(r,d),console.log("[Assets] Loaded object:",r,(o=d==null?void 0:d.constructor)==null?void 0:o.name)}catch(d){console.error("[Assets] Failed to load object:",r,d)}})))};return this.readyPromise=(async()=>{await i(t);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(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 i=await me.create(e,t,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},ga=new En,fa=new Proxy(ga,{get(n,e){if(e in n&&typeof n[e]=="function")return n[e].bind(n);if(n.get(e))return n.get(e)}});function ha(n,e){ga.init(n,e)}Je();var Rt=class extends ze{async init(){St(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 zt=require("pixi.js"),de={width:400,height:600,designWidth:400,scaleFactor:1},dt={scale:1,position:1},Nt=[];function Sr(n,e,t,i,a,r,s){Nt.push({element:n,originalScale:r,positionHelper:e,heightPercent:a}),e(n,t,i,a,r,s,!1)}function Cr(){Nt.forEach(({element:n,originalScale:e,positionHelper:t,heightPercent:i})=>{let a=e*de.scaleFactor;t(n,de.width,de.height,i,a,!0,!1)})}function ma(){Nt.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Dt(n,e){console.log(`[SCREEN] updateScreenState called: ${n}x${e}`),de.width=n,de.height=e,de.scaleFactor=Math.min(n/de.designWidth,1.15),dt.scale=de.scaleFactor,dt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${dt.scale.toFixed(3)}`),Cr()}var k={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 Lr(n,e,t){let i=k[n];i&&i[e]!==void 0&&(i[e]=t,console.log(`Updated ${n}.${e} = ${t}`))}function Tr(){return k}var _r={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(n,e){return typeof n=="number"&&Number.isFinite(n)?n:e}function pt(n,e={x:.5,y:.5}){var t;if(Array.isArray(n))return{x:jt(n[0],e.x),y:jt(n[1],e.y)};if(n&&typeof n=="object"){let i=n;return{x:jt(i.x,e.x),y:jt(i.y,e.y)}}if(typeof n=="string"){let i=n.trim().toLowerCase();return(t=_r[i])!=null?t:e}return e}function He(n,e,t,i={}){var g,m,h,A,b,f;let a=pt(t),r=(g=i.inset)!=null?g:{},s=(m=i.padding)!=null?m:{x:0,y:0},o=((h=r.left)!=null?h:0)+s.x,d=((A=r.right)!=null?A:0)+s.x,c=((b=r.top)!=null?b:0)+s.y,u=((f=r.bottom)!=null?f:0)+s.y,l=Math.max(0,n-o-d),p=Math.max(0,e-c-u);return{x:o+l*a.x,y:c+p*a.y}}function Be(n,e,t,i={}){var h,A,b,f,x,w;let a=(h=i.inset)!=null?h:{},r=(A=i.padding)!=null?A:{x:0,y:0},s=((b=a.left)!=null?b:0)+r.x,o=((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,n-s-o),l=Math.max(0,e-d-c),p=pt(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:s+u*g,y:d+l*m}}function $t(n,e,t,i={}){var u,l,p;if(!n)return;let a=i.positionRatio?Be(e,t,i.positionRatio,{inset:i.inset,padding:i.screenPadding}):He(e,t,i.anchor,{inset:i.inset,padding:i.screenPadding}),r=(u=i.offset)!=null?u:{x:0,y:0},s=a.x+r.x,o=a.y+r.y;n.anchor&&i.renderAnchor&&n.anchor.set(i.renderAnchor.x,i.renderAnchor.y),X(n,s,o);let d=(l=i.scale)!=null?l:1,c=(p=i.scaleMultiplier)!=null?p:1;(i.scale!==void 0||i.scaleMultiplier!==void 0)&&ie(n,d*c)}if(typeof window!="undefined"){let n=window.innerWidth,e=window.innerHeight,t=()=>{let i=window.innerWidth,a=window.innerHeight;(i!==n||a!==e)&&(n=i,e=a,Dt(i,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Dt(window.innerWidth,window.innerHeight),window.updateDebugConfig=Lr,window.getDebugConfig=Tr,window.copyConfig=Nr,window.applyConfig=ct,window.applyConfigForRatio=Hr,window.positionAtBottom=ba,window.positionAtTop=kr,window.positionAtCenter=Or,window.positionAtLeft=Ir,window.positionAtRight=Rr,window.positionAtBottomLeft=jr,window.positionAtBottomRight=Dr,window.positionAtTopLeft=$r,window.positionAtTopRight=zr,window.applyPositionContract=Mr,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(n,e,t=0){return n*e+t}function Bt(n,e,t=0){return n*(1-e)+t}function Ft(n,e,t=0){return n*e+t}function Ut(n,e,t=0){return n*(1-e)+t}function W(n,e=0){return n/2+e}function Pr(n,e){return n*e}function Mr(n,e,t,i){var s,o,d,c,u,l,p,g,m,h,A,b,f,x,w,y,O,j,N,z;let a=0,r=0;switch(i.type){case"top":a=W(e,(o=(s=i.offset)==null?void 0:s.x)!=null?o:0),r=Ht(t,i.percent,(c=(d=i.offset)==null?void 0:d.y)!=null?c:0);break;case"bottom":a=W(e,(l=(u=i.offset)==null?void 0:u.x)!=null?l:0),r=Bt(t,i.percent,(g=(p=i.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=Ft(e,i.percent,(h=(m=i.offset)==null?void 0:m.x)!=null?h:0),r=W(t,(b=(A=i.offset)==null?void 0:A.y)!=null?b:0);break;case"right":a=Ut(e,i.percent,(x=(f=i.offset)==null?void 0:f.x)!=null?x:0),r=W(t,(y=(w=i.offset)==null?void 0:w.y)!=null?y:0);break;case"center":a=W(e,(j=(O=i.offset)==null?void 0:O.x)!=null?j:0),r=W(t,(z=(N=i.offset)==null?void 0:N.y)!=null?z:0);break}n.position?n.position.set(a,r):(n.x=a,n.y=r),i.scale!==void 0&&i.scale!==1&&n.scale&&(typeof n.scale.set=="function"?n.scale.set(i.scale,i.scale):(n.scale.x=i.scale,n.scale.y=i.scale))}function ba(n,e,t,i=.2,a=1,r=!0,s=!1){let o=Pr(t,i),d=Bt(t,i/2);X(n,W(e),d);let c=r?a*de.scaleFactor:a;ie(n,c),s&&!Nt.find(u=>u.element===n)&&Sr(n,ba,e,t,i,a,r)}function kr(n,e,t,i=.1,a=1){X(n,W(e),Ht(t,i)),ie(n,a)}function Or(n,e,t,i=0,a=0,r=1){X(n,W(e,i),W(t,a)),ie(n,r)}function Ir(n,e,t,i=.1,a=1){X(n,Ft(e,i),W(t)),ie(n,a)}function Rr(n,e,t,i=.1,a=1){X(n,Ut(e,i),W(t)),ie(n,a)}function jr(n,e,t,i=.05,a=.05,r=1){X(n,Ft(e,a),Bt(t,i)),ie(n,r)}function Dr(n,e,t,i=.05,a=.05,r=1){X(n,Ut(e,a),Bt(t,i)),ie(n,r)}function $r(n,e,t,i=.05,a=.05,r=1){X(n,Ft(e,a),Ht(t,i)),ie(n,r)}function zr(n,e,t,i=.05,a=.05,r=1){X(n,Ut(e,a),Ht(t,i)),ie(n,r)}function X(n,e,t){n&&n.position?typeof n.position.set=="function"?n.position.set(e,t):(n.position.x=e,n.position.y=t):n&&(n.x=e,n.y=t)}function ie(n,e){e!==1&&n&&n.scale&&(typeof n.scale.set=="function"?n.scale.set(e,e):n.scale.x!==void 0&&n.scale.y!==void 0&&(n.scale.x=e,n.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 Nr(n){return n&&Se[n]?JSON.parse(JSON.stringify(Se[n])):JSON.parse(JSON.stringify(k))}function ct(n){Object.keys(n).forEach(e=>{let t=e;k[t]&&n[t]&&Object.assign(k[t],n[t])}),console.log("Config applied:",n)}function Hr(n,e){let t=n/e;t>1.6?(ct(Se.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(ct(Se.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(ct(Se.square),console.log("Applied SQUARE config for ratio:",t)):(ct(Se.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let n=window;n.configPresets=Se,n.resolveAnchorVec2=n.resolveAnchorVec2||pt,n.resolveScreenAnchorPoint=n.resolveScreenAnchorPoint||He,n.resolveScreenRatioPoint=n.resolveScreenRatioPoint||Be}var G=null;function ya(n,e,t,i,a,r={}){var J,ye,Fe,Ue,Ge,qe,Ve,We,Z,ut,An,Sn,Cn,Ln,Tn,_n,Pn,Mn,kn,On,In,Rn,jn,Dn,$n,zn,Nn,Hn,Bn,Fn,Un,Gn,qn,Vn,Wn,Yn,Kn;let s=(J=r.enableDebugLogs)!=null?J:!1;s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:i.width,height:i.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",r));let{mainContainer:o,label:d,background:c,backgroundTexture:u,app:l}=n;if(!l||!l.renderer){s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}s&&(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=i.width,g=i.height;s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:p,baseHeight:g});let m=p*k.layout.screen_scale_x,h=g*k.layout.screen_scale_y,A=p/2,b=e.engine.runtime||{},f=b.layout||{};s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:k.layout.screen_scale_x,screen_scale_y:k.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=k.engine.scale)!=null?ye:1),O=(Fe=r.skipMainContainerTransform)!=null?Fe:!1;!O&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(y):(o.scale.x=y,o.scale.y=y));let j=(Ue=f.main_container_anchor)!=null?Ue:"center",N=(Ge=f.main_container_position_ratio)!=null?Ge:{x:.5,y:.5},z=(qe=f.main_container_offset)!=null?qe:{x:0,y:0},H=f.main_container_position_ratio?Be(p,g,N):He(p,g,j),I=H.x+z.x+k.layout.position_offset.x,C=H.y+z.y+k.layout.position_offset.y;if(!O&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(I,C):(o.position.x=I,o.position.y=C)),a&&(o!=null&&o.toLocal))for(let[B,F]of e.objects.entries()){let R=F==null?void 0:F.transform;if(!R||((Ve=R.position_mode)!=null?Ve:"static")!=="static")continue;let _=(We=a.get)==null?void 0:We.call(a,B),Q=((Z=_==null?void 0:_.getDisplayObject)==null?void 0:Z.call(_))||(_==null?void 0:_.pixiObject)||_;if(!Q||Q.parent!==o)continue;let Ye=R.position_ratio!=null?Be(p,g,R.position_ratio):He(p,g,(ut=R.anchor)!=null?ut:"center"),gt=o.toLocal(new zt.Point(Ye.x,Ye.y)),ft=(An=R.position)!=null?An:{x:0,y:0},Ke=gt.x+ft.x,ve=gt.y+ft.y;typeof(_==null?void 0:_.setPosition)=="function"?_.setPosition(Ke,ve):(X(Q,Ke,ve),(Sn=_==null?void 0:_.transform)!=null&&Sn.position&&(_.transform.position.x=Ke,_.transform.position.y=ve))}let E=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,L=((E==null?void 0:E.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(k.layout.debug_rect_visible&&L){(!G||G.parent!==l.stage)&&(G==null||G.destroy(),G=new zt.Graphics,G.zIndex=9999,l.stage.addChild(G)),G.clear();let B=k.layout.debug_rect_scale_x,F=k.layout.debug_rect_scale_y,R=(p-4)*B,Y=(g-4)*F,_=(p-R)/2,Q=(g-Y)/2;s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:R,rectH:Y,offsetX:_,offsetY:Q}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+_,y:2+Q,width:R,height:Y})),G.rect(2+_,2+Q,R,Y).stroke({width:k.layout.debug_rect_thickness,color:k.layout.debug_rect_color})}else G&&(G.destroy(),G=null);let T=((Cn=n.label)==null?void 0:Cn.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(d&&d.position&&T){let B=(Ln=T==null?void 0:T.render)==null?void 0:Ln.anchor,F=(_n=(Tn=T==null?void 0:T.transform)==null?void 0:Tn.anchor)!=null?_n:"center",R=(Pn=T==null?void 0:T.transform)==null?void 0:Pn.position_ratio,Y=((Mn=T==null?void 0:T.transform)==null?void 0:Mn.offset)||{x:0,y:0};$t(d,p,g,{anchor:F,positionRatio:R,offset:{x:Y.x*y,y:Y.y*y},renderAnchor:B})}if(d&&d.alpha>0){let B=1+Math.sin(t*k.engine.label_pulse_speed)*k.engine.label_pulse_intensity,F=(On=(kn=T==null?void 0:T.transform)==null?void 0:kn.scale)!=null?On:1,R=B*y*F;d.scale&&(typeof d.scale.set=="function"?d.scale.set(R):(d.scale.x=R,d.scale.y=R))}if(s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),c){s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!c),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(In=c.constructor)==null?void 0:In.name)),c.alpha=((jn=(Rn=b.background)==null?void 0:Rn.alpha)!=null?jn:.98)*k.engine.background_alpha,s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",c.alpha);let B=e.objects.get("background_1");s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",B);let F=(B==null?void 0:B.transform)||{};s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",F);let R=F.offset||{x:0,y:0},Y=(($n=(Dn=b.background)==null?void 0:Dn.offset_y)!=null?$n:0)+k.engine.background_offset_y,_=(Nn=(zn=B==null?void 0:B.render)==null?void 0:zn.anchor)!=null?Nn:{x:.5,y:.5},Q=(Hn=F.anchor)!=null?Hn:"center",Ye=F.position_ratio;if(s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:R,bgRuntimeOffsetY:Y,bgRenderAnchor:_,bgScreenAnchor:Q,bgPositionRatio:Ye,baseWidth:p,baseHeight:g,finalScale:y}),$t(c,p,g,{anchor:Q,positionRatio:Ye,offset:{x:R.x*y,y:R.y*y+Y},renderAnchor:_}),s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:c.x,y:c.y,scaleX:(Bn=c.scale)==null?void 0:Bn.x,scaleY:(Fn=c.scale)==null?void 0:Fn.y,anchorX:(Un=c.anchor)==null?void 0:Un.x,anchorY:(Gn=c.anchor)==null?void 0:Gn.y,pivotX:(qn=c.pivot)==null?void 0:qn.x,pivotY:(Vn=c.pivot)==null?void 0:Vn.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 gt=Math.max(m/u.width,h/u.height),ft=(Yn=(Wn=b.background)==null?void 0:Wn.scale_multiplier)!=null?Yn:1.05,Ke=(Kn=F.scale)!=null?Kn:1,ve=gt*ft*k.engine.background_scale*Ke;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 va(n){var o,d,c;let{setState:e,updateLabelAlpha:t,updateHandAlpha:i,config:a,states:r}=n,s=((d=(o=a.engine)==null?void 0:o.runtime)==null?void 0:d.timeline)||{};e(r.showHook),setTimeout(()=>{t(1),i(1),e(r.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(c=s.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});
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: ${n}`,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,i){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=i}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:i}=await Mt(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=i,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:i}=e.detail;this.resize(t,i)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let i of this.systems)i.update&&i.update(t,this.totalTime)}resize(e,t){for(let i of this.systems)i.onResize&&i.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(i=>i instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var Ne=class{setContext(e){this.context=e}};var He=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 sa=ht(require("pixi.js"),1),oa=sa;typeof window!="undefined"&&(window.__basePixi=sa);Xe();var le=require("pixi.js");Xe();var la=n=>n*Math.PI/180;function wr(n,e){var s,o,d,c,u;let t=e.ui;if(!(t!=null&&t.text))return null;let i="#ffffff";(s=e.render)!=null&&s.tint&&(i=e.render.tint);let a=new le.TextStyle({fontFamily:(o=t.font)!=null?o:"Arial",fontSize:(d=t.fontSize)!=null?d:16,fill:i,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=n,r}function ca(n){var u,l,p,g,m,h,A,b,f,x;let{stage:e,mainContainer:t,activeConfig:i,gameObjectManager:a,allowList:r,denyList:s}=n,o={},d={},c={};t.sortableChildren=!0;for(let[w,y]of i.objects.entries()){if(s!=null&&s.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,j=(g=(p=y==null?void 0:y.render)==null?void 0:p.asset)==null?void 0:g.type,N=!!(I&&j==="image"),z=!!((m=y==null?void 0:y.ui)!=null&&m.text),H=z?(h=y==null?void 0:y.ui)==null?void 0:h.renderMode:void 0,R;if(H==="png"&&N?R="png":H==="text"&&z?R="text":N?R="png":z?R="text":R="skip",R!=="skip"){if(R==="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,L=(S==null?void 0:S.position)||(S==null?void 0:S.offset);L&&C.position.set((A=L.x)!=null?A:0,(b=L.y)!=null?b:0);let _=typeof(S==null?void 0:S.scale)=="number"?S.scale:1;C.scale.set(_,_);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{}o[w]=C,c[w]=C}else if(R==="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 L=y.transform,_=(L==null?void 0:L.position)||(L==null?void 0:L.offset);_&&E.position.set((f=_.x)!=null?f:0,(x=_.y)!=null?x:0);let X=typeof(L==null?void 0:L.scale)=="number"?L.scale:1;E.scale.set(X,X);let ye=typeof(L==null?void 0:L.rotation)=="number"?L.rotation:0;E.rotation=la(ye),E.parent||t.addChild(E);try{a.create(w,E)}catch{}o[w]=E,d[w]=E}}}return t.parent||e.addChild(t),{objects:o,sprites:d,texts:c}}var En=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new He}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 i=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async r=>{var o;let s=this.registry.get(r);if(!s){console.warn("[Assets] No config found for object:",r);return}try{let d=await me.create(r,s,this.app);this.instanceCache.set(r,d),console.log("[Assets] Loaded object:",r,(o=d==null?void 0:d.constructor)==null?void 0:o.name)}catch(d){console.error("[Assets] Failed to load object:",r,d)}})))};return this.readyPromise=(async()=>{await i(t);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(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 i=await me.create(e,t,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},da=new En,pa=new Proxy(da,{get(n,e){if(e in n&&typeof n[e]=="function")return n[e].bind(n);if(n.get(e))return n.get(e)}});function ua(n,e){da.init(n,e)}Xe();var It=class extends Ne{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(n,e,t,i,a,r,s){zt.push({element:n,originalScale:r,positionHelper:e,heightPercent:a}),e(n,t,i,a,r,s,!1)}function Ar(){zt.forEach(({element:n,originalScale:e,positionHelper:t,heightPercent:i})=>{let a=e*ce.scaleFactor;t(n,ce.width,ce.height,i,a,!0,!1)})}function ga(){zt.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function jt(n,e){console.log(`[SCREEN] updateScreenState called: ${n}x${e}`),ce.width=n,ce.height=e,ce.scaleFactor=Math.min(n/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(n,e,t){let i=O[n];i&&i[e]!==void 0&&(i[e]=t,console.log(`Updated ${n}.${e} = ${t}`))}function Cr(){return O}var Lr={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 Rt(n,e){return typeof n=="number"&&Number.isFinite(n)?n:e}function Ce(n,e={x:.5,y:.5}){var t;if(Array.isArray(n))return{x:Rt(n[0],e.x),y:Rt(n[1],e.y)};if(n&&typeof n=="object"){let i=n;return{x:Rt(i.x,e.x),y:Rt(i.y,e.y)}}if(typeof n=="string"){let i=n.trim().toLowerCase();return(t=Lr[i])!=null?t:e}return e}function Be(n,e,t,i={}){var g,m,h,A,b,f;let a=Ce(t),r=(g=i.inset)!=null?g:{},s=(m=i.padding)!=null?m:{x:0,y:0},o=((h=r.left)!=null?h:0)+s.x,d=((A=r.right)!=null?A:0)+s.x,c=((b=r.top)!=null?b:0)+s.y,u=((f=r.bottom)!=null?f:0)+s.y,l=Math.max(0,n-o-d),p=Math.max(0,e-c-u);return{x:o+l*a.x,y:c+p*a.y}}function Fe(n,e,t,i={}){var h,A,b,f,x,w;let a=(h=i.inset)!=null?h:{},r=(A=i.padding)!=null?A:{x:0,y:0},s=((b=a.left)!=null?b:0)+r.x,o=((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,n-s-o),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:s+u*g,y:d+l*m}}function Dt(n,e,t,i={}){var u,l,p;if(!n)return;let a=i.positionRatio?Fe(e,t,i.positionRatio,{inset:i.inset,padding:i.screenPadding}):Be(e,t,i.anchor,{inset:i.inset,padding:i.screenPadding}),r=(u=i.offset)!=null?u:{x:0,y:0},s=a.x+r.x,o=a.y+r.y;n.anchor&&i.renderAnchor&&n.anchor.set(i.renderAnchor.x,i.renderAnchor.y),K(n,s,o);let d=(l=i.scale)!=null?l:1,c=(p=i.scaleMultiplier)!=null?p:1;(i.scale!==void 0||i.scaleMultiplier!==void 0)&&ne(n,d*c)}if(typeof window!="undefined"){let n=window.innerWidth,e=window.innerHeight,t=()=>{let i=window.innerWidth,a=window.innerHeight;(i!==n||a!==e)&&(n=i,e=a,jt(i,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),jt(window.innerWidth,window.innerHeight),window.updateDebugConfig=Sr,window.getDebugConfig=Cr,window.copyConfig=$r,window.applyConfig=lt,window.applyConfigForRatio=zr,window.positionAtBottom=fa,window.positionAtTop=Pr,window.positionAtCenter=Mr,window.positionAtLeft=kr,window.positionAtRight=Or,window.positionAtBottomLeft=Ir,window.positionAtBottomRight=Rr,window.positionAtTopLeft=jr,window.positionAtTopRight=Dr,window.applyPositionContract=_r,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 Nt(n,e,t=0){return n*e+t}function Ht(n,e,t=0){return n*(1-e)+t}function Bt(n,e,t=0){return n*e+t}function Ft(n,e,t=0){return n*(1-e)+t}function W(n,e=0){return n/2+e}function Tr(n,e){return n*e}function _r(n,e,t,i){var s,o,d,c,u,l,p,g,m,h,A,b,f,x,w,y,I,j,N,z;let a=0,r=0;switch(i.type){case"top":a=W(e,(o=(s=i.offset)==null?void 0:s.x)!=null?o:0),r=Nt(t,i.percent,(c=(d=i.offset)==null?void 0:d.y)!=null?c:0);break;case"bottom":a=W(e,(l=(u=i.offset)==null?void 0:u.x)!=null?l:0),r=Ht(t,i.percent,(g=(p=i.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=Bt(e,i.percent,(h=(m=i.offset)==null?void 0:m.x)!=null?h:0),r=W(t,(b=(A=i.offset)==null?void 0:A.y)!=null?b:0);break;case"right":a=Ft(e,i.percent,(x=(f=i.offset)==null?void 0:f.x)!=null?x:0),r=W(t,(y=(w=i.offset)==null?void 0:w.y)!=null?y:0);break;case"center":a=W(e,(j=(I=i.offset)==null?void 0:I.x)!=null?j:0),r=W(t,(z=(N=i.offset)==null?void 0:N.y)!=null?z:0);break}n.position?n.position.set(a,r):(n.x=a,n.y=r),i.scale!==void 0&&i.scale!==1&&n.scale&&(typeof n.scale.set=="function"?n.scale.set(i.scale,i.scale):(n.scale.x=i.scale,n.scale.y=i.scale))}function fa(n,e,t,i=.2,a=1,r=!0,s=!1){let o=Tr(t,i),d=Ht(t,i/2);K(n,W(e),d);let c=r?a*ce.scaleFactor:a;ne(n,c),s&&!zt.find(u=>u.element===n)&&Er(n,fa,e,t,i,a,r)}function Pr(n,e,t,i=.1,a=1){K(n,W(e),Nt(t,i)),ne(n,a)}function Mr(n,e,t,i=0,a=0,r=1){K(n,W(e,i),W(t,a)),ne(n,r)}function kr(n,e,t,i=.1,a=1){K(n,Bt(e,i),W(t)),ne(n,a)}function Or(n,e,t,i=.1,a=1){K(n,Ft(e,i),W(t)),ne(n,a)}function Ir(n,e,t,i=.05,a=.05,r=1){K(n,Bt(e,a),Ht(t,i)),ne(n,r)}function Rr(n,e,t,i=.05,a=.05,r=1){K(n,Ft(e,a),Ht(t,i)),ne(n,r)}function jr(n,e,t,i=.05,a=.05,r=1){K(n,Bt(e,a),Nt(t,i)),ne(n,r)}function Dr(n,e,t,i=.05,a=.05,r=1){K(n,Ft(e,a),Nt(t,i)),ne(n,r)}function K(n,e,t){n&&n.position?typeof n.position.set=="function"?n.position.set(e,t):(n.position.x=e,n.position.y=t):n&&(n.x=e,n.y=t)}function ne(n,e){e!==1&&n&&n.scale&&(typeof n.scale.set=="function"?n.scale.set(e,e):n.scale.x!==void 0&&n.scale.y!==void 0&&(n.scale.x=e,n.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(n){return n&&Se[n]?JSON.parse(JSON.stringify(Se[n])):JSON.parse(JSON.stringify(O))}function lt(n){Object.keys(n).forEach(e=>{let t=e;O[t]&&n[t]&&Object.assign(O[t],n[t])}),console.log("Config applied:",n)}function zr(n,e){let t=n/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 n=window;n.configPresets=Se,n.resolveAnchorVec2=n.resolveAnchorVec2||Ce,n.resolveScreenAnchorPoint=n.resolveScreenAnchorPoint||Be,n.resolveScreenRatioPoint=n.resolveScreenRatioPoint||Fe}var G=null;function ha(n,e,t,i,a,r={}){var X,ye,Ue,Ge,qe,Ve,We,Ye,J,dt,An,Sn,Cn,Ln,Tn,_n,Pn,Mn,kn,On,In,Rn,jn,Dn,$n,zn,Nn,Hn,Bn,Fn,Un,Gn,qn,Vn;let s=(X=r.enableDebugLogs)!=null?X:!1;s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:i.width,height:i.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",r));let{mainContainer:o,label:d,background:c,backgroundTexture:u,app:l}=n;if(!l||!l.renderer){s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}s&&(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=i.width,g=i.height;s&&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||{};s&&(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&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(y):(o.scale.x=y,o.scale.y=y));let j=(Ge=f.main_container_anchor)!=null?Ge:"center",N=(qe=f.main_container_position_ratio)!=null?qe:{x:.5,y:.5},z=(Ve=f.main_container_offset)!=null?Ve:{x:0,y:0},H=f.main_container_position_ratio?Fe(p,g,N):Be(p,g,j),R=H.x+z.x+O.layout.position_offset.x,C=H.y+z.y+O.layout.position_offset.y;if(!I&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(R,C):(o.position.x=R,o.position.y=C)),a&&(o!=null&&o.toLocal))for(let[F,B]of e.objects.entries()){let M=B==null?void 0:B.transform;if(!M||((We=M.position_mode)!=null?We:"static")!=="static")continue;let T=(Ye=a.get)==null?void 0:Ye.call(a,F),Z=((J=T==null?void 0:T.getDisplayObject)==null?void 0:J.call(T))||(T==null?void 0:T.pixiObject)||T;if(!Z||Z.parent!==o)continue;let pt=M.position_ratio!=null?Fe(p,g,M.position_ratio):Be(p,g,(dt=M.anchor)!=null?dt:"center"),ut=o.toLocal(new $t.Point(pt.x,pt.y)),gt=(An=M.position)!=null?An:{x:0,y:0},ve=ut.x+gt.x,Ut=ut.y+gt.y;typeof(T==null?void 0:T.setPosition)=="function"?T.setPosition(ve,Ut):(K(Z,ve,Ut),(Sn=T==null?void 0:T.transform)!=null&&Sn.position&&(T.transform.position.x=ve,T.transform.position.y=Ut))}let E=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,L=((E==null?void 0:E.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(O.layout.debug_rect_visible&&L){(!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,M=(p-4)*F,de=(g-4)*B,T=(p-M)/2,Z=(g-de)/2;s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:M,rectH:de,offsetX:T,offsetY:Z}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+T,y:2+Z,width:M,height:de})),G.rect(2+T,2+Z,M,de).stroke({width:O.layout.debug_rect_thickness,color:O.layout.debug_rect_color})}else G&&(G.destroy(),G=null);let _=((Cn=n.label)==null?void 0:Cn.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(d&&d.position&&_){let F=(Tn=(Ln=_==null?void 0:_.transform)==null?void 0:Ln.anchor)!=null?Tn:"center",B=(_n=_==null?void 0:_.transform)==null?void 0:_n.position_ratio,M=((Pn=_==null?void 0:_.transform)==null?void 0:Pn.offset)||{x:0,y:0};Dt(d,p,g,{anchor:F,positionRatio:B,offset:{x:M.x*y,y:M.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=(kn=(Mn=_==null?void 0:_.transform)==null?void 0:Mn.scale)!=null?kn:1,M=F*y*B;d.scale&&(typeof d.scale.set=="function"?d.scale.set(M):(d.scale.x=M,d.scale.y=M))}if(s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),c){s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!c),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(On=c.constructor)==null?void 0:On.name)),c.alpha=((Rn=(In=b.background)==null?void 0:In.alpha)!=null?Rn:.98)*O.engine.background_alpha,s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",c.alpha);let F=e.objects.get("background_1");s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",F);let B=(F==null?void 0:F.transform)||{};s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",B);let M=B.offset||{x:0,y:0},de=((Dn=(jn=b.background)==null?void 0:jn.offset_y)!=null?Dn:0)+O.engine.background_offset_y,T=($n=B.anchor)!=null?$n:"center",Z=B.position_ratio;if(s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:M,bgRuntimeOffsetY:de,bgScreenAnchor:T,bgPositionRatio:Z,baseWidth:p,baseHeight:g,finalScale:y}),Dt(c,p,g,{anchor:T,positionRatio:Z,offset:{x:M.x*y,y:M.y*y+de},renderAnchor:Ce(T)}),s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:c.x,y:c.y,scaleX:(zn=c.scale)==null?void 0:zn.x,scaleY:(Nn=c.scale)==null?void 0:Nn.y,anchorX:(Hn=c.anchor)==null?void 0:Hn.x,anchorY:(Bn=c.anchor)==null?void 0:Bn.y,pivotX:(Fn=c.pivot)==null?void 0:Fn.x,pivotY:(Un=c.pivot)==null?void 0:Un.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=(qn=(Gn=b.background)==null?void 0:Gn.scale_multiplier)!=null?qn:1.05,gt=(Vn=B.scale)!=null?Vn: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(n){var o,d,c;let{setState:e,updateLabelAlpha:t,updateHandAlpha:i,config:a,states:r}=n,s=((d=(o=a.engine)==null?void 0:o.runtime)==null?void 0:d.timeline)||{};e(r.showHook),setTimeout(()=>{t(1),i(1),e(r.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(c=s.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});