handler-playable-sdk 1.0.88 → 1.0.90

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.
Files changed (46) hide show
  1. package/dist/AssetCropModal-5GIDIW5V.js +1 -0
  2. package/dist/chunk-JYGZ4R4K.js +52 -0
  3. package/dist/{chunk-GM4KXIYY.js → chunk-NHIKK74M.js} +126 -155
  4. package/dist/cli/brand-dna.mjs +1 -1
  5. package/dist/cli/canva-import.mjs +1 -1
  6. package/dist/cli/cleanup-assets.mjs +1 -1
  7. package/dist/cli/fix-scales.mjs +1 -1
  8. package/dist/cli/index.js +1 -1
  9. package/dist/cli/screen-helper.mjs +1 -1
  10. package/dist/cli/setup-library.mjs +1 -1
  11. package/dist/cli/student-helper/add-logic.mjs +1 -1
  12. package/dist/cli/student-helper/add-object.mjs +1 -1
  13. package/dist/cli/student-helper/arg-parsing.mjs +1 -1
  14. package/dist/cli/student-helper/asset-registry.mjs +1 -1
  15. package/dist/cli/student-helper/bullet-system.mjs +1 -1
  16. package/dist/cli/student-helper/collectable-system.mjs +1 -1
  17. package/dist/cli/student-helper/constants.mjs +1 -1
  18. package/dist/cli/student-helper/drag-snap-couples.mjs +1 -1
  19. package/dist/cli/student-helper/endgame-screen.mjs +1 -1
  20. package/dist/cli/student-helper/fs-io.mjs +1 -1
  21. package/dist/cli/student-helper/logic-defaults.mjs +1 -1
  22. package/dist/cli/student-helper/print-help.mjs +1 -1
  23. package/dist/cli/student-helper/prompts.mjs +1 -1
  24. package/dist/cli/student-helper/scratch-card.mjs +1 -1
  25. package/dist/cli/student-helper/screen-utils.mjs +1 -1
  26. package/dist/cli/student-helper/snippets.mjs +1 -1
  27. package/dist/cli/student-helper/start-screen.mjs +1 -1
  28. package/dist/cli/student-helper/swerve-collect.mjs +1 -1
  29. package/dist/cli/student-helper/tap-destroy.mjs +1 -1
  30. package/dist/cli/student-helper/template-packs.mjs +1 -1
  31. package/dist/cli/student-helper.mjs +1 -1
  32. package/dist/cli/sync-screens.mjs +1 -1
  33. package/dist/cli/validate-assets.mjs +1 -1
  34. package/dist/cli/validate.mjs +1 -1
  35. package/dist/index.cjs +225 -203
  36. package/dist/index.css +36 -0
  37. package/dist/index.d.cts +1 -0
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.js +1 -1
  40. package/dist/pixi/index.cjs +88 -68
  41. package/dist/pixi/index.css +36 -0
  42. package/dist/pixi/index.js +1 -1
  43. package/dist/three/index.cjs +124 -104
  44. package/dist/three/index.css +36 -0
  45. package/dist/three/index.js +1 -1
  46. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- "use strict";var Ga=Object.create;var Rt=Object.defineProperty;var Ua=Object.getOwnPropertyDescriptor;var qa=Object.getOwnPropertyNames;var Va=Object.getPrototypeOf,Ya=Object.prototype.hasOwnProperty;var he=(i,e)=>()=>(i&&(e=i(i=0)),e);var mn=(i,e)=>{for(var t in e)Rt(i,t,{get:e[t],enumerable:!0})},bn=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of qa(e))!Ya.call(i,a)&&a!==t&&Rt(i,a,{get:()=>e[a],enumerable:!(n=Ua(e,a))||n.enumerable});return i};var ci=(i,e,t)=>(t=i!=null?Ga(Va(i)):{},bn(e||!i||!i.__esModule?Rt(t,"default",{value:i,enumerable:!0}):t,i)),Wa=i=>bn(Rt({},"__esModule",{value:!0}),i);var es,ce=he(()=>{"use strict";es="handler_preview_override_mode";if(typeof window!="undefined"){let i=window.localStorage.getItem(es);window.__enableConfigOverrides=i===null?!0:i==="true"}});var Kn,ze,Ar,hi=he(()=>{"use strict";ce();Kn=null,ze="dev";if(typeof window!="undefined"){let i=window.__BUILD_SETTINGS__;if(i!=null&&i.buildMode)Kn=i,ze=i.buildMode,console.log("[CONFIG] Loaded inline build settings:",i,"buildMode:",ze);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);Kn=t,ze=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",ze)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",ze)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",ze);Ar=ze==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var fi=he(()=>{"use strict"});var Jn=he(()=>{"use strict";fi();hi()});var mi=he(()=>{"use strict";hi();fi();Jn()});var re,Kt=he(()=>{"use strict";re=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()}};re.store=new Map});function ks(){var i,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(i=document.querySelector("script"))==null?void 0:i.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),n=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!n)}catch{return!1}}async function Ps(){try{if(typeof window!="undefined"){let i=await fetch("./build-settings.json");if(i.ok){let e=await i.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Is(){try{if(typeof window!="undefined"){let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}async function Ms(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${M}`),Object.keys(me).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(me)),me;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),me={...window.INLINE_ASSETS},me;if(!(M==="publish"&&pe!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),me;if(!wi){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),wi=(async()=>{try{try{let s=await import(e+"?t="+Date.now());if(s.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(s.INLINE_ASSETS)),s.INLINE_ASSETS}catch(s){console.warn("[AssetLoader] ES module import failed, trying text parse:",s)}let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.text();console.log("[AssetLoader] Received JS code, length:",n.length);let a=n.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)try{let s=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let r=new Function("return "+s)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(r)),r}catch(s){return console.warn("[AssetLoader] Failed to parse inline assets:",s),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",n.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return me=await wi,console.log("[AssetLoader] Final inline assets cache:",Object.keys(me)),me}function xi(i){return i===null||typeof i!="object"||(Object.freeze(i),Object.values(i).forEach(e=>xi(e))),i}function js(i=64,e=64,t=16711680){let n=document.createElement("canvas");n.width=i,n.height=e;let a=n.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,i,e),a.strokeStyle="#000",a.strokeRect(0,0,i,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",i/2,e/2),be.Texture.from(n)}function Xt(i,e){da.set(i,e)}var be,la,ca,He,M,pe,ke,me,wi,da,Pe,Jt=he(()=>{"use strict";be=require("pixi.js");Kt();la=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",ca=ks(),He=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,M=ca?"publish":la,pe=He==null?void 0:He.assetsInlined;He!=null&&He.buildMode&&(M=He.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${M}`));ke=Is();ke!=null&&ke.buildMode&&(M=ke.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${M}`));(ke==null?void 0:ke.assetsInlined)!==void 0&&(pe=ke.assetsInlined);Ps().then(i=>{i!=null&&i.buildMode&&i.buildMode!==M&&(M=i.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${M}`)),(i==null?void 0:i.assetsInlined)!==void 0&&(pe=i.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${la}, Runtime: ${ca?"publish":"dev"}, Effective: ${M}`);me={},wi=null;da=new Map;Pe=class{static async load(e,t,n,a){let s=`${e}:${t.path}`,r=re.get(s);if(r!==void 0)return r;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${M}`),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 Ms(),c=o[e];if(!c&&a&&(c=o[a],c&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${a}`)),!c&&t.path){let d=t.path.split("/");if(d.length>=2){let p=d[d.length-1].split(".")[0];o[p]&&(c=o[p],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${p}`))}}if(console.log("[AssetLoader] Inline data for",e,":",c?"FOUND":"NOT FOUND"),M==="publish"&&pe!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!c))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${t.path}`);let u=da.get(t.type);if(u)try{let d=await u(t.path,c,e,n);return re.set(s,d),d}catch(d){return this.handleFailure(e,t.type,d)}try{let d;switch(t.type){case"image":d=await this.loadImage(t.path,c);break;case"json":d=await this.loadJSON(t.path,c),d=xi(d);break;default:throw new Error(`Unknown asset type: ${t.type}`)}return re.set(s,d),d}catch(d){return this.handleFailure(e,t.type,d)}}static async loadImage(e,t){let n=M==="publish",a=n&&pe!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${M}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof t!="string"||!t.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof t}`);try{return await be.Assets.load(t)}catch(s){throw console.error("[AssetLoader] Failed to load texture from data URI:",s),s}}if(t&&typeof t=="string"&&t.startsWith("data:"))try{return await be.Assets.load(t)}catch(s){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",s),await be.Assets.load(e)}return await be.Assets.load(e)}static async loadJSON(e,t){let n=M==="publish",a=n&&pe!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${M}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let r=atob(t.split(",")[1]);return JSON.parse(r)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let r=atob(t.split(",")[1]);return JSON.parse(r)}return JSON.parse(t)}let s=await fetch(e);if(!s.ok)throw new Error(`JSON fetch failed: ${e}`);return s.json()}static handleFailure(e,t,n){if(M==="dev"){let s=t==="image"?js():xi({__placeholder:!0,type:t});return re.set(e+":"+((n==null?void 0:n.path)||"missing"),s),s}throw n}};Xt("image",async(i,e)=>{let t=M==="publish",n=t&&pe!==!1,a=M==="brand",s=t&&pe===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${M}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${i}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return be.Assets.load(e)}let r=i;return(a||s)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(r=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(r=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${r}"`))),be.Assets.load(e||r)});Xt("json",async(i,e)=>{let t=M==="publish",n=t&&pe!==!1,a=M==="brand",s=t&&pe===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${M}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${i}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let r=i;if((a||s)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(r=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(r=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${r}"`))),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(r);if(!o.ok)throw new Error(`JSON fetch failed: ${i}`);return o.json()})});function Zt(i,e){pa.init(i,e),typeof window!="undefined"&&(window.__AssetTextures=Ie)}var Si,pa,Ie,Et=he(()=>{"use strict";Jt();Si=class{constructor(){this.textures=new Map;this.readyPromise=null;this.priorityReadyPromise=null;this.priorityReadyResolve=null;this.config=null;this.app=null;this.attempted=new Set;this.waiters=new Set}init(e,t){if(this.config===e&&this.app===t&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.attempted.clear(),this.waiters.clear(),this.priorityReadyPromise=new Promise(n=>{this.priorityReadyResolve=n}),this.config=e,this.app=t,console.log("[AssetTextures] Initialized with config, cleared previous textures")}async ready(){if(this.readyPromise){await this.readyPromise;return}if(!this.config)throw new Error("[AssetTextures] Must call init() before ready() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before ready() - app is null");let e=this.config,t=this.app;return this.readyPromise=(async()=>{var r;console.log("[AssetTextures] Loading all assets...");let n=new Set(["background_loading_1"]),a=[],s=[];for(let[o,c]of e.objects.entries()){let l=(r=c.render)==null?void 0:r.asset;if(!l)continue;let u=async()=>{var d;try{let p=(d=c.identity)==null?void 0:d.id;console.log(`[AssetTextures] Loading ${l.type}: ${o} (${p})`);let g=await Pe.load(o,l,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{}}};n.has(o)?a.push(u()):s.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(s),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 c,l,u,d;try{let p=(u=(l=(c=this.config)==null?void 0:c.objects)==null?void 0:l.get)==null?void 0:u.call(l,o);return!!((d=p==null?void 0:p.render)!=null&&d.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let s=()=>a.every(o=>this.textures.has(o)||this.attempted.has(o));if(s())return;let r=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(o=>{let c=!1,l=()=>{c||s()&&(c=!0,this.waiters.delete(l),o())};this.waiters.add(l),l(),r>0&&setTimeout(()=>{c||(c=!0,this.waiters.delete(l),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),o())},r)})}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())}},pa=new Si,Ie=new Proxy(pa,{get(i,e){return e in i&&typeof i[e]=="function"?i[e].bind(i):i.get(e)},set(i,e,t){return i.set(e,t),!0}})});var ha={};mn(ha,{AssetEditorModal:()=>Ti});var Ti,ki=he(()=>{"use strict";Ti=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,n,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=n,this.onApplyCallback=a,this.createModal(e,n),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let n=document.createElement("div");n.className="asset-editor-modal",n.innerHTML=`
1
+ "use strict";var Ua=Object.create;var Rt=Object.defineProperty;var qa=Object.getOwnPropertyDescriptor;var Va=Object.getOwnPropertyNames;var Ya=Object.getPrototypeOf,Wa=Object.prototype.hasOwnProperty;var ce=(i,e)=>()=>(i&&(e=i(i=0)),e);var mn=(i,e)=>{for(var t in e)Rt(i,t,{get:e[t],enumerable:!0})},bn=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Va(e))!Wa.call(i,a)&&a!==t&&Rt(i,a,{get:()=>e[a],enumerable:!(n=qa(e,a))||n.enumerable});return i};var ci=(i,e,t)=>(t=i!=null?Ua(Ya(i)):{},bn(e||!i||!i.__esModule?Rt(t,"default",{value:i,enumerable:!0}):t,i)),Ka=i=>bn(Rt({},"__esModule",{value:!0}),i);var ts,de=ce(()=>{"use strict";ts="handler_preview_override_mode";if(typeof window!="undefined"){let i=window.localStorage.getItem(ts);window.__enableConfigOverrides=i===null?!0:i==="true"}});var Kn,ze,Tr,hi=ce(()=>{"use strict";de();Kn=null,ze="dev";if(typeof window!="undefined"){let i=window.__BUILD_SETTINGS__;if(i!=null&&i.buildMode)Kn=i,ze=i.buildMode,console.log("[CONFIG] Loaded inline build settings:",i,"buildMode:",ze);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);Kn=t,ze=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",ze)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",ze)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",ze);Tr=ze==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var fi=ce(()=>{"use strict"});var Jn=ce(()=>{"use strict";fi();hi()});var mi=ce(()=>{"use strict";hi();fi();Jn()});var re,Kt=ce(()=>{"use strict";re=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()}};re.store=new Map});function Ps(){var i,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(i=document.querySelector("script"))==null?void 0:i.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),n=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!n)}catch{return!1}}async function Ms(){try{if(typeof window!="undefined"){let i=await fetch("./build-settings.json");if(i.ok){let e=await i.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function js(){try{if(typeof window!="undefined"){let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}async function _s(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${M}`),Object.keys(me).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(me)),me;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),me={...window.INLINE_ASSETS},me;if(!(M==="publish"&&ue!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),me;if(!wi){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),wi=(async()=>{try{try{let s=await import(e+"?t="+Date.now());if(s.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(s.INLINE_ASSETS)),s.INLINE_ASSETS}catch(s){console.warn("[AssetLoader] ES module import failed, trying text parse:",s)}let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.text();console.log("[AssetLoader] Received JS code, length:",n.length);let a=n.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)try{let s=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let r=new Function("return "+s)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(r)),r}catch(s){return console.warn("[AssetLoader] Failed to parse inline assets:",s),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",n.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return me=await wi,console.log("[AssetLoader] Final inline assets cache:",Object.keys(me)),me}function xi(i){return i===null||typeof i!="object"||(Object.freeze(i),Object.values(i).forEach(e=>xi(e))),i}function Os(i=64,e=64,t=16711680){let n=document.createElement("canvas");n.width=i,n.height=e;let a=n.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,i,e),a.strokeStyle="#000",a.strokeRect(0,0,i,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",i/2,e/2),be.Texture.from(n)}function Xt(i,e){da.set(i,e)}var be,la,ca,He,M,ue,ke,me,wi,da,Ie,Jt=ce(()=>{"use strict";be=require("pixi.js");Kt();la=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",ca=Ps(),He=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,M=ca?"publish":la,ue=He==null?void 0:He.assetsInlined;He!=null&&He.buildMode&&(M=He.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${M}`));ke=js();ke!=null&&ke.buildMode&&(M=ke.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${M}`));(ke==null?void 0:ke.assetsInlined)!==void 0&&(ue=ke.assetsInlined);Ms().then(i=>{i!=null&&i.buildMode&&i.buildMode!==M&&(M=i.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${M}`)),(i==null?void 0:i.assetsInlined)!==void 0&&(ue=i.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${la}, Runtime: ${ca?"publish":"dev"}, Effective: ${M}`);me={},wi=null;da=new Map;Ie=class{static async load(e,t,n,a){let s=`${e}:${t.path}`,r=re.get(s);if(r!==void 0)return r;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${M}`),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 _s(),c=o[e];if(!c&&a&&(c=o[a],c&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${a}`)),!c&&t.path){let p=t.path.split("/");if(p.length>=2){let d=p[p.length-1].split(".")[0];o[d]&&(c=o[d],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${d}`))}}if(console.log("[AssetLoader] Inline data for",e,":",c?"FOUND":"NOT FOUND"),M==="publish"&&ue!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!c))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${t.path}`);let u=da.get(t.type);if(u)try{let p=await u(t.path,c,e,n);return re.set(s,p),p}catch(p){return this.handleFailure(e,t.type,p)}try{let p;switch(t.type){case"image":p=await this.loadImage(t.path,c);break;case"json":p=await this.loadJSON(t.path,c),p=xi(p);break;default:throw new Error(`Unknown asset type: ${t.type}`)}return re.set(s,p),p}catch(p){return this.handleFailure(e,t.type,p)}}static async loadImage(e,t){let n=M==="publish",a=n&&ue!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${M}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof t!="string"||!t.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof t}`);try{return await be.Assets.load(t)}catch(s){throw console.error("[AssetLoader] Failed to load texture from data URI:",s),s}}if(t&&typeof t=="string"&&t.startsWith("data:"))try{return await be.Assets.load(t)}catch(s){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",s),await be.Assets.load(e)}return await be.Assets.load(e)}static async loadJSON(e,t){let n=M==="publish",a=n&&ue!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${M}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let r=atob(t.split(",")[1]);return JSON.parse(r)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let r=atob(t.split(",")[1]);return JSON.parse(r)}return JSON.parse(t)}let s=await fetch(e);if(!s.ok)throw new Error(`JSON fetch failed: ${e}`);return s.json()}static handleFailure(e,t,n){if(M==="dev"){let s=t==="image"?Os():xi({__placeholder:!0,type:t});return re.set(e+":"+((n==null?void 0:n.path)||"missing"),s),s}throw n}};Xt("image",async(i,e)=>{let t=M==="publish",n=t&&ue!==!1,a=M==="brand",s=t&&ue===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${M}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${i}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return be.Assets.load(e)}let r=i;return(a||s)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(r=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(r=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${r}"`))),be.Assets.load(e||r)});Xt("json",async(i,e)=>{let t=M==="publish",n=t&&ue!==!1,a=M==="brand",s=t&&ue===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${M}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${i}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let r=i;if((a||s)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(r=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(r=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${r}"`))),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(r);if(!o.ok)throw new Error(`JSON fetch failed: ${i}`);return o.json()})});function Zt(i,e){pa.init(i,e),typeof window!="undefined"&&(window.__AssetTextures=Pe)}var Si,pa,Pe,Et=ce(()=>{"use strict";Jt();Si=class{constructor(){this.textures=new Map;this.readyPromise=null;this.priorityReadyPromise=null;this.priorityReadyResolve=null;this.config=null;this.app=null;this.attempted=new Set;this.waiters=new Set}init(e,t){if(this.config===e&&this.app===t&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.attempted.clear(),this.waiters.clear(),this.priorityReadyPromise=new Promise(n=>{this.priorityReadyResolve=n}),this.config=e,this.app=t,console.log("[AssetTextures] Initialized with config, cleared previous textures")}async ready(){if(this.readyPromise){await this.readyPromise;return}if(!this.config)throw new Error("[AssetTextures] Must call init() before ready() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before ready() - app is null");let e=this.config,t=this.app;return this.readyPromise=(async()=>{var r;console.log("[AssetTextures] Loading all assets...");let n=new Set(["background_loading_1"]),a=[],s=[];for(let[o,c]of e.objects.entries()){let l=(r=c.render)==null?void 0:r.asset;if(!l)continue;let u=async()=>{var p;try{let d=(p=c.identity)==null?void 0:p.id;console.log(`[AssetTextures] Loading ${l.type}: ${o} (${d})`);let g=await Ie.load(o,l,t,d);this.textures.set(o,g),console.log(`[AssetTextures] \u2713 Loaded: ${o}`)}catch(d){console.error(`[AssetTextures] \u2717 Failed to load: ${o}`,d)}finally{this.attempted.add(o);try{for(let d of Array.from(this.waiters))d()}catch{}}};n.has(o)?a.push(u()):s.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(s),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 c,l,u,p;try{let d=(u=(l=(c=this.config)==null?void 0:c.objects)==null?void 0:l.get)==null?void 0:u.call(l,o);return!!((p=d==null?void 0:d.render)!=null&&p.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let s=()=>a.every(o=>this.textures.has(o)||this.attempted.has(o));if(s())return;let r=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(o=>{let c=!1,l=()=>{c||s()&&(c=!0,this.waiters.delete(l),o())};this.waiters.add(l),l(),r>0&&setTimeout(()=>{c||(c=!0,this.waiters.delete(l),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),o())},r)})}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())}},pa=new Si,Pe=new Proxy(pa,{get(i,e){return e in i&&typeof i[e]=="function"?i[e].bind(i):i.get(e)},set(i,e,t){return i.set(e,t),!0}})});var ha={};mn(ha,{AssetEditorModal:()=>Ti});var Ti,ki=ce(()=>{"use strict";Ti=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,n,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=n,this.onApplyCallback=a,this.createModal(e,n),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let n=document.createElement("div");n.className="asset-editor-modal",n.innerHTML=`
2
2
  <div class="asset-editor-card">
3
3
  <div class="asset-editor-header">
4
4
  <div>
@@ -43,7 +43,58 @@
43
43
  <button class="debug-btn primary" data-modal-apply>Apply</button>
44
44
  </div>
45
45
  </div>
46
- `,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(r=>{r.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.addEventListener("click",o=>{let l=o.target.dataset.tab;l&&this.switchTab(l)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let a=this.modal.querySelector("[data-ai-edit]");a==null||a.addEventListener("click",()=>{this.openAiEditor("edit")});let s=this.modal.querySelector("[data-modal-apply]");s==null||s.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",r=>{r.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let t=window.__openAiEditor;if(typeof t!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";e==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:a=>{this.onApplyCallback&&this.onApplyCallback(a),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var ur={};mn(ur,{AssetCache:()=>re,AssetLoader:()=>Pe,AssetSystem:()=>li,AssetTextures:()=>Ie,Assets:()=>Ha,BaseSystem:()=>rt,GameEngine:()=>oi,GameObject:()=>Ot,GameObjectManager:()=>at,ObjectFactory:()=>ye,Renderer:()=>_t,RuntimeObjectRegistry:()=>ot,Transform:()=>jt,applyScreenAnchor:()=>Ft,basePixi:()=>za,clearResponsiveElements:()=>ia,createPixiBase:()=>si,getRegisteredFontIds:()=>ja,globalResponsiveMultipliers:()=>St,initAssetTextures:()=>Zt,initAssets:()=>Fa,layout:()=>aa,playLottieOverlay:()=>Oa,registerFont:()=>Ma,registerType:()=>Xt,resolveAnchorVec2:()=>Te,resolveFont:()=>Pa,resolveFontWeight:()=>Ia,resolveScreenAnchorPoint:()=>De,resolveScreenRatioPoint:()=>Ne,runInitSequence:()=>Ba,setLottieInstance:()=>Qt,spawnSceneFromConfig:()=>Da,updateScreenState:()=>Ht});module.exports=Wa(ur);var ka=require("pixi.js");var Le={};function zt(i,e,t=!1){Le[i]||(Le[i]=[]),Le[i].push({fn:e,once:t})}function di(i,e){if(Le[i]){if(!e){delete Le[i];return}Le[i]=Le[i].filter(t=>t.fn!==e)}}function $t(i,...e){let t=Le[i];if(t)for(let n of[...t])n.fn(...e),n.once&&di(i,n.fn)}function ee(i,e){zt(i,e,!0)}var $=null,ae=[],Ye=null;function wn(i){$=i,ae=[],Ye!==null&&(clearTimeout(Ye),Ye=null)}function xn(){var i,e,t;return{endpoint:($==null?void 0:$.endpoint)||"",transport:($==null?void 0:$.transport)||"beacon",batchSize:(i=$==null?void 0:$.batchSize)!=null?i:10,flushIntervalMs:(e=$==null?void 0:$.flushIntervalMs)!=null?e:300,maxQueue:(t=$==null?void 0:$.maxQueue)!=null?t:200,debug:!!($!=null&&$.debug)}}async function yn(i,e,t,n){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let s=navigator.sendBeacon(i,new Blob([a],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",s,e);return}catch(s){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",s)}try{await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",e)}catch(s){n&&console.warn("[handler.telemetry] fetch failed",s)}}function pi(i,e){let t=xn();if(e&&t.endpoint){if(ae.push(i),ae.length>t.maxQueue&&(ae=ae.slice(ae.length-t.maxQueue)),ae.length>=t.batchSize){vn();return}Ye===null&&(Ye=window.setTimeout(()=>{Ye=null,vn()},t.flushIntervalMs))}}async function vn(){let i=xn();if(!i.endpoint||ae.length===0)return;let e=ae.splice(0,i.batchSize);await yn(i.endpoint,{events:e},i.transport,i.debug),ae.length>0&&await yn(i.endpoint,{events:ae.splice(0,i.batchSize)},i.transport,i.debug)}function Sn(i){return Math.max(0,Math.min(1,i))}function Ka(i){let e=String(i!=null?i:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),n=t?Number(t[1]):1.8;return a=>1+(n+1)*Math.pow(a-1,3)+n*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function wt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Xa(i,e){let t=i==null?void 0:i[e];return typeof t=="number"?t:0}function En(i,e,t){try{i[e]=t}catch{}}function Ja(i){let e=i==null?void 0:i.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,n=typeof e.y=="number"?e.y:1;return{x:t,y:n}}function Cn(i,e){let t=i==null?void 0:i.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function An(i,e){let t=Ja(i);if(!t)return{from:null,to:null};let n=null,a=null;return typeof e.scale=="number"?(n=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(n=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(n=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),n===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:n!=null?n:t.x,y:a!=null?a:t.y}}}function Ln(){let i=new Set,e=new WeakMap,t=null,n=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),i.size>0&&n()})},a=u=>{var p;i.add(u);let d=(p=e.get(u.target))!=null?p:new Set;d.add(u),e.set(u.target,d),n()},s=u=>{i.delete(u);let d=e.get(u.target);d&&(d.delete(u),d.size===0&&e.delete(u.target))},r=u=>{u.killed||(u.killed=!0,s(u))},o=()=>{var d,p;let u=wt();for(let g of Array.from(i)){if(g.killed||g.paused)continue;let m=u-g.startMs-g.delayMs;if(m<0)continue;let f=g.durationMs>0?m/g.durationMs:1,C=Sn(f),b=g.repeat>=0?g.repeat+1:1,h=g.repeat>0?Math.min(Math.floor(f),b-1):0;if(g.repeat>0&&f>=1){let x=f-h;C=Sn(x)}let y=g.ease(C);g.yoyo&&h%2===1&&(y=1-y);for(let x of g.props)En(g.target,x.key,x.from+(x.to-x.from)*y);g.scaleFrom&&g.scaleTo&&Cn(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*y,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*y});try{(d=g.onUpdate)==null||d.call(g)}catch{}if(f>=b){r(g);try{(p=g.onComplete)==null||p.call(g)}catch{}}}},c=(u,d,p)=>{var x;let g=Math.max(0,(typeof d.duration=="number"?d.duration:.5)*1e3),m=Math.max(0,(typeof d.delay=="number"?d.delay:0)*1e3+((x=p==null?void 0:p.delayMsOverride)!=null?x:0)),f=Ka(d.ease),C=typeof d.repeat=="number"?Math.max(0,d.repeat|0):0,b=d.yoyo===!0,h=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),y=[];for(let P of Object.keys(d)){if(h.has(P))continue;let L=d[P];typeof L=="number"&&y.push({key:P,from:Xa(u,P),to:L})}let w=An(u,d);return{target:u,startMs:wt(),delayMs:m,durationMs:g,ease:f,props:y,scaleFrom:w.from,scaleTo:w.to,repeat:C,yoyo:b,onUpdate:typeof d.onUpdate=="function"?d.onUpdate:void 0,onComplete:typeof d.onComplete=="function"?d.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},l={to(u,d){let p=c(u,d);return a(p),{kill:()=>r(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=wt())},resume:()=>{var f;if(!p.paused)return;let g=(f=p.pauseAtMs)!=null?f:wt(),m=wt()-g;p.startMs+=m,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(u,d,p){return l.set(u,d),l.to(u,p)},set(u,d){if(!u||!d)return;for(let g of Object.keys(d)){let m=d[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof m=="number"&&En(u,g,m)}let p=An(u,d);p.to&&Cn(u,p.to)},killTweensOf(u){let d=e.get(u);if(d)for(let p of Array.from(d))r(p)},timeline(u={}){let d=[],p=0,g=!1,m=[],f=h=>{if(typeof h=="number")return Math.max(0,h*1e3);let y=typeof h=="string"?h.trim():"";return y.startsWith("+=")?p+Math.max(0,Number(y.slice(2))*1e3||0):y?Math.max(0,Number(y)*1e3||0):p},C=h=>{d.push(h);let y=Math.max(0,(typeof h.vars.duration=="number"?h.vars.duration:.5)*1e3);p=Math.max(p,h.atMs+y)},b={to(h,y,w){return C({kind:"to",target:h,vars:y,atMs:f(w)}),b},fromTo(h,y,w,x){return C({kind:"fromTo",target:h,vars:w,from:y,atMs:f(x)}),b},play(){var h,y;if(g)return b;g=!0,m=[];for(let w of d)w.kind==="fromTo"&&l.set(w.target,(h=w.from)!=null?h:{}),m.push(l.to(w.target,{...w.vars,delay:w.atMs/1e3+((y=w.vars.delay)!=null?y:0)}));return b},pause(){for(let h of m)h.pause();return b},kill(){for(let h of m)h.kill();m=[],g=!1}};return u.paused||b.play(),b}};return l}function Tn(){if(typeof window=="undefined")return;let i=window;if(!i.gsap)try{i.gsap=Ln()}catch{}}var kn={name:"handler-playable-sdk",version:"1.0.88",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 --external jszip && 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/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.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 --external jszip && 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 dist/cli/student-helper/*.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 te=0,Qa=te++,Pn=te++,In=te++,Mn=te++,jn=te++,_n=te++,On=te++,Rn=te++,zn=te++,$n=te++,Dn=te++,Nn=te++,j=Qa;function Hn(){return j===Pn}function Fn(){return j===In}function Bn(){return j===Mn}function Gn(){return j===jn}function We(){return j===_n}function Ke(){return j===On}function Un(){return j===Rn}function qn(){return j===zn}function Vn(){return j===$n}function ui(){return j===Dn}function gi(){return j===Nn}function Yn(){let i=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(i==="mraid")try{mraid.getState(),j=Pn;return}catch{}else if(i==="dapi")try{dapi.isReady(),j=In;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(j=Mn)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(j=jn)}catch{}else if(e==="mintegral")window.gameReady&&(j=_n);else if(e==="tapjoy")window.TJ_API&&(j=On);else if(e==="tiktok")window.openAppStore&&(j=Rn);else if(e==="smadex")try{window.smxTracking&&(j=zn)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(j=$n)}catch{}else e==="vungle"?j=Dn:(i==="nucleo"||e==="nucleo")&&(j=Nn)}var Dt=ci(require("lottie-web"),1),Wn=Dt.default;typeof window!="undefined"&&(window.lottie=Dt.default,window.__baseLottie=Dt.default);mi();function D(i,e){let t=(a,s)=>s===0?a:t(s,a%s),n=t(i,e);return`${i/n}:${e/n}`}var qr=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:D(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:D(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:D(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:D(360,780)}],Vr=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:D(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:D(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:D(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:D(412,915)}],Yr=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:D(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:D(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:D(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:D(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:D(800,1280)}],Zn=[{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:D(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:D(768,1024),mraidScale:.7}];var Wr=[...Zn];var os=Zn[0];ce();var ta=require("pixi.js"),fe={width:400,height:600,designWidth:400,scaleFactor:1},St={scale:1,position:1},Bt=[];function ls(i,e,t,n,a,s,r){Bt.push({element:i,originalScale:s,positionHelper:e,heightPercent:a}),e(i,t,n,a,s,r,!1)}function cs(){Bt.forEach(({element:i,originalScale:e,positionHelper:t,heightPercent:n})=>{let a=e*fe.scaleFactor;t(i,fe.width,fe.height,n,a,!0,!1)})}function ia(){Bt.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Ht(i,e){console.log(`[SCREEN] updateScreenState called: ${i}x${e}`),fe.width=i,fe.height=e,fe.scaleFactor=Math.min(i/fe.designWidth,1.15),St.scale=fe.scaleFactor,St.position=1,console.log(`[SCREEN] Global multipliers - scale: ${St.scale.toFixed(3)}`),cs()}var _={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 ds(i,e,t){let n=_[i];n&&n[e]!==void 0&&(n[e]=t,console.log(`Updated ${i}.${e} = ${t}`))}function ps(){return _}var us={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 Nt(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function Te(i,e={x:.5,y:.5}){var t;if(Array.isArray(i))return{x:Nt(i[0],e.x),y:Nt(i[1],e.y)};if(i&&typeof i=="object"){let n=i;return{x:Nt(n.x,e.x),y:Nt(n.y,e.y)}}if(typeof i=="string"){let n=i.trim().toLowerCase();return(t=us[n])!=null?t:e}return e}function De(i,e,t,n={}){var g,m,f,C,b,h;let a=Te(t),s=(g=n.inset)!=null?g:{},r=(m=n.padding)!=null?m:{x:0,y:0},o=((f=s.left)!=null?f:0)+r.x,c=((C=s.right)!=null?C:0)+r.x,l=((b=s.top)!=null?b:0)+r.y,u=((h=s.bottom)!=null?h:0)+r.y,d=Math.max(0,i-o-c),p=Math.max(0,e-l-u);return{x:o+d*a.x,y:l+p*a.y}}function Ne(i,e,t,n={}){var f,C,b,h,y,w;let a=(f=n.inset)!=null?f:{},s=(C=n.padding)!=null?C:{x:0,y:0},r=((b=a.left)!=null?b:0)+s.x,o=((h=a.right)!=null?h:0)+s.x,c=((y=a.top)!=null?y:0)+s.y,l=((w=a.bottom)!=null?w:0)+s.y,u=Math.max(0,i-r-o),d=Math.max(0,e-c-l),p=Te(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:r+u*g,y:c+d*m}}function Ft(i,e,t,n={}){var u,d,p;if(!i)return;let a=n.positionRatio?Ne(e,t,n.positionRatio,{inset:n.inset,padding:n.screenPadding}):De(e,t,n.anchor,{inset:n.inset,padding:n.screenPadding}),s=(u=n.offset)!=null?u:{x:0,y:0},r=a.x+s.x,o=a.y+s.y;i.anchor&&n.renderAnchor&&i.anchor.set(n.renderAnchor.x,n.renderAnchor.y),se(i,r,o);let c=(d=n.scale)!=null?d:1,l=(p=n.scaleMultiplier)!=null?p:1;(n.scale!==void 0||n.scaleMultiplier!==void 0)&&de(i,c*l)}if(typeof window!="undefined"){let i=window.innerWidth,e=window.innerHeight,t=()=>{let n=window.innerWidth,a=window.innerHeight;(n!==i||a!==e)&&(i=n,e=a,Ht(n,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Ht(window.innerWidth,window.innerHeight),window.updateDebugConfig=ds,window.getDebugConfig=ps,window.copyConfig=Es,window.applyConfig=xt,window.applyConfigForRatio=Cs,window.positionAtBottom=na,window.positionAtTop=fs,window.positionAtCenter=ms,window.positionAtLeft=bs,window.positionAtRight=ys,window.positionAtBottomLeft=vs,window.positionAtBottomRight=ws,window.positionAtTopLeft=xs,window.positionAtTopRight=Ss,window.applyPositionContract=hs,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 Gt(i,e,t=0){return i*e+t}function Ut(i,e,t=0){return i*(1-e)+t}function qt(i,e,t=0){return i*e+t}function Vt(i,e,t=0){return i*(1-e)+t}function ie(i,e=0){return i/2+e}function gs(i,e){return i*e}function hs(i,e,t,n){var r,o,c,l,u,d,p,g,m,f,C,b,h,y,w,x,P,L,B,R;let a=0,s=0;switch(n.type){case"top":a=ie(e,(o=(r=n.offset)==null?void 0:r.x)!=null?o:0),s=Gt(t,n.percent,(l=(c=n.offset)==null?void 0:c.y)!=null?l:0);break;case"bottom":a=ie(e,(d=(u=n.offset)==null?void 0:u.x)!=null?d:0),s=Ut(t,n.percent,(g=(p=n.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=qt(e,n.percent,(f=(m=n.offset)==null?void 0:m.x)!=null?f:0),s=ie(t,(b=(C=n.offset)==null?void 0:C.y)!=null?b:0);break;case"right":a=Vt(e,n.percent,(y=(h=n.offset)==null?void 0:h.x)!=null?y:0),s=ie(t,(x=(w=n.offset)==null?void 0:w.y)!=null?x:0);break;case"center":a=ie(e,(L=(P=n.offset)==null?void 0:P.x)!=null?L:0),s=ie(t,(R=(B=n.offset)==null?void 0:B.y)!=null?R:0);break}i.position?i.position.set(a,s):(i.x=a,i.y=s),n.scale!==void 0&&n.scale!==1&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(n.scale,n.scale):(i.scale.x=n.scale,i.scale.y=n.scale))}function na(i,e,t,n=.2,a=1,s=!0,r=!1){let o=gs(t,n),c=Ut(t,n/2);se(i,ie(e),c);let l=s?a*fe.scaleFactor:a;de(i,l),r&&!Bt.find(u=>u.element===i)&&ls(i,na,e,t,n,a,s)}function fs(i,e,t,n=.1,a=1){se(i,ie(e),Gt(t,n)),de(i,a)}function ms(i,e,t,n=0,a=0,s=1){se(i,ie(e,n),ie(t,a)),de(i,s)}function bs(i,e,t,n=.1,a=1){se(i,qt(e,n),ie(t)),de(i,a)}function ys(i,e,t,n=.1,a=1){se(i,Vt(e,n),ie(t)),de(i,a)}function vs(i,e,t,n=.05,a=.05,s=1){se(i,qt(e,a),Ut(t,n)),de(i,s)}function ws(i,e,t,n=.05,a=.05,s=1){se(i,Vt(e,a),Ut(t,n)),de(i,s)}function xs(i,e,t,n=.05,a=.05,s=1){se(i,qt(e,a),Gt(t,n)),de(i,s)}function Ss(i,e,t,n=.05,a=.05,s=1){se(i,Vt(e,a),Gt(t,n)),de(i,s)}function se(i,e,t){i&&i.position?typeof i.position.set=="function"?i.position.set(e,t):(i.position.x=e,i.position.y=t):i&&(i.x=e,i.y=t)}function de(i,e){e!==1&&i&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(e,e):i.scale.x!==void 0&&i.scale.y!==void 0&&(i.scale.x=e,i.scale.y=e))}var $e={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 Es(i){return i&&$e[i]?JSON.parse(JSON.stringify($e[i])):JSON.parse(JSON.stringify(_))}function xt(i){Object.keys(i).forEach(e=>{let t=e;_[t]&&i[t]&&Object.assign(_[t],i[t])}),console.log("Config applied:",i)}function Cs(i,e){let t=i/e;t>1.6?(xt($e.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(xt($e.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(xt($e.square),console.log("Applied SQUARE config for ratio:",t)):(xt($e.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let i=window;i.configPresets=$e,i.resolveAnchorVec2=i.resolveAnchorVec2||Te,i.resolveScreenAnchorPoint=i.resolveScreenAnchorPoint||De,i.resolveScreenRatioPoint=i.resolveScreenRatioPoint||Ne}var K=null,ea=new Map;function aa(i,e,t,n,a,s={}){var Se,Ee,Ce,Ae,Y,_e,lt,ct,dt,pt,ut,gt,ht,ft,mt,bt,F,Z,U,Q,Ue,Oe,Bi,Gi,Ui,qi,Vi,Yi,Wi,Ki,Xi,Ji,Zi,Qi,en,tn,nn,an,sn,rn,on,ln,cn,dn,pn,un,gn,hn,fn;let r=(Se=s.enableDebugLogs)!=null?Se:!1;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:n.width,height:n.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",s));let{mainContainer:o,label:c,background:l,backgroundTexture:u,app:d}=i;if(!d||!d.renderer){r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:d.renderer.width,height:d.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:d.screen.width,height:d.screen.height}));let p=n.width,g=n.height;r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:p,baseHeight:g});let m=p*_.layout.screen_scale_x,f=g*_.layout.screen_scale_y,C=p/2,b=e.engine.runtime||{},h=b.layout||{};r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:_.layout.screen_scale_x,screen_scale_y:_.layout.screen_scale_y}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Calculated dimensions:",{width:m,height:f,midX:C}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",b),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",h));let y=f>m,w=(Ee=h.design_width_portrait)!=null?Ee:y?400:600,x=(Ce=h.design_height_portrait)!=null?Ce:y?600:400,P=Math.min(m/w,f/x);P=Math.min(P,1.15);let L=P*((Ae=_.engine.scale)!=null?Ae:1),B=(Y=s.skipMainContainerTransform)!=null?Y:!1;!B&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(L):(o.scale.x=L,o.scale.y=L));let R=(_e=h.main_container_anchor)!=null?_e:"center",H=(lt=h.main_container_position_ratio)!=null?lt:{x:.5,y:.5},z=(ct=h.main_container_offset)!=null?ct:{x:0,y:0},T=h.main_container_position_ratio?Ne(p,g,H):De(p,g,R),E=T.x+z.x+_.layout.position_offset.x,S=T.y+z.y+_.layout.position_offset.y;if(!B&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(E,S):(o.position.x=E,o.position.y=S)),a&&(o!=null&&o.toLocal)){let G=g>p,W=(dt=h.design_width_portrait)!=null?dt:G?320:480,N=(pt=h.design_height_portrait)!=null?pt:G?480:320;for(let[oe,le]of e.objects.entries()){let q=le==null?void 0:le.transform;if(!q||((ut=q.position_mode)!=null?ut:"static")!=="static")continue;let k=(gt=a.get)==null?void 0:gt.call(a,oe),yt=((ht=k==null?void 0:k.getDisplayObject)==null?void 0:ht.call(k))||(k==null?void 0:k.pixiObject)||k;if(!yt||yt.parent!==o)continue;let ge=(ft=q.anchor)!=null?ft:"bottom-left";ge==="bottom-left"&&q.anchor==null&&console.log("[DEBUG FALLBACK] LayoutManager transform.anchor \u2192 bottom-left");let qe=q.position_ratio!=null?Ne(W,N,q.position_ratio):De(W,N,ge),Ve=(mt=q.position)!=null?mt:{x:0,y:0},vt=qe.x-W/2+Ve.x,Re=qe.y-N/2+Ve.y;typeof(k==null?void 0:k.setPosition)=="function"?k.setPosition(vt,Re):(se(yt,vt,Re),(bt=k==null?void 0:k.transform)!=null&&bt.position&&(k.transform.position.x=vt,k.transform.position.y=Re))}}let A=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,J=((A==null?void 0:A.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(_.layout.debug_rect_visible&&J){(!K||K.parent!==d.stage)&&(K==null||K.destroy(),K=new ta.Graphics,K.zIndex=9999,d.stage.addChild(K)),K.clear();let G=_.layout.debug_rect_scale_x,W=_.layout.debug_rect_scale_y,N=(p-4)*G,oe=(g-4)*W,le=(p-N)/2,q=(g-oe)/2;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:N,rectH:oe,offsetX:le,offsetY:q}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+le,y:2+q,width:N,height:oe})),K.rect(2+le,2+q,N,oe).stroke({width:_.layout.debug_rect_thickness,color:_.layout.debug_rect_color})}else K&&(K.destroy(),K=null);let O=((F=i.label)==null?void 0:F.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(c&&c.position&&O){let G=(U=(Z=O==null?void 0:O.transform)==null?void 0:Z.anchor)!=null?U:"center",W=(Q=O==null?void 0:O.transform)==null?void 0:Q.position_ratio,N=((Ue=O==null?void 0:O.transform)==null?void 0:Ue.offset)||{x:0,y:0};Ft(c,p,g,{anchor:G,positionRatio:W,offset:{x:N.x*L,y:N.y*L},renderAnchor:Te(G)})}if(c&&c.alpha>0){let G=1+Math.sin(t*_.engine.label_pulse_speed)*_.engine.label_pulse_intensity,W=(Bi=(Oe=O==null?void 0:O.transform)==null?void 0:Oe.scale)!=null?Bi:1,N=G*L*W;c.scale&&(typeof c.scale.set=="function"?c.scale.set(N):(c.scale.x=N,c.scale.y=N))}r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING =====");let ne=l?e.objects.get("background_1"):null,je=!!ne&&(l==null?void 0:l.parent)===o;if(l&&!je){r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!l),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(Gi=l.constructor)==null?void 0:Gi.name)),l.alpha=((qi=(Ui=b.background)==null?void 0:Ui.alpha)!=null?qi:.98)*_.engine.background_alpha,r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",l.alpha),r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",ne);let G=(ne==null?void 0:ne.transform)||{};r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",G);let W=G.offset||{x:0,y:0},N=((Yi=(Vi=b.background)==null?void 0:Vi.offset_y)!=null?Yi:0)+_.engine.background_offset_y,oe=(Wi=G.anchor)!=null?Wi:"center",le=G.position_ratio;if(r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:W,bgRuntimeOffsetY:N,bgScreenAnchor:oe,bgPositionRatio:le,baseWidth:p,baseHeight:g,finalScale:L}),Ft(l,p,g,{anchor:oe,positionRatio:le,offset:{x:W.x*L,y:W.y*L+N},renderAnchor:Te(oe)}),r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:l.x,y:l.y,scaleX:(Ki=l.scale)==null?void 0:Ki.x,scaleY:(Xi=l.scale)==null?void 0:Xi.y,anchorX:(Ji=l.anchor)==null?void 0:Ji.x,anchorY:(Zi=l.anchor)==null?void 0:Zi.y,pivotX:(Qi=l.pivot)==null?void 0:Qi.x,pivotY:(en=l.pivot)==null?void 0:en.y,width:l.width,height:l.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 qe=Math.max(m/u.width,f/u.height),Ve=(nn=(tn=b.background)==null?void 0:tn.scale_multiplier)!=null?nn:1.05,vt=(an=G.scale)!=null?an:1,Re=qe*Ve*_.engine.background_scale*vt;l.scale&&(typeof l.scale.set=="function"?l.scale.set(Re):(l.scale.x=Re,l.scale.y=Re))}else l&&typeof l.clear=="function"&&(l.clear(),l.rect(-m/2,-f/2,m,f).fill({color:1444375}));let q=`${p}x${g}`,I=ea.get(q),k={x:Number((sn=l.x)!=null?sn:0),y:Number((rn=l.y)!=null?rn:0),scaleX:Number((ln=(on=l.scale)==null?void 0:on.x)!=null?ln:1),scaleY:Number((dn=(cn=l.scale)==null?void 0:cn.y)!=null?dn:1),rotation:Number.isFinite(l.rotation)?l.rotation:void 0,anchorX:Number.isFinite((pn=l.anchor)==null?void 0:pn.x)?l.anchor.x:void 0,anchorY:Number.isFinite((un=l.anchor)==null?void 0:un.y)?l.anchor.y:void 0,pivotX:Number.isFinite((gn=l.pivot)==null?void 0:gn.x)?l.pivot.x:void 0,pivotY:Number.isFinite((hn=l.pivot)==null?void 0:hn.y)?l.pivot.y:void 0},yt=Number.isFinite(k.x)&&Number.isFinite(k.y)&&Number.isFinite(k.scaleX)&&Number.isFinite(k.scaleY),ge=k;if(I){let qe=Math.hypot(k.x-I.x,k.y-I.y),Ve=Math.max(p,g)*.5;(!yt||qe>Ve)&&((fn=l.position)!=null&&fn.set?l.position.set(I.x,I.y):(l.x=I.x,l.y=I.y),l.scale&&(typeof l.scale.set=="function"?l.scale.set(I.scaleX,I.scaleY):(l.scale.x=I.scaleX,l.scale.y=I.scaleY)),Number.isFinite(I.rotation)&&typeof l.rotation=="number"&&(l.rotation=I.rotation),l.anchor&&Number.isFinite(I.anchorX)&&Number.isFinite(I.anchorY)&&l.anchor.set(I.anchorX,I.anchorY),l.pivot&&Number.isFinite(I.pivotX)&&Number.isFinite(I.pivotY)&&l.pivot.set(I.pivotX,I.pivotY),ge=I)}Number.isFinite(ge.x)&&Number.isFinite(ge.y)&&Number.isFinite(ge.scaleX)&&Number.isFinite(ge.scaleY)&&ea.set(q,ge)}}function As(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Ls(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}async function Ts(i){return await new Promise(e=>{let t=new Image;t.onload=()=>e({width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}),t.onerror=()=>e(null),t.src=i})}async function yi(i){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",i);let n=await fetch(i);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,i),null;let a=await n.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let s=await As(a),r=await Ts(s),o=Ls(s);return console.log("[ImageUtils] Success resolution:",r==null?void 0:r.width,"x",r==null?void 0:r.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:s,width:(e=r==null?void 0:r.width)!=null?e:0,height:(t=r==null?void 0:r.height)!=null?t:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function Yt(i,e=30){try{console.log("[ImageUtils] Removing background color...");let t=await new Promise((d,p)=>{let g=new Image;g.onload=()=>d(g),g.onerror=()=>p(new Error("Failed to load image")),g.src=i}),n=document.createElement("canvas");n.width=t.width,n.height=t.height;let a=n.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),i;a.drawImage(t,0,0);let s=a.getImageData(0,0,n.width,n.height),r=s.data,c=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(d=>({r:r[d.offset],g:r[d.offset+1],b:r[d.offset+2]})),l=0;for(let d=0;d<r.length;d+=4){let p=r[d],g=r[d+1],m=r[d+2],f=!1;for(let C of c)if(Math.sqrt(Math.pow(p-C.r,2)+Math.pow(g-C.g,2)+Math.pow(m-C.b,2))<e){f=!0;break}f&&(r[d+3]=0,l++)}return console.log(`[ImageUtils] Removed background from ${l} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(s,0,0),n.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),i}}var sa=require("@google/genai");async function vi(i,e,t=[],n={}){var a,s,r,o,c,l,u;try{if(!(i!=null&&i.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let b=0;b<t.length;b++){let h=t[b];if(!h.base64||!h.mimeType)throw new Error(`Image ${b+1} is missing required data`);if(h.base64.length<1e3&&console.warn(`Image ${b+1} data appears very small, may be corrupted`),!h.mimeType.startsWith("image/"))throw new Error(`Image ${b+1} has invalid MIME type: ${h.mimeType}`)}let d=new sa.GoogleGenAI({apiKey:i}),p="gemini-2.5-flash",g=[e];t.length>0&&t.forEach((b,h)=>{g.push({inlineData:{data:b.base64,mimeType:b.mimeType}}),console.log(`[Gemini] Added image ${h+1}: ${b.mimeType}, size: ${Math.round(b.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${t.length} images and prompt length: ${e.length}`);let m=await d.models.generateContent({model:p,contents:g}),f="",C=(r=(s=(a=m.candidates)==null?void 0:a[0])==null?void 0:s.content)==null?void 0:r.parts;if(C)for(let b of C)b.text&&(f+=b.text);if(!f.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${f.length}`),f}catch(d){throw console.error("[Gemini] API error:",d),(o=d.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."):(c=d.message)!=null&&c.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(l=d.message)!=null&&l.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(u=d.message)!=null&&u.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):d}}var ra=require("@google/genai");async function Wt(i,e,t=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new ra.GoogleGenAI({apiKey:i}),s=[{text:e}];t.length>0&&t.forEach((o,c)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${c}`),s.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let r=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:s});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!r.candidates||!r.candidates[0]||!r.candidates[0].content||!r.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of r.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let c=o.inlineData.data,l=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${l};base64,${c}`}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 _s=require("pixi.js");Et();Kt();ce();var ua=require("pixi.js");var Rs=require("pixi.js");ce();function qs(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Vs(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}function Ys(i){return`
46
+ `,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(r=>{r.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.addEventListener("click",o=>{let l=o.target.dataset.tab;l&&this.switchTab(l)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let a=this.modal.querySelector("[data-ai-edit]");a==null||a.addEventListener("click",()=>{this.openAiEditor("edit")});let s=this.modal.querySelector("[data-modal-apply]");s==null||s.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",r=>{r.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let t=window.__openAiEditor;if(typeof t!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";e==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:a=>{this.onApplyCallback&&this.onApplyCallback(a),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var Pi,fa=ce(()=>{"use strict";Pi=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=`
47
+ <div class="asset-crop-card">
48
+ <div class="asset-crop-header">
49
+ <div>
50
+ <div class="asset-crop-title">Crop Image</div>
51
+ <div class="asset-crop-subtitle">Drag to reposition, scroll to zoom</div>
52
+ </div>
53
+ <button class="asset-crop-close" data-action="close">\xD7</button>
54
+ </div>
55
+
56
+ <div class="asset-crop-body">
57
+ <div class="asset-crop-column">
58
+ <div class="asset-crop-canvas-container">
59
+ <canvas class="asset-crop-canvas"></canvas>
60
+ </div>
61
+
62
+ <div class="asset-crop-controls">
63
+ <div class="asset-crop-zoom">
64
+ <label class="asset-crop-label">Zoom</label>
65
+ <input type="range" min="0.1" max="3" step="0.1" value="1" class="asset-crop-zoom-slider" />
66
+ <span class="asset-crop-zoom-value">1.0x</span>
67
+ </div>
68
+
69
+ <div class="asset-crop-aspect">
70
+ <label class="asset-crop-label">Aspect Ratio</label>
71
+ <select class="asset-crop-aspect-select">
72
+ <option value="free">Free</option>
73
+ <option value="1:1">Square (1:1)</option>
74
+ <option value="4:3">Standard (4:3)</option>
75
+ <option value="16:9">Widescreen (16:9)</option>
76
+ <option value="3:2">Photo (3:2)</option>
77
+ </select>
78
+ </div>
79
+
80
+ <button class="asset-crop-reset" data-action="reset">Reset</button>
81
+ </div>
82
+ </div>
83
+
84
+ <div class="asset-crop-column">
85
+ <div class="asset-crop-preview">
86
+ <div class="asset-crop-preview-label">Preview</div>
87
+ <canvas class="asset-crop-preview-canvas"></canvas>
88
+ </div>
89
+ </div>
90
+ </div>
91
+
92
+ <div class="asset-crop-actions">
93
+ <button class="asset-crop-apply" data-action="cancel">Cancel</button>
94
+ <button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
95
+ </div>
96
+ </div>
97
+ `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var n;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(n=this.options)!=null&&n.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,n=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,n-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,n=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,n,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,n,a),this.ctx.fillStyle="#ffffff";let s=8;[[e,t],[e+n-s,t],[e,t+a-s],[e+n-s,t+a-s]].forEach(([o,c])=>{var l;(l=this.ctx)==null||l.fillRect(o,c,s,s)})}updatePreview(){if(!this.modal||!this.image)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let n=150;e.width=n,e.height=n;let a=n/this.cropWidth,s=n/this.cropHeight,r=Math.min(a,s),o=this.cropWidth*r,c=this.cropHeight*r,l=(n-o)/2,u=(n-c)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,l,u,o,c)}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",n=>{let a=parseFloat(n.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",n=>{let a=n.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",n=>{switch(n.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",n=>{n.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,n=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,n=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let n=e.toDataURL("image/png");this.options.onCrop(n),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(i){new Pi().open(i)}});var hr={};mn(hr,{AssetCache:()=>re,AssetLoader:()=>Ie,AssetSystem:()=>li,AssetTextures:()=>Pe,Assets:()=>Fa,BaseSystem:()=>rt,GameEngine:()=>oi,GameObject:()=>Ot,GameObjectManager:()=>at,ObjectFactory:()=>ye,Renderer:()=>_t,RuntimeObjectRegistry:()=>ot,Transform:()=>jt,applyScreenAnchor:()=>Ft,basePixi:()=>$a,clearResponsiveElements:()=>ia,createPixiBase:()=>si,getRegisteredFontIds:()=>_a,globalResponsiveMultipliers:()=>St,initAssetTextures:()=>Zt,initAssets:()=>Ba,layout:()=>aa,playLottieOverlay:()=>Ra,registerFont:()=>ja,registerType:()=>Xt,resolveAnchorVec2:()=>Te,resolveFont:()=>Pa,resolveFontWeight:()=>Ma,resolveScreenAnchorPoint:()=>De,resolveScreenRatioPoint:()=>Ne,runInitSequence:()=>Ga,setLottieInstance:()=>Qt,spawnSceneFromConfig:()=>Na,updateScreenState:()=>Ht});module.exports=Ka(hr);var Ia=require("pixi.js");var Le={};function zt(i,e,t=!1){Le[i]||(Le[i]=[]),Le[i].push({fn:e,once:t})}function di(i,e){if(Le[i]){if(!e){delete Le[i];return}Le[i]=Le[i].filter(t=>t.fn!==e)}}function $t(i,...e){let t=Le[i];if(t)for(let n of[...t])n.fn(...e),n.once&&di(i,n.fn)}function ee(i,e){zt(i,e,!0)}var $=null,ae=[],Ye=null;function wn(i){$=i,ae=[],Ye!==null&&(clearTimeout(Ye),Ye=null)}function xn(){var i,e,t;return{endpoint:($==null?void 0:$.endpoint)||"",transport:($==null?void 0:$.transport)||"beacon",batchSize:(i=$==null?void 0:$.batchSize)!=null?i:10,flushIntervalMs:(e=$==null?void 0:$.flushIntervalMs)!=null?e:300,maxQueue:(t=$==null?void 0:$.maxQueue)!=null?t:200,debug:!!($!=null&&$.debug)}}async function yn(i,e,t,n){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let s=navigator.sendBeacon(i,new Blob([a],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",s,e);return}catch(s){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",s)}try{await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",e)}catch(s){n&&console.warn("[handler.telemetry] fetch failed",s)}}function pi(i,e){let t=xn();if(e&&t.endpoint){if(ae.push(i),ae.length>t.maxQueue&&(ae=ae.slice(ae.length-t.maxQueue)),ae.length>=t.batchSize){vn();return}Ye===null&&(Ye=window.setTimeout(()=>{Ye=null,vn()},t.flushIntervalMs))}}async function vn(){let i=xn();if(!i.endpoint||ae.length===0)return;let e=ae.splice(0,i.batchSize);await yn(i.endpoint,{events:e},i.transport,i.debug),ae.length>0&&await yn(i.endpoint,{events:ae.splice(0,i.batchSize)},i.transport,i.debug)}function Sn(i){return Math.max(0,Math.min(1,i))}function Xa(i){let e=String(i!=null?i:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),n=t?Number(t[1]):1.8;return a=>1+(n+1)*Math.pow(a-1,3)+n*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function wt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Ja(i,e){let t=i==null?void 0:i[e];return typeof t=="number"?t:0}function En(i,e,t){try{i[e]=t}catch{}}function Za(i){let e=i==null?void 0:i.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,n=typeof e.y=="number"?e.y:1;return{x:t,y:n}}function Cn(i,e){let t=i==null?void 0:i.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function An(i,e){let t=Za(i);if(!t)return{from:null,to:null};let n=null,a=null;return typeof e.scale=="number"?(n=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(n=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(n=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),n===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:n!=null?n:t.x,y:a!=null?a:t.y}}}function Ln(){let i=new Set,e=new WeakMap,t=null,n=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),i.size>0&&n()})},a=u=>{var d;i.add(u);let p=(d=e.get(u.target))!=null?d:new Set;p.add(u),e.set(u.target,p),n()},s=u=>{i.delete(u);let p=e.get(u.target);p&&(p.delete(u),p.size===0&&e.delete(u.target))},r=u=>{u.killed||(u.killed=!0,s(u))},o=()=>{var p,d;let u=wt();for(let g of Array.from(i)){if(g.killed||g.paused)continue;let m=u-g.startMs-g.delayMs;if(m<0)continue;let f=g.durationMs>0?m/g.durationMs:1,C=Sn(f),b=g.repeat>=0?g.repeat+1:1,h=g.repeat>0?Math.min(Math.floor(f),b-1):0;if(g.repeat>0&&f>=1){let x=f-h;C=Sn(x)}let y=g.ease(C);g.yoyo&&h%2===1&&(y=1-y);for(let x of g.props)En(g.target,x.key,x.from+(x.to-x.from)*y);g.scaleFrom&&g.scaleTo&&Cn(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*y,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*y});try{(p=g.onUpdate)==null||p.call(g)}catch{}if(f>=b){r(g);try{(d=g.onComplete)==null||d.call(g)}catch{}}}},c=(u,p,d)=>{var x;let g=Math.max(0,(typeof p.duration=="number"?p.duration:.5)*1e3),m=Math.max(0,(typeof p.delay=="number"?p.delay:0)*1e3+((x=d==null?void 0:d.delayMsOverride)!=null?x:0)),f=Xa(p.ease),C=typeof p.repeat=="number"?Math.max(0,p.repeat|0):0,b=p.yoyo===!0,h=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),y=[];for(let I of Object.keys(p)){if(h.has(I))continue;let L=p[I];typeof L=="number"&&y.push({key:I,from:Ja(u,I),to:L})}let w=An(u,p);return{target:u,startMs:wt(),delayMs:m,durationMs:g,ease:f,props:y,scaleFrom:w.from,scaleTo:w.to,repeat:C,yoyo:b,onUpdate:typeof p.onUpdate=="function"?p.onUpdate:void 0,onComplete:typeof p.onComplete=="function"?p.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},l={to(u,p){let d=c(u,p);return a(d),{kill:()=>r(d),pause:()=>{d.paused||(d.paused=!0,d.pauseAtMs=wt())},resume:()=>{var f;if(!d.paused)return;let g=(f=d.pauseAtMs)!=null?f:wt(),m=wt()-g;d.startMs+=m,d.paused=!1,d.pauseAtMs=null},isActive:()=>!d.killed&&!d.paused}},fromTo(u,p,d){return l.set(u,p),l.to(u,d)},set(u,p){if(!u||!p)return;for(let g of Object.keys(p)){let m=p[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof m=="number"&&En(u,g,m)}let d=An(u,p);d.to&&Cn(u,d.to)},killTweensOf(u){let p=e.get(u);if(p)for(let d of Array.from(p))r(d)},timeline(u={}){let p=[],d=0,g=!1,m=[],f=h=>{if(typeof h=="number")return Math.max(0,h*1e3);let y=typeof h=="string"?h.trim():"";return y.startsWith("+=")?d+Math.max(0,Number(y.slice(2))*1e3||0):y?Math.max(0,Number(y)*1e3||0):d},C=h=>{p.push(h);let y=Math.max(0,(typeof h.vars.duration=="number"?h.vars.duration:.5)*1e3);d=Math.max(d,h.atMs+y)},b={to(h,y,w){return C({kind:"to",target:h,vars:y,atMs:f(w)}),b},fromTo(h,y,w,x){return C({kind:"fromTo",target:h,vars:w,from:y,atMs:f(x)}),b},play(){var h,y;if(g)return b;g=!0,m=[];for(let w of p)w.kind==="fromTo"&&l.set(w.target,(h=w.from)!=null?h:{}),m.push(l.to(w.target,{...w.vars,delay:w.atMs/1e3+((y=w.vars.delay)!=null?y:0)}));return b},pause(){for(let h of m)h.pause();return b},kill(){for(let h of m)h.kill();m=[],g=!1}};return u.paused||b.play(),b}};return l}function Tn(){if(typeof window=="undefined")return;let i=window;if(!i.gsap)try{i.gsap=Ln()}catch{}}var kn={name:"handler-playable-sdk",version:"1.0.90",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 --external jszip && 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/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.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 --external jszip && 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 dist/cli/student-helper/*.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 te=0,es=te++,In=te++,Pn=te++,Mn=te++,jn=te++,_n=te++,On=te++,Rn=te++,zn=te++,$n=te++,Dn=te++,Nn=te++,j=es;function Hn(){return j===In}function Fn(){return j===Pn}function Bn(){return j===Mn}function Gn(){return j===jn}function We(){return j===_n}function Ke(){return j===On}function Un(){return j===Rn}function qn(){return j===zn}function Vn(){return j===$n}function ui(){return j===Dn}function gi(){return j===Nn}function Yn(){let i=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(i==="mraid")try{mraid.getState(),j=In;return}catch{}else if(i==="dapi")try{dapi.isReady(),j=Pn;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(j=Mn)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(j=jn)}catch{}else if(e==="mintegral")window.gameReady&&(j=_n);else if(e==="tapjoy")window.TJ_API&&(j=On);else if(e==="tiktok")window.openAppStore&&(j=Rn);else if(e==="smadex")try{window.smxTracking&&(j=zn)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(j=$n)}catch{}else e==="vungle"?j=Dn:(i==="nucleo"||e==="nucleo")&&(j=Nn)}var Dt=ci(require("lottie-web"),1),Wn=Dt.default;typeof window!="undefined"&&(window.lottie=Dt.default,window.__baseLottie=Dt.default);mi();function D(i,e){let t=(a,s)=>s===0?a:t(s,a%s),n=t(i,e);return`${i/n}:${e/n}`}var Yr=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:D(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:D(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:D(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:D(360,780)}],Wr=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:D(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:D(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:D(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:D(412,915)}],Kr=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:D(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:D(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:D(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:D(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:D(800,1280)}],Zn=[{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:D(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:D(768,1024),mraidScale:.7}];var Xr=[...Zn];var ls=Zn[0];de();var ta=require("pixi.js"),fe={width:400,height:600,designWidth:400,scaleFactor:1},St={scale:1,position:1},Bt=[];function ds(i,e,t,n,a,s,r){Bt.push({element:i,originalScale:s,positionHelper:e,heightPercent:a}),e(i,t,n,a,s,r,!1)}function ps(){Bt.forEach(({element:i,originalScale:e,positionHelper:t,heightPercent:n})=>{let a=e*fe.scaleFactor;t(i,fe.width,fe.height,n,a,!0,!1)})}function ia(){Bt.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Ht(i,e){console.log(`[SCREEN] updateScreenState called: ${i}x${e}`),fe.width=i,fe.height=e,fe.scaleFactor=Math.min(i/fe.designWidth,1.15),St.scale=fe.scaleFactor,St.position=1,console.log(`[SCREEN] Global multipliers - scale: ${St.scale.toFixed(3)}`),ps()}var _={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 us(i,e,t){let n=_[i];n&&n[e]!==void 0&&(n[e]=t,console.log(`Updated ${i}.${e} = ${t}`))}function gs(){return _}var hs={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 Nt(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function Te(i,e={x:.5,y:.5}){var t;if(Array.isArray(i))return{x:Nt(i[0],e.x),y:Nt(i[1],e.y)};if(i&&typeof i=="object"){let n=i;return{x:Nt(n.x,e.x),y:Nt(n.y,e.y)}}if(typeof i=="string"){let n=i.trim().toLowerCase();return(t=hs[n])!=null?t:e}return e}function De(i,e,t,n={}){var g,m,f,C,b,h;let a=Te(t),s=(g=n.inset)!=null?g:{},r=(m=n.padding)!=null?m:{x:0,y:0},o=((f=s.left)!=null?f:0)+r.x,c=((C=s.right)!=null?C:0)+r.x,l=((b=s.top)!=null?b:0)+r.y,u=((h=s.bottom)!=null?h:0)+r.y,p=Math.max(0,i-o-c),d=Math.max(0,e-l-u);return{x:o+p*a.x,y:l+d*a.y}}function Ne(i,e,t,n={}){var f,C,b,h,y,w;let a=(f=n.inset)!=null?f:{},s=(C=n.padding)!=null?C:{x:0,y:0},r=((b=a.left)!=null?b:0)+s.x,o=((h=a.right)!=null?h:0)+s.x,c=((y=a.top)!=null?y:0)+s.y,l=((w=a.bottom)!=null?w:0)+s.y,u=Math.max(0,i-r-o),p=Math.max(0,e-c-l),d=Te(t,{x:.5,y:.5}),g=Math.min(Math.max(d.x,0),1),m=Math.min(Math.max(d.y,0),1);return{x:r+u*g,y:c+p*m}}function Ft(i,e,t,n={}){var u,p,d;if(!i)return;let a=n.positionRatio?Ne(e,t,n.positionRatio,{inset:n.inset,padding:n.screenPadding}):De(e,t,n.anchor,{inset:n.inset,padding:n.screenPadding}),s=(u=n.offset)!=null?u:{x:0,y:0},r=a.x+s.x,o=a.y+s.y;i.anchor&&n.renderAnchor&&i.anchor.set(n.renderAnchor.x,n.renderAnchor.y),se(i,r,o);let c=(p=n.scale)!=null?p:1,l=(d=n.scaleMultiplier)!=null?d:1;(n.scale!==void 0||n.scaleMultiplier!==void 0)&&pe(i,c*l)}if(typeof window!="undefined"){let i=window.innerWidth,e=window.innerHeight,t=()=>{let n=window.innerWidth,a=window.innerHeight;(n!==i||a!==e)&&(i=n,e=a,Ht(n,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Ht(window.innerWidth,window.innerHeight),window.updateDebugConfig=us,window.getDebugConfig=gs,window.copyConfig=As,window.applyConfig=xt,window.applyConfigForRatio=Ls,window.positionAtBottom=na,window.positionAtTop=bs,window.positionAtCenter=ys,window.positionAtLeft=vs,window.positionAtRight=ws,window.positionAtBottomLeft=xs,window.positionAtBottomRight=Ss,window.positionAtTopLeft=Es,window.positionAtTopRight=Cs,window.applyPositionContract=ms,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 Gt(i,e,t=0){return i*e+t}function Ut(i,e,t=0){return i*(1-e)+t}function qt(i,e,t=0){return i*e+t}function Vt(i,e,t=0){return i*(1-e)+t}function ie(i,e=0){return i/2+e}function fs(i,e){return i*e}function ms(i,e,t,n){var r,o,c,l,u,p,d,g,m,f,C,b,h,y,w,x,I,L,B,R;let a=0,s=0;switch(n.type){case"top":a=ie(e,(o=(r=n.offset)==null?void 0:r.x)!=null?o:0),s=Gt(t,n.percent,(l=(c=n.offset)==null?void 0:c.y)!=null?l:0);break;case"bottom":a=ie(e,(p=(u=n.offset)==null?void 0:u.x)!=null?p:0),s=Ut(t,n.percent,(g=(d=n.offset)==null?void 0:d.y)!=null?g:0);break;case"left":a=qt(e,n.percent,(f=(m=n.offset)==null?void 0:m.x)!=null?f:0),s=ie(t,(b=(C=n.offset)==null?void 0:C.y)!=null?b:0);break;case"right":a=Vt(e,n.percent,(y=(h=n.offset)==null?void 0:h.x)!=null?y:0),s=ie(t,(x=(w=n.offset)==null?void 0:w.y)!=null?x:0);break;case"center":a=ie(e,(L=(I=n.offset)==null?void 0:I.x)!=null?L:0),s=ie(t,(R=(B=n.offset)==null?void 0:B.y)!=null?R:0);break}i.position?i.position.set(a,s):(i.x=a,i.y=s),n.scale!==void 0&&n.scale!==1&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(n.scale,n.scale):(i.scale.x=n.scale,i.scale.y=n.scale))}function na(i,e,t,n=.2,a=1,s=!0,r=!1){let o=fs(t,n),c=Ut(t,n/2);se(i,ie(e),c);let l=s?a*fe.scaleFactor:a;pe(i,l),r&&!Bt.find(u=>u.element===i)&&ds(i,na,e,t,n,a,s)}function bs(i,e,t,n=.1,a=1){se(i,ie(e),Gt(t,n)),pe(i,a)}function ys(i,e,t,n=0,a=0,s=1){se(i,ie(e,n),ie(t,a)),pe(i,s)}function vs(i,e,t,n=.1,a=1){se(i,qt(e,n),ie(t)),pe(i,a)}function ws(i,e,t,n=.1,a=1){se(i,Vt(e,n),ie(t)),pe(i,a)}function xs(i,e,t,n=.05,a=.05,s=1){se(i,qt(e,a),Ut(t,n)),pe(i,s)}function Ss(i,e,t,n=.05,a=.05,s=1){se(i,Vt(e,a),Ut(t,n)),pe(i,s)}function Es(i,e,t,n=.05,a=.05,s=1){se(i,qt(e,a),Gt(t,n)),pe(i,s)}function Cs(i,e,t,n=.05,a=.05,s=1){se(i,Vt(e,a),Gt(t,n)),pe(i,s)}function se(i,e,t){i&&i.position?typeof i.position.set=="function"?i.position.set(e,t):(i.position.x=e,i.position.y=t):i&&(i.x=e,i.y=t)}function pe(i,e){e!==1&&i&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(e,e):i.scale.x!==void 0&&i.scale.y!==void 0&&(i.scale.x=e,i.scale.y=e))}var $e={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 As(i){return i&&$e[i]?JSON.parse(JSON.stringify($e[i])):JSON.parse(JSON.stringify(_))}function xt(i){Object.keys(i).forEach(e=>{let t=e;_[t]&&i[t]&&Object.assign(_[t],i[t])}),console.log("Config applied:",i)}function Ls(i,e){let t=i/e;t>1.6?(xt($e.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(xt($e.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(xt($e.square),console.log("Applied SQUARE config for ratio:",t)):(xt($e.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let i=window;i.configPresets=$e,i.resolveAnchorVec2=i.resolveAnchorVec2||Te,i.resolveScreenAnchorPoint=i.resolveScreenAnchorPoint||De,i.resolveScreenRatioPoint=i.resolveScreenRatioPoint||Ne}var K=null,ea=new Map;function aa(i,e,t,n,a,s={}){var Se,Ee,Ce,Ae,Y,_e,lt,ct,dt,pt,ut,gt,ht,ft,mt,bt,F,Z,U,Q,Ue,Oe,Bi,Gi,Ui,qi,Vi,Yi,Wi,Ki,Xi,Ji,Zi,Qi,en,tn,nn,an,sn,rn,on,ln,cn,dn,pn,un,gn,hn,fn;let r=(Se=s.enableDebugLogs)!=null?Se:!1;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:n.width,height:n.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",s));let{mainContainer:o,label:c,background:l,backgroundTexture:u,app:p}=i;if(!p||!p.renderer){r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:p.renderer.width,height:p.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:p.screen.width,height:p.screen.height}));let d=n.width,g=n.height;r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:d,baseHeight:g});let m=d*_.layout.screen_scale_x,f=g*_.layout.screen_scale_y,C=d/2,b=e.engine.runtime||{},h=b.layout||{};r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:_.layout.screen_scale_x,screen_scale_y:_.layout.screen_scale_y}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Calculated dimensions:",{width:m,height:f,midX:C}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",b),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",h));let y=f>m,w=(Ee=h.design_width_portrait)!=null?Ee:y?400:600,x=(Ce=h.design_height_portrait)!=null?Ce:y?600:400,I=Math.min(m/w,f/x);I=Math.min(I,1.15);let L=I*((Ae=_.engine.scale)!=null?Ae:1),B=(Y=s.skipMainContainerTransform)!=null?Y:!1;!B&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(L):(o.scale.x=L,o.scale.y=L));let R=(_e=h.main_container_anchor)!=null?_e:"center",H=(lt=h.main_container_position_ratio)!=null?lt:{x:.5,y:.5},z=(ct=h.main_container_offset)!=null?ct:{x:0,y:0},T=h.main_container_position_ratio?Ne(d,g,H):De(d,g,R),E=T.x+z.x+_.layout.position_offset.x,S=T.y+z.y+_.layout.position_offset.y;if(!B&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(E,S):(o.position.x=E,o.position.y=S)),a&&(o!=null&&o.toLocal)){let G=g>d,W=(dt=h.design_width_portrait)!=null?dt:G?320:480,N=(pt=h.design_height_portrait)!=null?pt:G?480:320;for(let[oe,le]of e.objects.entries()){let q=le==null?void 0:le.transform;if(!q||((ut=q.position_mode)!=null?ut:"static")!=="static")continue;let k=(gt=a.get)==null?void 0:gt.call(a,oe),yt=((ht=k==null?void 0:k.getDisplayObject)==null?void 0:ht.call(k))||(k==null?void 0:k.pixiObject)||k;if(!yt||yt.parent!==o)continue;let he=(ft=q.anchor)!=null?ft:"bottom-left";he==="bottom-left"&&q.anchor==null&&console.log("[DEBUG FALLBACK] LayoutManager transform.anchor \u2192 bottom-left");let qe=q.position_ratio!=null?Ne(W,N,q.position_ratio):De(W,N,he),Ve=(mt=q.position)!=null?mt:{x:0,y:0},vt=qe.x-W/2+Ve.x,Re=qe.y-N/2+Ve.y;typeof(k==null?void 0:k.setPosition)=="function"?k.setPosition(vt,Re):(se(yt,vt,Re),(bt=k==null?void 0:k.transform)!=null&&bt.position&&(k.transform.position.x=vt,k.transform.position.y=Re))}}let A=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,J=((A==null?void 0:A.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(_.layout.debug_rect_visible&&J){(!K||K.parent!==p.stage)&&(K==null||K.destroy(),K=new ta.Graphics,K.zIndex=9999,p.stage.addChild(K)),K.clear();let G=_.layout.debug_rect_scale_x,W=_.layout.debug_rect_scale_y,N=(d-4)*G,oe=(g-4)*W,le=(d-N)/2,q=(g-oe)/2;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:d,baseHeight:g,rectW:N,rectH:oe,offsetX:le,offsetY:q}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+le,y:2+q,width:N,height:oe})),K.rect(2+le,2+q,N,oe).stroke({width:_.layout.debug_rect_thickness,color:_.layout.debug_rect_color})}else K&&(K.destroy(),K=null);let O=((F=i.label)==null?void 0:F.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(c&&c.position&&O){let G=(U=(Z=O==null?void 0:O.transform)==null?void 0:Z.anchor)!=null?U:"center",W=(Q=O==null?void 0:O.transform)==null?void 0:Q.position_ratio,N=((Ue=O==null?void 0:O.transform)==null?void 0:Ue.offset)||{x:0,y:0};Ft(c,d,g,{anchor:G,positionRatio:W,offset:{x:N.x*L,y:N.y*L},renderAnchor:Te(G)})}if(c&&c.alpha>0){let G=1+Math.sin(t*_.engine.label_pulse_speed)*_.engine.label_pulse_intensity,W=(Bi=(Oe=O==null?void 0:O.transform)==null?void 0:Oe.scale)!=null?Bi:1,N=G*L*W;c.scale&&(typeof c.scale.set=="function"?c.scale.set(N):(c.scale.x=N,c.scale.y=N))}r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING =====");let ne=l?e.objects.get("background_1"):null,je=!!ne&&(l==null?void 0:l.parent)===o;if(l&&!je){r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!l),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(Gi=l.constructor)==null?void 0:Gi.name)),l.alpha=((qi=(Ui=b.background)==null?void 0:Ui.alpha)!=null?qi:.98)*_.engine.background_alpha,r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",l.alpha),r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",ne);let G=(ne==null?void 0:ne.transform)||{};r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",G);let W=G.offset||{x:0,y:0},N=((Yi=(Vi=b.background)==null?void 0:Vi.offset_y)!=null?Yi:0)+_.engine.background_offset_y,oe=(Wi=G.anchor)!=null?Wi:"center",le=G.position_ratio;if(r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:W,bgRuntimeOffsetY:N,bgScreenAnchor:oe,bgPositionRatio:le,baseWidth:d,baseHeight:g,finalScale:L}),Ft(l,d,g,{anchor:oe,positionRatio:le,offset:{x:W.x*L,y:W.y*L+N},renderAnchor:Te(oe)}),r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:l.x,y:l.y,scaleX:(Ki=l.scale)==null?void 0:Ki.x,scaleY:(Xi=l.scale)==null?void 0:Xi.y,anchorX:(Ji=l.anchor)==null?void 0:Ji.x,anchorY:(Zi=l.anchor)==null?void 0:Zi.y,pivotX:(Qi=l.pivot)==null?void 0:Qi.x,pivotY:(en=l.pivot)==null?void 0:en.y,width:l.width,height:l.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 qe=Math.max(m/u.width,f/u.height),Ve=(nn=(tn=b.background)==null?void 0:tn.scale_multiplier)!=null?nn:1.05,vt=(an=G.scale)!=null?an:1,Re=qe*Ve*_.engine.background_scale*vt;l.scale&&(typeof l.scale.set=="function"?l.scale.set(Re):(l.scale.x=Re,l.scale.y=Re))}else l&&typeof l.clear=="function"&&(l.clear(),l.rect(-m/2,-f/2,m,f).fill({color:1444375}));let q=`${d}x${g}`,P=ea.get(q),k={x:Number((sn=l.x)!=null?sn:0),y:Number((rn=l.y)!=null?rn:0),scaleX:Number((ln=(on=l.scale)==null?void 0:on.x)!=null?ln:1),scaleY:Number((dn=(cn=l.scale)==null?void 0:cn.y)!=null?dn:1),rotation:Number.isFinite(l.rotation)?l.rotation:void 0,anchorX:Number.isFinite((pn=l.anchor)==null?void 0:pn.x)?l.anchor.x:void 0,anchorY:Number.isFinite((un=l.anchor)==null?void 0:un.y)?l.anchor.y:void 0,pivotX:Number.isFinite((gn=l.pivot)==null?void 0:gn.x)?l.pivot.x:void 0,pivotY:Number.isFinite((hn=l.pivot)==null?void 0:hn.y)?l.pivot.y:void 0},yt=Number.isFinite(k.x)&&Number.isFinite(k.y)&&Number.isFinite(k.scaleX)&&Number.isFinite(k.scaleY),he=k;if(P){let qe=Math.hypot(k.x-P.x,k.y-P.y),Ve=Math.max(d,g)*.5;(!yt||qe>Ve)&&((fn=l.position)!=null&&fn.set?l.position.set(P.x,P.y):(l.x=P.x,l.y=P.y),l.scale&&(typeof l.scale.set=="function"?l.scale.set(P.scaleX,P.scaleY):(l.scale.x=P.scaleX,l.scale.y=P.scaleY)),Number.isFinite(P.rotation)&&typeof l.rotation=="number"&&(l.rotation=P.rotation),l.anchor&&Number.isFinite(P.anchorX)&&Number.isFinite(P.anchorY)&&l.anchor.set(P.anchorX,P.anchorY),l.pivot&&Number.isFinite(P.pivotX)&&Number.isFinite(P.pivotY)&&l.pivot.set(P.pivotX,P.pivotY),he=P)}Number.isFinite(he.x)&&Number.isFinite(he.y)&&Number.isFinite(he.scaleX)&&Number.isFinite(he.scaleY)&&ea.set(q,he)}}function Ts(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function ks(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}async function Is(i){return await new Promise(e=>{let t=new Image;t.onload=()=>e({width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}),t.onerror=()=>e(null),t.src=i})}async function yi(i){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",i);let n=await fetch(i);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,i),null;let a=await n.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let s=await Ts(a),r=await Is(s),o=ks(s);return console.log("[ImageUtils] Success resolution:",r==null?void 0:r.width,"x",r==null?void 0:r.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:s,width:(e=r==null?void 0:r.width)!=null?e:0,height:(t=r==null?void 0:r.height)!=null?t:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function Yt(i,e=30){try{console.log("[ImageUtils] Removing background color...");let t=await new Promise((p,d)=>{let g=new Image;g.onload=()=>p(g),g.onerror=()=>d(new Error("Failed to load image")),g.src=i}),n=document.createElement("canvas");n.width=t.width,n.height=t.height;let a=n.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),i;a.drawImage(t,0,0);let s=a.getImageData(0,0,n.width,n.height),r=s.data,c=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(p=>({r:r[p.offset],g:r[p.offset+1],b:r[p.offset+2]})),l=0;for(let p=0;p<r.length;p+=4){let d=r[p],g=r[p+1],m=r[p+2],f=!1;for(let C of c)if(Math.sqrt(Math.pow(d-C.r,2)+Math.pow(g-C.g,2)+Math.pow(m-C.b,2))<e){f=!0;break}f&&(r[p+3]=0,l++)}return console.log(`[ImageUtils] Removed background from ${l} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(s,0,0),n.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),i}}var sa=require("@google/genai");async function vi(i,e,t=[],n={}){var a,s,r,o,c,l,u;try{if(!(i!=null&&i.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let b=0;b<t.length;b++){let h=t[b];if(!h.base64||!h.mimeType)throw new Error(`Image ${b+1} is missing required data`);if(h.base64.length<1e3&&console.warn(`Image ${b+1} data appears very small, may be corrupted`),!h.mimeType.startsWith("image/"))throw new Error(`Image ${b+1} has invalid MIME type: ${h.mimeType}`)}let p=new sa.GoogleGenAI({apiKey:i}),d="gemini-2.5-flash",g=[e];t.length>0&&t.forEach((b,h)=>{g.push({inlineData:{data:b.base64,mimeType:b.mimeType}}),console.log(`[Gemini] Added image ${h+1}: ${b.mimeType}, size: ${Math.round(b.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${t.length} images and prompt length: ${e.length}`);let m=await p.models.generateContent({model:d,contents:g}),f="",C=(r=(s=(a=m.candidates)==null?void 0:a[0])==null?void 0:s.content)==null?void 0:r.parts;if(C)for(let b of C)b.text&&(f+=b.text);if(!f.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${f.length}`),f}catch(p){throw console.error("[Gemini] API error:",p),(o=p.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."):(c=p.message)!=null&&c.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(l=p.message)!=null&&l.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(u=p.message)!=null&&u.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):p}}var ra=require("@google/genai");async function Wt(i,e,t=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new ra.GoogleGenAI({apiKey:i}),s=[{text:e}];t.length>0&&t.forEach((o,c)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${c}`),s.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let r=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:s});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!r.candidates||!r.candidates[0]||!r.candidates[0].content||!r.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of r.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let c=o.inlineData.data,l=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${l};base64,${c}`}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 Rs=require("pixi.js");Et();Kt();de();var ua=require("pixi.js");var $s=require("pixi.js");de();function Ys(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Ws(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}function Ks(i){return`
47
98
  Analyze these screenshots of a brand or game and extract its "Brand DNA".
48
99
 
49
100
  Provide a concise summary (2-3 sentences) covering:
@@ -60,9 +111,24 @@ Palette: [#RRGGBB, #RRGGBB, ...]
60
111
  ${i?`
61
112
  ADDITIONAL RULES/NOTES:
62
113
  ${i}`:""}
63
- `.trim()}function ga(){let i=[],e="",t=null;return{async addSources(n){let a=[];for(let s of n){let r=await qs(s),o=Vs(r),c={id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,name:s.name,base64:o.base64,mimeType:o.mimeType,dataUrl:r};i.push(c),a.push(c)}return a},getSources(){return i.slice()},async analyze(n,a,s){if(i.length===0)throw new Error("No screenshots to analyze.");let r=Ys(a),o=i.map(p=>({base64:p.base64,mimeType:p.mimeType})),c=await vi(n,r,o,{model:s}),l=e,u=[],d=c.split(`
64
- `);for(let p of d)if(p.toLowerCase().startsWith("summary:"))l=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(!l||l===e)&&(l=c.split(`
65
- Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:l,palette:u.slice(0,10)},t},setSummary(n){e=n,t&&(t={...t,summary:n})},getResult(){return t}}}var Fe="handler_api_key_";var Xe=class{static setKey(e,t,n){try{let a={key:this.encryptKey(t),created:Date.now(),lastUsed:Date.now(),label:n||e},s=`${Fe}${e}`;localStorage.setItem(s,JSON.stringify(a))}catch(a){console.error("[ApiKeyStorage] Failed to store API key:",a)}}static getKey(e){try{let t=`${Fe}${e}`,n=localStorage.getItem(t);if(!n)return null;let a=JSON.parse(n);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=`${Fe}${e}`;return localStorage.getItem(t)!==null}static removeKey(e){try{let t=`${Fe}${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 n=localStorage.key(t);if(n&&n.startsWith(Fe)){let a=n.substring(Fe.length),s=localStorage.getItem(n);if(s){let r=JSON.parse(s);e.push({service:a,label:r.label,created:r.created,lastUsed:r.lastUsed})}}}}catch(t){console.error("[ApiKeyStorage] Failed to get stored services:",t)}return e.sort((t,n)=>n.lastUsed-t.lastUsed)}static clearAll(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&n.startsWith(Fe)&&e.push(n)}e.forEach(t=>localStorage.removeItem(t))}catch(e){console.error("[ApiKeyStorage] Failed to clear API keys:",e)}}static encryptKey(e){try{let n="handler_preview_salt_2024"+e;return btoa(n)}catch(t){return console.warn("[ApiKeyStorage] Encryption failed, storing as-is:",t),e}}static decryptKey(e){try{let t=atob(e),n="handler_preview_salt_2024";return t.startsWith(n)?t.substring(n.length):t}catch(t){return console.warn("[ApiKeyStorage] Decryption failed, returning as-is:",t),e}}},Ei=()=>Xe.getKey("gemini"),Ci=(i,e)=>Xe.setKey("gemini",i,e),Ws=()=>Xe.hasKey("gemini");window.ApiKeyStorage=Xe;window.getGeminiApiKey=Ei;window.setGeminiApiKey=Ci;window.hasGeminiApiKey=Ws;var Li=class{constructor(){this.modal=null;this.options=null;this.analyzer=ga();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,n;(t=this.promptInput)==null||t.focus(),(n=this.promptInput)==null||n.select()},100)}createModal(){var t;let e=document.createElement("div");e.className="ai-modal",e.innerHTML=`
114
+ `.trim()}function ga(){let i=[],e="",t=null;return{async addSources(n){let a=[];for(let s of n){let r=await Ys(s),o=Ws(r),c={id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,name:s.name,base64:o.base64,mimeType:o.mimeType,dataUrl:r};i.push(c),a.push(c)}return a},getSources(){return i.slice()},async analyze(n,a,s){if(i.length===0)throw new Error("No screenshots to analyze.");let r=Ks(a),o=i.map(d=>({base64:d.base64,mimeType:d.mimeType})),c=await vi(n,r,o,{model:s}),l=e,u=[],p=c.split(`
115
+ `);for(let d of p)if(d.toLowerCase().startsWith("summary:"))l=d.slice(8).trim();else if(d.toLowerCase().includes("palette:")){let g=d.match(/#[0-9A-Fa-f]{6}/g);g&&g.forEach(m=>{u.includes(m.toUpperCase())||u.push(m.toUpperCase())})}return(!l||l===e)&&(l=c.split(`
116
+ Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:l,palette:u.slice(0,10)},t},setSummary(n){e=n,t&&(t={...t,summary:n})},getResult(){return t}}}var Fe="handler_api_key_";var Xe=class{static setKey(e,t,n){try{let a={key:this.encryptKey(t),created:Date.now(),lastUsed:Date.now(),label:n||e},s=`${Fe}${e}`;localStorage.setItem(s,JSON.stringify(a))}catch(a){console.error("[ApiKeyStorage] Failed to store API key:",a)}}static getKey(e){try{let t=`${Fe}${e}`,n=localStorage.getItem(t);if(!n)return null;let a=JSON.parse(n);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=`${Fe}${e}`;return localStorage.getItem(t)!==null}static removeKey(e){try{let t=`${Fe}${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 n=localStorage.key(t);if(n&&n.startsWith(Fe)){let a=n.substring(Fe.length),s=localStorage.getItem(n);if(s){let r=JSON.parse(s);e.push({service:a,label:r.label,created:r.created,lastUsed:r.lastUsed})}}}}catch(t){console.error("[ApiKeyStorage] Failed to get stored services:",t)}return e.sort((t,n)=>n.lastUsed-t.lastUsed)}static clearAll(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&n.startsWith(Fe)&&e.push(n)}e.forEach(t=>localStorage.removeItem(t))}catch(e){console.error("[ApiKeyStorage] Failed to clear API keys:",e)}}static encryptKey(e){try{let n="handler_preview_salt_2024"+e;return btoa(n)}catch(t){return console.warn("[ApiKeyStorage] Encryption failed, storing as-is:",t),e}}static decryptKey(e){try{let t=atob(e),n="handler_preview_salt_2024";return t.startsWith(n)?t.substring(n.length):t}catch(t){return console.warn("[ApiKeyStorage] Decryption failed, returning as-is:",t),e}}},Ei=()=>Xe.getKey("gemini"),Ci=(i,e)=>Xe.setKey("gemini",i,e),Xs=()=>Xe.hasKey("gemini");window.ApiKeyStorage=Xe;window.getGeminiApiKey=Ei;window.setGeminiApiKey=Ci;window.hasGeminiApiKey=Xs;var Li=class{constructor(){this.modal=null;this.options=null;this.analyzer=ga();this.currentPrompt="";this.isGenerating=!1;this.generatedImages=[];this.selectedImageIndex=-1;this.savedLibraryPaths=new Map;this.promptInput=null;this.generateBtn=null;this.saveLibraryBtn=null;this.loadingEl=null;this.galleryEl=null;this.previewEl=null;this.statusEl=null}open(e){this.options=e,this.currentPrompt=e.initialPrompt||"",this.generatedImages=[],this.selectedImageIndex=-1,this.isGenerating=!1,this.savedLibraryPaths.clear(),this.createModal(),document.body.appendChild(this.modal),setTimeout(()=>{var t,n;(t=this.promptInput)==null||t.focus(),(n=this.promptInput)==null||n.select()},100)}createModal(){var t;let e=document.createElement("div");e.className="ai-modal",e.innerHTML=`
117
+ <style>
118
+ .ai-gallery-item {
119
+ position: relative;
120
+ }
121
+ .ai-gallery-saved {
122
+ position: absolute;
123
+ top: 4px;
124
+ right: 4px;
125
+ font-size: 14px;
126
+ background: rgba(0, 0, 0, 0.6);
127
+ border-radius: 4px;
128
+ padding: 2px 4px;
129
+ pointer-events: none;
130
+ }
131
+ </style>
66
132
  <div class="ai-modal-card">
67
133
  <div class="ai-modal-header">
68
134
  <div class="ai-modal-actions">
@@ -134,21 +200,26 @@ Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:l,palette:u.slice(0
134
200
  </div>
135
201
  </div>
136
202
 
203
+ <!-- STATUS MESSAGE -->
204
+ <div class="ai-status" data-status style="padding: 8px 16px; font-size: 12px; color: #888; text-align: center;"></div>
205
+
137
206
  <!-- ACTION BUTTONS -->
138
207
  <div class="ai-modal-actions">
139
208
  <button class="ai-btn" data-action="cancel">Cancel</button>
140
209
  <button class="ai-btn" data-action="generate" disabled>Generate</button>
210
+ <button class="ai-btn success" data-action="save-library" disabled>\u{1F4BE} Save to Library</button>
141
211
  <button class="ai-btn primary" data-action="apply" disabled>Apply</button>
142
212
  </div>
143
213
  </div>
144
- `,this.modal=e,this.attachEventListeners(),this.updatePromptFromDna()}attachEventListeners(){var n;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]"),(n=this.promptInput)==null||n.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 s=a.target;switch(s.dataset.action||((o=s.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 s=a.target;if(s.classList.contains("ai-gallery-item")||s.closest(".ai-gallery-item")){let r=s.closest(".ai-gallery-item"),o=parseInt(r.dataset.index||"-1");o>=0&&this.selectImage(o)}}),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 n=this.analyzer.getResult();if(n!=null&&n.summary&&this.promptInput){let a=`${this.currentPrompt}
214
+ `,this.modal=e,this.attachEventListeners(),this.updatePromptFromDna()}attachEventListeners(){var n;if(!this.modal)return;this.promptInput=this.modal.querySelector(".ai-textarea"),this.generateBtn=this.modal.querySelector('[data-action="generate"]'),this.saveLibraryBtn=this.modal.querySelector('[data-action="save-library"]'),this.loadingEl=this.modal.querySelector("[data-loading]"),this.galleryEl=this.modal.querySelector("[data-gallery]"),this.previewEl=this.modal.querySelector("[data-preview]"),this.statusEl=this.modal.querySelector("[data-status]"),(n=this.promptInput)==null||n.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 s=a.target;switch(s.dataset.action||((o=s.closest("[data-action]"))==null?void 0:o.getAttribute("data-action"))){case"generate":this.generateImage();break;case"save-library":this.saveSelectedImageToLibrary();break;case"apply":this.applySelectedImage();break;case"gallery":this.toggleGallery();break;case"close":case"cancel":this.close();break}}),this.modal.addEventListener("click",a=>{let s=a.target;if(s.classList.contains("ai-gallery-item")||s.closest(".ai-gallery-item")){let r=s.closest(".ai-gallery-item"),o=parseInt(r.dataset.index||"-1");o>=0&&this.selectImage(o)}}),this.updateGenerateButton(),this.setStatus("Ready. Generate an image to get started.")}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 n=this.analyzer.getResult();if(n!=null&&n.summary&&this.promptInput){let a=`${this.currentPrompt}
145
215
 
146
- Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}catch(n){console.warn("[AiEditorModal] Failed to apply brand DNA:",n)}}async generateImage(){var e,t,n,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 s=this.getApiKey();if(!s){alert("Please set your Gemini API key first. You can do this in the AI Creative Suite panel.");return}let r=[];if(this.options.currentValue&&this.options.currentValue.startsWith("data:"))try{let l=await yi(this.options.currentValue);l&&(r=[{base64:l.base64,mimeType:l.mimeType}])}catch(l){console.warn("[AiEditorModal] Failed to load current image:",l)}let o=await Wt(s,this.currentPrompt,r,{aspectRatio:"1:1"}),c=await Yt(o);this.generatedImages.push(c||o),this.selectedImageIndex=this.generatedImages.length-1,this.updateGallery(),this.updatePreview(),this.updateApplyButton()}catch(s){console.error("[AiEditorModal] Generation failed:",s),alert(`Generation failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{this.isGenerating=!1,(n=this.loadingEl)==null||n.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,n)=>`
147
- <div class="ai-gallery-item ${n===this.selectedImageIndex?"active":""}" data-index="${n}">
148
- <img class="ai-gallery-thumb" src="${t}" alt="Generated ${n+1}" />
149
- <div class="ai-gallery-label">#${n+1}</div>
150
- </div>
151
- `).join(""))}updatePreview(){if(!this.previewEl||this.selectedImageIndex<0)return;let e=this.generatedImages[this.selectedImageIndex];this.previewEl.innerHTML=`<img src="${e}" alt="Selected image" />`}selectImage(e){e<0||e>=this.generatedImages.length||(this.selectedImageIndex=e,this.updateGallery(),this.updatePreview(),this.updateApplyButton())}toggleGallery(){this.galleryEl&&this.galleryEl.classList.toggle("hidden")}updateApplyButton(){var t;let e=(t=this.modal)==null?void 0:t.querySelector('[data-action="apply"]');e&&(e.disabled=this.selectedImageIndex<0)}applySelectedImage(){var t;if(this.selectedImageIndex<0||!((t=this.options)!=null&&t.onApply))return;let e=this.generatedImages[this.selectedImageIndex];this.options.onApply(e),this.close()}getApiKey(){let e=Ei();if(e)return e;try{let t=this.analyzer.getResult();if(t&&t.apiKey)return Ci(t.apiKey,"From Brand DNA"),t.apiKey}catch(t){console.warn("[AiEditorModal] Failed to get API key from brand DNA:",t)}return null}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.options=null}},Ai=null;window.__openAiEditor=function(i,e,t,n){Ai||(Ai=new Li),Ai.open({objectId:i,initialPrompt:e,currentValue:t,path:n==null?void 0:n.path,onApply:a=>{if(n!=null&&n.path){let s=window.updateManager;if(s)s.updateProperty(i,n.path,a);else{let r=window.getEditableObjectConfig,o=r==null?void 0:r(i);if(o){let c=n.path.split("."),l=o;for(let u=0;u<c.length-1;u++)l[c[u]]||(l[c[u]]={}),l=l[c[u]];l[c[c.length-1]]=a}}}window.dispatchEvent(new CustomEvent("inspector:refresh"))}})};ki();var Pi=class{constructor(){this.modal=null;this.options=null}open(e){this.options=e,this.createModal(),document.body.appendChild(this.modal)}createModal(){if(!this.options)return;let{assetPath:e,assetType:t,objectId:n}=this.options,a=n||"Asset Preview",s=document.createElement("div");s.className="asset-preview-modal",s.innerHTML=`
216
+ Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}catch(n){console.warn("[AiEditorModal] Failed to apply brand DNA:",n)}}async generateImage(){var e,t,n,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 s=this.getApiKey();if(!s){alert("Please set your Gemini API key first. You can do this in the AI Creative Suite panel.");return}let r=[];if(this.options.currentValue&&this.options.currentValue.startsWith("data:"))try{let l=await yi(this.options.currentValue);l&&(r=[{base64:l.base64,mimeType:l.mimeType}])}catch(l){console.warn("[AiEditorModal] Failed to load current image:",l)}let o=await Wt(s,this.currentPrompt,r,{aspectRatio:"1:1"}),c=await Yt(o);this.generatedImages.push(c||o),this.selectedImageIndex=this.generatedImages.length-1,this.updateGallery(),this.updatePreview(),this.updateApplyButton()}catch(s){console.error("[AiEditorModal] Generation failed:",s),alert(`Generation failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{this.isGenerating=!1,(n=this.loadingEl)==null||n.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,n)=>{let a=this.savedLibraryPaths.has(n),s=a?this.savedLibraryPaths.get(n):null,r=s?s.split("/").pop():"";return`
217
+ <div class="ai-gallery-item ${n===this.selectedImageIndex?"active":""}" data-index="${n}">
218
+ <img class="ai-gallery-thumb" src="${t}" alt="Generated ${n+1}" />
219
+ <div class="ai-gallery-label">#${n+1}${a?" \u2713":""}</div>
220
+ ${a?`<div class="ai-gallery-saved" title="Saved: ${r}">\u{1F4BE}</div>`:""}
221
+ </div>
222
+ `}).join(""))}updatePreview(){if(!this.previewEl||this.selectedImageIndex<0)return;let e=this.generatedImages[this.selectedImageIndex];this.previewEl.innerHTML=`<img src="${e}" alt="Selected image" />`}selectImage(e){e<0||e>=this.generatedImages.length||(this.selectedImageIndex=e,this.updateGallery(),this.updatePreview(),this.updateApplyButton())}toggleGallery(){this.galleryEl&&this.galleryEl.classList.toggle("hidden")}updateApplyButton(){var n,a;let e=(n=this.modal)==null?void 0:n.querySelector('[data-action="apply"]'),t=(a=this.modal)==null?void 0:a.querySelector('[data-action="save-library"]');e&&(e.disabled=this.selectedImageIndex<0),t&&(t.disabled=this.selectedImageIndex<0)}setStatus(e,t=!1){this.statusEl&&(this.statusEl.textContent=e,this.statusEl.style.color=t?"#ff4444":"#888")}async saveSelectedImageToLibrary(){var r;if(this.selectedImageIndex<0){this.setStatus("No image selected.",!0);return}let e=this.generatedImages[this.selectedImageIndex];if(!e){this.setStatus("Invalid image data.",!0);return}if(this.savedLibraryPaths.has(this.selectedImageIndex)){let o=this.savedLibraryPaths.get(this.selectedImageIndex);this.setStatus(`Already saved: ${o}`);return}let t=((r=this.options)==null?void 0:r.objectId)||"asset",a=`${t.replace(/[^a-zA-Z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"")}_ai_${Date.now()}.png`,s=this.inferCategoryFromObjectId(t);this.setStatus("Saving to library...");try{let c=await(await fetch("/api/library/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:s,filename:a,data:e,overwrite:!0})})).json();if(c.success){console.log("[AiEditorModal] \u2705 Saved to library:",c.path),this.savedLibraryPaths.set(this.selectedImageIndex,c.path),this.setStatus(`\u2705 Saved: ${a}`);let l=window.addAssetToRegistry;typeof l=="function"&&l(s,a);let u=window.getEditableAssets;if(typeof u=="function"){let d=u();d&&!d.categories&&(d.categories=[]),d!=null&&d.categories&&!d.categories.includes(s)&&(d.categories.push(s),console.log(`[AiEditorModal] Added category ${s} to registry`))}try{(await fetch("/api/setup-library",{method:"POST",headers:{"Content-Type":"application/json"}})).ok?console.log("[AiEditorModal] \u2705 Registry rebuilt from disk"):console.warn("[AiEditorModal] Setup-library returned non-OK status")}catch(d){console.warn("[AiEditorModal] Setup-library not available:",d)}let p=window.refreshAssetLibrary;typeof p=="function"&&(console.log("[AiEditorModal] Refreshing library panel..."),await p()),this.updateGallery()}else console.error("[AiEditorModal] \u274C Save failed:",c.error),this.setStatus(`Save failed: ${c.error}`,!0)}catch(o){console.error("[AiEditorModal] \u274C Save error:",o),this.setStatus("Save failed. Check console.",!0)}}inferCategoryFromObjectId(e){let t=e.toLowerCase();return t.includes("background")?"backgrounds":t.includes("character")?"characters":t.includes("key")?"collectedkeys":t.includes("draggable")?"draggables":t.includes("environment")||t.includes("env")||t.includes("hand")||t.includes("prop")||t.includes("item")?"environment":t.includes("machine")?"machines":t.includes("tutorial")?"tutorial":t.includes("ui")||t.includes("button")||t.includes("label")||t.includes("icon")||t.includes("logo")?"ui":t.includes("effect")||t.includes("confetti")||t.includes("particle")?"effects":"ui"}async applySelectedImage(){var n;if(this.selectedImageIndex<0||!((n=this.options)!=null&&n.onApply))return;let t=this.generatedImages[this.selectedImageIndex];this.savedLibraryPaths.has(this.selectedImageIndex)?(t=this.savedLibraryPaths.get(this.selectedImageIndex),this.setStatus("Applying saved image...")):(this.setStatus("Saving to library before applying..."),await this.saveSelectedImageToLibrary(),this.savedLibraryPaths.has(this.selectedImageIndex)?(t=this.savedLibraryPaths.get(this.selectedImageIndex),this.setStatus("\u2705 Saved and applying...")):this.setStatus("Failed to save. Applying data URL instead.",!0)),this.options.onApply(t),setTimeout(()=>{this.close()},500)}getApiKey(){let e=Ei();if(e)return e;try{let t=this.analyzer.getResult();if(t&&t.apiKey)return Ci(t.apiKey,"From Brand DNA"),t.apiKey}catch(t){console.warn("[AiEditorModal] Failed to get API key from brand DNA:",t)}return null}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.options=null}},Ai=null;window.__openAiEditor=function(i,e,t,n){Ai||(Ai=new Li),Ai.open({objectId:i,initialPrompt:e,currentValue:t,path:n==null?void 0:n.path,onApply:a=>{if(n!=null&&n.path){let s=window.updateManager;if(s)s.updateProperty(i,n.path,a);else{let r=window.getEditableObjectConfig,o=r==null?void 0:r(i);if(o){let c=n.path.split("."),l=o;for(let u=0;u<c.length-1;u++)l[c[u]]||(l[c[u]]={}),l=l[c[u]];l[c[c.length-1]]=a}}}window.dispatchEvent(new CustomEvent("inspector:refresh"))}})};ki();var Ii=class{constructor(){this.modal=null;this.options=null}open(e){this.options=e,this.createModal(),document.body.appendChild(this.modal)}createModal(){if(!this.options)return;let{assetPath:e,assetType:t,objectId:n}=this.options,a=n||"Asset Preview",s=document.createElement("div");s.className="asset-preview-modal",s.innerHTML=`
152
223
  <div class="asset-preview-card">
153
224
  <div class="asset-preview-header">
154
225
  <div class="asset-preview-title">${a}</div>
@@ -175,58 +246,7 @@ Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
175
246
  <source src="${a}" type="audio/wav">
176
247
  Your browser does not support the audio element.
177
248
  </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",n=>{let a=n.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(()=>(ki(),ha)).then(({AssetEditorModal:e})=>{new e().show(this.options.objectId||"unknown",this.options.propertyPath||"",this.options.assetPath,n=>{var a;(a=this.options)!=null&&a.onChange&&this.options.onChange(n),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 n;(n=this.options)!=null&&n.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(i){new Pi().open(i)};var Ii=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
- <div class="asset-crop-card">
180
- <div class="asset-crop-header">
181
- <div>
182
- <div class="asset-crop-title">Crop Image</div>
183
- <div class="asset-crop-subtitle">Drag to reposition, scroll to zoom</div>
184
- </div>
185
- <button class="asset-crop-close" data-action="close">\xD7</button>
186
- </div>
187
-
188
- <div class="asset-crop-body">
189
- <div class="asset-crop-column">
190
- <div class="asset-crop-canvas-container">
191
- <canvas class="asset-crop-canvas"></canvas>
192
- </div>
193
-
194
- <div class="asset-crop-controls">
195
- <div class="asset-crop-zoom">
196
- <label class="asset-crop-label">Zoom</label>
197
- <input type="range" min="0.1" max="3" step="0.1" value="1" class="asset-crop-zoom-slider" />
198
- <span class="asset-crop-zoom-value">1.0x</span>
199
- </div>
200
-
201
- <div class="asset-crop-aspect">
202
- <label class="asset-crop-label">Aspect Ratio</label>
203
- <select class="asset-crop-aspect-select">
204
- <option value="free">Free</option>
205
- <option value="1:1">Square (1:1)</option>
206
- <option value="4:3">Standard (4:3)</option>
207
- <option value="16:9">Widescreen (16:9)</option>
208
- <option value="3:2">Photo (3:2)</option>
209
- </select>
210
- </div>
211
-
212
- <button class="asset-crop-reset" data-action="reset">Reset</button>
213
- </div>
214
- </div>
215
-
216
- <div class="asset-crop-column">
217
- <div class="asset-crop-preview">
218
- <div class="asset-crop-preview-label">Preview</div>
219
- <canvas class="asset-crop-preview-canvas"></canvas>
220
- </div>
221
- </div>
222
- </div>
223
-
224
- <div class="asset-crop-actions">
225
- <button class="asset-crop-apply" data-action="cancel">Cancel</button>
226
- <button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
227
- </div>
228
- </div>
229
- `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var n;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(n=this.options)!=null&&n.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,n=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,n-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,n=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,n,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,n,a),this.ctx.fillStyle="#ffffff";let s=8;[[e,t],[e+n-s,t],[e,t+a-s],[e+n-s,t+a-s]].forEach(([o,c])=>{var l;(l=this.ctx)==null||l.fillRect(o,c,s,s)})}updatePreview(){if(!this.modal||!this.image)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let n=150;e.width=n,e.height=n;let a=n/this.cropWidth,s=n/this.cropHeight,r=Math.min(a,s),o=this.cropWidth*r,c=this.cropHeight*r,l=(n-o)/2,u=(n-c)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,l,u,o,c)}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",n=>{let a=parseFloat(n.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",n=>{let a=n.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",n=>{switch(n.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",n=>{n.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,n=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,n=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let n=e.toDataURL("image/png");this.options.onCrop(n),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(i){new Ii().open(i)};ce();var Be=require("pixi.js");var Ct=require("pixi.js");Jt();var Ks=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Mi=Ks;if(typeof window!="undefined")try{let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);e!=null&&e.buildMode&&(Mi=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${Mi}`))}}catch{}function Xs(i){var t,n,a,s,r;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(i);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(i))return{x:(t=i[0])!=null?t:.5,y:(n=i[1])!=null?n:.5};if(i&&typeof i=="object"&&"x"in i&&"y"in i)return{x:(a=i.x)!=null?a:.5,y:(s=i.y)!=null?s:.5};if(typeof i=="string"){let o=i.trim().toLowerCase();return(r=e[o])!=null?r:{x:.5,y:.5}}return null}var ye=class{static async create(e,t,n){var c,l,u,d,p,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${Mi}`);let a=(c=t==null?void 0:t.render)==null?void 0:c.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let f=new Ct.Container;return this.applyTransform(f,t==null?void 0:t.transform,t),f}let s=(l=t==null?void 0:t.identity)==null?void 0:l.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${s}, type: ${a.type}, path: ${a.path}`);let r=await Pe.load(e,a,n,s);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=r==null?void 0:r.constructor)==null?void 0:u.name}`);let o;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",r,"for object:",e),o=new Ct.Sprite(r),console.log("[ObjectFactory] Created object:",o,"type:",(d=o==null?void 0:o.constructor)==null?void 0:d.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=r==null?void 0:r.constructor)==null?void 0:p.name,r),r&&(((g=r.constructor)==null?void 0:g.name)==="Container"||r instanceof Ct.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let f=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],C=!1;for(let b of f)try{let h=await fetch(b);if(h.ok){o=await h.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=o==null?void 0:o.constructor)==null?void 0:m.name),C=!0;break}}catch{continue}C||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=r)}else o=r;else o=r,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,n){var a,s,r,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(a=t.position.x)!=null?a:0,e.y=(s=t.position.y)!=null?s:0):"position"in e&&e.position&&e.position.set((r=t.position.x)!=null?r: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 c=Xs(t.anchor);c&&("set"in e.anchor?e.anchor.set(c.x,c.y):(e.anchor.x=c.x,e.anchor.y=c.y))}}};ce();ce();ce();var fa=ci(require("lottie-web"),1);Qt(Wn);typeof window!="undefined"&&!window.lottie&&(window.lottie=fa.default);mi();ce();var ji=kn.version,Zs=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"]);Tn();var Sa={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"},Ea=Math.random().toString(36).slice(2),Qe=null,Je={...Sa},Ca="web_embed",zi={},Tt,_i=!1,Lt=!1,Pt=!1,Aa=!1,Hi=1,ti=0,ai=!1,ve=!1,Ze="",et=Math.floor(window.innerWidth),tt=Math.floor(window.innerHeight),$i=et>tt,we=!1,kt=!1,ma=!1,ba=!1,Oi=!1,ii=null,Ge=null,Di=!1,Ni=!1,ei=new Map;function La(){if(!Ge)return null;let i=Date.now()-Ge;return!Number.isFinite(i)||i<0?null:i}function Ri(i){if(Di)return;let e=La();e!==null&&(Di=!0,v("session_time",{duration_ms:e,reason:i}))}function ya(){if(Qe)return Qe;let i=document.createElement("div");return i.id="handler-root",i.setAttribute("data-handler-root","true"),document.body.appendChild(i),Qe=i,i}function ni(i){switch(i){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return i}}function Ta(i,e){return{event_name:i,ts:Date.now(),session_id:Ea,deployment_id:Je.deployment_id,variant_id:Je.variant_id,export_profile_id:Je.profile_id,instance_id:Je.instance_id||"default",env:Ca==="mraid"?"mraid":"web",attribution:Tt,payload:e}}function v(i,e){let t=ni(i),n=Ta(t,e);pi(n,!!zi.analytics),$t(t,n),t!==i&&$t(i,n)}function It(){ii&&(ii(et,tt),ii=null)}function it(i){Hi=i,v("volume",i)}function nt(i){i&&(Aa=!0),!Pt&&(Pt=!0,v("pause"),it(0))}function Mt(i){!i&&Aa||Pt&&(Pt=!1,v("resume"),it(Hi))}function Me(i,e){et=Math.floor(i||window.innerWidth),tt=Math.floor(e||window.innerHeight),$i=et>tt,v("resize",{width:et,height:tt})}function Qs(){if(Hn())try{let i=mraid.getMaxSize();Me(i.width,i.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?Mt():nt()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let t=mraid.getMaxSize();Me(t.width,t.height)}),mraid.getAudioVolume){let t=mraid.getAudioVolume();it(t?1:0)}if(mraid.addEventListener("audioVolumeChange",t=>{t!==null&&it(t>0?1:0)}),mraid.addEventListener("error",(t,n)=>{console.warn("mraid error:",t,"action:",n)}),ai=!0,mraid.isViewable()&&mraid.getState()!=="hidden")we=!0,v("boot"),v("view"),v("ready"),ve=!0,It();else{let t=()=>{we=!0,v("boot"),v("view"),v("ready"),ve=!0,It()};mraid.addEventListener("ready",t)}}catch(i){console.warn("MRAID hook skipped",i)}}function er(){if(Fn())try{let i=dapi.getScreenSize();Me(i.width,i.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?Mt():nt()}),dapi.addEventListener("adResized",t=>{let n=dapi.getScreenSize();Me(t.width||n.width,t.height||n.height)});let e=dapi.getAudioVolume();if(it(e?1:0),dapi.addEventListener("audioVolumeChange",t=>it(t?1:0)),ai=!0,dapi.isViewable())we=!0,v("boot"),v("view"),v("ready"),ve=!0,It();else{let t=()=>{we=!0,v("boot"),v("view"),v("ready"),ve=!0,It()};dapi.addEventListener("ready",t)}}catch(i){console.warn("DAPI hook skipped",i)}}function va(){let i=()=>{we||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(we=!0,v("boot"),v("view"),v("ready"),ve=!0,It(),kt&&(kt=!1,ue.start()))};window.addEventListener("resize",()=>Me()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(Mt(),i()):nt()}),document.readyState==="complete"||document.readyState==="interactive"?i():window.addEventListener("load",i),ai=!0}function tr(){let i=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(ma=!0),!(ma&&e instanceof MouseEvent)&&(ti+=1,Ni||(Ni=!0,v("first_interaction",{count:ti})),v("interaction",ti))};document.addEventListener("mousedown",i),document.addEventListener("touchstart",i)}function wa(i){var n,a,s,r,o,c,l,u,d,p,g,m;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(n=window.ExitApi)==null||n.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(i||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(Ke())(s=(a=window.TJ_API)==null?void 0:a.click)==null||s.call(a);else if(Bn())(o=(r=window.FbPlayableAd)==null?void 0:r.onCTAClick)==null||o.call(r);else if(Vn())(l=(c=window.ScPlayableAd)==null?void 0:c.onCTAClick)==null||l.call(c);else if(qn())try{(d=(u=window.smxTracking)==null?void 0:u.redirect)==null||d.call(u)}catch(f){console.warn("Smadex redirect failed",f)}else if(Gn()){let f=window.ExitApi;f&&typeof f.exit=="function"?f.exit(i||Ze||""):i&&window.open(i)}else We()?(p=window.install)==null||p.call(window):Un()?(g=window.openAppStore)==null||g.call(window):ui()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):i&&window.open(i)}function ir(){let i=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let n=new Image;n.src=t};if(i==="bigabid"){let t=window.BIGABID_BIDTIMEMACROS;if(!t)return;ee("view",()=>e(t.mraid_viewable)),ee("start",()=>e(t.game_viewable)),ee("engagement",()=>e(t.engagement));let n=()=>e(t.complete);ee("complete",n),zt("engagement",a=>{var s;((s=a==null?void 0:a.payload)==null?void 0:s.count)>3&&n()}),ee("cta_click",()=>e(t.click))}else if(i==="inmobi"){let t=window.INMOBI_DSPMACROS;if(!t)return;ee("view",()=>e(t.Ad_Load_Start)),ee("start",()=>e(t.Ad_Viewable)),ee("engagement",()=>e(t.First_Engagement)),ee("complete",()=>e(t.Gameplay_Complete)),ee("cta_click",()=>e(t.DSP_Click)),ee("start",()=>{[5,10,15,20,25,30].forEach(n=>setTimeout(()=>e(t[`Spent_${n}_Seconds`]),n*1e3))})}}function nr(){if(!Ke())return;let i=window.TJ_API;i&&i.setPlayableAPI&&i.setPlayableAPI({skipAd:()=>{try{ue.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function xa(){var e,t,n;let i=window.TJ_API;(e=i==null?void 0:i.objectiveComplete)==null||e.call(i),(t=i==null?void 0:i.playableFinished)==null||t.call(i),(n=i==null?void 0:i.gameplayFinished)==null||n.call(i)}function ar(){We()&&(window.mintGameStart=()=>{Mt(!0),Me()},window.mintGameClose=()=>{nt(!0)})}function sr(){if(!gi())return;let i=window.NUC;!i||!i.trigger||(ue.on("cta_click",()=>{var e,t;return(t=(e=i.trigger).convert)==null?void 0:t.call(e,Ze)}),ue.on("complete",()=>{var e,t;return(t=(e=i.trigger).tryAgain)==null?void 0:t.call(e)}))}var ue={init(i={},e){var t;if(Ca=i.profile||"web_embed",zi=i.consent||{},Je={...Sa,...i.ids||{}},Qe=i.rootEl||Qe,Tt=void 0,wn((t=i.telemetry)!=null&&t.endpoint?i.telemetry:null),Ge=null,Di=!1,Ni=!1,ei.clear(),Ze=i.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(ii=e),v("init"),document.body.oncontextmenu=()=>!1,ya(),or(Qe),Yn(),Qs(),er(),!ai){if(document.readyState==="complete")va();else if(!ba){ba=!0;let n=()=>{va(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}tr(),ir(),nr(),ar(),sr(),console.log(`%c @handler/playable-sdk %c v${ji} `,"background: var(--ui-console-info); color: var(--ui-white); font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: var(--ui-console-bg); color: var(--ui-console-text); font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),we&&!ve&&(v("boot"),v("view"),v("ready"),kt&&(kt=!1,ue.start()),ve=!0),ve=we},getRoot(){return ya()},get version(){return ji},get maxWidth(){return et},get maxHeight(){return tt},get isLandscape(){return $i},get isReady(){return ve},get isStarted(){return _i},get isPaused(){return Pt},get isFinished(){return Lt},get volume(){return Hi},get interactions(){return ti},on(i,e){zt(ni(i),e)},off(i,e){di(ni(i),e)},start(){var i,e;if(!_i){if(!we){kt=!0;return}if(_i=!0,Ge||(Ge=Date.now()),v("start"),Me(),We())nt(),(i=window.gameReady)==null||i.call(window);else if(Ke()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:$i?"landscape":"portrait",buildID:ji})}}},finish(){var i,e;Lt||(Lt=!0,v("complete"),Ri("complete"),We()?(i=window.gameEnd)==null||i.call(window):ui()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Ke()&&xa())},install(i){if(!Lt){Lt=!0,Ke()?(xa(),setTimeout(()=>ue.install(i),300)):(v("complete"),setTimeout(()=>ue.install(i),0));return}Oi||(Oi=!0,setTimeout(()=>Oi=!1,500),v("cta_click"),v("conversion"),Ri("cta"),wa(i||Ze))},emit(i,e){let t=ni(i);if(!Zs.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${i} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let n=Ta(t,e);pi(n,!!zi.analytics),$t(t,n)},gameStart(){ue.start()},gameEnd(){ue.finish()},ctaClick(i,e){v("cta_click",{url:i||Ze,manual:!0}),(e==null?void 0:e.open)!==!1&&wa(i||Ze)},ctaShow(i){v("cta_show",i)},ctaDismiss(i){v("cta_dismiss",i)},getGameTimeMs(){return La()},endSession(i="manual"){Ri(i)},setAttribution(i){Tt=i},abTest(i,e){if(!i)throw new Error("abTest requires experimentId");if(!Array.isArray(e)||e.length<2)throw new Error("abTest requires at least 2 variants");let t=Math.abs(rr(`${Ea}:${i}`))%e.length,n=e[t];return Tt={...Tt||{},experiment_id:i},Je.variant_id=n,v("ab_assign",{experiment_id:i,variant_id:n}),n},levelStart(i,e){Ge||(Ge=Date.now()),v("level_start",{level_id:i,...e})},levelComplete(i,e){v("level_complete",{level_id:i,...e})},levelFail(i,e){v("level_fail",{level_id:i,...e})},checkpoint(i,e){v("checkpoint",{checkpoint_id:i,...e})},reward(i,e){v("reward",{reward_id:i,...e})},tutorialStart(i,e){v("tutorial_start",{step_id:i,...e})},tutorialComplete(i,e){v("tutorial_complete",{step_id:i,...e})},tutorialSkip(i,e){v("tutorial_skip",{step_id:i,...e})},timerStart(i){i&&ei.set(i,Date.now())},timerEnd(i,e="custom",t){if(!i)return;let n=ei.get(i);if(!n)return;ei.delete(i);let a=Date.now()-n;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){v("engagement",{action:"timer",key:i,duration_ms:a,...t});return}v(e,{key:i,duration_ms:a,...t})}},fps(i,e){v("fps",{value:i,...e})},memory(i,e){v("memory",{bytes:i,...e})},assetLoadStart(i,e){v("asset_load_start",{asset_id:i,...e})},assetLoadComplete(i,e){v("asset_load_complete",{asset_id:i,...e})},reportError(i,e,t){v("error",{code:i,message:e,...t})},retry(){var i,e,t;if(We())(i=window.gameRetry)==null||i.call(window);else if(gi()){let n=window.NUC;(t=(e=n==null?void 0:n.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}v("engagement",{action:"retry"})},pause(){nt(!0)},resume(){Mt(!0)},resize(i,e){Me(i,e)}},At=ue;function rr(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function or(i){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
249
+ `;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",n=>{let a=n.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(()=>(ki(),ha)).then(({AssetEditorModal:e})=>{new e().show(this.options.objectId||"unknown",this.options.propertyPath||"",this.options.assetPath,n=>{var a;(a=this.options)!=null&&a.onChange&&this.options.onChange(n),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 n;(n=this.options)!=null&&n.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(i){new Ii().open(i)};fa();de();var Be=require("pixi.js");var Ct=require("pixi.js");Jt();var Js=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Mi=Js;if(typeof window!="undefined")try{let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);e!=null&&e.buildMode&&(Mi=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${Mi}`))}}catch{}function Zs(i){var t,n,a,s,r;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(i);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(i))return{x:(t=i[0])!=null?t:.5,y:(n=i[1])!=null?n:.5};if(i&&typeof i=="object"&&"x"in i&&"y"in i)return{x:(a=i.x)!=null?a:.5,y:(s=i.y)!=null?s:.5};if(typeof i=="string"){let o=i.trim().toLowerCase();return(r=e[o])!=null?r:{x:.5,y:.5}}return null}var ye=class{static async create(e,t,n){var c,l,u,p,d,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${Mi}`);let a=(c=t==null?void 0:t.render)==null?void 0:c.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let f=new Ct.Container;return this.applyTransform(f,t==null?void 0:t.transform,t),f}let s=(l=t==null?void 0:t.identity)==null?void 0:l.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${s}, type: ${a.type}, path: ${a.path}`);let r=await Ie.load(e,a,n,s);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=r==null?void 0:r.constructor)==null?void 0:u.name}`);let o;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",r,"for object:",e),o=new Ct.Sprite(r),console.log("[ObjectFactory] Created object:",o,"type:",(p=o==null?void 0:o.constructor)==null?void 0:p.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:",(d=r==null?void 0:r.constructor)==null?void 0:d.name,r),r&&(((g=r.constructor)==null?void 0:g.name)==="Container"||r instanceof Ct.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let f=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],C=!1;for(let b of f)try{let h=await fetch(b);if(h.ok){o=await h.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=o==null?void 0:o.constructor)==null?void 0:m.name),C=!0;break}}catch{continue}C||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=r)}else o=r;else o=r,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,n){var a,s,r,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(a=t.position.x)!=null?a:0,e.y=(s=t.position.y)!=null?s:0):"position"in e&&e.position&&e.position.set((r=t.position.x)!=null?r: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 c=Zs(t.anchor);c&&("set"in e.anchor?e.anchor.set(c.x,c.y):(e.anchor.x=c.x,e.anchor.y=c.y))}}};de();de();de();var ma=ci(require("lottie-web"),1);Qt(Wn);typeof window!="undefined"&&!window.lottie&&(window.lottie=ma.default);mi();de();var ji=kn.version,er=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"]);Tn();var Ea={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"},Ca=Math.random().toString(36).slice(2),Qe=null,Je={...Ea},Aa="web_embed",zi={},Tt,_i=!1,Lt=!1,It=!1,La=!1,Hi=1,ti=0,ai=!1,ve=!1,Ze="",et=Math.floor(window.innerWidth),tt=Math.floor(window.innerHeight),$i=et>tt,we=!1,kt=!1,ba=!1,ya=!1,Oi=!1,ii=null,Ge=null,Di=!1,Ni=!1,ei=new Map;function Ta(){if(!Ge)return null;let i=Date.now()-Ge;return!Number.isFinite(i)||i<0?null:i}function Ri(i){if(Di)return;let e=Ta();e!==null&&(Di=!0,v("session_time",{duration_ms:e,reason:i}))}function va(){if(Qe)return Qe;let i=document.createElement("div");return i.id="handler-root",i.setAttribute("data-handler-root","true"),document.body.appendChild(i),Qe=i,i}function ni(i){switch(i){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return i}}function ka(i,e){return{event_name:i,ts:Date.now(),session_id:Ca,deployment_id:Je.deployment_id,variant_id:Je.variant_id,export_profile_id:Je.profile_id,instance_id:Je.instance_id||"default",env:Aa==="mraid"?"mraid":"web",attribution:Tt,payload:e}}function v(i,e){let t=ni(i),n=ka(t,e);pi(n,!!zi.analytics),$t(t,n),t!==i&&$t(i,n)}function Pt(){ii&&(ii(et,tt),ii=null)}function it(i){Hi=i,v("volume",i)}function nt(i){i&&(La=!0),!It&&(It=!0,v("pause"),it(0))}function Mt(i){!i&&La||It&&(It=!1,v("resume"),it(Hi))}function Me(i,e){et=Math.floor(i||window.innerWidth),tt=Math.floor(e||window.innerHeight),$i=et>tt,v("resize",{width:et,height:tt})}function tr(){if(Hn())try{let i=mraid.getMaxSize();Me(i.width,i.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?Mt():nt()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let t=mraid.getMaxSize();Me(t.width,t.height)}),mraid.getAudioVolume){let t=mraid.getAudioVolume();it(t?1:0)}if(mraid.addEventListener("audioVolumeChange",t=>{t!==null&&it(t>0?1:0)}),mraid.addEventListener("error",(t,n)=>{console.warn("mraid error:",t,"action:",n)}),ai=!0,mraid.isViewable()&&mraid.getState()!=="hidden")we=!0,v("boot"),v("view"),v("ready"),ve=!0,Pt();else{let t=()=>{we=!0,v("boot"),v("view"),v("ready"),ve=!0,Pt()};mraid.addEventListener("ready",t)}}catch(i){console.warn("MRAID hook skipped",i)}}function ir(){if(Fn())try{let i=dapi.getScreenSize();Me(i.width,i.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?Mt():nt()}),dapi.addEventListener("adResized",t=>{let n=dapi.getScreenSize();Me(t.width||n.width,t.height||n.height)});let e=dapi.getAudioVolume();if(it(e?1:0),dapi.addEventListener("audioVolumeChange",t=>it(t?1:0)),ai=!0,dapi.isViewable())we=!0,v("boot"),v("view"),v("ready"),ve=!0,Pt();else{let t=()=>{we=!0,v("boot"),v("view"),v("ready"),ve=!0,Pt()};dapi.addEventListener("ready",t)}}catch(i){console.warn("DAPI hook skipped",i)}}function wa(){let i=()=>{we||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(we=!0,v("boot"),v("view"),v("ready"),ve=!0,Pt(),kt&&(kt=!1,ge.start()))};window.addEventListener("resize",()=>Me()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(Mt(),i()):nt()}),document.readyState==="complete"||document.readyState==="interactive"?i():window.addEventListener("load",i),ai=!0}function nr(){let i=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(ba=!0),!(ba&&e instanceof MouseEvent)&&(ti+=1,Ni||(Ni=!0,v("first_interaction",{count:ti})),v("interaction",ti))};document.addEventListener("mousedown",i),document.addEventListener("touchstart",i)}function xa(i){var n,a,s,r,o,c,l,u,p,d,g,m;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(n=window.ExitApi)==null||n.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(i||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(Ke())(s=(a=window.TJ_API)==null?void 0:a.click)==null||s.call(a);else if(Bn())(o=(r=window.FbPlayableAd)==null?void 0:r.onCTAClick)==null||o.call(r);else if(Vn())(l=(c=window.ScPlayableAd)==null?void 0:c.onCTAClick)==null||l.call(c);else if(qn())try{(p=(u=window.smxTracking)==null?void 0:u.redirect)==null||p.call(u)}catch(f){console.warn("Smadex redirect failed",f)}else if(Gn()){let f=window.ExitApi;f&&typeof f.exit=="function"?f.exit(i||Ze||""):i&&window.open(i)}else We()?(d=window.install)==null||d.call(window):Un()?(g=window.openAppStore)==null||g.call(window):ui()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):i&&window.open(i)}function ar(){let i=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let n=new Image;n.src=t};if(i==="bigabid"){let t=window.BIGABID_BIDTIMEMACROS;if(!t)return;ee("view",()=>e(t.mraid_viewable)),ee("start",()=>e(t.game_viewable)),ee("engagement",()=>e(t.engagement));let n=()=>e(t.complete);ee("complete",n),zt("engagement",a=>{var s;((s=a==null?void 0:a.payload)==null?void 0:s.count)>3&&n()}),ee("cta_click",()=>e(t.click))}else if(i==="inmobi"){let t=window.INMOBI_DSPMACROS;if(!t)return;ee("view",()=>e(t.Ad_Load_Start)),ee("start",()=>e(t.Ad_Viewable)),ee("engagement",()=>e(t.First_Engagement)),ee("complete",()=>e(t.Gameplay_Complete)),ee("cta_click",()=>e(t.DSP_Click)),ee("start",()=>{[5,10,15,20,25,30].forEach(n=>setTimeout(()=>e(t[`Spent_${n}_Seconds`]),n*1e3))})}}function sr(){if(!Ke())return;let i=window.TJ_API;i&&i.setPlayableAPI&&i.setPlayableAPI({skipAd:()=>{try{ge.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function Sa(){var e,t,n;let i=window.TJ_API;(e=i==null?void 0:i.objectiveComplete)==null||e.call(i),(t=i==null?void 0:i.playableFinished)==null||t.call(i),(n=i==null?void 0:i.gameplayFinished)==null||n.call(i)}function rr(){We()&&(window.mintGameStart=()=>{Mt(!0),Me()},window.mintGameClose=()=>{nt(!0)})}function or(){if(!gi())return;let i=window.NUC;!i||!i.trigger||(ge.on("cta_click",()=>{var e,t;return(t=(e=i.trigger).convert)==null?void 0:t.call(e,Ze)}),ge.on("complete",()=>{var e,t;return(t=(e=i.trigger).tryAgain)==null?void 0:t.call(e)}))}var ge={init(i={},e){var t;if(Aa=i.profile||"web_embed",zi=i.consent||{},Je={...Ea,...i.ids||{}},Qe=i.rootEl||Qe,Tt=void 0,wn((t=i.telemetry)!=null&&t.endpoint?i.telemetry:null),Ge=null,Di=!1,Ni=!1,ei.clear(),Ze=i.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(ii=e),v("init"),document.body.oncontextmenu=()=>!1,va(),cr(Qe),Yn(),tr(),ir(),!ai){if(document.readyState==="complete")wa();else if(!ya){ya=!0;let n=()=>{wa(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}nr(),ar(),sr(),rr(),or(),console.log(`%c @handler/playable-sdk %c v${ji} `,"background: var(--ui-console-info); color: var(--ui-white); font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: var(--ui-console-bg); color: var(--ui-console-text); font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),we&&!ve&&(v("boot"),v("view"),v("ready"),kt&&(kt=!1,ge.start()),ve=!0),ve=we},getRoot(){return va()},get version(){return ji},get maxWidth(){return et},get maxHeight(){return tt},get isLandscape(){return $i},get isReady(){return ve},get isStarted(){return _i},get isPaused(){return It},get isFinished(){return Lt},get volume(){return Hi},get interactions(){return ti},on(i,e){zt(ni(i),e)},off(i,e){di(ni(i),e)},start(){var i,e;if(!_i){if(!we){kt=!0;return}if(_i=!0,Ge||(Ge=Date.now()),v("start"),Me(),We())nt(),(i=window.gameReady)==null||i.call(window);else if(Ke()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:$i?"landscape":"portrait",buildID:ji})}}},finish(){var i,e;Lt||(Lt=!0,v("complete"),Ri("complete"),We()?(i=window.gameEnd)==null||i.call(window):ui()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Ke()&&Sa())},install(i){if(!Lt){Lt=!0,Ke()?(Sa(),setTimeout(()=>ge.install(i),300)):(v("complete"),setTimeout(()=>ge.install(i),0));return}Oi||(Oi=!0,setTimeout(()=>Oi=!1,500),v("cta_click"),v("conversion"),Ri("cta"),xa(i||Ze))},emit(i,e){let t=ni(i);if(!er.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${i} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let n=ka(t,e);pi(n,!!zi.analytics),$t(t,n)},gameStart(){ge.start()},gameEnd(){ge.finish()},ctaClick(i,e){v("cta_click",{url:i||Ze,manual:!0}),(e==null?void 0:e.open)!==!1&&xa(i||Ze)},ctaShow(i){v("cta_show",i)},ctaDismiss(i){v("cta_dismiss",i)},getGameTimeMs(){return Ta()},endSession(i="manual"){Ri(i)},setAttribution(i){Tt=i},abTest(i,e){if(!i)throw new Error("abTest requires experimentId");if(!Array.isArray(e)||e.length<2)throw new Error("abTest requires at least 2 variants");let t=Math.abs(lr(`${Ca}:${i}`))%e.length,n=e[t];return Tt={...Tt||{},experiment_id:i},Je.variant_id=n,v("ab_assign",{experiment_id:i,variant_id:n}),n},levelStart(i,e){Ge||(Ge=Date.now()),v("level_start",{level_id:i,...e})},levelComplete(i,e){v("level_complete",{level_id:i,...e})},levelFail(i,e){v("level_fail",{level_id:i,...e})},checkpoint(i,e){v("checkpoint",{checkpoint_id:i,...e})},reward(i,e){v("reward",{reward_id:i,...e})},tutorialStart(i,e){v("tutorial_start",{step_id:i,...e})},tutorialComplete(i,e){v("tutorial_complete",{step_id:i,...e})},tutorialSkip(i,e){v("tutorial_skip",{step_id:i,...e})},timerStart(i){i&&ei.set(i,Date.now())},timerEnd(i,e="custom",t){if(!i)return;let n=ei.get(i);if(!n)return;ei.delete(i);let a=Date.now()-n;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){v("engagement",{action:"timer",key:i,duration_ms:a,...t});return}v(e,{key:i,duration_ms:a,...t})}},fps(i,e){v("fps",{value:i,...e})},memory(i,e){v("memory",{bytes:i,...e})},assetLoadStart(i,e){v("asset_load_start",{asset_id:i,...e})},assetLoadComplete(i,e){v("asset_load_complete",{asset_id:i,...e})},reportError(i,e,t){v("error",{code:i,message:e,...t})},retry(){var i,e,t;if(We())(i=window.gameRetry)==null||i.call(window);else if(gi()){let n=window.NUC;(t=(e=n==null?void 0:n.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}v("engagement",{action:"retry"})},pause(){nt(!0)},resume(){Mt(!0)},resize(i,e){Me(i,e)}},At=ge;function lr(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function cr(i){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
230
250
  (function(){
231
251
  var events = ['touchstart','touchend','mousedown','keydown'];
232
252
  function unlock(){
@@ -242,14 +262,14 @@ Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
242
262
  }
243
263
  events.forEach(function(e){ document.addEventListener(e, unlock, false); });
244
264
  })();
245
- `,i.appendChild(e)}async function si(i,e={}){let t=new ka.Application;await t.init({resizeTo:i,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let n=r=>{var d,p,g,m;if(!t.renderer)return;let o=(d=r==null?void 0:r.width)!=null?d:i.clientWidth,c=(p=r==null?void 0:r.height)!=null?p:i.clientHeight,l=o&&o>0?o:(g=window.innerWidth)!=null?g:320,u=c&&c>0?c:(m=window.innerHeight)!=null?m:480;t.renderer.resize(l,u)};i.appendChild(t.canvas),i.style.position="relative",i.style.display="flex",i.style.flexDirection="column",i.style.alignItems="stretch",i.style.width="100%",i.style.height="100dvh",i.style.minHeight="100vh",i.style.maxWidth="100%",i.style.maxHeight="100%",i.style.boxSizing="border-box",i.style.overflow="hidden",e.background&&(i.style.background=e.background),n();let a=document.createElement("div");return a.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),i.appendChild(a),At.on("pause",()=>{t.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),At.on("resume",()=>{t.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),At.on("resize",({payload:r})=>{n({width:r==null?void 0:r.width,height:r==null?void 0:r.height})}),window.addEventListener("resize",()=>n()),requestAnimationFrame(()=>n()),new ResizeObserver(r=>{let o=r[0];if(o&&o.contentRect.width>0&&o.contentRect.height>0){let c=Math.round(o.contentRect.width),l=Math.round(o.contentRect.height);if(n({width:c,height:l}),typeof window!="undefined"&&window.gameApp&&window.gameObjectManager){let u={width:c,height:l,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:"auto-resize",isLandscape:c>l};window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:u}))}}}).observe(i),{app:t,stage:t.stage,overlay:a,applySize:n}}var X=require("pixi.js"),jt=class{constructor(e){var a,s;let t=e==null?void 0:e.position,n=e==null?void 0:e.offset;this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0},this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0},this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y},this.scale=(a=e==null?void 0:e.scale)!=null?a:1,this.rotation=(s=e==null?void 0:e.rotation)!=null?s:0}update(e){let t=e.position,n=e.offset;t!==void 0&&(this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0}),n!==void 0&&(this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0}),(t!==void 0||n!==void 0)&&(this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y}),e.scale!==void 0&&(this.scale=e.scale),e.rotation!==void 0&&(this.rotation=e.rotation)}syncToPixi(e){e&&(e.position.set(this.position.x,this.position.y),e.scale.set(this.scale),e.rotation=this.rotation)}},_t=class{constructor(e){var t,n,a,s;this.z_index=(t=e==null?void 0:e.z_index)!=null?t:0,this.alpha=(n=e==null?void 0:e.alpha)!=null?n:1,this.visible=(a=e==null?void 0:e.visible)!=null?a:!0,this.tint=(s=e==null?void 0:e.tint)!=null?s: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 s=a[t];s&&(e.texture=s)}}catch{}}},Ot=class{constructor(e,t,n,a){this._tickerCleanup=null;this.onRebuildRequired=null;this.instanceId=e,this.objectConfig=t,this.pixiObject=n,this._config=a,this.transform=new jt(a.transform),this.renderer=new _t(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&&(X.Ticker.shared.remove(this._introTicker),this._introTicker=null),this.pixiObject&&this.pixiObject.parent&&this.pixiObject.parent.removeChild(this.pixiObject)}updateConfig(e){var c,l,u,d,p,g,m,f,C,b,h;let t=(l=(c=this._config)==null?void 0:c.motion)==null?void 0:l.intro,n=(u=e==null?void 0:e.motion)==null?void 0:u.intro;n!=null&&n.enabled&&JSON.stringify(t)!==JSON.stringify(n)&&(this._shouldReplayIntro=!0);let a=(g=(p=(d=this._config)==null?void 0:d.render)==null?void 0:p.asset)==null?void 0:g.type,s=(f=(m=e==null?void 0:e.render)==null?void 0:m.asset)==null?void 0:f.type,r=(b=(C=this._config)==null?void 0:C.ui)==null?void 0:b.renderMode,o=(h=e==null?void 0:e.ui)==null?void 0:h.renderMode;if((a!==s||r!==o)&&(console.log(`[GameObject] Rebuild required for ${this.instanceId}: type changed from ${a}/${r} to ${s}/${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,s,r,o;if(!this.pixiObject||!("anchor"in this.pixiObject)||!this.pixiObject.anchor)return;let e=(s=(a=this._config)==null?void 0:a.render)==null?void 0:s.anchor,t=(o=(r=this._config)==null?void 0:r.transform)==null?void 0:o.anchor,n=e&&typeof e=="object"?e:t&&typeof t=="object"?t:null;n&&typeof n.x=="number"&&typeof n.y=="number"&&this.pixiObject.anchor.set(n.x,n.y)}applyEffectsScale(){var s,r,o;if(!((s=this.pixiObject)!=null&&s.scale))return;let e=(r=this._config)==null?void 0:r.effects,t=typeof(e==null?void 0:e.scale_x)=="number"?e.scale_x:1,n=typeof(e==null?void 0:e.scale_y)=="number"?e.scale_y:1;if(t===1&&n===1)return;let a=(o=this.transform.scale)!=null?o:1;typeof this.pixiObject.scale.set=="function"?this.pixiObject.scale.set(a*t,a*n):(this.pixiObject.scale.x=a*t,this.pixiObject.scale.y=a*n)}applyEffects(){var n,a,s,r,o,c,l,u,d;if(!this.pixiObject)return;let e=(n=this._config)==null?void 0:n.effects;if(!e||e.enabled===!1){this.pixiObject.filters=null;return}let t=[];if((a=e.blur)!=null&&a.enabled){let p=new X.BlurFilter;p.blur=(s=e.blur.strength)!=null?s:4,t.push(p)}if((r=e.shadow)!=null&&r.enabled){let p=e.shadow,g=new X.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((c=e.glow)!=null&&c.enabled){let p=e.glow,g=new X.BlurFilter;if(g.blur=(l=p.blur)!=null?l:8,t.push(g),p.color){let m=new X.ColorMatrixFilter,f=typeof p.color=="string"?parseInt(p.color.replace("#",""),16):p.color;m.tint(f),t.push(m)}}(u=e.stroke)!=null&&u.enabled&&console.warn("[Effects] Stroke/outline effect requires pixi-filters. Install: npm install pixi-filters"),(d=e.distortion)!=null&&d.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,d,p,g,m,f,C;let e=(u=this._config)==null?void 0:u.motion;if(!e||!((d=e.intro)!=null&&d.enabled)||!this.pixiObject)return;let t=e.intro,n=(t.duration||0)/1e3,a=(t.delay||0)/1e3,s=this.transform.position.y,r=this.transform.scale*(((g=(p=this._config)==null?void 0:p.effects)==null?void 0:g.scale_x)||1),o=this.transform.scale*(((f=(m=this._config)==null?void 0:m.effects)==null?void 0:f.scale_y)||1);if(this.pixiObject.alpha=(C=t.startAlpha)!=null?C:0,t.startScale!==void 0&&this.pixiObject.scale.set(r*t.startScale,o*t.startScale),t.startYOffset!==void 0&&(this.pixiObject.y=s+(t.startYOffset||0)),this._introTicker&&X.Ticker.shared.remove(this._introTicker),n<=0&&a<=0){this.pixiObject.alpha=this.renderer.alpha,this.pixiObject.y=this.transform.position.y,this.pixiObject.scale.set(r,o);return}let c=0,l=b=>{var R,H,z,T,E,S;if(c+=b.deltaTime/60,c<a)return;let h=n>0?Math.min(1,(c-a)/n):1,y=1-Math.pow(1-h,3),w=this.renderer.alpha,x=this.transform.scale*(((H=(R=this._config)==null?void 0:R.effects)==null?void 0:H.scale_x)||1),P=this.transform.scale*(((T=(z=this._config)==null?void 0:z.effects)==null?void 0:T.scale_y)||1),L=this.transform.position.y,B=this.transform.position.x;if(this.pixiObject.alpha=((E=t.startAlpha)!=null?E:0)+(w-((S=t.startAlpha)!=null?S:0))*y,t.startScale!==void 0){let A=t.startScale+(1-t.startScale)*y;this.pixiObject.scale.set(x*A,P*A)}t.startYOffset!==void 0&&(this.pixiObject.y=L+t.startYOffset+(L-(L+t.startYOffset))*y),h>=1&&(X.Ticker.shared.remove(l),this._introTicker=null,this.pixiObject.alpha=w,this.pixiObject.x=B,this.pixiObject.y=L,this.pixiObject.scale.set(x,P))};this._introTicker=l,X.Ticker.shared.add(l)}applyMotion(){var d,p,g,m,f,C;let e=(d=this._config)==null?void 0:d.motion,t=e&&e.enabled!==!1,n=JSON.stringify(e);if(this._lastMotionStr===n&&this._tickerCleanup)return;if(this._lastMotionStr=n,!t){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null);return}if(this._tickerCleanup&&this._tickerCleanup(),!(((p=e.pulse)==null?void 0:p.enabled)||((g=e.swing)==null?void 0:g.enabled)||((m=e.continuousMove)==null?void 0:m.enabled)||((f=e.continuousRotate)==null?void 0:f.enabled)||((C=e.orbit)==null?void 0:C.enabled)))return;let s=0,r=0,o=0,c=0,l=1/60,u=b=>{var z,T,E,S,A,V,J,O,ne,je,Se,Ee,Ce,Ae,Y,_e,lt,ct,dt,pt,ut,gt,ht,ft,mt,bt;let h=((z=b.deltaTime)!=null?z:1)*l;s+=b.deltaTime*.05;let y=this.transform.scale,w=y*(((E=(T=this._config)==null?void 0:T.effects)==null?void 0:E.scale_x)||1),x=y*(((A=(S=this._config)==null?void 0:S.effects)==null?void 0:A.scale_y)||1),P=this.transform.position.x,L=this.transform.position.y,B=this.transform.rotation,R=0,H=0;if((V=e.swing)!=null&&V.enabled){let F=(J=e.swing.amplitude)!=null?J:10,Z=(O=e.swing.speed)!=null?O:1,U=Math.sin(s*Z)*F;e.swing.axis==="vertical"?H+=U:e.swing.axis==="both"?(R+=U,H+=U):R+=U}if((ne=e.continuousMove)!=null&&ne.enabled){let F=(je=e.continuousMove.axis)!=null?je:"x",Z=Math.max(0,(Se=e.continuousMove.speed)!=null?Se:50),U=Math.sign((Ee=e.continuousMove.direction)!=null?Ee:1)||1,Q=Math.max(0,(Ce=e.continuousMove.lifetime)!=null?Ce:0);r+=h;let Ue=Q>0?Math.min(r,Q):r,Oe=Z*U*Ue;(F==="x"||F==="both")&&(R+=Oe),(F==="y"||F==="both")&&(H+=Oe)}if((Ae=e.orbit)!=null&&Ae.enabled){let F=Math.max(0,(Y=e.orbit.radius)!=null?Y:50),Z=Math.max(0,(_e=e.orbit.speed)!=null?_e:45),U=Math.sign((lt=e.orbit.direction)!=null?lt:1)||1,Q=Z*Math.PI/180;c+=Q*U*h;let Ue=(ct=e.orbit.pivotOffsetX)!=null?ct:0,Oe=(dt=e.orbit.pivotOffsetY)!=null?dt:0;R+=Ue+F*Math.cos(c),H+=Oe+F*Math.sin(c)}if(this.pixiObject.x=P+R,this.pixiObject.y=L+H,(pt=e.pulse)!=null&&pt.enabled){let F=(ut=e.pulse.intensity)!=null?ut:.1,Z=(gt=e.pulse.speed)!=null?gt:1,Q=1+Math.sin(s*Z)*F;(ht=this.pixiObject.scale)!=null&&ht.set?this.pixiObject.scale.set(w*Q,x*Q):this.pixiObject.scale&&(this.pixiObject.scale.x=w*Q,this.pixiObject.scale.y=x*Q)}if((ft=e.continuousRotate)!=null&&ft.enabled){let F=Math.max(0,(mt=e.continuousRotate.speed)!=null?mt:90),Z=Math.sign((bt=e.continuousRotate.direction)!=null?bt:1)||1,U=F*Math.PI/180;o+=U*Z*h,this.pixiObject.rotation=B+o}};X.Ticker.shared.add(u),this._tickerCleanup=()=>{var b,h,y,w,x;if(X.Ticker.shared.remove(u),this.pixiObject){let P=this.transform.scale*(((h=(b=this._config)==null?void 0:b.effects)==null?void 0:h.scale_x)||1),L=this.transform.scale*(((w=(y=this._config)==null?void 0:y.effects)==null?void 0:w.scale_y)||1);this.pixiObject.x=this.transform.position.x,this.pixiObject.y=this.transform.position.y,this.pixiObject.rotation=this.transform.rotation,(x=this.pixiObject.scale)!=null&&x.set?this.pixiObject.scale.set(P,L):this.pixiObject.scale&&(this.pixiObject.scale.x=P,this.pixiObject.scale.y=L)}}}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)}},at=class{constructor(e){this.objects=new Map;this.onObjectRebuildRequired=null;this.config=e}create(e,t){let n=this.config.objects.get(e);if(!n)throw new Error(`Object config not found: ${e}`);let a=new Ot(e,n.object_config||e,t,n);return this.objects.set(e,a),a.onRebuildRequired=async(s,r)=>{if(this.onObjectRebuildRequired){console.log(`[GameObjectManager] Triggering rebuild for ${e}`);let o=await this.onObjectRebuildRequired(e,r);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`),s.updateConfig(r)},a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[t,n]of this.objects.entries()){let a=e.objects.get(t);a&&n.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(e){let t=this.objects.get(e);t&&t.destroy(),this.objects.delete(e)}clear(){for(let e of this.objects.values())e.destroy();this.objects.clear()}};var ri={"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 Pa(i){let e=ri[i];return e?e.family:(console.warn(`Font ID "${i}" not found in registry, using fallback`),"Arial, sans-serif")}function Ia(i){var t;let e=ri[i];return e&&(t=e.weight)!=null?t:"400"}function Ma(i,e){ri[i]=e}function ja(){return Object.keys(ri)}var st=null;function lr(){return console.log("[LottieOverlay] getLottie called, lottieLib cached?",!!st),console.log("[LottieOverlay] window.lottie exists?",typeof window!="undefined"&&!!window.lottie),st||(typeof window!="undefined"&&window.lottie?(st=window.lottie,console.log("[LottieOverlay] \u2705 Found window.lottie, cached it")):(console.warn("[LottieOverlay] \u274C lottie-web is not available globally. Make sure it is loaded before using Lottie animations."),console.log("[LottieOverlay] window keys:",typeof window!="undefined"?Object.keys(window).filter(i=>i.toLowerCase().includes("lottie")):"no window"),st=null)),st}function cr(i){return!i||i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`}function dr(i){try{let e=new XMLHttpRequest;return e.open("GET",cr(i),!1),e.send(null),e.status<200||e.status>=300||!e.responseText?null:JSON.parse(e.responseText)}catch{return null}}function _a(i){return!i||typeof i!="object"||!Array.isArray(i.layers)?null:(Array.isArray(i.assets)||(i.assets=[]),Array.isArray(i.chars)||(i.chars=[]),i)}function Qt(i){st=i}function Oa(i,e,t,n){var P,L,B,R,H,z,T,E,S,A,V,J,O,ne,je,Se,Ee,Ce,Ae;let a=t.objects.get(i);if(!a)return console.warn(`[LottieOverlay] Object config not found: ${i}`),null;let s=((P=a.effects)==null?void 0:P.lottie)||{},r=a.transform||{},o=a.render||{};if(s.enabled===!1||o.visible===!1)return null;let c=n==null?void 0:n[i],l=_a(c);if(!l){let Y=(B=(L=a.render)==null?void 0:L.asset)==null?void 0:B.path;if(typeof Y=="string"&&Y.toLowerCase().endsWith(".json")){let _e=dr(Y);if(l=_a(_e),l)try{n[i]=l}catch{}}}if(!l){let Y=c&&typeof c=="object"?Object.prototype.toString.call(c):typeof c;return console.warn(`[LottieOverlay] Lottie JSON invalid for: ${i}`,{kind:Y}),null}let u=lr();if(!u)return console.warn(`[LottieOverlay] lottie-web is not available. Cannot play animation: ${i}`),null;let d=(R=s.width)!=null?R:300,p=(H=s.height)!=null?H:300,g=(z=r.scale)!=null?z:1,m=((E=(T=r.position)==null?void 0:T.x)!=null?E:0)+((A=(S=r.offset)==null?void 0:S.x)!=null?A:0),f=((J=(V=r.position)==null?void 0:V.y)!=null?J:0)+((ne=(O=r.offset)==null?void 0:O.y)!=null?ne:0),C=(je=r.rotation)!=null?je:0,b=(Se=o.z_index)!=null?Se:100,h=(Ee=o.alpha)!=null?Ee:1,y=document.createElement("div");y.style.cssText=`
265
+ `,i.appendChild(e)}async function si(i,e={}){let t=new Ia.Application;await t.init({resizeTo:i,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let n=r=>{var p,d,g,m;if(!t.renderer)return;let o=(p=r==null?void 0:r.width)!=null?p:i.clientWidth,c=(d=r==null?void 0:r.height)!=null?d:i.clientHeight,l=o&&o>0?o:(g=window.innerWidth)!=null?g:320,u=c&&c>0?c:(m=window.innerHeight)!=null?m:480;t.renderer.resize(l,u)};i.appendChild(t.canvas),i.style.position="relative",i.style.display="flex",i.style.flexDirection="column",i.style.alignItems="stretch",i.style.width="100%",i.style.height="100dvh",i.style.minHeight="100vh",i.style.maxWidth="100%",i.style.maxHeight="100%",i.style.boxSizing="border-box",i.style.overflow="hidden",e.background&&(i.style.background=e.background),n();let a=document.createElement("div");return a.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),i.appendChild(a),At.on("pause",()=>{t.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),At.on("resume",()=>{t.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),At.on("resize",({payload:r})=>{n({width:r==null?void 0:r.width,height:r==null?void 0:r.height})}),window.addEventListener("resize",()=>n()),requestAnimationFrame(()=>n()),new ResizeObserver(r=>{let o=r[0];if(o&&o.contentRect.width>0&&o.contentRect.height>0){let c=Math.round(o.contentRect.width),l=Math.round(o.contentRect.height);if(n({width:c,height:l}),typeof window!="undefined"&&window.gameApp&&window.gameObjectManager){let u={width:c,height:l,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:"auto-resize",isLandscape:c>l};window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:u}))}}}).observe(i),{app:t,stage:t.stage,overlay:a,applySize:n}}var X=require("pixi.js"),jt=class{constructor(e){var a,s;let t=e==null?void 0:e.position,n=e==null?void 0:e.offset;this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0},this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0},this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y},this.scale=(a=e==null?void 0:e.scale)!=null?a:1,this.rotation=(s=e==null?void 0:e.rotation)!=null?s:0}update(e){let t=e.position,n=e.offset;t!==void 0&&(this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0}),n!==void 0&&(this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0}),(t!==void 0||n!==void 0)&&(this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y}),e.scale!==void 0&&(this.scale=e.scale),e.rotation!==void 0&&(this.rotation=e.rotation)}syncToPixi(e){e&&(e.position.set(this.position.x,this.position.y),e.scale.set(this.scale),e.rotation=this.rotation)}},_t=class{constructor(e){var t,n,a,s;this.z_index=(t=e==null?void 0:e.z_index)!=null?t:0,this.alpha=(n=e==null?void 0:e.alpha)!=null?n:1,this.visible=(a=e==null?void 0:e.visible)!=null?a:!0,this.tint=(s=e==null?void 0:e.tint)!=null?s: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 s=a[t];s&&(e.texture=s)}}catch{}}},Ot=class{constructor(e,t,n,a){this._tickerCleanup=null;this.onRebuildRequired=null;this.instanceId=e,this.objectConfig=t,this.pixiObject=n,this._config=a,this.transform=new jt(a.transform),this.renderer=new _t(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&&(X.Ticker.shared.remove(this._introTicker),this._introTicker=null),this.pixiObject&&this.pixiObject.parent&&this.pixiObject.parent.removeChild(this.pixiObject)}updateConfig(e){var c,l,u,p,d,g,m,f,C,b,h;let t=(l=(c=this._config)==null?void 0:c.motion)==null?void 0:l.intro,n=(u=e==null?void 0:e.motion)==null?void 0:u.intro;n!=null&&n.enabled&&JSON.stringify(t)!==JSON.stringify(n)&&(this._shouldReplayIntro=!0);let a=(g=(d=(p=this._config)==null?void 0:p.render)==null?void 0:d.asset)==null?void 0:g.type,s=(f=(m=e==null?void 0:e.render)==null?void 0:m.asset)==null?void 0:f.type,r=(b=(C=this._config)==null?void 0:C.ui)==null?void 0:b.renderMode,o=(h=e==null?void 0:e.ui)==null?void 0:h.renderMode;if((a!==s||r!==o)&&(console.log(`[GameObject] Rebuild required for ${this.instanceId}: type changed from ${a}/${r} to ${s}/${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,s,r,o;if(!this.pixiObject||!("anchor"in this.pixiObject)||!this.pixiObject.anchor)return;let e=(s=(a=this._config)==null?void 0:a.render)==null?void 0:s.anchor,t=(o=(r=this._config)==null?void 0:r.transform)==null?void 0:o.anchor,n=e&&typeof e=="object"?e:t&&typeof t=="object"?t:null;n&&typeof n.x=="number"&&typeof n.y=="number"&&this.pixiObject.anchor.set(n.x,n.y)}applyEffectsScale(){var s,r,o;if(!((s=this.pixiObject)!=null&&s.scale))return;let e=(r=this._config)==null?void 0:r.effects,t=typeof(e==null?void 0:e.scale_x)=="number"?e.scale_x:1,n=typeof(e==null?void 0:e.scale_y)=="number"?e.scale_y:1;if(t===1&&n===1)return;let a=(o=this.transform.scale)!=null?o:1;typeof this.pixiObject.scale.set=="function"?this.pixiObject.scale.set(a*t,a*n):(this.pixiObject.scale.x=a*t,this.pixiObject.scale.y=a*n)}applyEffects(){var n,a,s,r,o,c,l,u,p;if(!this.pixiObject)return;let e=(n=this._config)==null?void 0:n.effects;if(!e||e.enabled===!1){this.pixiObject.filters=null;return}let t=[];if((a=e.blur)!=null&&a.enabled){let d=new X.BlurFilter;d.blur=(s=e.blur.strength)!=null?s:4,t.push(d)}if((r=e.shadow)!=null&&r.enabled){let d=e.shadow,g=new X.BlurFilter;g.blur=(o=d.blur)!=null?o:4,g.blendMode="multiply",t.push(g),(d.offsetX!==0||d.offsetY!==0)&&console.warn("[Effects] Drop shadow offset requires pixi-filters. Install: npm install pixi-filters")}if((c=e.glow)!=null&&c.enabled){let d=e.glow,g=new X.BlurFilter;if(g.blur=(l=d.blur)!=null?l:8,t.push(g),d.color){let m=new X.ColorMatrixFilter,f=typeof d.color=="string"?parseInt(d.color.replace("#",""),16):d.color;m.tint(f),t.push(m)}}(u=e.stroke)!=null&&u.enabled&&console.warn("[Effects] Stroke/outline effect requires pixi-filters. Install: npm install pixi-filters"),(p=e.distortion)!=null&&p.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,p,d,g,m,f,C;let e=(u=this._config)==null?void 0:u.motion;if(!e||!((p=e.intro)!=null&&p.enabled)||!this.pixiObject)return;let t=e.intro,n=(t.duration||0)/1e3,a=(t.delay||0)/1e3,s=this.transform.position.y,r=this.transform.scale*(((g=(d=this._config)==null?void 0:d.effects)==null?void 0:g.scale_x)||1),o=this.transform.scale*(((f=(m=this._config)==null?void 0:m.effects)==null?void 0:f.scale_y)||1);if(this.pixiObject.alpha=(C=t.startAlpha)!=null?C:0,t.startScale!==void 0&&this.pixiObject.scale.set(r*t.startScale,o*t.startScale),t.startYOffset!==void 0&&(this.pixiObject.y=s+(t.startYOffset||0)),this._introTicker&&X.Ticker.shared.remove(this._introTicker),n<=0&&a<=0){this.pixiObject.alpha=this.renderer.alpha,this.pixiObject.y=this.transform.position.y,this.pixiObject.scale.set(r,o);return}let c=0,l=b=>{var R,H,z,T,E,S;if(c+=b.deltaTime/60,c<a)return;let h=n>0?Math.min(1,(c-a)/n):1,y=1-Math.pow(1-h,3),w=this.renderer.alpha,x=this.transform.scale*(((H=(R=this._config)==null?void 0:R.effects)==null?void 0:H.scale_x)||1),I=this.transform.scale*(((T=(z=this._config)==null?void 0:z.effects)==null?void 0:T.scale_y)||1),L=this.transform.position.y,B=this.transform.position.x;if(this.pixiObject.alpha=((E=t.startAlpha)!=null?E:0)+(w-((S=t.startAlpha)!=null?S:0))*y,t.startScale!==void 0){let A=t.startScale+(1-t.startScale)*y;this.pixiObject.scale.set(x*A,I*A)}t.startYOffset!==void 0&&(this.pixiObject.y=L+t.startYOffset+(L-(L+t.startYOffset))*y),h>=1&&(X.Ticker.shared.remove(l),this._introTicker=null,this.pixiObject.alpha=w,this.pixiObject.x=B,this.pixiObject.y=L,this.pixiObject.scale.set(x,I))};this._introTicker=l,X.Ticker.shared.add(l)}applyMotion(){var p,d,g,m,f,C;let e=(p=this._config)==null?void 0:p.motion,t=e&&e.enabled!==!1,n=JSON.stringify(e);if(this._lastMotionStr===n&&this._tickerCleanup)return;if(this._lastMotionStr=n,!t){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null);return}if(this._tickerCleanup&&this._tickerCleanup(),!(((d=e.pulse)==null?void 0:d.enabled)||((g=e.swing)==null?void 0:g.enabled)||((m=e.continuousMove)==null?void 0:m.enabled)||((f=e.continuousRotate)==null?void 0:f.enabled)||((C=e.orbit)==null?void 0:C.enabled)))return;let s=0,r=0,o=0,c=0,l=1/60,u=b=>{var z,T,E,S,A,V,J,O,ne,je,Se,Ee,Ce,Ae,Y,_e,lt,ct,dt,pt,ut,gt,ht,ft,mt,bt;let h=((z=b.deltaTime)!=null?z:1)*l;s+=b.deltaTime*.05;let y=this.transform.scale,w=y*(((E=(T=this._config)==null?void 0:T.effects)==null?void 0:E.scale_x)||1),x=y*(((A=(S=this._config)==null?void 0:S.effects)==null?void 0:A.scale_y)||1),I=this.transform.position.x,L=this.transform.position.y,B=this.transform.rotation,R=0,H=0;if((V=e.swing)!=null&&V.enabled){let F=(J=e.swing.amplitude)!=null?J:10,Z=(O=e.swing.speed)!=null?O:1,U=Math.sin(s*Z)*F;e.swing.axis==="vertical"?H+=U:e.swing.axis==="both"?(R+=U,H+=U):R+=U}if((ne=e.continuousMove)!=null&&ne.enabled){let F=(je=e.continuousMove.axis)!=null?je:"x",Z=Math.max(0,(Se=e.continuousMove.speed)!=null?Se:50),U=Math.sign((Ee=e.continuousMove.direction)!=null?Ee:1)||1,Q=Math.max(0,(Ce=e.continuousMove.lifetime)!=null?Ce:0);r+=h;let Ue=Q>0?Math.min(r,Q):r,Oe=Z*U*Ue;(F==="x"||F==="both")&&(R+=Oe),(F==="y"||F==="both")&&(H+=Oe)}if((Ae=e.orbit)!=null&&Ae.enabled){let F=Math.max(0,(Y=e.orbit.radius)!=null?Y:50),Z=Math.max(0,(_e=e.orbit.speed)!=null?_e:45),U=Math.sign((lt=e.orbit.direction)!=null?lt:1)||1,Q=Z*Math.PI/180;c+=Q*U*h;let Ue=(ct=e.orbit.pivotOffsetX)!=null?ct:0,Oe=(dt=e.orbit.pivotOffsetY)!=null?dt:0;R+=Ue+F*Math.cos(c),H+=Oe+F*Math.sin(c)}if(this.pixiObject.x=I+R,this.pixiObject.y=L+H,(pt=e.pulse)!=null&&pt.enabled){let F=(ut=e.pulse.intensity)!=null?ut:.1,Z=(gt=e.pulse.speed)!=null?gt:1,Q=1+Math.sin(s*Z)*F;(ht=this.pixiObject.scale)!=null&&ht.set?this.pixiObject.scale.set(w*Q,x*Q):this.pixiObject.scale&&(this.pixiObject.scale.x=w*Q,this.pixiObject.scale.y=x*Q)}if((ft=e.continuousRotate)!=null&&ft.enabled){let F=Math.max(0,(mt=e.continuousRotate.speed)!=null?mt:90),Z=Math.sign((bt=e.continuousRotate.direction)!=null?bt:1)||1,U=F*Math.PI/180;o+=U*Z*h,this.pixiObject.rotation=B+o}};X.Ticker.shared.add(u),this._tickerCleanup=()=>{var b,h,y,w,x;if(X.Ticker.shared.remove(u),this.pixiObject){let I=this.transform.scale*(((h=(b=this._config)==null?void 0:b.effects)==null?void 0:h.scale_x)||1),L=this.transform.scale*(((w=(y=this._config)==null?void 0:y.effects)==null?void 0:w.scale_y)||1);this.pixiObject.x=this.transform.position.x,this.pixiObject.y=this.transform.position.y,this.pixiObject.rotation=this.transform.rotation,(x=this.pixiObject.scale)!=null&&x.set?this.pixiObject.scale.set(I,L):this.pixiObject.scale&&(this.pixiObject.scale.x=I,this.pixiObject.scale.y=L)}}}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)}},at=class{constructor(e){this.objects=new Map;this.onObjectRebuildRequired=null;this.config=e}create(e,t){let n=this.config.objects.get(e);if(!n)throw new Error(`Object config not found: ${e}`);let a=new Ot(e,n.object_config||e,t,n);return this.objects.set(e,a),a.onRebuildRequired=async(s,r)=>{if(this.onObjectRebuildRequired){console.log(`[GameObjectManager] Triggering rebuild for ${e}`);let o=await this.onObjectRebuildRequired(e,r);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`),s.updateConfig(r)},a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[t,n]of this.objects.entries()){let a=e.objects.get(t);a&&n.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(e){let t=this.objects.get(e);t&&t.destroy(),this.objects.delete(e)}clear(){for(let e of this.objects.values())e.destroy();this.objects.clear()}};var ri={"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 Pa(i){let e=ri[i];return e?e.family:(console.warn(`Font ID "${i}" not found in registry, using fallback`),"Arial, sans-serif")}function Ma(i){var t;let e=ri[i];return e&&(t=e.weight)!=null?t:"400"}function ja(i,e){ri[i]=e}function _a(){return Object.keys(ri)}var st=null;function dr(){return console.log("[LottieOverlay] getLottie called, lottieLib cached?",!!st),console.log("[LottieOverlay] window.lottie exists?",typeof window!="undefined"&&!!window.lottie),st||(typeof window!="undefined"&&window.lottie?(st=window.lottie,console.log("[LottieOverlay] \u2705 Found window.lottie, cached it")):(console.warn("[LottieOverlay] \u274C lottie-web is not available globally. Make sure it is loaded before using Lottie animations."),console.log("[LottieOverlay] window keys:",typeof window!="undefined"?Object.keys(window).filter(i=>i.toLowerCase().includes("lottie")):"no window"),st=null)),st}function pr(i){return!i||i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`}function ur(i){try{let e=new XMLHttpRequest;return e.open("GET",pr(i),!1),e.send(null),e.status<200||e.status>=300||!e.responseText?null:JSON.parse(e.responseText)}catch{return null}}function Oa(i){return!i||typeof i!="object"||!Array.isArray(i.layers)?null:(Array.isArray(i.assets)||(i.assets=[]),Array.isArray(i.chars)||(i.chars=[]),i)}function Qt(i){st=i}function Ra(i,e,t,n){var I,L,B,R,H,z,T,E,S,A,V,J,O,ne,je,Se,Ee,Ce,Ae;let a=t.objects.get(i);if(!a)return console.warn(`[LottieOverlay] Object config not found: ${i}`),null;let s=((I=a.effects)==null?void 0:I.lottie)||{},r=a.transform||{},o=a.render||{};if(s.enabled===!1||o.visible===!1)return null;let c=n==null?void 0:n[i],l=Oa(c);if(!l){let Y=(B=(L=a.render)==null?void 0:L.asset)==null?void 0:B.path;if(typeof Y=="string"&&Y.toLowerCase().endsWith(".json")){let _e=ur(Y);if(l=Oa(_e),l)try{n[i]=l}catch{}}}if(!l){let Y=c&&typeof c=="object"?Object.prototype.toString.call(c):typeof c;return console.warn(`[LottieOverlay] Lottie JSON invalid for: ${i}`,{kind:Y}),null}let u=dr();if(!u)return console.warn(`[LottieOverlay] lottie-web is not available. Cannot play animation: ${i}`),null;let p=(R=s.width)!=null?R:300,d=(H=s.height)!=null?H:300,g=(z=r.scale)!=null?z:1,m=((E=(T=r.position)==null?void 0:T.x)!=null?E:0)+((A=(S=r.offset)==null?void 0:S.x)!=null?A:0),f=((J=(V=r.position)==null?void 0:V.y)!=null?J:0)+((ne=(O=r.offset)==null?void 0:O.y)!=null?ne:0),C=(je=r.rotation)!=null?je:0,b=(Se=o.z_index)!=null?Se:100,h=(Ee=o.alpha)!=null?Ee:1,y=document.createElement("div");y.style.cssText=`
246
266
  position: absolute;
247
267
  top: calc(50% + ${f}px);
248
268
  left: calc(50% + ${m}px);
249
269
  transform: translate(-50%, -50%) scale(${g}) rotate(${C}deg);
250
- width: ${d}px;
251
- height: ${p}px;
270
+ width: ${p}px;
271
+ height: ${d}px;
252
272
  pointer-events: none;
253
273
  z-index: ${b};
254
274
  opacity: ${h};
255
- `,e.appendChild(y);let w;try{w=u.loadAnimation({container:y,renderer:s.renderer||"svg",loop:(Ce=s.loop)!=null?Ce:!1,autoplay:(Ae=s.autoplay)!=null?Ae:!0,animationData:l})}catch(Y){return y.parentNode&&y.parentNode.removeChild(y),console.warn(`[LottieOverlay] Failed to start animation: ${i}`,Y),null}s.speed!==void 0&&w.setSpeed(s.speed);let x=()=>{w.destroy(),y.parentNode&&y.parentNode.removeChild(y)};return s.loop||w.addEventListener("complete",x),{animation:w,cleanup:x}}Jt();Kt();var oi=class{constructor(e,t,n){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=n}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:n}=await si(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=n,this.gameObjectManager=new at(this.config),this.stage.eventMode="passive",this.stage.interactive=!1,this.stage.interactiveChildren=!0,this.stage.sortableChildren=!0,this.context={app:this.app,stage:this.stage,config:this.config,gameObjectManager:this.gameObjectManager,destinationUrl:this.destinationUrl,root:this.root,engine:this};for(let a of this.systems)a.setContext(this.context);return{app:this.app,gameObjectManager:this.gameObjectManager}}async initSystems(){if(!this.context)throw new Error("[GameEngine] createApp() must be called before initSystems()");for(let e of this.systems)e.init&&await e.init()}async init(e){return await this.createApp(e),await this.initSystems(),{app:this.app,gameObjectManager:this.gameObjectManager}}registerSystems(e){this.systems.push(...e)}async start(){for(let e of this.systems)e.onStart&&await e.onStart();this.app.ticker.add(this.update.bind(this)),window.addEventListener("handler-preview:screen",e=>{let{width:t,height:n}=e.detail;this.resize(t,n)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let n of this.systems)n.update&&n.update(t,this.totalTime)}resize(e,t){for(let n of this.systems)n.onResize&&n.onResize(e,t)}updateConfig(e){this.config=e;for(let t of this.systems)t.context.config=e,t.onConfigUpdate&&t.onConfigUpdate(e)}destroy(){for(let e of this.systems)e.onDestroy&&e.onDestroy();this.app.ticker.remove(this.update.bind(this)),this.app.destroy(!0,{children:!0,texture:!1})}getApp(){return this.app}getGameObjectManager(){return this.gameObjectManager}getTotalTime(){return this.totalTime}getSystem(e){let t=this.systems.find(n=>n instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var rt=class{setContext(e){this.context=e}};var ot=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 Ra=ci(require("pixi.js"),1),za=Ra;typeof window!="undefined"&&(window.__basePixi=Ra);Et();var xe=require("pixi.js");Et();var $a=i=>i*Math.PI/180;function pr(i,e){var r,o,c,l,u;let t=e.ui;if(!(t!=null&&t.text))return null;let n="#ffffff";(r=e.render)!=null&&r.tint&&(n=e.render.tint);let a=new xe.TextStyle({fontFamily:(o=t.font)!=null?o:"Arial",fontSize:(c=t.fontSize)!=null?c:16,fill:n,align:(l=t.align)!=null?l:"center",letterSpacing:(u=t.letterSpacing)!=null?u:0}),s=new xe.Text({text:t.text,style:a});return s.label=i,s}function Da(i){var u,d,p,g,m,f,C,b,h,y;let{stage:e,mainContainer:t,activeConfig:n,gameObjectManager:a,allowList:s,denyList:r}=i,o={},c={},l={};t.sortableChildren=!0;for(let[w,x]of n.objects.entries()){if(r!=null&&r.has(w)||s&&!s.has(w)||(x==null?void 0:x.enabled)===!1)continue;let P=(d=(u=x==null?void 0:x.render)==null?void 0:u.asset)==null?void 0:d.path,L=(g=(p=x==null?void 0:x.render)==null?void 0:p.asset)==null?void 0:g.type,B=!!(P&&L==="image"),R=!!((m=x==null?void 0:x.ui)!=null&&m.text),H=R?(f=x==null?void 0:x.ui)==null?void 0:f.renderMode:void 0,z;if(H==="png"&&B?z="png":H==="text"&&R?z="text":B?z="png":R?z="text":z="skip",z!=="skip"){if(z==="text"){let T=pr(w,x);if(!T)continue;let E=x.render;T.alpha=typeof(E==null?void 0:E.alpha)=="number"?E.alpha:1,T.visible=(E==null?void 0:E.visible)!==!1,T.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"?T.anchor.set(E.anchor.x,E.anchor.y):T.anchor.set(.5,.5);let S=x.transform,A=(S==null?void 0:S.position)||(S==null?void 0:S.offset);A&&T.position.set((C=A.x)!=null?C:0,(b=A.y)!=null?b:0);let V=typeof(S==null?void 0:S.scale)=="number"?S.scale:1;T.scale.set(V,V);let J=typeof(S==null?void 0:S.rotation)=="number"?S.rotation:0;T.rotation=$a(J),T.parent||t.addChild(T);try{a.create(w,T)}catch{}o[w]=T,l[w]=T}else if(z==="png"){let T=Ie[w]||(typeof xe.Texture!="undefined"?xe.Texture.EMPTY:void 0),E=new xe.Sprite(T);E.label=w;let S=x.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 A=x.transform,V=(A==null?void 0:A.position)||(A==null?void 0:A.offset);V&&E.position.set((h=V.x)!=null?h:0,(y=V.y)!=null?y:0);let J=typeof(A==null?void 0:A.scale)=="number"?A.scale:1;E.scale.set(J,J);let O=typeof(A==null?void 0:A.rotation)=="number"?A.rotation:0;E.rotation=$a(O),E.parent||t.addChild(E);try{a.create(w,E)}catch{}o[w]=E,c[w]=E}}}return t.parent||e.addChild(t),{objects:o,sprites:c,texts:l}}var Fi=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new ot}init(e,t){this.registry.init(e),this.app=t}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let t=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(t.length===0)return;let n=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async s=>{var o;let r=this.registry.get(s);if(!r){console.warn("[Assets] No config found for object:",s);return}try{let c=await ye.create(s,r,this.app);this.instanceCache.set(s,c),console.log("[Assets] Loaded object:",s,(o=c==null?void 0:c.constructor)==null?void 0:o.name)}catch(c){console.error("[Assets] Failed to load object:",s,c)}})))};return this.readyPromise=(async()=>{await n(t);let a=this.registry.getAllIds().filter(s=>!this.instanceCache.has(s));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await n(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let t=this.registry.get(e);if(t){let n=await ye.create(e,t,this.app);this.instanceCache.set(e,n)}}get(e){return this.instanceCache.get(e)}},Na=new Fi,Ha=new Proxy(Na,{get(i,e){if(e in i&&typeof i[e]=="function")return i[e].bind(i);if(i.get(e))return i.get(e)}});function Fa(i,e){Na.init(i,e)}Et();var li=class extends rt{async init(){Zt(this.context.config,this.context.app),await Ie.ready(),console.log("[AssetSystem] All assets preloaded and ready")}async onStart(){}onConfigUpdate(){console.log("[AssetSystem] Config updated - systems will refresh textures")}};function Ba(i){var o,c,l;let{setState:e,updateLabelAlpha:t,updateHandAlpha:n,config:a,states:s}=i,r=((c=(o=a.engine)==null?void 0:o.runtime)==null?void 0:c.timeline)||{};e(s.showHook),setTimeout(()=>{t(1),n(1),e(s.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(l=r.tutorial_delay_ms)!=null?l: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});
275
+ `,e.appendChild(y);let w;try{w=u.loadAnimation({container:y,renderer:s.renderer||"svg",loop:(Ce=s.loop)!=null?Ce:!1,autoplay:(Ae=s.autoplay)!=null?Ae:!0,animationData:l})}catch(Y){return y.parentNode&&y.parentNode.removeChild(y),console.warn(`[LottieOverlay] Failed to start animation: ${i}`,Y),null}s.speed!==void 0&&w.setSpeed(s.speed);let x=()=>{w.destroy(),y.parentNode&&y.parentNode.removeChild(y)};return s.loop||w.addEventListener("complete",x),{animation:w,cleanup:x}}Jt();Kt();var oi=class{constructor(e,t,n){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=n}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:n}=await si(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=n,this.gameObjectManager=new at(this.config),this.stage.eventMode="passive",this.stage.interactive=!1,this.stage.interactiveChildren=!0,this.stage.sortableChildren=!0,this.context={app:this.app,stage:this.stage,config:this.config,gameObjectManager:this.gameObjectManager,destinationUrl:this.destinationUrl,root:this.root,engine:this};for(let a of this.systems)a.setContext(this.context);return{app:this.app,gameObjectManager:this.gameObjectManager}}async initSystems(){if(!this.context)throw new Error("[GameEngine] createApp() must be called before initSystems()");for(let e of this.systems)e.init&&await e.init()}async init(e){return await this.createApp(e),await this.initSystems(),{app:this.app,gameObjectManager:this.gameObjectManager}}registerSystems(e){this.systems.push(...e)}async start(){for(let e of this.systems)e.onStart&&await e.onStart();this.app.ticker.add(this.update.bind(this)),window.addEventListener("handler-preview:screen",e=>{let{width:t,height:n}=e.detail;this.resize(t,n)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let n of this.systems)n.update&&n.update(t,this.totalTime)}resize(e,t){for(let n of this.systems)n.onResize&&n.onResize(e,t)}updateConfig(e){this.config=e;for(let t of this.systems)t.context.config=e,t.onConfigUpdate&&t.onConfigUpdate(e)}destroy(){for(let e of this.systems)e.onDestroy&&e.onDestroy();this.app.ticker.remove(this.update.bind(this)),this.app.destroy(!0,{children:!0,texture:!1})}getApp(){return this.app}getGameObjectManager(){return this.gameObjectManager}getTotalTime(){return this.totalTime}getSystem(e){let t=this.systems.find(n=>n instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var rt=class{setContext(e){this.context=e}};var ot=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 za=ci(require("pixi.js"),1),$a=za;typeof window!="undefined"&&(window.__basePixi=za);Et();var xe=require("pixi.js");Et();var Da=i=>i*Math.PI/180;function gr(i,e){var r,o,c,l,u;let t=e.ui;if(!(t!=null&&t.text))return null;let n="#ffffff";(r=e.render)!=null&&r.tint&&(n=e.render.tint);let a=new xe.TextStyle({fontFamily:(o=t.font)!=null?o:"Arial",fontSize:(c=t.fontSize)!=null?c:16,fill:n,align:(l=t.align)!=null?l:"center",letterSpacing:(u=t.letterSpacing)!=null?u:0}),s=new xe.Text({text:t.text,style:a});return s.label=i,s}function Na(i){var u,p,d,g,m,f,C,b,h,y;let{stage:e,mainContainer:t,activeConfig:n,gameObjectManager:a,allowList:s,denyList:r}=i,o={},c={},l={};t.sortableChildren=!0;for(let[w,x]of n.objects.entries()){if(r!=null&&r.has(w)||s&&!s.has(w)||(x==null?void 0:x.enabled)===!1)continue;let I=(p=(u=x==null?void 0:x.render)==null?void 0:u.asset)==null?void 0:p.path,L=(g=(d=x==null?void 0:x.render)==null?void 0:d.asset)==null?void 0:g.type,B=!!(I&&L==="image"),R=!!((m=x==null?void 0:x.ui)!=null&&m.text),H=R?(f=x==null?void 0:x.ui)==null?void 0:f.renderMode:void 0,z;if(H==="png"&&B?z="png":H==="text"&&R?z="text":B?z="png":R?z="text":z="skip",z!=="skip"){if(z==="text"){let T=gr(w,x);if(!T)continue;let E=x.render;T.alpha=typeof(E==null?void 0:E.alpha)=="number"?E.alpha:1,T.visible=(E==null?void 0:E.visible)!==!1,T.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"?T.anchor.set(E.anchor.x,E.anchor.y):T.anchor.set(.5,.5);let S=x.transform,A=(S==null?void 0:S.position)||(S==null?void 0:S.offset);A&&T.position.set((C=A.x)!=null?C:0,(b=A.y)!=null?b:0);let V=typeof(S==null?void 0:S.scale)=="number"?S.scale:1;T.scale.set(V,V);let J=typeof(S==null?void 0:S.rotation)=="number"?S.rotation:0;T.rotation=Da(J),T.parent||t.addChild(T);try{a.create(w,T)}catch{}o[w]=T,l[w]=T}else if(z==="png"){let T=Pe[w]||(typeof xe.Texture!="undefined"?xe.Texture.EMPTY:void 0),E=new xe.Sprite(T);E.label=w;let S=x.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 A=x.transform,V=(A==null?void 0:A.position)||(A==null?void 0:A.offset);V&&E.position.set((h=V.x)!=null?h:0,(y=V.y)!=null?y:0);let J=typeof(A==null?void 0:A.scale)=="number"?A.scale:1;E.scale.set(J,J);let O=typeof(A==null?void 0:A.rotation)=="number"?A.rotation:0;E.rotation=Da(O),E.parent||t.addChild(E);try{a.create(w,E)}catch{}o[w]=E,c[w]=E}}}return t.parent||e.addChild(t),{objects:o,sprites:c,texts:l}}var Fi=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new ot}init(e,t){this.registry.init(e),this.app=t}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let t=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(t.length===0)return;let n=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async s=>{var o;let r=this.registry.get(s);if(!r){console.warn("[Assets] No config found for object:",s);return}try{let c=await ye.create(s,r,this.app);this.instanceCache.set(s,c),console.log("[Assets] Loaded object:",s,(o=c==null?void 0:c.constructor)==null?void 0:o.name)}catch(c){console.error("[Assets] Failed to load object:",s,c)}})))};return this.readyPromise=(async()=>{await n(t);let a=this.registry.getAllIds().filter(s=>!this.instanceCache.has(s));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await n(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let t=this.registry.get(e);if(t){let n=await ye.create(e,t,this.app);this.instanceCache.set(e,n)}}get(e){return this.instanceCache.get(e)}},Ha=new Fi,Fa=new Proxy(Ha,{get(i,e){if(e in i&&typeof i[e]=="function")return i[e].bind(i);if(i.get(e))return i.get(e)}});function Ba(i,e){Ha.init(i,e)}Et();var li=class extends rt{async init(){Zt(this.context.config,this.context.app),await Pe.ready(),console.log("[AssetSystem] All assets preloaded and ready")}async onStart(){}onConfigUpdate(){console.log("[AssetSystem] Config updated - systems will refresh textures")}};function Ga(i){var o,c,l;let{setState:e,updateLabelAlpha:t,updateHandAlpha:n,config:a,states:s}=i,r=((c=(o=a.engine)==null?void 0:o.runtime)==null?void 0:c.timeline)||{};e(s.showHook),setTimeout(()=>{t(1),n(1),e(s.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(l=r.tutorial_delay_ms)!=null?l: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});