handler-playable-sdk 1.0.94 → 1.0.95

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 (45) hide show
  1. package/dist/{ConfigOverride-XECG7H5B.js → ConfigOverride-2HOZGV6G.js} +1 -1
  2. package/dist/chunk-5IRAZMOA.js +1 -0
  3. package/dist/{chunk-CIQG6PIB.js → chunk-LWADIFXM.js} +121 -121
  4. package/dist/chunk-SDFKEAA5.js +1 -0
  5. package/dist/cli/brand-dna.mjs +1 -1
  6. package/dist/cli/canva-import.mjs +1 -1
  7. package/dist/cli/cleanup-assets.mjs +1 -1
  8. package/dist/cli/fix-scales.mjs +1 -1
  9. package/dist/cli/index.js +1 -1
  10. package/dist/cli/screen-helper.mjs +1 -1
  11. package/dist/cli/setup-library.mjs +1 -1
  12. package/dist/cli/student-helper/add-logic.mjs +1 -1
  13. package/dist/cli/student-helper/add-object.mjs +1 -1
  14. package/dist/cli/student-helper/arg-parsing.mjs +1 -1
  15. package/dist/cli/student-helper/asset-registry.mjs +1 -1
  16. package/dist/cli/student-helper/bullet-system.mjs +1 -1
  17. package/dist/cli/student-helper/collectable-system.mjs +1 -1
  18. package/dist/cli/student-helper/constants.mjs +1 -1
  19. package/dist/cli/student-helper/drag-snap-couples.mjs +1 -1
  20. package/dist/cli/student-helper/endgame-screen.mjs +1 -1
  21. package/dist/cli/student-helper/fs-io.mjs +1 -1
  22. package/dist/cli/student-helper/logic-defaults.mjs +1 -1
  23. package/dist/cli/student-helper/print-help.mjs +1 -1
  24. package/dist/cli/student-helper/prompts.mjs +1 -1
  25. package/dist/cli/student-helper/scratch-card.mjs +1 -1
  26. package/dist/cli/student-helper/screen-utils.mjs +1 -1
  27. package/dist/cli/student-helper/snippets.mjs +1 -1
  28. package/dist/cli/student-helper/start-screen.mjs +1 -1
  29. package/dist/cli/student-helper/swerve-collect.mjs +1 -1
  30. package/dist/cli/student-helper/tap-destroy.mjs +1 -1
  31. package/dist/cli/student-helper/template-packs.mjs +1 -1
  32. package/dist/cli/student-helper.mjs +1 -1
  33. package/dist/cli/sync-screens.mjs +1 -1
  34. package/dist/cli/validate-assets.mjs +1 -1
  35. package/dist/cli/validate.mjs +1 -1
  36. package/dist/{config-TFSKV7GO.js → config-VJNOXXCC.js} +1 -1
  37. package/dist/index.cjs +123 -123
  38. package/dist/index.js +1 -1
  39. package/dist/pixi/index.cjs +12 -12
  40. package/dist/pixi/index.js +1 -1
  41. package/dist/three/index.cjs +13 -13
  42. package/dist/three/index.js +1 -1
  43. package/package.json +1 -1
  44. package/dist/chunk-EFRB44UC.js +0 -1
  45. package/dist/chunk-GVZ2445E.js +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";var vo=Object.create;var yt=Object.defineProperty;var wo=Object.getOwnPropertyDescriptor;var xo=Object.getOwnPropertyNames;var So=Object.getPrototypeOf,Eo=Object.prototype.hasOwnProperty;var K=(t,e)=>()=>(t&&(e=t(t=0)),e);var da=(t,e)=>{for(var n in e)yt(t,n,{get:e[n],enumerable:!0})},pa=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of xo(e))!Eo.call(t,a)&&a!==n&&yt(t,a,{get:()=>e[a],enumerable:!(i=wo(e,a))||i.enumerable});return t};var he=(t,e,n)=>(n=t!=null?vo(So(t)):{},pa(e||!t||!t.__esModule?yt(n,"default",{value:t,enumerable:!0}):n,t)),Co=t=>pa(yt({},"__esModule",{value:!0}),t);var J,xt=K(()=>{"use strict";J=class{static get(e){var n;return(n=this.store.get(e))==null?void 0:n.data}static set(e,n){this.store.set(e,{data:n})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};J.store=new Map});function _o(){var t,e;try{let n=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(t=document.querySelector("script"))==null?void 0:t.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),i=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(n&&!i)}catch{return!1}}async function jo(){try{if(typeof window!="undefined"){let t=await fetch("./build-settings.json");if(t.ok){let e=await t.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Oo(){try{if(typeof window!="undefined"){let t=new XMLHttpRequest;if(t.open("GET","./build-settings.json",!1),t.send(),t.status===200&&t.responseText){let e=JSON.parse(t.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}async function Ro(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${A}`),Object.keys(oe).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(oe)),oe;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),oe={...window.INLINE_ASSETS},oe;if(!(A==="publish"&&Z!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),oe;if(!sn){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),sn=(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 n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);let i=await n.text();console.log("[AssetLoader] Received JS code, length:",i.length);let a=i.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)try{let s=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let o=new Function("return "+s)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(o)),o}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:",i.substring(0,500)),{}}catch(n){return console.warn("[AssetLoader] Failed to load inline assets:",n),{}}})()}return oe=await sn,console.log("[AssetLoader] Final inline assets cache:",Object.keys(oe)),oe}function on(t){return t===null||typeof t!="object"||(Object.freeze(t),Object.values(t).forEach(e=>on(e))),t}function zo(t=64,e=64,n=16711680){let i=document.createElement("canvas");i.width=t,i.height=e;let a=i.getContext("2d");return a.fillStyle=`#${n.toString(16).padStart(6,"0")}`,a.fillRect(0,0,t,e),a.strokeStyle="#000",a.strokeRect(0,0,t,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",t/2,e/2),re.Texture.from(i)}function rn(t,e){qa.set(t,e)}var re,Ga,Ua,Ee,A,Z,me,oe,sn,qa,Ce,St=K(()=>{"use strict";re=require("pixi.js");xt();Ga=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Ua=_o(),Ee=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,A=Ua?"publish":Ga,Z=Ee==null?void 0:Ee.assetsInlined;Ee!=null&&Ee.buildMode&&(A=Ee.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${A}`));me=Oo();me!=null&&me.buildMode&&(A=me.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${A}`));(me==null?void 0:me.assetsInlined)!==void 0&&(Z=me.assetsInlined);jo().then(t=>{t!=null&&t.buildMode&&t.buildMode!==A&&(A=t.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${A}`)),(t==null?void 0:t.assetsInlined)!==void 0&&(Z=t.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${Ga}, Runtime: ${Ua?"publish":"dev"}, Effective: ${A}`);oe={},sn=null;qa=new Map;Ce=class{static async load(e,n,i,a){let s=`${e}:${n.path}`,o=J.get(s);if(o!==void 0)return o;console.log(`[AssetLoader] Loading asset: ${e}, type: ${n.type}, Effective mode: ${A}`),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 r=await Ro(),l=r[e];if(!l&&a&&(l=r[a],l&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${a}`)),!l&&n.path){let c=n.path.split("/");if(c.length>=2){let h=c[c.length-1].split(".")[0];r[h]&&(l=r[h],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${h}`))}}if(console.log("[AssetLoader] Inline data for",e,":",l?"FOUND":"NOT FOUND"),A==="publish"&&Z!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!l))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${n.path}`);let p=qa.get(n.type);if(p)try{let c=await p(n.path,l,e,i);return J.set(s,c),c}catch(c){return this.handleFailure(e,n.type,c)}try{let c;switch(n.type){case"image":c=await this.loadImage(n.path,l);break;case"json":c=await this.loadJSON(n.path,l),c=on(c);break;default:throw new Error(`Unknown asset type: ${n.type}`)}return J.set(s,c),c}catch(c){return this.handleFailure(e,n.type,c)}}static async loadImage(e,n){let i=A==="publish",a=i&&Z!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${A}, isPublishMode: ${i}, inlineData: ${n?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!n)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof n!="string"||!n.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof n}`);try{return await re.Assets.load(n)}catch(s){throw console.error("[AssetLoader] Failed to load texture from data URI:",s),s}}if(n&&typeof n=="string"&&n.startsWith("data:"))try{return await re.Assets.load(n)}catch(s){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",s),await re.Assets.load(e)}return await re.Assets.load(e)}static async loadJSON(e,n){let i=A==="publish",a=i&&Z!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${A}, isPublishMode: ${i}, inlineData: ${n?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!n)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof n=="object"&&n!==null)return n;if(typeof n=="string"&&n.startsWith("data:")){let o=atob(n.split(",")[1]);return JSON.parse(o)}return JSON.parse(n)}if(n){if(typeof n=="object"&&n!==null)return n;if(typeof n=="string"&&n.startsWith("data:")){let o=atob(n.split(",")[1]);return JSON.parse(o)}return JSON.parse(n)}let s=await fetch(e);if(!s.ok)throw new Error(`JSON fetch failed: ${e}`);return s.json()}static handleFailure(e,n,i){if(A==="dev"){let s=n==="image"?zo():on({__placeholder:!0,type:n});return J.set(e+":"+((i==null?void 0:i.path)||"missing"),s),s}throw i}};rn("image",async(t,e)=>{let n=A==="publish",i=n&&Z!==!1,a=A==="brand",s=n&&Z===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${A}, isPublishMode: ${n}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return re.Assets.load(e)}let o=t;return(a||s)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(o=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${o}"`))),re.Assets.load(e||o)});rn("json",async(t,e)=>{let n=A==="publish",i=n&&Z!==!1,a=A==="brand",s=n&&Z===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${A}, isPublishMode: ${n}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let o=t;if((a||s)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(o=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${o}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let r=await fetch(o);if(!r.ok)throw new Error(`JSON fetch failed: ${t}`);return r.json()})});var cn,Bo,Et,Je=K(()=>{"use strict";St();cn=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,n){if(this.config===e&&this.app===n&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.attempted.clear(),this.waiters.clear(),this.priorityReadyPromise=new Promise(i=>{this.priorityReadyResolve=i}),this.config=e,this.app=n,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,n=this.app;return this.readyPromise=(async()=>{var o;console.log("[AssetTextures] Loading all assets...");let i=new Set(["background_loading_1"]),a=[],s=[];for(let[r,l]of e.objects.entries()){let d=(o=l.render)==null?void 0:o.asset;if(!d)continue;let p=async()=>{var c;try{let h=(c=l.identity)==null?void 0:c.id;console.log(`[AssetTextures] Loading ${d.type}: ${r} (${h})`);let u=await Ce.load(r,d,n,h);this.textures.set(r,u),console.log(`[AssetTextures] \u2713 Loaded: ${r}`)}catch(h){console.error(`[AssetTextures] \u2717 Failed to load: ${r}`,h)}finally{this.attempted.add(r);try{for(let h of Array.from(this.waiters))h()}catch{}}};i.has(r)?a.push(p()):s.push(p())}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,n={}){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(r=>typeof r=="string"&&r))).filter(r=>{var l,d,p,c;try{let h=(p=(d=(l=this.config)==null?void 0:l.objects)==null?void 0:d.get)==null?void 0:p.call(d,r);return!!((c=h==null?void 0:h.render)!=null&&c.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let s=()=>a.every(r=>this.textures.has(r)||this.attempted.has(r));if(s())return;let o=typeof n.timeoutMs=="number"?n.timeoutMs:15e3;await new Promise(r=>{let l=!1,d=()=>{l||s()&&(l=!0,this.waiters.delete(d),r())};this.waiters.add(d),d(),o>0&&setTimeout(()=>{l||(l=!0,this.waiters.delete(d),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),r())},o)})}get(e){return this.textures.get(e)}set(e,n){this.textures.set(e,n),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())}},Bo=new cn,Et=new Proxy(Bo,{get(t,e){return e in t&&typeof t[e]=="function"?t[e].bind(t):t.get(e)},set(t,e,n){return t.set(e,n),!0}})});var pr,Q=K(()=>{"use strict";pr="handler_preview_override_mode";if(typeof window!="undefined"){let t=window.localStorage.getItem(pr);window.__enableConfigOverrides=t===null?!0:t==="true"}});var Wa,Te,Mc,mn=K(()=>{"use strict";Q();Wa=null,Te="dev";if(typeof window!="undefined"){let t=window.__BUILD_SETTINGS__;if(t!=null&&t.buildMode)Wa=t,Te=t.buildMode,console.log("[CONFIG] Loaded inline build settings:",t,"buildMode:",Te);else try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let n=JSON.parse(e.responseText);Wa=n,Te=n.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",n,"buildMode:",Te)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",Te)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",Te);Mc=Te==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var fn=K(()=>{"use strict"});var Xa=K(()=>{"use strict";fn();mn()});var yn=K(()=>{"use strict";mn();fn();Xa()});var is={};da(is,{AssetEditorModal:()=>An});var An,Tn=K(()=>{"use strict";An=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,n,i,a){this.currentObjectId=e,this.currentPath=n,this.currentAsset=i,this.onApplyCallback=a,this.createModal(e,i),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,n){let i=document.createElement("div");i.className="asset-editor-modal",i.innerHTML=`
1
+ "use strict";var vo=Object.create;var yt=Object.defineProperty;var wo=Object.getOwnPropertyDescriptor;var xo=Object.getOwnPropertyNames;var So=Object.getPrototypeOf,Eo=Object.prototype.hasOwnProperty;var K=(t,e)=>()=>(t&&(e=t(t=0)),e);var da=(t,e)=>{for(var n in e)yt(t,n,{get:e[n],enumerable:!0})},pa=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of xo(e))!Eo.call(t,a)&&a!==n&&yt(t,a,{get:()=>e[a],enumerable:!(i=wo(e,a))||i.enumerable});return t};var he=(t,e,n)=>(n=t!=null?vo(So(t)):{},pa(e||!t||!t.__esModule?yt(n,"default",{value:t,enumerable:!0}):n,t)),Co=t=>pa(yt({},"__esModule",{value:!0}),t);var J,xt=K(()=>{"use strict";J=class{static get(e){var n;return(n=this.store.get(e))==null?void 0:n.data}static set(e,n){this.store.set(e,{data:n})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};J.store=new Map});function _o(){var t,e;try{let n=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(t=document.querySelector("script"))==null?void 0:t.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),i=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(n&&!i)}catch{return!1}}async function jo(){try{if(typeof window!="undefined"){let t=await fetch("./build-settings.json");if(t.ok){let e=await t.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Oo(){try{if(typeof window!="undefined"){let t=new XMLHttpRequest;if(t.open("GET","./build-settings.json",!1),t.send(),t.status===200&&t.responseText){let e=JSON.parse(t.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}async function Ro(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${A}`),Object.keys(oe).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(oe)),oe;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),oe={...window.INLINE_ASSETS},oe;if(!(A==="publish"&&Z!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),oe;if(!sn){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),sn=(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 n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);let i=await n.text();console.log("[AssetLoader] Received JS code, length:",i.length);let a=i.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)try{let s=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let o=new Function("return "+s)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(o)),o}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:",i.substring(0,500)),{}}catch(n){return console.warn("[AssetLoader] Failed to load inline assets:",n),{}}})()}return oe=await sn,console.log("[AssetLoader] Final inline assets cache:",Object.keys(oe)),oe}function on(t){return t===null||typeof t!="object"||(Object.freeze(t),Object.values(t).forEach(e=>on(e))),t}function zo(t=64,e=64,n=16711680){let i=document.createElement("canvas");i.width=t,i.height=e;let a=i.getContext("2d");return a.fillStyle=`#${n.toString(16).padStart(6,"0")}`,a.fillRect(0,0,t,e),a.strokeStyle="#000",a.strokeRect(0,0,t,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",t/2,e/2),re.Texture.from(i)}function rn(t,e){qa.set(t,e)}var re,Ga,Ua,Ee,A,Z,me,oe,sn,qa,Ce,St=K(()=>{"use strict";re=require("pixi.js");xt();Ga=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Ua=_o(),Ee=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,A=Ua?"publish":Ga,Z=Ee==null?void 0:Ee.assetsInlined;Ee!=null&&Ee.buildMode&&(A=Ee.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${A}`));me=Oo();me!=null&&me.buildMode&&(A=me.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${A}`));(me==null?void 0:me.assetsInlined)!==void 0&&(Z=me.assetsInlined);jo().then(t=>{t!=null&&t.buildMode&&t.buildMode!==A&&(A=t.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${A}`)),(t==null?void 0:t.assetsInlined)!==void 0&&(Z=t.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${Ga}, Runtime: ${Ua?"publish":"dev"}, Effective: ${A}`);oe={},sn=null;qa=new Map;Ce=class{static async load(e,n,i,a){let s=`${e}:${n.path}`,o=J.get(s);if(o!==void 0)return o;console.log(`[AssetLoader] Loading asset: ${e}, type: ${n.type}, Effective mode: ${A}`),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 r=await Ro(),l=r[e];if(!l&&a&&(l=r[a],l&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${a}`)),!l&&n.path){let c=n.path.split("/");if(c.length>=2){let h=c[c.length-1].split(".")[0];r[h]&&(l=r[h],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${h}`))}}if(console.log("[AssetLoader] Inline data for",e,":",l?"FOUND":"NOT FOUND"),A==="publish"&&Z!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!l))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${n.path}`);let p=qa.get(n.type);if(p)try{let c=await p(n.path,l,e,i);return J.set(s,c),c}catch(c){return this.handleFailure(e,n.type,c)}try{let c;switch(n.type){case"image":c=await this.loadImage(n.path,l);break;case"json":c=await this.loadJSON(n.path,l),c=on(c);break;default:throw new Error(`Unknown asset type: ${n.type}`)}return J.set(s,c),c}catch(c){return this.handleFailure(e,n.type,c)}}static async loadImage(e,n){let i=A==="publish",a=i&&Z!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${A}, isPublishMode: ${i}, inlineData: ${n?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!n)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof n!="string"||!n.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof n}`);try{return await re.Assets.load(n)}catch(s){throw console.error("[AssetLoader] Failed to load texture from data URI:",s),s}}if(n&&typeof n=="string"&&n.startsWith("data:"))try{return await re.Assets.load(n)}catch(s){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",s),await re.Assets.load(e)}return await re.Assets.load(e)}static async loadJSON(e,n){let i=A==="publish",a=i&&Z!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${A}, isPublishMode: ${i}, inlineData: ${n?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!n)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof n=="object"&&n!==null)return n;if(typeof n=="string"&&n.startsWith("data:")){let o=atob(n.split(",")[1]);return JSON.parse(o)}return JSON.parse(n)}if(n){if(typeof n=="object"&&n!==null)return n;if(typeof n=="string"&&n.startsWith("data:")){let o=atob(n.split(",")[1]);return JSON.parse(o)}return JSON.parse(n)}let s=await fetch(e);if(!s.ok)throw new Error(`JSON fetch failed: ${e}`);return s.json()}static handleFailure(e,n,i){if(A==="dev"){let s=n==="image"?zo():on({__placeholder:!0,type:n});return J.set(e+":"+((i==null?void 0:i.path)||"missing"),s),s}throw i}};rn("image",async(t,e)=>{let n=A==="publish",i=n&&Z!==!1,a=A==="brand",s=n&&Z===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${A}, isPublishMode: ${n}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return re.Assets.load(e)}let o=t;return(a||s)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(o=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${o}"`))),re.Assets.load(e||o)});rn("json",async(t,e)=>{let n=A==="publish",i=n&&Z!==!1,a=A==="brand",s=n&&Z===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${A}, isPublishMode: ${n}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let o=t;if((a||s)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(o=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${o}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let r=await fetch(o);if(!r.ok)throw new Error(`JSON fetch failed: ${t}`);return r.json()})});var cn,Bo,Et,Je=K(()=>{"use strict";St();cn=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,n){if(this.config===e&&this.app===n&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.attempted.clear(),this.waiters.clear(),this.priorityReadyPromise=new Promise(i=>{this.priorityReadyResolve=i}),this.config=e,this.app=n,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,n=this.app;return this.readyPromise=(async()=>{var o;console.log("[AssetTextures] Loading all assets...");let i=new Set(["background_loading_1"]),a=[],s=[];for(let[r,l]of e.objects.entries()){let d=(o=l.render)==null?void 0:o.asset;if(!d)continue;let p=async()=>{var c;try{let h=(c=l.identity)==null?void 0:c.id;console.log(`[AssetTextures] Loading ${d.type}: ${r} (${h})`);let u=await Ce.load(r,d,n,h);this.textures.set(r,u),console.log(`[AssetTextures] \u2713 Loaded: ${r}`)}catch(h){console.error(`[AssetTextures] \u2717 Failed to load: ${r}`,h)}finally{this.attempted.add(r);try{for(let h of Array.from(this.waiters))h()}catch{}}};i.has(r)?a.push(p()):s.push(p())}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,n={}){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(r=>typeof r=="string"&&r))).filter(r=>{var l,d,p,c;try{let h=(p=(d=(l=this.config)==null?void 0:l.objects)==null?void 0:d.get)==null?void 0:p.call(d,r);return!!((c=h==null?void 0:h.render)!=null&&c.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let s=()=>a.every(r=>this.textures.has(r)||this.attempted.has(r));if(s())return;let o=typeof n.timeoutMs=="number"?n.timeoutMs:15e3;await new Promise(r=>{let l=!1,d=()=>{l||s()&&(l=!0,this.waiters.delete(d),r())};this.waiters.add(d),d(),o>0&&setTimeout(()=>{l||(l=!0,this.waiters.delete(d),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),r())},o)})}get(e){return this.textures.get(e)}set(e,n){this.textures.set(e,n),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())}},Bo=new cn,Et=new Proxy(Bo,{get(t,e){return e in t&&typeof t[e]=="function"?t[e].bind(t):t.get(e)},set(t,e,n){return t.set(e,n),!0}})});var pr,Q=K(()=>{"use strict";pr="handler_preview_override_mode";if(typeof window!="undefined"){let t=window.localStorage.getItem(pr);window.__enableConfigOverrides=t===null?!0:t==="true"}});var Wa,Te,Pc,mn=K(()=>{"use strict";Q();Wa=null,Te="dev";if(typeof window!="undefined"){let t=window.__BUILD_SETTINGS__;if(t!=null&&t.buildMode)Wa=t,Te=t.buildMode,console.log("[CONFIG] Loaded inline build settings:",t,"buildMode:",Te);else try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let n=JSON.parse(e.responseText);Wa=n,Te=n.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",n,"buildMode:",Te)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",Te)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",Te);Pc=Te==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var fn=K(()=>{"use strict"});var Xa=K(()=>{"use strict";fn();mn()});var yn=K(()=>{"use strict";mn();fn();Xa()});var is={};da(is,{AssetEditorModal:()=>An});var An,Tn=K(()=>{"use strict";An=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,n,i,a){this.currentObjectId=e,this.currentPath=n,this.currentAsset=i,this.onApplyCallback=a,this.createModal(e,i),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,n){let i=document.createElement("div");i.className="asset-editor-modal",i.innerHTML=`
2
2
  <div class="asset-editor-card">
3
3
  <div class="asset-editor-header">
4
4
  <div>
@@ -94,7 +94,7 @@
94
94
  <button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
95
95
  </div>
96
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.image&&this.image.naturalWidth>0&&this.image.naturalHeight>0?(console.log("[AssetCropModal] Image loaded:",this.image.naturalWidth,"x",this.image.naturalHeight),this.initializeCrop(),this.render()):(console.error("[AssetCropModal] Image loaded but invalid dimensions"),this.showError("Failed to load image"))},this.image.onerror=e=>{console.error("[AssetCropModal] Image load error:",e),this.showError("Failed to load image. Please check the image URL.")},this.image.src=this.options.imageSrc,this.canvas&&this.ctx&&(this.ctx.fillStyle="rgba(128, 128, 128, 0.3)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 255, 255, 0.7)",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText("Loading image...",this.canvas.width/2,this.canvas.height/2)))}showError(e){var i;if(!this.canvas||!this.ctx)return;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 0, 0, 0.2)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="#ff4444",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText(e,this.canvas.width/2,this.canvas.height/2);let n=(i=this.modal)==null?void 0:i.querySelector(".asset-crop-preview-canvas");if(n){let a=n.getContext("2d");a&&(a.fillStyle="rgba(255, 0, 0, 0.2)",a.fillRect(0,0,n.width,n.height))}}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,n=this.canvas.width/this.canvas.height;e>n?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*n,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/n,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let n=this.image.width/this.image.height,i=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>n?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,i-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,n=this.canvas.height/this.cropHeight;this.scale=Math.min(e,n)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){if(!(!this.ctx||!this.canvas)){if(!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0){console.warn("[AssetCropModal] Image not ready for rendering"),this.showError("Image not loaded");return}this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);try{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()}catch(e){console.error("[AssetCropModal] Error drawing image:",e),this.showError("Error drawing image");return}this.drawCropOverlay(),this.updatePreview()}}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,n=this.panY,i=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,n,i,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,n,i,a),this.ctx.fillStyle="#ffffff";let s=8;[[e,n],[e+i-s,n],[e,n+a-s],[e+i-s,n+a-s]].forEach(([r,l])=>{var d;(d=this.ctx)==null||d.fillRect(r,l,s,s)})}updatePreview(){if(!this.modal||!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let n=e.getContext("2d");if(!n)return;let i=150;e.width=i,e.height=i,n.clearRect(0,0,i,i);let a=i/this.cropWidth,s=i/this.cropHeight,o=Math.min(a,s),r=this.cropWidth*o,l=this.cropHeight*o,d=(i-r)/2,p=(i-l)/2;try{n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,d,p,r,l)}catch(c){console.error("[AssetCropModal] Error drawing preview:",c),n.fillStyle="rgba(255, 0, 0, 0.2)",n.fillRect(0,0,i,i)}}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",i=>{let a=parseFloat(i.target.value);this.setZoom(a)});let n=this.modal.querySelector(".asset-crop-aspect-select");n==null||n.addEventListener("change",i=>{let a=i.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let n=e.clientX-this.dragStartX,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+n,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let n=e.deltaY>0?.9:1.1;this.setZoom(this.scale*n)}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 n=e.touches[0].clientX-this.dragStartX,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+n,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let n;switch(e){case"1:1":n=1;break;case"4:3":n=4/3;break;case"16:9":n=16/9;break;case"3:2":n=3/2;break;default:n=void 0}n&&this.applyAspectRatio(n),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),n=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),n&&(n.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,n=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-n,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"),n=e.getContext("2d");if(!n)return;e.width=this.cropWidth,e.height=this.cropHeight,n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let i=e.toDataURL("image/png");this.options.onCrop(i),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(t){new kn().open(t)}});var il={};da(il,{AspectClass:()=>Hn,GameObject:()=>ct,GameObjectManager:()=>Dt,Renderer:()=>lt,ResponsiveUISystem:()=>Ue,Transform:()=>rt,animateHandClick:()=>Es,animatePanelEntrance:()=>Ss,createBrushTexture:()=>Ms,createEndGamePanel:()=>xs,createHandTutorial:()=>Cs,createThreeBase:()=>bs,createTutorialLabel:()=>As,getAspectClass:()=>Ht,getRegisteredFontIds:()=>ws,loadAsset:()=>Fn,loadCharacterFrames:()=>Ps,registerFont:()=>vs,resolveFont:()=>te,resolveFontWeight:()=>ne,updateHandAnimation:()=>Ts});module.exports=Co(il);var W=he(require("three"),1);var ge={};function bt(t,e,n=!1){ge[t]||(ge[t]=[]),ge[t].push({fn:e,once:n})}function Zt(t,e){if(ge[t]){if(!e){delete ge[t];return}ge[t]=ge[t].filter(n=>n.fn!==e)}}function vt(t,...e){let n=ge[t];if(n)for(let i of[...n])i.fn(...e),i.once&&Zt(t,i.fn)}function B(t,e){bt(t,e,!0)}var M=null,V=[],_e=null;function ga(t){M=t,V=[],_e!==null&&(clearTimeout(_e),_e=null)}function ma(){var t,e,n;return{endpoint:(M==null?void 0:M.endpoint)||"",transport:(M==null?void 0:M.transport)||"beacon",batchSize:(t=M==null?void 0:M.batchSize)!=null?t:10,flushIntervalMs:(e=M==null?void 0:M.flushIntervalMs)!=null?e:300,maxQueue:(n=M==null?void 0:M.maxQueue)!=null?n:200,debug:!!(M!=null&&M.debug)}}async function ua(t,e,n,i){let a=JSON.stringify(e);if(n==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let s=navigator.sendBeacon(t,new Blob([a],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",s,e);return}catch(s){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",s)}try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(s){i&&console.warn("[handler.telemetry] fetch failed",s)}}function Qt(t,e){let n=ma();if(e&&n.endpoint){if(V.push(t),V.length>n.maxQueue&&(V=V.slice(V.length-n.maxQueue)),V.length>=n.batchSize){ha();return}_e===null&&(_e=window.setTimeout(()=>{_e=null,ha()},n.flushIntervalMs))}}async function ha(){let t=ma();if(!t.endpoint||V.length===0)return;let e=V.splice(0,t.batchSize);await ua(t.endpoint,{events:e},t.transport,t.debug),V.length>0&&await ua(t.endpoint,{events:V.splice(0,t.batchSize)},t.transport,t.debug)}function fa(t){return Math.max(0,Math.min(1,t))}function Ao(t){let e=String(t!=null?t:"power2.out");if(e==="linear")return n=>n;if(e==="sine.inOut")return n=>.5-Math.cos(Math.PI*n)/2;if(e==="power2.out"||e==="easeOutQuad")return n=>1-(1-n)*(1-n);if(e.startsWith("back.out")){let n=e.match(/back\.out\(([\d.]+)\)/),i=n?Number(n[1]):1.8;return a=>1+(i+1)*Math.pow(a-1,3)+i*Math.pow(a-1,2)}return n=>1-(1-n)*(1-n)}function Ye(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function To(t,e){let n=t==null?void 0:t[e];return typeof n=="number"?n:0}function ya(t,e,n){try{t[e]=n}catch{}}function Lo(t){let e=t==null?void 0:t.scale;if(!e)return null;let n=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:n,y:i}}function ba(t,e){let n=t==null?void 0:t.scale;if(n)try{typeof n.set=="function"?n.set(e.x,e.y):(typeof n.x=="number"&&(n.x=e.x),typeof n.y=="number"&&(n.y=e.y))}catch{}}function va(t,e){let n=Lo(t);if(!n)return{from:null,to:null};let i=null,a=null;return typeof e.scale=="number"?(i=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),i===null&&a===null?{from:null,to:null}:{from:{x:n.x,y:n.y},to:{x:i!=null?i:n.x,y:a!=null?a:n.y}}}function wa(){let t=new Set,e=new WeakMap,n=null,i=()=>{if(n!=null)return;n=requestAnimationFrame(()=>{n=null,r(),t.size>0&&i()})},a=p=>{var h;t.add(p);let c=(h=e.get(p.target))!=null?h:new Set;c.add(p),e.set(p.target,c),i()},s=p=>{t.delete(p);let c=e.get(p.target);c&&(c.delete(p),c.size===0&&e.delete(p.target))},o=p=>{p.killed||(p.killed=!0,s(p))},r=()=>{var c,h;let p=Ye();for(let u of Array.from(t)){if(u.killed||u.paused)continue;let m=p-u.startMs-u.delayMs;if(m<0)continue;let g=u.durationMs>0?m/u.durationMs:1,w=fa(g),v=u.repeat>=0?u.repeat+1:1,b=u.repeat>0?Math.min(Math.floor(g),v-1):0;if(u.repeat>0&&g>=1){let S=g-b;w=fa(S)}let f=u.ease(w);u.yoyo&&b%2===1&&(f=1-f);for(let S of u.props)ya(u.target,S.key,S.from+(S.to-S.from)*f);u.scaleFrom&&u.scaleTo&&ba(u.target,{x:u.scaleFrom.x+(u.scaleTo.x-u.scaleFrom.x)*f,y:u.scaleFrom.y+(u.scaleTo.y-u.scaleFrom.y)*f});try{(c=u.onUpdate)==null||c.call(u)}catch{}if(g>=v){o(u);try{(h=u.onComplete)==null||h.call(u)}catch{}}}},l=(p,c,h)=>{var S;let u=Math.max(0,(typeof c.duration=="number"?c.duration:.5)*1e3),m=Math.max(0,(typeof c.delay=="number"?c.delay:0)*1e3+((S=h==null?void 0:h.delayMsOverride)!=null?S:0)),g=Ao(c.ease),w=typeof c.repeat=="number"?Math.max(0,c.repeat|0):0,v=c.yoyo===!0,b=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),f=[];for(let E of Object.keys(c)){if(b.has(E))continue;let C=c[E];typeof C=="number"&&f.push({key:E,from:To(p,E),to:C})}let y=va(p,c);return{target:p,startMs:Ye(),delayMs:m,durationMs:u,ease:g,props:f,scaleFrom:y.from,scaleTo:y.to,repeat:w,yoyo:v,onUpdate:typeof c.onUpdate=="function"?c.onUpdate:void 0,onComplete:typeof c.onComplete=="function"?c.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},d={to(p,c){let h=l(p,c);return a(h),{kill:()=>o(h),pause:()=>{h.paused||(h.paused=!0,h.pauseAtMs=Ye())},resume:()=>{var g;if(!h.paused)return;let u=(g=h.pauseAtMs)!=null?g:Ye(),m=Ye()-u;h.startMs+=m,h.paused=!1,h.pauseAtMs=null},isActive:()=>!h.killed&&!h.paused}},fromTo(p,c,h){return d.set(p,c),d.to(p,h)},set(p,c){if(!p||!c)return;for(let u of Object.keys(c)){let m=c[u];u==="scale"||u==="scaleX"||u==="scaleY"||typeof m=="number"&&ya(p,u,m)}let h=va(p,c);h.to&&ba(p,h.to)},killTweensOf(p){let c=e.get(p);if(c)for(let h of Array.from(c))o(h)},timeline(p={}){let c=[],h=0,u=!1,m=[],g=b=>{if(typeof b=="number")return Math.max(0,b*1e3);let f=typeof b=="string"?b.trim():"";return f.startsWith("+=")?h+Math.max(0,Number(f.slice(2))*1e3||0):f?Math.max(0,Number(f)*1e3||0):h},w=b=>{c.push(b);let f=Math.max(0,(typeof b.vars.duration=="number"?b.vars.duration:.5)*1e3);h=Math.max(h,b.atMs+f)},v={to(b,f,y){return w({kind:"to",target:b,vars:f,atMs:g(y)}),v},fromTo(b,f,y,S){return w({kind:"fromTo",target:b,vars:y,from:f,atMs:g(S)}),v},play(){var b,f;if(u)return v;u=!0,m=[];for(let y of c)y.kind==="fromTo"&&d.set(y.target,(b=y.from)!=null?b:{}),m.push(d.to(y.target,{...y.vars,delay:y.atMs/1e3+((f=y.vars.delay)!=null?f:0)}));return v},pause(){for(let b of m)b.pause();return v},kill(){for(let b of m)b.kill();m=[],u=!1}};return p.paused||v.play(),v}};return d}function xa(){if(typeof window=="undefined")return;let t=window;if(!t.gsap)try{t.gsap=wa()}catch{}}var Sa={name:"handler-playable-sdk",version:"1.0.94",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 G=0,Po=G++,Ea=G++,Ca=G++,Aa=G++,Ta=G++,La=G++,ka=G++,Pa=G++,Ma=G++,Ia=G++,_a=G++,ja=G++,T=Po;function Oa(){return T===Ea}function Ra(){return T===Ca}function za(){return T===Aa}function $a(){return T===Ta}function je(){return T===La}function Oe(){return T===ka}function Ha(){return T===Pa}function Da(){return T===Ma}function Na(){return T===Ia}function en(){return T===_a}function tn(){return T===ja}function Fa(){let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(t==="mraid")try{mraid.getState(),T=Ea;return}catch{}else if(t==="dapi")try{dapi.isReady(),T=Ca;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(T=Aa)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(T=Ta)}catch{}else if(e==="mintegral")window.gameReady&&(T=La);else if(e==="tapjoy")window.TJ_API&&(T=ka);else if(e==="tiktok")window.openAppStore&&(T=Pa);else if(e==="smadex")try{window.smxTracking&&(T=Ma)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(T=Ia)}catch{}else e==="vungle"?T=_a:(t==="nucleo"||e==="nucleo")&&(T=ja)}var wt=he(require("lottie-web"),1),Ba=wt.default;typeof window!="undefined"&&(window.lottie=wt.default,window.__baseLottie=wt.default);var Mo=require("pixi.js");var nn=require("pixi.js");var Io=null;function an(t){Io=t}St();xt();var Xe=require("pixi.js");St();var $o=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",ln=$o;if(typeof window!="undefined")try{let t=new XMLHttpRequest;if(t.open("GET","./build-settings.json",!1),t.send(),t.status===200&&t.responseText){let e=JSON.parse(t.responseText);e!=null&&e.buildMode&&(ln=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${ln}`))}}catch{}function Ho(t){var n,i,a,s,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(t);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(t))return{x:(n=t[0])!=null?n:.5,y:(i=t[1])!=null?i:.5};if(t&&typeof t=="object"&&"x"in t&&"y"in t)return{x:(a=t.x)!=null?a:.5,y:(s=t.y)!=null?s:.5};if(typeof t=="string"){let r=t.trim().toLowerCase();return(o=e[r])!=null?o:{x:.5,y:.5}}return null}var fe=class{static async create(e,n,i){var l,d,p,c,h,u,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${ln}`);let a=(l=n==null?void 0:n.render)==null?void 0:l.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let g=new Xe.Container;return this.applyTransform(g,n==null?void 0:n.transform,n),g}let s=(d=n==null?void 0:n.identity)==null?void 0:d.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${s}, type: ${a.type}, path: ${a.path}`);let o=await Ce.load(e,a,i,s);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(p=o==null?void 0:o.constructor)==null?void 0:p.name}`);let r;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),r=new Xe.Sprite(o),console.log("[ObjectFactory] Created object:",r,"type:",(c=r==null?void 0:r.constructor)==null?void 0:c.name),this.applyTransform(r,n==null?void 0:n.transform,n);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(h=o==null?void 0:o.constructor)==null?void 0:h.name,o),o&&(((u=o.constructor)==null?void 0:u.name)==="Container"||o instanceof Xe.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let g=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],w=!1;for(let v of g)try{let b=await fetch(v);if(b.ok){r=await b.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",v,"type:",(m=r==null?void 0:r.constructor)==null?void 0:m.name),w=!0;break}}catch{continue}w||(console.error("[ObjectFactory] Failed to reload JSON from any path"),r=o)}else r=o;else r=o,r&&typeof r=="object"&&("x"in r||"position"in r)&&this.applyTransform(r,n==null?void 0:n.transform,n);return r}static applyTransform(e,n,i){var a,s,o,r;if(!(!n||!e)&&(n.position&&("x"in e&&"y"in e?(e.x=(a=n.position.x)!=null?a:0,e.y=(s=n.position.y)!=null?s:0):"position"in e&&e.position&&e.position.set((o=n.position.x)!=null?o:0,(r=n.position.y)!=null?r:0)),n.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(n.scale):e.scale=n.scale),n.rotation!==void 0&&"rotation"in e&&(e.rotation=n.rotation),n.anchor&&"anchor"in e&&e.anchor)){let l=Ho(n.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};var Ke=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 Fo=he(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=Fo);Je();var Ct=require("pixi.js");Je();var dn=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Ke}init(e,n){this.registry.init(e),this.app=n}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let n=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(n.length===0)return;let i=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async s=>{var r;let o=this.registry.get(s);if(!o){console.warn("[Assets] No config found for object:",s);return}try{let l=await fe.create(s,o,this.app);this.instanceCache.set(s,l),console.log("[Assets] Loaded object:",s,(r=l==null?void 0:l.constructor)==null?void 0:r.name)}catch(l){console.error("[Assets] Failed to load object:",s,l)}})))};return this.readyPromise=(async()=>{await i(n);let a=this.registry.getAllIds().filter(s=>!this.instanceCache.has(s));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let n=this.registry.get(e);if(n){let i=await fe.create(e,n,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},Go=new dn,Uo=new Proxy(Go,{get(t,e){if(e in t&&typeof t[e]=="function")return t[e].bind(t);if(t.get(e))return t.get(e)}});Je();var Wo=require("pixi.js"),le={width:400,height:600,designWidth:400,scaleFactor:1},Tt={scale:1,position:1},un=[];function Yo(t,e,n,i,a,s,o){un.push({element:t,originalScale:s,positionHelper:e,heightPercent:a}),e(t,n,i,a,s,o,!1)}function Xo(){un.forEach(({element:t,originalScale:e,positionHelper:n,heightPercent:i})=>{let a=e*le.scaleFactor;n(t,le.width,le.height,i,a,!0,!1)})}function pn(t,e){console.log(`[SCREEN] updateScreenState called: ${t}x${e}`),le.width=t,le.height=e,le.scaleFactor=Math.min(t/le.designWidth,1.15),Tt.scale=le.scaleFactor,Tt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Tt.scale.toFixed(3)}`),Xo()}var Qe={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 Ko(t,e,n){let i=Qe[t];i&&i[e]!==void 0&&(i[e]=n,console.log(`Updated ${t}.${e} = ${n}`))}function Jo(){return Qe}var Zo={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 At(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function et(t,e={x:.5,y:.5}){var n;if(Array.isArray(t))return{x:At(t[0],e.x),y:At(t[1],e.y)};if(t&&typeof t=="object"){let i=t;return{x:At(i.x,e.x),y:At(i.y,e.y)}}if(typeof t=="string"){let i=t.trim().toLowerCase();return(n=Zo[i])!=null?n:e}return e}function hn(t,e,n,i={}){var u,m,g,w,v,b;let a=et(n),s=(u=i.inset)!=null?u:{},o=(m=i.padding)!=null?m:{x:0,y:0},r=((g=s.left)!=null?g:0)+o.x,l=((w=s.right)!=null?w:0)+o.x,d=((v=s.top)!=null?v:0)+o.y,p=((b=s.bottom)!=null?b:0)+o.y,c=Math.max(0,t-r-l),h=Math.max(0,e-d-p);return{x:r+c*a.x,y:d+h*a.y}}function gn(t,e,n,i={}){var g,w,v,b,f,y;let a=(g=i.inset)!=null?g:{},s=(w=i.padding)!=null?w:{x:0,y:0},o=((v=a.left)!=null?v:0)+s.x,r=((b=a.right)!=null?b:0)+s.x,l=((f=a.top)!=null?f:0)+s.y,d=((y=a.bottom)!=null?y:0)+s.y,p=Math.max(0,t-o-r),c=Math.max(0,e-l-d),h=et(n,{x:.5,y:.5}),u=Math.min(Math.max(h.x,0),1),m=Math.min(Math.max(h.y,0),1);return{x:o+p*u,y:l+c*m}}if(typeof window!="undefined"){let t=window.innerWidth,e=window.innerHeight,n=()=>{let i=window.innerWidth,a=window.innerHeight;(i!==t||a!==e)&&(t=i,e=a,pn(i,a))};window.addEventListener("resize",n),window.addEventListener("orientationchange",()=>{setTimeout(n,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",n),window.mraid.addEventListener("sizeChange",n)),pn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Ko,window.getDebugConfig=Jo,window.copyConfig=cr,window.applyConfig=Ze,window.applyConfigForRatio=dr,window.positionAtBottom=Va,window.positionAtTop=tr,window.positionAtCenter=nr,window.positionAtLeft=ir,window.positionAtRight=ar,window.positionAtBottomLeft=sr,window.positionAtBottomRight=or,window.positionAtTopLeft=rr,window.positionAtTopRight=lr,window.applyPositionContract=er,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 Lt(t,e,n=0){return t*e+n}function kt(t,e,n=0){return t*(1-e)+n}function Pt(t,e,n=0){return t*e+n}function Mt(t,e,n=0){return t*(1-e)+n}function U(t,e=0){return t/2+e}function Qo(t,e){return t*e}function er(t,e,n,i){var o,r,l,d,p,c,h,u,m,g,w,v,b,f,y,S,E,C,P,_;let a=0,s=0;switch(i.type){case"top":a=U(e,(r=(o=i.offset)==null?void 0:o.x)!=null?r:0),s=Lt(n,i.percent,(d=(l=i.offset)==null?void 0:l.y)!=null?d:0);break;case"bottom":a=U(e,(c=(p=i.offset)==null?void 0:p.x)!=null?c:0),s=kt(n,i.percent,(u=(h=i.offset)==null?void 0:h.y)!=null?u:0);break;case"left":a=Pt(e,i.percent,(g=(m=i.offset)==null?void 0:m.x)!=null?g:0),s=U(n,(v=(w=i.offset)==null?void 0:w.y)!=null?v:0);break;case"right":a=Mt(e,i.percent,(f=(b=i.offset)==null?void 0:b.x)!=null?f:0),s=U(n,(S=(y=i.offset)==null?void 0:y.y)!=null?S:0);break;case"center":a=U(e,(C=(E=i.offset)==null?void 0:E.x)!=null?C:0),s=U(n,(_=(P=i.offset)==null?void 0:P.y)!=null?_:0);break}t.position?t.position.set(a,s):(t.x=a,t.y=s),i.scale!==void 0&&i.scale!==1&&t.scale&&(typeof t.scale.set=="function"?t.scale.set(i.scale,i.scale):(t.scale.x=i.scale,t.scale.y=i.scale))}function Va(t,e,n,i=.2,a=1,s=!0,o=!1){let r=Qo(n,i),l=kt(n,i/2);ce(t,U(e),l);let d=s?a*le.scaleFactor:a;de(t,d),o&&!un.find(p=>p.element===t)&&Yo(t,Va,e,n,i,a,s)}function tr(t,e,n,i=.1,a=1){ce(t,U(e),Lt(n,i)),de(t,a)}function nr(t,e,n,i=0,a=0,s=1){ce(t,U(e,i),U(n,a)),de(t,s)}function ir(t,e,n,i=.1,a=1){ce(t,Pt(e,i),U(n)),de(t,a)}function ar(t,e,n,i=.1,a=1){ce(t,Mt(e,i),U(n)),de(t,a)}function sr(t,e,n,i=.05,a=.05,s=1){ce(t,Pt(e,a),kt(n,i)),de(t,s)}function or(t,e,n,i=.05,a=.05,s=1){ce(t,Mt(e,a),kt(n,i)),de(t,s)}function rr(t,e,n,i=.05,a=.05,s=1){ce(t,Pt(e,a),Lt(n,i)),de(t,s)}function lr(t,e,n,i=.05,a=.05,s=1){ce(t,Mt(e,a),Lt(n,i)),de(t,s)}function ce(t,e,n){t&&t.position?typeof t.position.set=="function"?t.position.set(e,n):(t.position.x=e,t.position.y=n):t&&(t.x=e,t.y=n)}function de(t,e){e!==1&&t&&t.scale&&(typeof t.scale.set=="function"?t.scale.set(e,e):t.scale.x!==void 0&&t.scale.y!==void 0&&(t.scale.x=e,t.scale.y=e))}var Ae={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 cr(t){return t&&Ae[t]?JSON.parse(JSON.stringify(Ae[t])):JSON.parse(JSON.stringify(Qe))}function Ze(t){Object.keys(t).forEach(e=>{let n=e;Qe[n]&&t[n]&&Object.assign(Qe[n],t[n])}),console.log("Config applied:",t)}function dr(t,e){let n=t/e;n>1.6?(Ze(Ae.wide),console.log("Applied WIDE config for ratio:",n)):n<.7?(Ze(Ae.tall),console.log("Applied TALL config for ratio:",n)):n>.8&&n<1.2?(Ze(Ae.square),console.log("Applied SQUARE config for ratio:",n)):(Ze(Ae.default),console.log("Applied DEFAULT config for ratio:",n))}if(typeof window!="undefined"){let t=window;t.configPresets=Ae,t.resolveAnchorVec2=t.resolveAnchorVec2||et,t.resolveScreenAnchorPoint=t.resolveScreenAnchorPoint||hn,t.resolveScreenRatioPoint=t.resolveScreenRatioPoint||gn}yn();function I(t,e){let n=(a,s)=>s===0?a:n(s,a%s),i=n(t,e);return`${t/i}:${e/i}`}var Kc=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:I(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:I(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:I(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:I(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:I(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:I(360,780)}],Jc=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:I(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:I(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:I(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:I(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:I(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:I(412,915)}],Zc=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:I(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:I(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:I(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:I(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:I(800,1280)}],Ka=[{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:I(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:I(768,1024),mraidScale:.7}];var Qc=[...Ka];var br=Ka[0];Q();function wr(t){return new Promise((e,n)=>{let i=new FileReader;i.onerror=()=>n(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(t)})}function xr(t){var a;let[e,n]=t.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:n!=null?n:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}async function Sr(t){return await new Promise(e=>{let n=new Image;n.onload=()=>e({width:n.naturalWidth||n.width,height:n.naturalHeight||n.height}),n.onerror=()=>e(null),n.src=t})}async function vn(t){var e,n;try{console.log("[ImageUtils] Fetching image data from URL:",t);let i=await fetch(t);if(!i.ok)return console.warn("[ImageUtils] Fetch failed with status:",i.status,t),null;let a=await i.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let s=await wr(a),o=await Sr(s),r=xr(s);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",r.mimeType),{base64:r.base64,mimeType:r.mimeType,dataUrl:s,width:(e=o==null?void 0:o.width)!=null?e:0,height:(n=o==null?void 0:o.height)!=null?n:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function It(t,e=30){try{console.log("[ImageUtils] Removing background color...");let n=await new Promise((c,h)=>{let u=new Image;u.onload=()=>c(u),u.onerror=()=>h(new Error("Failed to load image")),u.src=t}),i=document.createElement("canvas");i.width=n.width,i.height=n.height;let a=i.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),t;a.drawImage(n,0,0);let s=a.getImageData(0,0,i.width,i.height),o=s.data,l=[{name:"top-left",offset:0},{name:"top-right",offset:(i.width-1)*4},{name:"bottom-left",offset:(i.height-1)*i.width*4},{name:"bottom-right",offset:((i.height-1)*i.width+(i.width-1))*4}].map(c=>({r:o[c.offset],g:o[c.offset+1],b:o[c.offset+2]})),d=0;for(let c=0;c<o.length;c+=4){let h=o[c],u=o[c+1],m=o[c+2],g=!1;for(let w of l)if(Math.sqrt(Math.pow(h-w.r,2)+Math.pow(u-w.g,2)+Math.pow(m-w.b,2))<e){g=!0;break}g&&(o[c+3]=0,d++)}return console.log(`[ImageUtils] Removed background from ${d} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(s,0,0),i.toDataURL("image/png")}catch(n){return console.error("[ImageUtils] Error removing background:",n),t}}var Za=require("@google/genai");async function wn(t,e,n=[],i={}){var a,s,o,r,l,d,p;try{if(!(t!=null&&t.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let v=0;v<n.length;v++){let b=n[v];if(!b.base64||!b.mimeType)throw new Error(`Image ${v+1} is missing required data`);if(b.base64.length<1e3&&console.warn(`Image ${v+1} data appears very small, may be corrupted`),!b.mimeType.startsWith("image/"))throw new Error(`Image ${v+1} has invalid MIME type: ${b.mimeType}`)}let c=new Za.GoogleGenAI({apiKey:t}),h="gemini-2.5-flash",u=[e];n.length>0&&n.forEach((v,b)=>{u.push({inlineData:{data:v.base64,mimeType:v.mimeType}}),console.log(`[Gemini] Added image ${b+1}: ${v.mimeType}, size: ${Math.round(v.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${n.length} images and prompt length: ${e.length}`);let m=await c.models.generateContent({model:h,contents:u}),g="",w=(o=(s=(a=m.candidates)==null?void 0:a[0])==null?void 0:s.content)==null?void 0:o.parts;if(w)for(let v of w)v.text&&(g+=v.text);if(!g.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${g.length}`),g}catch(c){throw console.error("[Gemini] API error:",c),(r=c.message)!=null&&r.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."):(l=c.message)!=null&&l.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(d=c.message)!=null&&d.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(p=c.message)!=null&&p.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):c}}var Qa=require("@google/genai");async function _t(t,e,n=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Qa.GoogleGenAI({apiKey:t}),s=[{text:e}];n.length>0&&n.forEach((r,l)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${l}`),s.push({inlineData:{mimeType:r.mimeType,data:r.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:s});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let r of o.candidates[0].content.parts)if(r.text)console.log(r.text);else if(r.inlineData){let l=r.inlineData.data,d=r.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${d};base64,${l}`}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 Er=require("pixi.js");Je();xt();Q();var ts=require("pixi.js");var Ar=require("pixi.js");Q();function zr(t){return new Promise((e,n)=>{let i=new FileReader;i.onerror=()=>n(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(t)})}function $r(t){var a;let[e,n]=t.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:n!=null?n:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}function Hr(t){return`
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.image&&this.image.naturalWidth>0&&this.image.naturalHeight>0?(console.log("[AssetCropModal] Image loaded:",this.image.naturalWidth,"x",this.image.naturalHeight),this.initializeCrop(),this.render()):(console.error("[AssetCropModal] Image loaded but invalid dimensions"),this.showError("Failed to load image"))},this.image.onerror=e=>{console.error("[AssetCropModal] Image load error:",e),this.showError("Failed to load image. Please check the image URL.")},this.image.src=this.options.imageSrc,this.canvas&&this.ctx&&(this.ctx.fillStyle="rgba(128, 128, 128, 0.3)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 255, 255, 0.7)",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText("Loading image...",this.canvas.width/2,this.canvas.height/2)))}showError(e){var i;if(!this.canvas||!this.ctx)return;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 0, 0, 0.2)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="#ff4444",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText(e,this.canvas.width/2,this.canvas.height/2);let n=(i=this.modal)==null?void 0:i.querySelector(".asset-crop-preview-canvas");if(n){let a=n.getContext("2d");a&&(a.fillStyle="rgba(255, 0, 0, 0.2)",a.fillRect(0,0,n.width,n.height))}}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,n=this.canvas.width/this.canvas.height;e>n?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*n,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/n,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let n=this.image.width/this.image.height,i=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>n?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,i-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,n=this.canvas.height/this.cropHeight;this.scale=Math.min(e,n)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){if(!(!this.ctx||!this.canvas)){if(!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0){console.warn("[AssetCropModal] Image not ready for rendering"),this.showError("Image not loaded");return}this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);try{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()}catch(e){console.error("[AssetCropModal] Error drawing image:",e),this.showError("Error drawing image");return}this.drawCropOverlay(),this.updatePreview()}}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,n=this.panY,i=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,n,i,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,n,i,a),this.ctx.fillStyle="#ffffff";let s=8;[[e,n],[e+i-s,n],[e,n+a-s],[e+i-s,n+a-s]].forEach(([r,l])=>{var d;(d=this.ctx)==null||d.fillRect(r,l,s,s)})}updatePreview(){if(!this.modal||!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let n=e.getContext("2d");if(!n)return;let i=150;e.width=i,e.height=i,n.clearRect(0,0,i,i);let a=i/this.cropWidth,s=i/this.cropHeight,o=Math.min(a,s),r=this.cropWidth*o,l=this.cropHeight*o,d=(i-r)/2,p=(i-l)/2;try{n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,d,p,r,l)}catch(c){console.error("[AssetCropModal] Error drawing preview:",c),n.fillStyle="rgba(255, 0, 0, 0.2)",n.fillRect(0,0,i,i)}}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",i=>{let a=parseFloat(i.target.value);this.setZoom(a)});let n=this.modal.querySelector(".asset-crop-aspect-select");n==null||n.addEventListener("change",i=>{let a=i.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let n=e.clientX-this.dragStartX,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+n,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let n=e.deltaY>0?.9:1.1;this.setZoom(this.scale*n)}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 n=e.touches[0].clientX-this.dragStartX,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+n,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let n;switch(e){case"1:1":n=1;break;case"4:3":n=4/3;break;case"16:9":n=16/9;break;case"3:2":n=3/2;break;default:n=void 0}n&&this.applyAspectRatio(n),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),n=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),n&&(n.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,n=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-n,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"),n=e.getContext("2d");if(!n)return;e.width=this.cropWidth,e.height=this.cropHeight,n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let i=e.toDataURL("image/png");this.options.onCrop(i),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(t){new kn().open(t)}});var il={};da(il,{AspectClass:()=>Hn,GameObject:()=>ct,GameObjectManager:()=>Dt,Renderer:()=>lt,ResponsiveUISystem:()=>Ue,Transform:()=>rt,animateHandClick:()=>Es,animatePanelEntrance:()=>Ss,createBrushTexture:()=>Ps,createEndGamePanel:()=>xs,createHandTutorial:()=>Cs,createThreeBase:()=>bs,createTutorialLabel:()=>As,getAspectClass:()=>Ht,getRegisteredFontIds:()=>ws,loadAsset:()=>Fn,loadCharacterFrames:()=>Is,registerFont:()=>vs,resolveFont:()=>te,resolveFontWeight:()=>ne,updateHandAnimation:()=>Ts});module.exports=Co(il);var W=he(require("three"),1);var ge={};function bt(t,e,n=!1){ge[t]||(ge[t]=[]),ge[t].push({fn:e,once:n})}function Zt(t,e){if(ge[t]){if(!e){delete ge[t];return}ge[t]=ge[t].filter(n=>n.fn!==e)}}function vt(t,...e){let n=ge[t];if(n)for(let i of[...n])i.fn(...e),i.once&&Zt(t,i.fn)}function B(t,e){bt(t,e,!0)}var P=null,V=[],_e=null;function ga(t){P=t,V=[],_e!==null&&(clearTimeout(_e),_e=null)}function ma(){var t,e,n;return{endpoint:(P==null?void 0:P.endpoint)||"",transport:(P==null?void 0:P.transport)||"beacon",batchSize:(t=P==null?void 0:P.batchSize)!=null?t:10,flushIntervalMs:(e=P==null?void 0:P.flushIntervalMs)!=null?e:300,maxQueue:(n=P==null?void 0:P.maxQueue)!=null?n:200,debug:!!(P!=null&&P.debug)}}async function ua(t,e,n,i){let a=JSON.stringify(e);if(n==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let s=navigator.sendBeacon(t,new Blob([a],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",s,e);return}catch(s){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",s)}try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(s){i&&console.warn("[handler.telemetry] fetch failed",s)}}function Qt(t,e){let n=ma();if(e&&n.endpoint){if(V.push(t),V.length>n.maxQueue&&(V=V.slice(V.length-n.maxQueue)),V.length>=n.batchSize){ha();return}_e===null&&(_e=window.setTimeout(()=>{_e=null,ha()},n.flushIntervalMs))}}async function ha(){let t=ma();if(!t.endpoint||V.length===0)return;let e=V.splice(0,t.batchSize);await ua(t.endpoint,{events:e},t.transport,t.debug),V.length>0&&await ua(t.endpoint,{events:V.splice(0,t.batchSize)},t.transport,t.debug)}function fa(t){return Math.max(0,Math.min(1,t))}function Ao(t){let e=String(t!=null?t:"power2.out");if(e==="linear")return n=>n;if(e==="sine.inOut")return n=>.5-Math.cos(Math.PI*n)/2;if(e==="power2.out"||e==="easeOutQuad")return n=>1-(1-n)*(1-n);if(e.startsWith("back.out")){let n=e.match(/back\.out\(([\d.]+)\)/),i=n?Number(n[1]):1.8;return a=>1+(i+1)*Math.pow(a-1,3)+i*Math.pow(a-1,2)}return n=>1-(1-n)*(1-n)}function Ye(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function To(t,e){let n=t==null?void 0:t[e];return typeof n=="number"?n:0}function ya(t,e,n){try{t[e]=n}catch{}}function Lo(t){let e=t==null?void 0:t.scale;if(!e)return null;let n=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:n,y:i}}function ba(t,e){let n=t==null?void 0:t.scale;if(n)try{typeof n.set=="function"?n.set(e.x,e.y):(typeof n.x=="number"&&(n.x=e.x),typeof n.y=="number"&&(n.y=e.y))}catch{}}function va(t,e){let n=Lo(t);if(!n)return{from:null,to:null};let i=null,a=null;return typeof e.scale=="number"?(i=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),i===null&&a===null?{from:null,to:null}:{from:{x:n.x,y:n.y},to:{x:i!=null?i:n.x,y:a!=null?a:n.y}}}function wa(){let t=new Set,e=new WeakMap,n=null,i=()=>{if(n!=null)return;n=requestAnimationFrame(()=>{n=null,r(),t.size>0&&i()})},a=p=>{var h;t.add(p);let c=(h=e.get(p.target))!=null?h:new Set;c.add(p),e.set(p.target,c),i()},s=p=>{t.delete(p);let c=e.get(p.target);c&&(c.delete(p),c.size===0&&e.delete(p.target))},o=p=>{p.killed||(p.killed=!0,s(p))},r=()=>{var c,h;let p=Ye();for(let u of Array.from(t)){if(u.killed||u.paused)continue;let m=p-u.startMs-u.delayMs;if(m<0)continue;let g=u.durationMs>0?m/u.durationMs:1,w=fa(g),v=u.repeat>=0?u.repeat+1:1,b=u.repeat>0?Math.min(Math.floor(g),v-1):0;if(u.repeat>0&&g>=1){let S=g-b;w=fa(S)}let f=u.ease(w);u.yoyo&&b%2===1&&(f=1-f);for(let S of u.props)ya(u.target,S.key,S.from+(S.to-S.from)*f);u.scaleFrom&&u.scaleTo&&ba(u.target,{x:u.scaleFrom.x+(u.scaleTo.x-u.scaleFrom.x)*f,y:u.scaleFrom.y+(u.scaleTo.y-u.scaleFrom.y)*f});try{(c=u.onUpdate)==null||c.call(u)}catch{}if(g>=v){o(u);try{(h=u.onComplete)==null||h.call(u)}catch{}}}},l=(p,c,h)=>{var S;let u=Math.max(0,(typeof c.duration=="number"?c.duration:.5)*1e3),m=Math.max(0,(typeof c.delay=="number"?c.delay:0)*1e3+((S=h==null?void 0:h.delayMsOverride)!=null?S:0)),g=Ao(c.ease),w=typeof c.repeat=="number"?Math.max(0,c.repeat|0):0,v=c.yoyo===!0,b=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),f=[];for(let E of Object.keys(c)){if(b.has(E))continue;let C=c[E];typeof C=="number"&&f.push({key:E,from:To(p,E),to:C})}let y=va(p,c);return{target:p,startMs:Ye(),delayMs:m,durationMs:u,ease:g,props:f,scaleFrom:y.from,scaleTo:y.to,repeat:w,yoyo:v,onUpdate:typeof c.onUpdate=="function"?c.onUpdate:void 0,onComplete:typeof c.onComplete=="function"?c.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},d={to(p,c){let h=l(p,c);return a(h),{kill:()=>o(h),pause:()=>{h.paused||(h.paused=!0,h.pauseAtMs=Ye())},resume:()=>{var g;if(!h.paused)return;let u=(g=h.pauseAtMs)!=null?g:Ye(),m=Ye()-u;h.startMs+=m,h.paused=!1,h.pauseAtMs=null},isActive:()=>!h.killed&&!h.paused}},fromTo(p,c,h){return d.set(p,c),d.to(p,h)},set(p,c){if(!p||!c)return;for(let u of Object.keys(c)){let m=c[u];u==="scale"||u==="scaleX"||u==="scaleY"||typeof m=="number"&&ya(p,u,m)}let h=va(p,c);h.to&&ba(p,h.to)},killTweensOf(p){let c=e.get(p);if(c)for(let h of Array.from(c))o(h)},timeline(p={}){let c=[],h=0,u=!1,m=[],g=b=>{if(typeof b=="number")return Math.max(0,b*1e3);let f=typeof b=="string"?b.trim():"";return f.startsWith("+=")?h+Math.max(0,Number(f.slice(2))*1e3||0):f?Math.max(0,Number(f)*1e3||0):h},w=b=>{c.push(b);let f=Math.max(0,(typeof b.vars.duration=="number"?b.vars.duration:.5)*1e3);h=Math.max(h,b.atMs+f)},v={to(b,f,y){return w({kind:"to",target:b,vars:f,atMs:g(y)}),v},fromTo(b,f,y,S){return w({kind:"fromTo",target:b,vars:y,from:f,atMs:g(S)}),v},play(){var b,f;if(u)return v;u=!0,m=[];for(let y of c)y.kind==="fromTo"&&d.set(y.target,(b=y.from)!=null?b:{}),m.push(d.to(y.target,{...y.vars,delay:y.atMs/1e3+((f=y.vars.delay)!=null?f:0)}));return v},pause(){for(let b of m)b.pause();return v},kill(){for(let b of m)b.kill();m=[],u=!1}};return p.paused||v.play(),v}};return d}function xa(){if(typeof window=="undefined")return;let t=window;if(!t.gsap)try{t.gsap=wa()}catch{}}var Sa={name:"handler-playable-sdk",version:"1.0.95",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 G=0,Io=G++,Ea=G++,Ca=G++,Aa=G++,Ta=G++,La=G++,ka=G++,Ia=G++,Pa=G++,Ma=G++,_a=G++,ja=G++,T=Io;function Oa(){return T===Ea}function Ra(){return T===Ca}function za(){return T===Aa}function $a(){return T===Ta}function je(){return T===La}function Oe(){return T===ka}function Ha(){return T===Ia}function Da(){return T===Pa}function Na(){return T===Ma}function en(){return T===_a}function tn(){return T===ja}function Fa(){let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(t==="mraid")try{mraid.getState(),T=Ea;return}catch{}else if(t==="dapi")try{dapi.isReady(),T=Ca;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(T=Aa)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(T=Ta)}catch{}else if(e==="mintegral")window.gameReady&&(T=La);else if(e==="tapjoy")window.TJ_API&&(T=ka);else if(e==="tiktok")window.openAppStore&&(T=Ia);else if(e==="smadex")try{window.smxTracking&&(T=Pa)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(T=Ma)}catch{}else e==="vungle"?T=_a:(t==="nucleo"||e==="nucleo")&&(T=ja)}var wt=he(require("lottie-web"),1),Ba=wt.default;typeof window!="undefined"&&(window.lottie=wt.default,window.__baseLottie=wt.default);var Po=require("pixi.js");var nn=require("pixi.js");var Mo=null;function an(t){Mo=t}St();xt();var Xe=require("pixi.js");St();var $o=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",ln=$o;if(typeof window!="undefined")try{let t=new XMLHttpRequest;if(t.open("GET","./build-settings.json",!1),t.send(),t.status===200&&t.responseText){let e=JSON.parse(t.responseText);e!=null&&e.buildMode&&(ln=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${ln}`))}}catch{}function Ho(t){var n,i,a,s,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(t);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(t))return{x:(n=t[0])!=null?n:.5,y:(i=t[1])!=null?i:.5};if(t&&typeof t=="object"&&"x"in t&&"y"in t)return{x:(a=t.x)!=null?a:.5,y:(s=t.y)!=null?s:.5};if(typeof t=="string"){let r=t.trim().toLowerCase();return(o=e[r])!=null?o:{x:.5,y:.5}}return null}var fe=class{static async create(e,n,i){var l,d,p,c,h,u,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${ln}`);let a=(l=n==null?void 0:n.render)==null?void 0:l.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let g=new Xe.Container;return this.applyTransform(g,n==null?void 0:n.transform,n),g}let s=(d=n==null?void 0:n.identity)==null?void 0:d.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${s}, type: ${a.type}, path: ${a.path}`);let o=await Ce.load(e,a,i,s);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(p=o==null?void 0:o.constructor)==null?void 0:p.name}`);let r;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),r=new Xe.Sprite(o),console.log("[ObjectFactory] Created object:",r,"type:",(c=r==null?void 0:r.constructor)==null?void 0:c.name),this.applyTransform(r,n==null?void 0:n.transform,n);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(h=o==null?void 0:o.constructor)==null?void 0:h.name,o),o&&(((u=o.constructor)==null?void 0:u.name)==="Container"||o instanceof Xe.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let g=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],w=!1;for(let v of g)try{let b=await fetch(v);if(b.ok){r=await b.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",v,"type:",(m=r==null?void 0:r.constructor)==null?void 0:m.name),w=!0;break}}catch{continue}w||(console.error("[ObjectFactory] Failed to reload JSON from any path"),r=o)}else r=o;else r=o,r&&typeof r=="object"&&("x"in r||"position"in r)&&this.applyTransform(r,n==null?void 0:n.transform,n);return r}static applyTransform(e,n,i){var a,s,o,r;if(!(!n||!e)&&(n.position&&("x"in e&&"y"in e?(e.x=(a=n.position.x)!=null?a:0,e.y=(s=n.position.y)!=null?s:0):"position"in e&&e.position&&e.position.set((o=n.position.x)!=null?o:0,(r=n.position.y)!=null?r:0)),n.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(n.scale):e.scale=n.scale),n.rotation!==void 0&&"rotation"in e&&(e.rotation=n.rotation),n.anchor&&"anchor"in e&&e.anchor)){let l=Ho(n.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};var Ke=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 Fo=he(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=Fo);Je();var Ct=require("pixi.js");Je();var dn=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Ke}init(e,n){this.registry.init(e),this.app=n}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let n=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(n.length===0)return;let i=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async s=>{var r;let o=this.registry.get(s);if(!o){console.warn("[Assets] No config found for object:",s);return}try{let l=await fe.create(s,o,this.app);this.instanceCache.set(s,l),console.log("[Assets] Loaded object:",s,(r=l==null?void 0:l.constructor)==null?void 0:r.name)}catch(l){console.error("[Assets] Failed to load object:",s,l)}})))};return this.readyPromise=(async()=>{await i(n);let a=this.registry.getAllIds().filter(s=>!this.instanceCache.has(s));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let n=this.registry.get(e);if(n){let i=await fe.create(e,n,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},Go=new dn,Uo=new Proxy(Go,{get(t,e){if(e in t&&typeof t[e]=="function")return t[e].bind(t);if(t.get(e))return t.get(e)}});Je();var Wo=require("pixi.js"),le={width:400,height:600,designWidth:400,scaleFactor:1},Tt={scale:1,position:1},un=[];function Yo(t,e,n,i,a,s,o){un.push({element:t,originalScale:s,positionHelper:e,heightPercent:a}),e(t,n,i,a,s,o,!1)}function Xo(){un.forEach(({element:t,originalScale:e,positionHelper:n,heightPercent:i})=>{let a=e*le.scaleFactor;n(t,le.width,le.height,i,a,!0,!1)})}function pn(t,e){console.log(`[SCREEN] updateScreenState called: ${t}x${e}`),le.width=t,le.height=e,le.scaleFactor=Math.min(t/le.designWidth,1.15),Tt.scale=le.scaleFactor,Tt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Tt.scale.toFixed(3)}`),Xo()}var Qe={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 Ko(t,e,n){let i=Qe[t];i&&i[e]!==void 0&&(i[e]=n,console.log(`Updated ${t}.${e} = ${n}`))}function Jo(){return Qe}var Zo={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 At(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function et(t,e={x:.5,y:.5}){var n;if(Array.isArray(t))return{x:At(t[0],e.x),y:At(t[1],e.y)};if(t&&typeof t=="object"){let i=t;return{x:At(i.x,e.x),y:At(i.y,e.y)}}if(typeof t=="string"){let i=t.trim().toLowerCase();return(n=Zo[i])!=null?n:e}return e}function hn(t,e,n,i={}){var u,m,g,w,v,b;let a=et(n),s=(u=i.inset)!=null?u:{},o=(m=i.padding)!=null?m:{x:0,y:0},r=((g=s.left)!=null?g:0)+o.x,l=((w=s.right)!=null?w:0)+o.x,d=((v=s.top)!=null?v:0)+o.y,p=((b=s.bottom)!=null?b:0)+o.y,c=Math.max(0,t-r-l),h=Math.max(0,e-d-p);return{x:r+c*a.x,y:d+h*a.y}}function gn(t,e,n,i={}){var g,w,v,b,f,y;let a=(g=i.inset)!=null?g:{},s=(w=i.padding)!=null?w:{x:0,y:0},o=((v=a.left)!=null?v:0)+s.x,r=((b=a.right)!=null?b:0)+s.x,l=((f=a.top)!=null?f:0)+s.y,d=((y=a.bottom)!=null?y:0)+s.y,p=Math.max(0,t-o-r),c=Math.max(0,e-l-d),h=et(n,{x:.5,y:.5}),u=Math.min(Math.max(h.x,0),1),m=Math.min(Math.max(h.y,0),1);return{x:o+p*u,y:l+c*m}}if(typeof window!="undefined"){let t=window.innerWidth,e=window.innerHeight,n=()=>{let i=window.innerWidth,a=window.innerHeight;(i!==t||a!==e)&&(t=i,e=a,pn(i,a))};window.addEventListener("resize",n),window.addEventListener("orientationchange",()=>{setTimeout(n,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",n),window.mraid.addEventListener("sizeChange",n)),pn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Ko,window.getDebugConfig=Jo,window.copyConfig=cr,window.applyConfig=Ze,window.applyConfigForRatio=dr,window.positionAtBottom=Va,window.positionAtTop=tr,window.positionAtCenter=nr,window.positionAtLeft=ir,window.positionAtRight=ar,window.positionAtBottomLeft=sr,window.positionAtBottomRight=or,window.positionAtTopLeft=rr,window.positionAtTopRight=lr,window.applyPositionContract=er,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 Lt(t,e,n=0){return t*e+n}function kt(t,e,n=0){return t*(1-e)+n}function It(t,e,n=0){return t*e+n}function Pt(t,e,n=0){return t*(1-e)+n}function U(t,e=0){return t/2+e}function Qo(t,e){return t*e}function er(t,e,n,i){var o,r,l,d,p,c,h,u,m,g,w,v,b,f,y,S,E,C,I,_;let a=0,s=0;switch(i.type){case"top":a=U(e,(r=(o=i.offset)==null?void 0:o.x)!=null?r:0),s=Lt(n,i.percent,(d=(l=i.offset)==null?void 0:l.y)!=null?d:0);break;case"bottom":a=U(e,(c=(p=i.offset)==null?void 0:p.x)!=null?c:0),s=kt(n,i.percent,(u=(h=i.offset)==null?void 0:h.y)!=null?u:0);break;case"left":a=It(e,i.percent,(g=(m=i.offset)==null?void 0:m.x)!=null?g:0),s=U(n,(v=(w=i.offset)==null?void 0:w.y)!=null?v:0);break;case"right":a=Pt(e,i.percent,(f=(b=i.offset)==null?void 0:b.x)!=null?f:0),s=U(n,(S=(y=i.offset)==null?void 0:y.y)!=null?S:0);break;case"center":a=U(e,(C=(E=i.offset)==null?void 0:E.x)!=null?C:0),s=U(n,(_=(I=i.offset)==null?void 0:I.y)!=null?_:0);break}t.position?t.position.set(a,s):(t.x=a,t.y=s),i.scale!==void 0&&i.scale!==1&&t.scale&&(typeof t.scale.set=="function"?t.scale.set(i.scale,i.scale):(t.scale.x=i.scale,t.scale.y=i.scale))}function Va(t,e,n,i=.2,a=1,s=!0,o=!1){let r=Qo(n,i),l=kt(n,i/2);ce(t,U(e),l);let d=s?a*le.scaleFactor:a;de(t,d),o&&!un.find(p=>p.element===t)&&Yo(t,Va,e,n,i,a,s)}function tr(t,e,n,i=.1,a=1){ce(t,U(e),Lt(n,i)),de(t,a)}function nr(t,e,n,i=0,a=0,s=1){ce(t,U(e,i),U(n,a)),de(t,s)}function ir(t,e,n,i=.1,a=1){ce(t,It(e,i),U(n)),de(t,a)}function ar(t,e,n,i=.1,a=1){ce(t,Pt(e,i),U(n)),de(t,a)}function sr(t,e,n,i=.05,a=.05,s=1){ce(t,It(e,a),kt(n,i)),de(t,s)}function or(t,e,n,i=.05,a=.05,s=1){ce(t,Pt(e,a),kt(n,i)),de(t,s)}function rr(t,e,n,i=.05,a=.05,s=1){ce(t,It(e,a),Lt(n,i)),de(t,s)}function lr(t,e,n,i=.05,a=.05,s=1){ce(t,Pt(e,a),Lt(n,i)),de(t,s)}function ce(t,e,n){t&&t.position?typeof t.position.set=="function"?t.position.set(e,n):(t.position.x=e,t.position.y=n):t&&(t.x=e,t.y=n)}function de(t,e){e!==1&&t&&t.scale&&(typeof t.scale.set=="function"?t.scale.set(e,e):t.scale.x!==void 0&&t.scale.y!==void 0&&(t.scale.x=e,t.scale.y=e))}var Ae={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 cr(t){return t&&Ae[t]?JSON.parse(JSON.stringify(Ae[t])):JSON.parse(JSON.stringify(Qe))}function Ze(t){Object.keys(t).forEach(e=>{let n=e;Qe[n]&&t[n]&&Object.assign(Qe[n],t[n])}),console.log("Config applied:",t)}function dr(t,e){let n=t/e;n>1.6?(Ze(Ae.wide),console.log("Applied WIDE config for ratio:",n)):n<.7?(Ze(Ae.tall),console.log("Applied TALL config for ratio:",n)):n>.8&&n<1.2?(Ze(Ae.square),console.log("Applied SQUARE config for ratio:",n)):(Ze(Ae.default),console.log("Applied DEFAULT config for ratio:",n))}if(typeof window!="undefined"){let t=window;t.configPresets=Ae,t.resolveAnchorVec2=t.resolveAnchorVec2||et,t.resolveScreenAnchorPoint=t.resolveScreenAnchorPoint||hn,t.resolveScreenRatioPoint=t.resolveScreenRatioPoint||gn}yn();function M(t,e){let n=(a,s)=>s===0?a:n(s,a%s),i=n(t,e);return`${t/i}:${e/i}`}var Kc=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:M(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:M(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:M(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:M(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:M(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:M(360,780)}],Jc=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:M(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:M(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:M(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:M(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:M(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:M(412,915)}],Zc=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:M(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:M(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:M(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:M(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:M(800,1280)}],Ka=[{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:M(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:M(768,1024),mraidScale:.7}];var Qc=[...Ka];var br=Ka[0];Q();function wr(t){return new Promise((e,n)=>{let i=new FileReader;i.onerror=()=>n(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(t)})}function xr(t){var a;let[e,n]=t.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:n!=null?n:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}async function Sr(t){return await new Promise(e=>{let n=new Image;n.onload=()=>e({width:n.naturalWidth||n.width,height:n.naturalHeight||n.height}),n.onerror=()=>e(null),n.src=t})}async function vn(t){var e,n;try{console.log("[ImageUtils] Fetching image data from URL:",t);let i=await fetch(t);if(!i.ok)return console.warn("[ImageUtils] Fetch failed with status:",i.status,t),null;let a=await i.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let s=await wr(a),o=await Sr(s),r=xr(s);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",r.mimeType),{base64:r.base64,mimeType:r.mimeType,dataUrl:s,width:(e=o==null?void 0:o.width)!=null?e:0,height:(n=o==null?void 0:o.height)!=null?n:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function Mt(t,e=30){try{console.log("[ImageUtils] Removing background color...");let n=await new Promise((c,h)=>{let u=new Image;u.onload=()=>c(u),u.onerror=()=>h(new Error("Failed to load image")),u.src=t}),i=document.createElement("canvas");i.width=n.width,i.height=n.height;let a=i.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),t;a.drawImage(n,0,0);let s=a.getImageData(0,0,i.width,i.height),o=s.data,l=[{name:"top-left",offset:0},{name:"top-right",offset:(i.width-1)*4},{name:"bottom-left",offset:(i.height-1)*i.width*4},{name:"bottom-right",offset:((i.height-1)*i.width+(i.width-1))*4}].map(c=>({r:o[c.offset],g:o[c.offset+1],b:o[c.offset+2]})),d=0;for(let c=0;c<o.length;c+=4){let h=o[c],u=o[c+1],m=o[c+2],g=!1;for(let w of l)if(Math.sqrt(Math.pow(h-w.r,2)+Math.pow(u-w.g,2)+Math.pow(m-w.b,2))<e){g=!0;break}g&&(o[c+3]=0,d++)}return console.log(`[ImageUtils] Removed background from ${d} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(s,0,0),i.toDataURL("image/png")}catch(n){return console.error("[ImageUtils] Error removing background:",n),t}}var Za=require("@google/genai");async function wn(t,e,n=[],i={}){var a,s,o,r,l,d,p;try{if(!(t!=null&&t.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let v=0;v<n.length;v++){let b=n[v];if(!b.base64||!b.mimeType)throw new Error(`Image ${v+1} is missing required data`);if(b.base64.length<1e3&&console.warn(`Image ${v+1} data appears very small, may be corrupted`),!b.mimeType.startsWith("image/"))throw new Error(`Image ${v+1} has invalid MIME type: ${b.mimeType}`)}let c=new Za.GoogleGenAI({apiKey:t}),h="gemini-2.5-flash",u=[e];n.length>0&&n.forEach((v,b)=>{u.push({inlineData:{data:v.base64,mimeType:v.mimeType}}),console.log(`[Gemini] Added image ${b+1}: ${v.mimeType}, size: ${Math.round(v.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${n.length} images and prompt length: ${e.length}`);let m=await c.models.generateContent({model:h,contents:u}),g="",w=(o=(s=(a=m.candidates)==null?void 0:a[0])==null?void 0:s.content)==null?void 0:o.parts;if(w)for(let v of w)v.text&&(g+=v.text);if(!g.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${g.length}`),g}catch(c){throw console.error("[Gemini] API error:",c),(r=c.message)!=null&&r.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."):(l=c.message)!=null&&l.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(d=c.message)!=null&&d.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(p=c.message)!=null&&p.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):c}}var Qa=require("@google/genai");async function _t(t,e,n=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Qa.GoogleGenAI({apiKey:t}),s=[{text:e}];n.length>0&&n.forEach((r,l)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${l}`),s.push({inlineData:{mimeType:r.mimeType,data:r.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:s});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let r of o.candidates[0].content.parts)if(r.text)console.log(r.text);else if(r.inlineData){let l=r.inlineData.data,d=r.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${d};base64,${l}`}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 Er=require("pixi.js");Je();xt();Q();var ts=require("pixi.js");var Ar=require("pixi.js");Q();function zr(t){return new Promise((e,n)=>{let i=new FileReader;i.onerror=()=>n(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(t)})}function $r(t){var a;let[e,n]=t.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:n!=null?n:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}function Hr(t){return`
98
98
  Analyze these screenshots of a brand or game and extract its "Brand DNA".
99
99
 
100
100
  Provide a concise summary (2-3 sentences) covering:
@@ -213,7 +213,7 @@ Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),n={summary:d,palette:p.slice(0
213
213
  </div>
214
214
  `,this.modal=e,this.attachEventListeners(),this.updatePromptFromDna()}attachEventListeners(){var i;if(!this.modal)return;this.promptInput=this.modal.querySelector(".ai-textarea"),this.generateBtn=this.modal.querySelector('[data-action="generate"]'),this.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]"),(i=this.promptInput)==null||i.addEventListener("input",()=>{var a;this.currentPrompt=((a=this.promptInput)==null?void 0:a.value)||"",this.updateGenerateButton()});let e=this.modal.querySelector('[data-strength="creativity"]'),n=this.modal.querySelector(".ai-strength-value");e==null||e.addEventListener("input",()=>{n.textContent=e.value}),this.modal.addEventListener("click",a=>{var r;let s=a.target;switch(s.dataset.action||((r=s.closest("[data-action]"))==null?void 0:r.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 o=s.closest(".ai-gallery-item"),r=parseInt(o.dataset.index||"-1");r>=0&&this.selectImage(r)}}),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 n;let e=(n=this.modal)==null?void 0:n.querySelector("#ai-use-dna");if(e!=null&&e.checked)try{let i=this.analyzer.getResult();if(i!=null&&i.summary&&this.promptInput){let a=`${this.currentPrompt}
215
215
 
216
- Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}catch(i){console.warn("[AiEditorModal] Failed to apply brand DNA:",i)}}async generateImage(){var e,n,i,a;if(!(!this.options||this.isGenerating)){this.isGenerating=!0,this.updateGenerateButton(),(e=this.loadingEl)==null||e.classList.remove("hidden"),(n=this.previewEl)==null||n.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 o=[];if(this.options.currentValue&&this.options.currentValue.startsWith("data:"))try{let d=await vn(this.options.currentValue);d&&(o=[{base64:d.base64,mimeType:d.mimeType}])}catch(d){console.warn("[AiEditorModal] Failed to load current image:",d)}let r=await _t(s,this.currentPrompt,o,{aspectRatio:"1:1"}),l=await It(r);this.generatedImages.push(l||r),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,(i=this.loadingEl)==null||i.classList.add("hidden"),(a=this.previewEl)==null||a.classList.remove("hidden"),this.updateGenerateButton()}}}updateGallery(){if(!this.galleryEl)return;let e=this.galleryEl.querySelector("[data-gallery-grid]");e&&(e.innerHTML=this.generatedImages.map((n,i)=>{let a=this.savedLibraryPaths.has(i),s=a?this.savedLibraryPaths.get(i):null,o=s?s.split("/").pop():"";return`
216
+ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}catch(i){console.warn("[AiEditorModal] Failed to apply brand DNA:",i)}}async generateImage(){var e,n,i,a;if(!(!this.options||this.isGenerating)){this.isGenerating=!0,this.updateGenerateButton(),(e=this.loadingEl)==null||e.classList.remove("hidden"),(n=this.previewEl)==null||n.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 o=[];if(this.options.currentValue&&this.options.currentValue.startsWith("data:"))try{let d=await vn(this.options.currentValue);d&&(o=[{base64:d.base64,mimeType:d.mimeType}])}catch(d){console.warn("[AiEditorModal] Failed to load current image:",d)}let r=await _t(s,this.currentPrompt,o,{aspectRatio:"1:1"}),l=await Mt(r);this.generatedImages.push(l||r),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,(i=this.loadingEl)==null||i.classList.add("hidden"),(a=this.previewEl)==null||a.classList.remove("hidden"),this.updateGenerateButton()}}}updateGallery(){if(!this.galleryEl)return;let e=this.galleryEl.querySelector("[data-gallery-grid]");e&&(e.innerHTML=this.generatedImages.map((n,i)=>{let a=this.savedLibraryPaths.has(i),s=a?this.savedLibraryPaths.get(i):null,o=s?s.split("/").pop():"";return`
217
217
  <div class="ai-gallery-item ${i===this.selectedImageIndex?"active":""}" data-index="${i}">
218
218
  <img class="ai-gallery-thumb" src="${n}" alt="Generated ${i+1}" />
219
219
  <div class="ai-gallery-label">#${i+1}${a?" \u2713":""}</div>
@@ -246,7 +246,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
246
246
  <source src="${a}" type="audio/wav">
247
247
  Your browser does not support the audio element.
248
248
  </audio>
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 ${n} assets</div>`}}resolveAssetUrl(e){return e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("/")?e:`/raw/${e}`}attachEventListeners(){if(!this.modal)return;this.modal.addEventListener("click",i=>{let a=i.target;(a.dataset.action==="close"||a===this.modal)&&this.close()});let e=this.modal.querySelector('[data-action="change"]');e&&e.addEventListener("click",()=>{this.openAssetEditor()});let n=this.modal.querySelector('[data-action="edit"]');n&&n.addEventListener("click",()=>{this.openAiEditor(),this.close()})}openAssetEditor(){this.options&&Promise.resolve().then(()=>(Tn(),is)).then(({AssetEditorModal:e})=>{new e().show(this.options.objectId||"unknown",this.options.propertyPath||"",this.options.assetPath,i=>{var a;(a=this.options)!=null&&a.onChange&&this.options.onChange(i),this.close()})})}openAiEditor(){if(!this.options||this.options.assetType!=="image")return;let e=window.__openAiEditor;typeof e=="function"&&e(this.options.objectId||"asset","Edit this image asset",this.options.assetPath,{path:this.options.propertyPath,onApply:n=>{var i;(i=this.options)!=null&&i.onChange&&this.options.onChange(n)}})}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.options=null}};window.openAssetPreview=function(t){new Ln().open(t)};as();Q();var ke=require("pixi.js");Q();Q();Q();var ss=he(require("lottie-web"),1);an(Ba);typeof window!="undefined"&&!window.lottie&&(window.lottie=ss.default);yn();Q();var Pn=Sa.version,Fr=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"]);xa();var us={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"},hs=Math.random().toString(36).slice(2),De=null,$e={...us},gs="web_embed",jn={},nt,Mn=!1,tt=!1,at=!1,ms=!1,$n=1,Ot=0,$t=!1,pe=!1,He="",Ne=Math.floor(window.innerWidth),Fe=Math.floor(window.innerHeight),On=Ne>Fe,ue=!1,it=!1,os=!1,rs=!1,In=!1,Rt=null,Pe=null,Rn=!1,zn=!1,jt=new Map;function fs(){if(!Pe)return null;let t=Date.now()-Pe;return!Number.isFinite(t)||t<0?null:t}function _n(t){if(Rn)return;let e=fs();e!==null&&(Rn=!0,x("session_time",{duration_ms:e,reason:t}))}function ls(){if(De)return De;let t=document.createElement("div");return t.id="handler-root",t.setAttribute("data-handler-root","true"),document.body.appendChild(t),De=t,t}function zt(t){switch(t){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return t}}function ys(t,e){return{event_name:t,ts:Date.now(),session_id:hs,deployment_id:$e.deployment_id,variant_id:$e.variant_id,export_profile_id:$e.profile_id,instance_id:$e.instance_id||"default",env:gs==="mraid"?"mraid":"web",attribution:nt,payload:e}}function x(t,e){let n=zt(t),i=ys(n,e);Qt(i,!!jn.analytics),vt(n,i),n!==t&&vt(t,i)}function st(){Rt&&(Rt(Ne,Fe),Rt=null)}function Be(t){$n=t,x("volume",t)}function Ge(t){t&&(ms=!0),!at&&(at=!0,x("pause"),Be(0))}function ot(t){!t&&ms||at&&(at=!1,x("resume"),Be($n))}function ye(t,e){Ne=Math.floor(t||window.innerWidth),Fe=Math.floor(e||window.innerHeight),On=Ne>Fe,x("resize",{width:Ne,height:Fe})}function Br(){if(Oa())try{let t=mraid.getMaxSize();ye(t.width,t.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ot():Ge()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ye(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();Be(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&Be(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),$t=!0,mraid.isViewable()&&mraid.getState()!=="hidden")ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st();else{let n=()=>{ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st()};mraid.addEventListener("ready",n)}}catch(t){console.warn("MRAID hook skipped",t)}}function Gr(){if(Ra())try{let t=dapi.getScreenSize();ye(t.width,t.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ot():Ge()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();ye(n.width||i.width,n.height||i.height)});let e=dapi.getAudioVolume();if(Be(e?1:0),dapi.addEventListener("audioVolumeChange",n=>Be(n?1:0)),$t=!0,dapi.isViewable())ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st();else{let n=()=>{ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st()};dapi.addEventListener("ready",n)}}catch(t){console.warn("DAPI hook skipped",t)}}function cs(){let t=()=>{ue||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st(),it&&(it=!1,ee.start()))};window.addEventListener("resize",()=>ye()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ot(),t()):Ge()}),document.readyState==="complete"||document.readyState==="interactive"?t():window.addEventListener("load",t),$t=!0}function Ur(){let t=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(os=!0),!(os&&e instanceof MouseEvent)&&(Ot+=1,zn||(zn=!0,x("first_interaction",{count:Ot})),x("interaction",Ot))};document.addEventListener("mousedown",t),document.addEventListener("touchstart",t)}function ds(t){var i,a,s,o,r,l,d,p,c,h,u,m;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(t||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(Oe())(s=(a=window.TJ_API)==null?void 0:a.click)==null||s.call(a);else if(za())(r=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||r.call(o);else if(Na())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Da())try{(c=(p=window.smxTracking)==null?void 0:p.redirect)==null||c.call(p)}catch(g){console.warn("Smadex redirect failed",g)}else if($a()){let g=window.ExitApi;g&&typeof g.exit=="function"?g.exit(t||He||""):t&&window.open(t)}else je()?(h=window.install)==null||h.call(window):Ha()?(u=window.openAppStore)==null||u.call(window):en()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):t&&window.open(t)}function qr(){let t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=n=>{if(!n)return;let i=new Image;i.src=n};if(t==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;B("view",()=>e(n.mraid_viewable)),B("start",()=>e(n.game_viewable)),B("engagement",()=>e(n.engagement));let i=()=>e(n.complete);B("complete",i),bt("engagement",a=>{var s;((s=a==null?void 0:a.payload)==null?void 0:s.count)>3&&i()}),B("cta_click",()=>e(n.click))}else if(t==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;B("view",()=>e(n.Ad_Load_Start)),B("start",()=>e(n.Ad_Viewable)),B("engagement",()=>e(n.First_Engagement)),B("complete",()=>e(n.Gameplay_Complete)),B("cta_click",()=>e(n.DSP_Click)),B("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>e(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Vr(){if(!Oe())return;let t=window.TJ_API;t&&t.setPlayableAPI&&t.setPlayableAPI({skipAd:()=>{try{ee.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function ps(){var e,n,i;let t=window.TJ_API;(e=t==null?void 0:t.objectiveComplete)==null||e.call(t),(n=t==null?void 0:t.playableFinished)==null||n.call(t),(i=t==null?void 0:t.gameplayFinished)==null||i.call(t)}function Wr(){je()&&(window.mintGameStart=()=>{ot(!0),ye()},window.mintGameClose=()=>{Ge(!0)})}function Yr(){if(!tn())return;let t=window.NUC;!t||!t.trigger||(ee.on("cta_click",()=>{var e,n;return(n=(e=t.trigger).convert)==null?void 0:n.call(e,He)}),ee.on("complete",()=>{var e,n;return(n=(e=t.trigger).tryAgain)==null?void 0:n.call(e)}))}var ee={init(t={},e){var n;if(gs=t.profile||"web_embed",jn=t.consent||{},$e={...us,...t.ids||{}},De=t.rootEl||De,nt=void 0,ga((n=t.telemetry)!=null&&n.endpoint?t.telemetry:null),Pe=null,Rn=!1,zn=!1,jt.clear(),He=t.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Rt=e),x("init"),document.body.oncontextmenu=()=>!1,ls(),Kr(De),Fa(),Br(),Gr(),!$t){if(document.readyState==="complete")cs();else if(!rs){rs=!0;let i=()=>{cs(),window.removeEventListener("load",i),document.removeEventListener("DOMContentLoaded",i)};window.addEventListener("load",i),document.addEventListener("DOMContentLoaded",i)}}Ur(),qr(),Vr(),Wr(),Yr(),console.log(`%c @handler/playable-sdk %c v${Pn} `,"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;"),ue&&!pe&&(x("boot"),x("view"),x("ready"),it&&(it=!1,ee.start()),pe=!0),pe=ue},getRoot(){return ls()},get version(){return Pn},get maxWidth(){return Ne},get maxHeight(){return Fe},get isLandscape(){return On},get isReady(){return pe},get isStarted(){return Mn},get isPaused(){return at},get isFinished(){return tt},get volume(){return $n},get interactions(){return Ot},on(t,e){bt(zt(t),e)},off(t,e){Zt(zt(t),e)},start(){var t,e;if(!Mn){if(!ue){it=!0;return}if(Mn=!0,Pe||(Pe=Date.now()),x("start"),ye(),je())Ge(),(t=window.gameReady)==null||t.call(window);else if(Oe()){let n=window.TJ_API;(e=n==null?void 0:n.setPlayableBuild)==null||e.call(n,{orientation:On?"landscape":"portrait",buildID:Pn})}}},finish(){var t,e;tt||(tt=!0,x("complete"),_n("complete"),je()?(t=window.gameEnd)==null||t.call(window):en()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Oe()&&ps())},install(t){if(!tt){tt=!0,Oe()?(ps(),setTimeout(()=>ee.install(t),300)):(x("complete"),setTimeout(()=>ee.install(t),0));return}In||(In=!0,setTimeout(()=>In=!1,500),x("cta_click"),x("conversion"),_n("cta"),ds(t||He))},emit(t,e){let n=zt(t);if(!Fr.has(n)&&n!=="resize"&&n!=="volume"&&!n.startsWith("custom."))throw new Error(`Event ${t} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=ys(n,e);Qt(i,!!jn.analytics),vt(n,i)},gameStart(){ee.start()},gameEnd(){ee.finish()},ctaClick(t,e){x("cta_click",{url:t||He,manual:!0}),(e==null?void 0:e.open)!==!1&&ds(t||He)},ctaShow(t){x("cta_show",t)},ctaDismiss(t){x("cta_dismiss",t)},getGameTimeMs(){return fs()},endSession(t="manual"){_n(t)},setAttribution(t){nt=t},abTest(t,e){if(!t)throw new Error("abTest requires experimentId");if(!Array.isArray(e)||e.length<2)throw new Error("abTest requires at least 2 variants");let n=Math.abs(Xr(`${hs}:${t}`))%e.length,i=e[n];return nt={...nt||{},experiment_id:t},$e.variant_id=i,x("ab_assign",{experiment_id:t,variant_id:i}),i},levelStart(t,e){Pe||(Pe=Date.now()),x("level_start",{level_id:t,...e})},levelComplete(t,e){x("level_complete",{level_id:t,...e})},levelFail(t,e){x("level_fail",{level_id:t,...e})},checkpoint(t,e){x("checkpoint",{checkpoint_id:t,...e})},reward(t,e){x("reward",{reward_id:t,...e})},tutorialStart(t,e){x("tutorial_start",{step_id:t,...e})},tutorialComplete(t,e){x("tutorial_complete",{step_id:t,...e})},tutorialSkip(t,e){x("tutorial_skip",{step_id:t,...e})},timerStart(t){t&&jt.set(t,Date.now())},timerEnd(t,e="custom",n){if(!t)return;let i=jt.get(t);if(!i)return;jt.delete(t);let a=Date.now()-i;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){x("engagement",{action:"timer",key:t,duration_ms:a,...n});return}x(e,{key:t,duration_ms:a,...n})}},fps(t,e){x("fps",{value:t,...e})},memory(t,e){x("memory",{bytes:t,...e})},assetLoadStart(t,e){x("asset_load_start",{asset_id:t,...e})},assetLoadComplete(t,e){x("asset_load_complete",{asset_id:t,...e})},reportError(t,e,n){x("error",{code:t,message:e,...n})},retry(){var t,e,n;if(je())(t=window.gameRetry)==null||t.call(window);else if(tn()){let i=window.NUC;(n=(e=i==null?void 0:i.trigger)==null?void 0:e.tryAgain)==null||n.call(e)}x("engagement",{action:"retry"})},pause(){Ge(!0)},resume(){ot(!0)},resize(t,e){ye(t,e)}},Re=ee;function Xr(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e|0}function Kr(t){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 ${n} assets</div>`}}resolveAssetUrl(e){return e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("/")?e:`/raw/${e}`}attachEventListeners(){if(!this.modal)return;this.modal.addEventListener("click",i=>{let a=i.target;(a.dataset.action==="close"||a===this.modal)&&this.close()});let e=this.modal.querySelector('[data-action="change"]');e&&e.addEventListener("click",()=>{this.openAssetEditor()});let n=this.modal.querySelector('[data-action="edit"]');n&&n.addEventListener("click",()=>{this.openAiEditor(),this.close()})}openAssetEditor(){this.options&&Promise.resolve().then(()=>(Tn(),is)).then(({AssetEditorModal:e})=>{new e().show(this.options.objectId||"unknown",this.options.propertyPath||"",this.options.assetPath,i=>{var a;(a=this.options)!=null&&a.onChange&&this.options.onChange(i),this.close()})})}openAiEditor(){if(!this.options||this.options.assetType!=="image")return;let e=window.__openAiEditor;typeof e=="function"&&e(this.options.objectId||"asset","Edit this image asset",this.options.assetPath,{path:this.options.propertyPath,onApply:n=>{var i;(i=this.options)!=null&&i.onChange&&this.options.onChange(n)}})}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.options=null}};window.openAssetPreview=function(t){new Ln().open(t)};as();Q();var ke=require("pixi.js");Q();Q();Q();var ss=he(require("lottie-web"),1);an(Ba);typeof window!="undefined"&&!window.lottie&&(window.lottie=ss.default);yn();Q();var In=Sa.version,Fr=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"]);xa();var us={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"},hs=Math.random().toString(36).slice(2),De=null,$e={...us},gs="web_embed",jn={},nt,Pn=!1,tt=!1,at=!1,ms=!1,$n=1,Ot=0,$t=!1,pe=!1,He="",Ne=Math.floor(window.innerWidth),Fe=Math.floor(window.innerHeight),On=Ne>Fe,ue=!1,it=!1,os=!1,rs=!1,Mn=!1,Rt=null,Ie=null,Rn=!1,zn=!1,jt=new Map;function fs(){if(!Ie)return null;let t=Date.now()-Ie;return!Number.isFinite(t)||t<0?null:t}function _n(t){if(Rn)return;let e=fs();e!==null&&(Rn=!0,x("session_time",{duration_ms:e,reason:t}))}function ls(){if(De)return De;let t=document.createElement("div");return t.id="handler-root",t.setAttribute("data-handler-root","true"),document.body.appendChild(t),De=t,t}function zt(t){switch(t){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return t}}function ys(t,e){return{event_name:t,ts:Date.now(),session_id:hs,deployment_id:$e.deployment_id,variant_id:$e.variant_id,export_profile_id:$e.profile_id,instance_id:$e.instance_id||"default",env:gs==="mraid"?"mraid":"web",attribution:nt,payload:e}}function x(t,e){let n=zt(t),i=ys(n,e);Qt(i,!!jn.analytics),vt(n,i),n!==t&&vt(t,i)}function st(){Rt&&(Rt(Ne,Fe),Rt=null)}function Be(t){$n=t,x("volume",t)}function Ge(t){t&&(ms=!0),!at&&(at=!0,x("pause"),Be(0))}function ot(t){!t&&ms||at&&(at=!1,x("resume"),Be($n))}function ye(t,e){Ne=Math.floor(t||window.innerWidth),Fe=Math.floor(e||window.innerHeight),On=Ne>Fe,x("resize",{width:Ne,height:Fe})}function Br(){if(Oa())try{let t=mraid.getMaxSize();ye(t.width,t.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ot():Ge()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ye(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();Be(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&Be(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),$t=!0,mraid.isViewable()&&mraid.getState()!=="hidden")ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st();else{let n=()=>{ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st()};mraid.addEventListener("ready",n)}}catch(t){console.warn("MRAID hook skipped",t)}}function Gr(){if(Ra())try{let t=dapi.getScreenSize();ye(t.width,t.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ot():Ge()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();ye(n.width||i.width,n.height||i.height)});let e=dapi.getAudioVolume();if(Be(e?1:0),dapi.addEventListener("audioVolumeChange",n=>Be(n?1:0)),$t=!0,dapi.isViewable())ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st();else{let n=()=>{ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st()};dapi.addEventListener("ready",n)}}catch(t){console.warn("DAPI hook skipped",t)}}function cs(){let t=()=>{ue||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(ue=!0,x("boot"),x("view"),x("ready"),pe=!0,st(),it&&(it=!1,ee.start()))};window.addEventListener("resize",()=>ye()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ot(),t()):Ge()}),document.readyState==="complete"||document.readyState==="interactive"?t():window.addEventListener("load",t),$t=!0}function Ur(){let t=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(os=!0),!(os&&e instanceof MouseEvent)&&(Ot+=1,zn||(zn=!0,x("first_interaction",{count:Ot})),x("interaction",Ot))};document.addEventListener("mousedown",t),document.addEventListener("touchstart",t)}function ds(t){var i,a,s,o,r,l,d,p,c,h,u,m;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(t||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(Oe())(s=(a=window.TJ_API)==null?void 0:a.click)==null||s.call(a);else if(za())(r=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||r.call(o);else if(Na())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Da())try{(c=(p=window.smxTracking)==null?void 0:p.redirect)==null||c.call(p)}catch(g){console.warn("Smadex redirect failed",g)}else if($a()){let g=window.ExitApi;g&&typeof g.exit=="function"?g.exit(t||He||""):t&&window.open(t)}else je()?(h=window.install)==null||h.call(window):Ha()?(u=window.openAppStore)==null||u.call(window):en()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):t&&window.open(t)}function qr(){let t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=n=>{if(!n)return;let i=new Image;i.src=n};if(t==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;B("view",()=>e(n.mraid_viewable)),B("start",()=>e(n.game_viewable)),B("engagement",()=>e(n.engagement));let i=()=>e(n.complete);B("complete",i),bt("engagement",a=>{var s;((s=a==null?void 0:a.payload)==null?void 0:s.count)>3&&i()}),B("cta_click",()=>e(n.click))}else if(t==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;B("view",()=>e(n.Ad_Load_Start)),B("start",()=>e(n.Ad_Viewable)),B("engagement",()=>e(n.First_Engagement)),B("complete",()=>e(n.Gameplay_Complete)),B("cta_click",()=>e(n.DSP_Click)),B("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>e(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Vr(){if(!Oe())return;let t=window.TJ_API;t&&t.setPlayableAPI&&t.setPlayableAPI({skipAd:()=>{try{ee.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function ps(){var e,n,i;let t=window.TJ_API;(e=t==null?void 0:t.objectiveComplete)==null||e.call(t),(n=t==null?void 0:t.playableFinished)==null||n.call(t),(i=t==null?void 0:t.gameplayFinished)==null||i.call(t)}function Wr(){je()&&(window.mintGameStart=()=>{ot(!0),ye()},window.mintGameClose=()=>{Ge(!0)})}function Yr(){if(!tn())return;let t=window.NUC;!t||!t.trigger||(ee.on("cta_click",()=>{var e,n;return(n=(e=t.trigger).convert)==null?void 0:n.call(e,He)}),ee.on("complete",()=>{var e,n;return(n=(e=t.trigger).tryAgain)==null?void 0:n.call(e)}))}var ee={init(t={},e){var n;if(gs=t.profile||"web_embed",jn=t.consent||{},$e={...us,...t.ids||{}},De=t.rootEl||De,nt=void 0,ga((n=t.telemetry)!=null&&n.endpoint?t.telemetry:null),Ie=null,Rn=!1,zn=!1,jt.clear(),He=t.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Rt=e),x("init"),document.body.oncontextmenu=()=>!1,ls(),Kr(De),Fa(),Br(),Gr(),!$t){if(document.readyState==="complete")cs();else if(!rs){rs=!0;let i=()=>{cs(),window.removeEventListener("load",i),document.removeEventListener("DOMContentLoaded",i)};window.addEventListener("load",i),document.addEventListener("DOMContentLoaded",i)}}Ur(),qr(),Vr(),Wr(),Yr(),console.log(`%c @handler/playable-sdk %c v${In} `,"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;"),ue&&!pe&&(x("boot"),x("view"),x("ready"),it&&(it=!1,ee.start()),pe=!0),pe=ue},getRoot(){return ls()},get version(){return In},get maxWidth(){return Ne},get maxHeight(){return Fe},get isLandscape(){return On},get isReady(){return pe},get isStarted(){return Pn},get isPaused(){return at},get isFinished(){return tt},get volume(){return $n},get interactions(){return Ot},on(t,e){bt(zt(t),e)},off(t,e){Zt(zt(t),e)},start(){var t,e;if(!Pn){if(!ue){it=!0;return}if(Pn=!0,Ie||(Ie=Date.now()),x("start"),ye(),je())Ge(),(t=window.gameReady)==null||t.call(window);else if(Oe()){let n=window.TJ_API;(e=n==null?void 0:n.setPlayableBuild)==null||e.call(n,{orientation:On?"landscape":"portrait",buildID:In})}}},finish(){var t,e;tt||(tt=!0,x("complete"),_n("complete"),je()?(t=window.gameEnd)==null||t.call(window):en()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Oe()&&ps())},install(t){if(!tt){tt=!0,Oe()?(ps(),setTimeout(()=>ee.install(t),300)):(x("complete"),setTimeout(()=>ee.install(t),0));return}Mn||(Mn=!0,setTimeout(()=>Mn=!1,500),x("cta_click"),x("conversion"),_n("cta"),ds(t||He))},emit(t,e){let n=zt(t);if(!Fr.has(n)&&n!=="resize"&&n!=="volume"&&!n.startsWith("custom."))throw new Error(`Event ${t} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=ys(n,e);Qt(i,!!jn.analytics),vt(n,i)},gameStart(){ee.start()},gameEnd(){ee.finish()},ctaClick(t,e){x("cta_click",{url:t||He,manual:!0}),(e==null?void 0:e.open)!==!1&&ds(t||He)},ctaShow(t){x("cta_show",t)},ctaDismiss(t){x("cta_dismiss",t)},getGameTimeMs(){return fs()},endSession(t="manual"){_n(t)},setAttribution(t){nt=t},abTest(t,e){if(!t)throw new Error("abTest requires experimentId");if(!Array.isArray(e)||e.length<2)throw new Error("abTest requires at least 2 variants");let n=Math.abs(Xr(`${hs}:${t}`))%e.length,i=e[n];return nt={...nt||{},experiment_id:t},$e.variant_id=i,x("ab_assign",{experiment_id:t,variant_id:i}),i},levelStart(t,e){Ie||(Ie=Date.now()),x("level_start",{level_id:t,...e})},levelComplete(t,e){x("level_complete",{level_id:t,...e})},levelFail(t,e){x("level_fail",{level_id:t,...e})},checkpoint(t,e){x("checkpoint",{checkpoint_id:t,...e})},reward(t,e){x("reward",{reward_id:t,...e})},tutorialStart(t,e){x("tutorial_start",{step_id:t,...e})},tutorialComplete(t,e){x("tutorial_complete",{step_id:t,...e})},tutorialSkip(t,e){x("tutorial_skip",{step_id:t,...e})},timerStart(t){t&&jt.set(t,Date.now())},timerEnd(t,e="custom",n){if(!t)return;let i=jt.get(t);if(!i)return;jt.delete(t);let a=Date.now()-i;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){x("engagement",{action:"timer",key:t,duration_ms:a,...n});return}x(e,{key:t,duration_ms:a,...n})}},fps(t,e){x("fps",{value:t,...e})},memory(t,e){x("memory",{bytes:t,...e})},assetLoadStart(t,e){x("asset_load_start",{asset_id:t,...e})},assetLoadComplete(t,e){x("asset_load_complete",{asset_id:t,...e})},reportError(t,e,n){x("error",{code:t,message:e,...n})},retry(){var t,e,n;if(je())(t=window.gameRetry)==null||t.call(window);else if(tn()){let i=window.NUC;(n=(e=i==null?void 0:i.trigger)==null?void 0:e.tryAgain)==null||n.call(e)}x("engagement",{action:"retry"})},pause(){Ge(!0)},resume(){ot(!0)},resize(t,e){ye(t,e)}},Re=ee;function Xr(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e|0}function Kr(t){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
250
250
  (function(){
251
251
  var events = ['touchstart','touchend','mousedown','keydown'];
252
252
  function unlock(){
@@ -285,13 +285,13 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
285
285
  overflow: hidden !important;
286
286
  `,t.appendChild(o);let r=document.createElement("div");r.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","min-width:100%","min-height:100%","max-width:100%","max-height:100%","pointer-events:auto","box-sizing:border-box","margin:0","padding:0","overflow:hidden"].join(";")),o.appendChild(r);let l=new W.Scene,{width:d,height:p}=n(),c=new W.AmbientLight(16777215,.6);l.add(c);let h=new W.DirectionalLight(16777215,.8);h.position.set(5,5,5),h.castShadow=!1,l.add(h);let u=new W.DirectionalLight(16777215,.3);u.position.set(-5,0,5),l.add(u);let m=new W.PerspectiveCamera(55,d/p,.1,100);m.position.set(0,0,3.2),m.lookAt(0,0,0),m.updateMatrixWorld();let g=new W.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});g.setPixelRatio(window.devicePixelRatio||1),g.setSize(d,p),g.setClearColor(0,0),g.domElement.style.position="absolute",g.domElement.style.top="0",g.domElement.style.left="0",g.domElement.style.right="0",g.domElement.style.bottom="0",g.domElement.style.width="100%",g.domElement.style.height="100%",g.domElement.style.minWidth="100%",g.domElement.style.minHeight="100%",g.domElement.style.maxWidth="100%",g.domElement.style.maxHeight="100%",g.domElement.style.display="block",g.domElement.style.pointerEvents="auto",g.domElement.style.margin="0",g.domElement.style.padding="0",g.domElement.style.boxSizing="border-box",r.appendChild(g.domElement);let w=f=>{var k;let y=t.getBoundingClientRect(),S=window.getComputedStyle(t);console.log("[THREE-BASE] applySize called:",{providedSize:f,rootRect:{width:y.width,height:y.height},clientSize:{width:t.clientWidth,height:t.clientHeight},styleSize:{width:t.style.width,height:t.style.height},computedStyle:{width:S.width,height:S.height,transform:S.transform,scale:S.scale},rendererCurrentSize:{width:g.domElement.width,height:g.domElement.height},rendererStyleSize:{width:g.domElement.style.width,height:g.domElement.style.height},stackTrace:(k=new Error().stack)==null?void 0:k.split(`
287
287
  `).slice(1,4).join(`
288
- `)});let E=y.width,C=y.height;if((E<=0||!isFinite(E))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:y.width,clientWidth:t.clientWidth}),E=t.clientWidth||window.innerWidth||320),(C<=0||!isFinite(C))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:y.height,clientHeight:t.clientHeight}),C=t.clientHeight||window.innerHeight||480),typeof(f==null?void 0:f.width)=="number"&&f.width>0){let R=Math.abs(f.width-y.width),j=y.width*.1;R>j?console.warn("[THREE-BASE] Provided width ignored (too different from container):",{provided:f.width,container:y.width,difference:R,tolerance:j,willUse:"container size (boundingRect)"}):(E=f.width,console.log("[THREE-BASE] Using provided width (within tolerance):",{provided:f.width,container:y.width}))}if(typeof(f==null?void 0:f.height)=="number"&&f.height>0){let R=Math.abs(f.height-y.height),j=y.height*.1;R>j?console.warn("[THREE-BASE] Provided height ignored (too different from container):",{provided:f.height,container:y.height,difference:R,tolerance:j,willUse:"container size (boundingRect)"}):(C=f.height,console.log("[THREE-BASE] Using provided height (within tolerance):",{provided:f.height,container:y.height}))}(E<=0||C<=0||!isFinite(E)||!isFinite(C))&&(console.warn("[THREE-BASE] Invalid size in applySize, using fallback",{newWidth:E,newHeight:C,size:f,rootRect:y}),E=y.width||t.clientWidth||320,C=y.height||t.clientHeight||480);let P=Math.floor(E),_=Math.floor(C);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:P,finalHeight:_,aspectRatio:P/_,beforeRendererSize:{width:g.domElement.width,height:g.domElement.height},beforeRendererStyle:{width:g.domElement.style.width,height:g.domElement.style.height}}),g.setSize(P,_),g.setPixelRatio(window.devicePixelRatio||1),m.aspect=P/_,m.updateProjectionMatrix();let L=t.getBoundingClientRect();console.log("[THREE-BASE] applySize after setting:",{rendererSize:{width:g.domElement.width,height:g.domElement.height},rendererStyle:{width:g.domElement.style.width,height:g.domElement.style.height},containerRect:{width:L.width,height:L.height},cameraAspect:m.aspect,matches:{width:Math.abs(g.domElement.width-L.width)<1,height:Math.abs(g.domElement.height-L.height)<1},sizeDifference:{width:g.domElement.width-L.width,height:g.domElement.height-L.height}})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{w()})});let v=!1;Re.on("pause",()=>{v=!0,document.querySelectorAll("audio").forEach(y=>y.pause())}),Re.on("resume",()=>{v=!1,document.querySelectorAll("audio").forEach(y=>{y.currentTime>0&&!y.ended&&y.play().catch(()=>{})})});let b=new Ue(t,o);return Re.on("resize",({payload:f})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:f,timestamp:Date.now(),rootRect:t.getBoundingClientRect()}),w({width:f==null?void 0:f.width,height:f==null?void 0:f.height}),b.updateLayout()}),window.addEventListener("resize",()=>{console.log("[THREE-BASE] Window resize event received:",{timestamp:Date.now(),windowSize:{width:window.innerWidth,height:window.innerHeight},rootRect:t.getBoundingClientRect()}),w(),b.updateLayout()}),{scene:l,camera:m,renderer:g,uiSystem:b,applySize:w}}var z=he(require("three"),1),rt=class{constructor(e){var n,i;this.position=(e==null?void 0:e.position)||{x:0,y:0},this.scale=(n=e==null?void 0:e.scale)!=null?n:1,this.rotation=(i=e==null?void 0:e.rotation)!=null?i:0}update(e){e.position!==void 0&&(this.position={...e.position}),e.scale!==void 0&&(this.scale=e.scale),e.rotation!==void 0&&(this.rotation=e.rotation)}syncToThree(e){let n=e.position.z,i=n===0||!isFinite(n)?.5:n;e.position.set(this.position.x,this.position.y,i),e.scale.set(this.scale,this.scale,this.scale),e.rotation.z=this.rotation}},lt=class{constructor(e){var n,i,a,s;this.z_index=(n=e==null?void 0:e.z_index)!=null?n:0,this.alpha=(i=e==null?void 0:e.alpha)!=null?i:1,this.visible=(a=e==null?void 0:e.visible)!=null?a:!0,this.tint=(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)}syncToThree(e){if(e.renderOrder=this.z_index,e.visible=this.visible,e instanceof z.Mesh&&e.material&&(Array.isArray(e.material)?e.material.forEach(n=>{n instanceof z.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):e.material instanceof z.Material&&(e.material.opacity=this.alpha,e.material.transparent=this.alpha<1)),this.tint!==null&&e instanceof z.Mesh&&e.material){let n=typeof this.tint=="string"?new z.Color(this.tint):new z.Color(this.tint);Array.isArray(e.material)?e.material.forEach(i=>{(i instanceof z.MeshBasicMaterial||i instanceof z.MeshStandardMaterial)&&i.color.copy(n)}):(e.material instanceof z.MeshBasicMaterial||e.material instanceof z.MeshStandardMaterial)&&e.material.color.copy(n)}}},ct=class{constructor(e,n,i,a){this.instanceId=e,this.objectConfig=n,this.threeObject=i,this._config=a,this.transform=new rt(a.transform),this.renderer=new lt(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}updateConfig(e){this._config=e,e.transform&&this.transform.update(e.transform),e.render&&this.renderer.update(e.render),this.sync()}getComponent(e){return this._config[e]}getPosition(){return{...this.transform.position}}setPosition(e,n){this.transform.position={x:e,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(e){this.renderer.alpha=e,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(e){this.renderer.visible=e,this.renderer.syncToThree(this.threeObject)}},Dt=class{constructor(e){this.objects=new Map;this.config=e}create(e,n){let i=this.config.objects.get(e);if(!i)throw new Error(`Object config not found: ${e}`);let a=new ct(e,i.object_config||e,n,i);return this.objects.set(e,a),a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[n,i]of this.objects.entries()){let a=e.objects.get(n);a&&i.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(e){this.objects.delete(e)}clear(){this.objects.clear()}};var Nt={"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 te(t){let e=Nt[t];return e?e.family:(console.warn(`Font ID "${t}" not found in registry, using fallback`),"Arial, sans-serif")}function ne(t){var n;let e=Nt[t];return e&&(n=e.weight)!=null?n:"400"}function vs(t,e){Nt[t]=e}function ws(){return Object.keys(Nt)}var qe=he(require("three"),1);function Me(t){return{element:t,get alpha(){return parseFloat(t.style.opacity||"1")},set alpha(e){t.style.opacity=e.toString()},get visible(){return t.style.display!=="none"},set visible(e){t.style.display=e?"":"none"},position:{set(e,n){t.style.left=`${e}px`,t.style.top=`${n}px`},get x(){return parseFloat(t.style.left||"0")},get y(){return parseFloat(t.style.top||"0")}},scale:{set(e,n){t.style.transform=`scale(${e})`},get x(){let e=t.style.transform.match(/scale\(([^)]+)\)/);return e?parseFloat(e[1]):1}}}}function xs(t,e,n,i){var ii,ai,si,oi,ri,li,ci,di,pi,ui,hi,gi,mi,fi,yi,bi,vi,wi,xi,Si,Ei,Ci,Ai,Ti,Li,ki,Pi,Mi,Ii,_i,ji,Oi,Ri,zi,$i,Hi,Di,Ni,Fi,Bi,Gi,Ui,qi,Vi,Wi,Yi,Xi,Ki,Ji,Zi,Qi,ea,ta,na,ia,aa,sa,oa,ra,la,ca;let a=t.objects.get("ui_endgame_1"),s=t.objects.get("ui_endgame_logo_1"),o=t.objects.get("ui_endgame_title_1"),r=t.objects.get("ui_endgame_subtitle_1"),l=t.objects.get("ui_endgame_footer_1"),d=t.objects.get("ui_endgame_cta_1"),p=t.objects.get("ui_endgame_cta_hint_1"),c=t.objects.get("ui_endgame_hand_1"),h=t.engine.runtime||{},u=((ii=a==null?void 0:a.gameplay)==null?void 0:ii.tuning)||{},m=(a==null?void 0:a.render)||{},g=i.getBoundingClientRect(),w=g.width>0?g.width*.9:320,v=g.height>0?g.height*.85:400,b=Math.min((ai=u.panel_width)!=null?ai:320,w),f=Math.min((si=u.panel_height)!=null?si:400,v),y=(oi=u.panel_padding)!=null?oi:32,S=(ri=u.panel_radius)!=null?ri:24,E=m.background_color||u.panel_bg_color||"#1a0a0a",C=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(li=u.panel_bg_alpha)!=null?li:.98,P=m.border_color||u.panel_border_color||"#ffffff",_=(ci=u.panel_border_width)!=null?ci:2,L=(di=u.panel_border_alpha)!=null?di:.3,k=document.createElement("div");k.style.cssText=`
288
+ `)});let E=y.width,C=y.height;if((E<=0||!isFinite(E))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:y.width,clientWidth:t.clientWidth}),E=t.clientWidth||window.innerWidth||320),(C<=0||!isFinite(C))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:y.height,clientHeight:t.clientHeight}),C=t.clientHeight||window.innerHeight||480),typeof(f==null?void 0:f.width)=="number"&&f.width>0){let R=Math.abs(f.width-y.width),j=y.width*.1;R>j?console.warn("[THREE-BASE] Provided width ignored (too different from container):",{provided:f.width,container:y.width,difference:R,tolerance:j,willUse:"container size (boundingRect)"}):(E=f.width,console.log("[THREE-BASE] Using provided width (within tolerance):",{provided:f.width,container:y.width}))}if(typeof(f==null?void 0:f.height)=="number"&&f.height>0){let R=Math.abs(f.height-y.height),j=y.height*.1;R>j?console.warn("[THREE-BASE] Provided height ignored (too different from container):",{provided:f.height,container:y.height,difference:R,tolerance:j,willUse:"container size (boundingRect)"}):(C=f.height,console.log("[THREE-BASE] Using provided height (within tolerance):",{provided:f.height,container:y.height}))}(E<=0||C<=0||!isFinite(E)||!isFinite(C))&&(console.warn("[THREE-BASE] Invalid size in applySize, using fallback",{newWidth:E,newHeight:C,size:f,rootRect:y}),E=y.width||t.clientWidth||320,C=y.height||t.clientHeight||480);let I=Math.floor(E),_=Math.floor(C);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:I,finalHeight:_,aspectRatio:I/_,beforeRendererSize:{width:g.domElement.width,height:g.domElement.height},beforeRendererStyle:{width:g.domElement.style.width,height:g.domElement.style.height}}),g.setSize(I,_),g.setPixelRatio(window.devicePixelRatio||1),m.aspect=I/_,m.updateProjectionMatrix();let L=t.getBoundingClientRect();console.log("[THREE-BASE] applySize after setting:",{rendererSize:{width:g.domElement.width,height:g.domElement.height},rendererStyle:{width:g.domElement.style.width,height:g.domElement.style.height},containerRect:{width:L.width,height:L.height},cameraAspect:m.aspect,matches:{width:Math.abs(g.domElement.width-L.width)<1,height:Math.abs(g.domElement.height-L.height)<1},sizeDifference:{width:g.domElement.width-L.width,height:g.domElement.height-L.height}})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{w()})});let v=!1;Re.on("pause",()=>{v=!0,document.querySelectorAll("audio").forEach(y=>y.pause())}),Re.on("resume",()=>{v=!1,document.querySelectorAll("audio").forEach(y=>{y.currentTime>0&&!y.ended&&y.play().catch(()=>{})})});let b=new Ue(t,o);return Re.on("resize",({payload:f})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:f,timestamp:Date.now(),rootRect:t.getBoundingClientRect()}),w({width:f==null?void 0:f.width,height:f==null?void 0:f.height}),b.updateLayout()}),window.addEventListener("resize",()=>{console.log("[THREE-BASE] Window resize event received:",{timestamp:Date.now(),windowSize:{width:window.innerWidth,height:window.innerHeight},rootRect:t.getBoundingClientRect()}),w(),b.updateLayout()}),{scene:l,camera:m,renderer:g,uiSystem:b,applySize:w}}var z=he(require("three"),1),rt=class{constructor(e){var n,i;this.position=(e==null?void 0:e.position)||{x:0,y:0},this.scale=(n=e==null?void 0:e.scale)!=null?n:1,this.rotation=(i=e==null?void 0:e.rotation)!=null?i:0}update(e){e.position!==void 0&&(this.position={...e.position}),e.scale!==void 0&&(this.scale=e.scale),e.rotation!==void 0&&(this.rotation=e.rotation)}syncToThree(e){let n=e.position.z,i=n===0||!isFinite(n)?.5:n;e.position.set(this.position.x,this.position.y,i),e.scale.set(this.scale,this.scale,this.scale),e.rotation.z=this.rotation}},lt=class{constructor(e){var n,i,a,s;this.z_index=(n=e==null?void 0:e.z_index)!=null?n:0,this.alpha=(i=e==null?void 0:e.alpha)!=null?i:1,this.visible=(a=e==null?void 0:e.visible)!=null?a:!0,this.tint=(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)}syncToThree(e){if(e.renderOrder=this.z_index,e.visible=this.visible,e instanceof z.Mesh&&e.material&&(Array.isArray(e.material)?e.material.forEach(n=>{n instanceof z.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):e.material instanceof z.Material&&(e.material.opacity=this.alpha,e.material.transparent=this.alpha<1)),this.tint!==null&&e instanceof z.Mesh&&e.material){let n=typeof this.tint=="string"?new z.Color(this.tint):new z.Color(this.tint);Array.isArray(e.material)?e.material.forEach(i=>{(i instanceof z.MeshBasicMaterial||i instanceof z.MeshStandardMaterial)&&i.color.copy(n)}):(e.material instanceof z.MeshBasicMaterial||e.material instanceof z.MeshStandardMaterial)&&e.material.color.copy(n)}}},ct=class{constructor(e,n,i,a){this.instanceId=e,this.objectConfig=n,this.threeObject=i,this._config=a,this.transform=new rt(a.transform),this.renderer=new lt(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}updateConfig(e){this._config=e,e.transform&&this.transform.update(e.transform),e.render&&this.renderer.update(e.render),this.sync()}getComponent(e){return this._config[e]}getPosition(){return{...this.transform.position}}setPosition(e,n){this.transform.position={x:e,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(e){this.renderer.alpha=e,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(e){this.renderer.visible=e,this.renderer.syncToThree(this.threeObject)}},Dt=class{constructor(e){this.objects=new Map;this.config=e}create(e,n){let i=this.config.objects.get(e);if(!i)throw new Error(`Object config not found: ${e}`);let a=new ct(e,i.object_config||e,n,i);return this.objects.set(e,a),a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[n,i]of this.objects.entries()){let a=e.objects.get(n);a&&i.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(e){this.objects.delete(e)}clear(){this.objects.clear()}};var Nt={"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 te(t){let e=Nt[t];return e?e.family:(console.warn(`Font ID "${t}" not found in registry, using fallback`),"Arial, sans-serif")}function ne(t){var n;let e=Nt[t];return e&&(n=e.weight)!=null?n:"400"}function vs(t,e){Nt[t]=e}function ws(){return Object.keys(Nt)}var qe=he(require("three"),1);function Pe(t){return{element:t,get alpha(){return parseFloat(t.style.opacity||"1")},set alpha(e){t.style.opacity=e.toString()},get visible(){return t.style.display!=="none"},set visible(e){t.style.display=e?"":"none"},position:{set(e,n){t.style.left=`${e}px`,t.style.top=`${n}px`},get x(){return parseFloat(t.style.left||"0")},get y(){return parseFloat(t.style.top||"0")}},scale:{set(e,n){t.style.transform=`scale(${e})`},get x(){let e=t.style.transform.match(/scale\(([^)]+)\)/);return e?parseFloat(e[1]):1}}}}function xs(t,e,n,i){var ii,ai,si,oi,ri,li,ci,di,pi,ui,hi,gi,mi,fi,yi,bi,vi,wi,xi,Si,Ei,Ci,Ai,Ti,Li,ki,Ii,Pi,Mi,_i,ji,Oi,Ri,zi,$i,Hi,Di,Ni,Fi,Bi,Gi,Ui,qi,Vi,Wi,Yi,Xi,Ki,Ji,Zi,Qi,ea,ta,na,ia,aa,sa,oa,ra,la,ca;let a=t.objects.get("ui_endgame_1"),s=t.objects.get("ui_endgame_logo_1"),o=t.objects.get("ui_endgame_title_1"),r=t.objects.get("ui_endgame_subtitle_1"),l=t.objects.get("ui_endgame_footer_1"),d=t.objects.get("ui_endgame_cta_1"),p=t.objects.get("ui_endgame_cta_hint_1"),c=t.objects.get("ui_endgame_hand_1"),h=t.engine.runtime||{},u=((ii=a==null?void 0:a.gameplay)==null?void 0:ii.tuning)||{},m=(a==null?void 0:a.render)||{},g=i.getBoundingClientRect(),w=g.width>0?g.width*.9:320,v=g.height>0?g.height*.85:400,b=Math.min((ai=u.panel_width)!=null?ai:320,w),f=Math.min((si=u.panel_height)!=null?si:400,v),y=(oi=u.panel_padding)!=null?oi:32,S=(ri=u.panel_radius)!=null?ri:24,E=m.background_color||u.panel_bg_color||"#1a0a0a",C=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(li=u.panel_bg_alpha)!=null?li:.98,I=m.border_color||u.panel_border_color||"#ffffff",_=(ci=u.panel_border_width)!=null?ci:2,L=(di=u.panel_border_alpha)!=null?di:.3,k=document.createElement("div");k.style.cssText=`
289
289
  position: absolute;
290
290
  width: ${b}px;
291
291
  height: ${f}px;
292
292
  background: ${E};
293
293
  opacity: ${C};
294
- border: ${_}px solid ${P};
294
+ border: ${_}px solid ${I};
295
295
  border-opacity: ${L};
296
296
  border-radius: ${S}px;
297
297
  display: block;
@@ -304,7 +304,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
304
304
  z-index: 1000;
305
305
  box-sizing: border-box;
306
306
  padding: ${y}px;
307
- `,i.appendChild(k);let R=Me(k);R.element=k;let j=((pi=s==null?void 0:s.gameplay)==null?void 0:pi.tuning)||{},be=(s==null?void 0:s.transform)||{},q=(ui=j.logo_size)!=null?ui:56,Y=(hi=be.scale)!=null?hi:1,Ie=(mi=(gi=be.offset)==null?void 0:gi.y)!=null?mi:-130,dt=(fi=j.logo_alpha)!=null?fi:1,Is=new qe.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),X=new qe.Sprite(Is);X.position.set(0,Ie,0),X.material.opacity=0;let pt=0,ut=0;if(n){let $=n.image;pt=($==null?void 0:$.width)||100,ut=($==null?void 0:$.height)||100}if(pt>0&&ut>0){let $=pt/ut,Kt,Jt;$>1?(Kt=q,Jt=q/$):(Jt=q,Kt=q*$);let yo=Kt/pt*Y,bo=Jt/ut*Y;X.scale.set(yo,bo,1)}else{let $=q/100*Y;X.scale.set($,$,1)}X.targetAlpha=dt,X.baseScaleX=X.scale.x,X.baseScaleY=X.scale.y;let H=o==null?void 0:o.ui,ie=((yi=o==null?void 0:o.gameplay)==null?void 0:yi.tuning)||{},_s=(H==null?void 0:H.text)||"MISSION ACCOMPLISHED",Bn=(H==null?void 0:H.font)||"brand.heading",Bt=(H==null?void 0:H.fontSize)||24,js=(bi=H==null?void 0:H.letterSpacing)!=null?bi:1,ht=(vi=o==null?void 0:o.render)==null?void 0:vi.tint,Os=typeof ht=="string"?ht:ht?`#${ht.toString(16).padStart(6,"0")}`:"#00FF88",Rs=b-y*2-30,zs=ie.font_weight_override?ie.font_weight_override:ne(Bn),ve=document.createElement("div");ve.textContent=_s,ve.style.cssText=`
307
+ `,i.appendChild(k);let R=Pe(k);R.element=k;let j=((pi=s==null?void 0:s.gameplay)==null?void 0:pi.tuning)||{},be=(s==null?void 0:s.transform)||{},q=(ui=j.logo_size)!=null?ui:56,Y=(hi=be.scale)!=null?hi:1,Me=(mi=(gi=be.offset)==null?void 0:gi.y)!=null?mi:-130,dt=(fi=j.logo_alpha)!=null?fi:1,Ms=new qe.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),X=new qe.Sprite(Ms);X.position.set(0,Me,0),X.material.opacity=0;let pt=0,ut=0;if(n){let $=n.image;pt=($==null?void 0:$.width)||100,ut=($==null?void 0:$.height)||100}if(pt>0&&ut>0){let $=pt/ut,Kt,Jt;$>1?(Kt=q,Jt=q/$):(Jt=q,Kt=q*$);let yo=Kt/pt*Y,bo=Jt/ut*Y;X.scale.set(yo,bo,1)}else{let $=q/100*Y;X.scale.set($,$,1)}X.targetAlpha=dt,X.baseScaleX=X.scale.x,X.baseScaleY=X.scale.y;let H=o==null?void 0:o.ui,ie=((yi=o==null?void 0:o.gameplay)==null?void 0:yi.tuning)||{},_s=(H==null?void 0:H.text)||"MISSION ACCOMPLISHED",Bn=(H==null?void 0:H.font)||"brand.heading",Bt=(H==null?void 0:H.fontSize)||24,js=(bi=H==null?void 0:H.letterSpacing)!=null?bi:1,ht=(vi=o==null?void 0:o.render)==null?void 0:vi.tint,Os=typeof ht=="string"?ht:ht?`#${ht.toString(16).padStart(6,"0")}`:"#00FF88",Rs=b-y*2-30,zs=ie.font_weight_override?ie.font_weight_override:ne(Bn),ve=document.createElement("div");ve.textContent=_s,ve.style.cssText=`
308
308
  font-family: ${te(Bn)};
309
309
  font-size: ${Bt}px;
310
310
  font-weight: ${zs};
@@ -318,7 +318,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
318
318
  transform: translate(-50%, -50%);
319
319
  white-space: nowrap;
320
320
  max-width: ${Rs}px;
321
- `;let Gn=y+30,$s=((Ai=u.title_offset_y)!=null?Ai:Gn+Bt/2)+((Ti=ie.animation_start_y_offset)!=null?Ti:-20);ve.style.top=`${$s}px`,ve.style.left="50%";let Un=Me(ve);Un.element=ve,k.appendChild(ve);let D=r==null?void 0:r.ui,qn=((Li=r==null?void 0:r.gameplay)==null?void 0:Li.tuning)||{},Hs=(D==null?void 0:D.text)||"RESCUE COMPLETE",Vn=(D==null?void 0:D.font)||"brand.body",Gt=(D==null?void 0:D.fontSize)||11,Ds=(ki=D==null?void 0:D.letterSpacing)!=null?ki:.5,gt=(Pi=r==null?void 0:r.render)==null?void 0:Pi.tint,Ns=typeof gt=="string"?gt:gt?`#${gt.toString(16).padStart(6,"0")}`:"#B0B0B0",we=document.createElement("div");we.textContent=Hs,we.style.cssText=`
321
+ `;let Gn=y+30,$s=((Ai=u.title_offset_y)!=null?Ai:Gn+Bt/2)+((Ti=ie.animation_start_y_offset)!=null?Ti:-20);ve.style.top=`${$s}px`,ve.style.left="50%";let Un=Pe(ve);Un.element=ve,k.appendChild(ve);let D=r==null?void 0:r.ui,qn=((Li=r==null?void 0:r.gameplay)==null?void 0:Li.tuning)||{},Hs=(D==null?void 0:D.text)||"RESCUE COMPLETE",Vn=(D==null?void 0:D.font)||"brand.body",Gt=(D==null?void 0:D.fontSize)||11,Ds=(ki=D==null?void 0:D.letterSpacing)!=null?ki:.5,gt=(Ii=r==null?void 0:r.render)==null?void 0:Ii.tint,Ns=typeof gt=="string"?gt:gt?`#${gt.toString(16).padStart(6,"0")}`:"#B0B0B0",we=document.createElement("div");we.textContent=Hs,we.style.cssText=`
322
322
  font-family: ${te(Vn)};
323
323
  font-size: ${Gt}px;
324
324
  font-weight: ${ne(Vn)};
@@ -329,7 +329,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
329
329
  position: absolute;
330
330
  transform: translate(-50%, -50%);
331
331
  white-space: nowrap;
332
- `;let Wn=Gn+Bt+15,Fs=((Mi=u.subtitle_offset_y)!=null?Mi:Wn+Gt/2)+((Ii=qn.animation_start_y_offset)!=null?Ii:-10);we.style.top=`${Fs}px`,we.style.left="50%";let Ut=Me(we);Ut.element=we,Ut.animationStartYOffset=(_i=qn.animation_start_y_offset)!=null?_i:-10,k.appendChild(we);let ae=l==null?void 0:l.ui,Yn=((ji=l==null?void 0:l.gameplay)==null?void 0:ji.tuning)||{},Bs=(ae==null?void 0:ae.text)||((Oi=h.ui)==null?void 0:Oi.cta_hint)||"Continue the adventure!",Xn=(ae==null?void 0:ae.font)||"brand.body",Kn=(ae==null?void 0:ae.fontSize)||16,mt=(Ri=l==null?void 0:l.render)==null?void 0:Ri.tint,Gs=typeof mt=="string"?mt:mt?`#${mt.toString(16).padStart(6,"0")}`:"#FFFFFF",Us=(zi=Yn.max_width)!=null?zi:b-y*2,qs=($i=Yn.line_height)!=null?$i:1.4,xe=document.createElement("div");xe.textContent=Bs,xe.style.cssText=`
332
+ `;let Wn=Gn+Bt+15,Fs=((Pi=u.subtitle_offset_y)!=null?Pi:Wn+Gt/2)+((Mi=qn.animation_start_y_offset)!=null?Mi:-10);we.style.top=`${Fs}px`,we.style.left="50%";let Ut=Pe(we);Ut.element=we,Ut.animationStartYOffset=(_i=qn.animation_start_y_offset)!=null?_i:-10,k.appendChild(we);let ae=l==null?void 0:l.ui,Yn=((ji=l==null?void 0:l.gameplay)==null?void 0:ji.tuning)||{},Bs=(ae==null?void 0:ae.text)||((Oi=h.ui)==null?void 0:Oi.cta_hint)||"Continue the adventure!",Xn=(ae==null?void 0:ae.font)||"brand.body",Kn=(ae==null?void 0:ae.fontSize)||16,mt=(Ri=l==null?void 0:l.render)==null?void 0:Ri.tint,Gs=typeof mt=="string"?mt:mt?`#${mt.toString(16).padStart(6,"0")}`:"#FFFFFF",Us=(zi=Yn.max_width)!=null?zi:b-y*2,qs=($i=Yn.line_height)!=null?$i:1.4,xe=document.createElement("div");xe.textContent=Bs,xe.style.cssText=`
333
333
  font-family: ${te(Xn)};
334
334
  font-size: ${Kn}px;
335
335
  font-weight: ${ne(Xn)};
@@ -341,7 +341,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
341
341
  max-width: ${Us}px;
342
342
  line-height: ${qs};
343
343
  word-wrap: break-word;
344
- `;let Vs=Wn+Gt+30,Ws=(Hi=u.footer_offset_y)!=null?Hi:Vs+Kn/2;xe.style.top=`${Ws}px`,xe.style.left="50%";let qt=Me(xe);qt.element=xe;let Ys=((Di=l==null?void 0:l.render)==null?void 0:Di.alpha)!==void 0&&((Ni=l==null?void 0:l.render)==null?void 0:Ni.alpha)!==null?l.render.alpha:1;qt.targetAlpha=Ys,k.appendChild(xe);let se=((Fi=d==null?void 0:d.gameplay)==null?void 0:Fi.tuning)||{},N=d==null?void 0:d.ui,Xs=(Bi=se.button_width)!=null?Bi:260,Jn=(Gi=se.button_height)!=null?Gi:56,Ks=(Ui=se.button_radius)!=null?Ui:16,Js=se.button_bg_color||((qi=h.theme)==null?void 0:qi.cta_background)||"#ffb43b",Zs=(Vi=se.button_bg_alpha)!=null?Vi:1,Qs=se.button_border_color||"#ffffff",eo=(Wi=se.button_border_width)!=null?Wi:2,ol=(Yi=se.button_border_alpha)!=null?Yi:.2,Vt=(Xi=u.cta_offset_y)!=null?Xi:f*.7,O=document.createElement("button");O.style.cssText=`
344
+ `;let Vs=Wn+Gt+30,Ws=(Hi=u.footer_offset_y)!=null?Hi:Vs+Kn/2;xe.style.top=`${Ws}px`,xe.style.left="50%";let qt=Pe(xe);qt.element=xe;let Ys=((Di=l==null?void 0:l.render)==null?void 0:Di.alpha)!==void 0&&((Ni=l==null?void 0:l.render)==null?void 0:Ni.alpha)!==null?l.render.alpha:1;qt.targetAlpha=Ys,k.appendChild(xe);let se=((Fi=d==null?void 0:d.gameplay)==null?void 0:Fi.tuning)||{},N=d==null?void 0:d.ui,Xs=(Bi=se.button_width)!=null?Bi:260,Jn=(Gi=se.button_height)!=null?Gi:56,Ks=(Ui=se.button_radius)!=null?Ui:16,Js=se.button_bg_color||((qi=h.theme)==null?void 0:qi.cta_background)||"#ffb43b",Zs=(Vi=se.button_bg_alpha)!=null?Vi:1,Qs=se.button_border_color||"#ffffff",eo=(Wi=se.button_border_width)!=null?Wi:2,ol=(Yi=se.button_border_alpha)!=null?Yi:.2,Vt=(Xi=u.cta_offset_y)!=null?Xi:f*.7,O=document.createElement("button");O.style.cssText=`
345
345
  width: ${Xs}px;
346
346
  height: ${Jn}px;
347
347
  background: ${Js};
@@ -353,7 +353,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
353
353
  position: absolute;
354
354
  transform: translate(-50%, -50%);
355
355
  box-shadow: inset 0 0 1px rgba(0,0,0,0.15);
356
- `,O.style.top=`${Vt}px`,O.style.left="50%";let Wt=Me(O);Wt.element=O,Wt.addEventListener=O.addEventListener.bind(O),k.appendChild(O);let to=(N==null?void 0:N.text)||((Ki=h.ui)==null?void 0:Ki.cta_label_end)||"DOWNLOAD",Zn=(N==null?void 0:N.font)||"brand.heading",no=(N==null?void 0:N.fontSize)||20,io=se.button_text_color||((Ji=h.theme)==null?void 0:Ji.cta_text)||"#1a0a0a";O.textContent=to,O.style.fontFamily=te(Zn),O.style.fontSize=`${no}px`,O.style.fontWeight=String(ne(Zn)),O.style.color=io,O.style.letterSpacing=`${(Zi=N==null?void 0:N.letterSpacing)!=null?Zi:1}px`;let Qn=Me(O);Qn.element=O;let F=p==null?void 0:p.ui,ei=((Qi=p==null?void 0:p.gameplay)==null?void 0:Qi.tuning)||{},ao=(F==null?void 0:F.text)||"Play the full game",ti=(F==null?void 0:F.font)||"brand.body",so=(F==null?void 0:F.fontSize)||11,oo=(ea=F==null?void 0:F.letterSpacing)!=null?ea:0,ft=(ta=p==null?void 0:p.render)==null?void 0:ta.tint,ro=typeof ft=="string"?ft:ft?`#${ft.toString(16).padStart(6,"0")}`:"#CCCCCC",Se=document.createElement("div");Se.textContent=ao,Se.style.cssText=`
356
+ `,O.style.top=`${Vt}px`,O.style.left="50%";let Wt=Pe(O);Wt.element=O,Wt.addEventListener=O.addEventListener.bind(O),k.appendChild(O);let to=(N==null?void 0:N.text)||((Ki=h.ui)==null?void 0:Ki.cta_label_end)||"DOWNLOAD",Zn=(N==null?void 0:N.font)||"brand.heading",no=(N==null?void 0:N.fontSize)||20,io=se.button_text_color||((Ji=h.theme)==null?void 0:Ji.cta_text)||"#1a0a0a";O.textContent=to,O.style.fontFamily=te(Zn),O.style.fontSize=`${no}px`,O.style.fontWeight=String(ne(Zn)),O.style.color=io,O.style.letterSpacing=`${(Zi=N==null?void 0:N.letterSpacing)!=null?Zi:1}px`;let Qn=Pe(O);Qn.element=O;let F=p==null?void 0:p.ui,ei=((Qi=p==null?void 0:p.gameplay)==null?void 0:Qi.tuning)||{},ao=(F==null?void 0:F.text)||"Play the full game",ti=(F==null?void 0:F.font)||"brand.body",so=(F==null?void 0:F.fontSize)||11,oo=(ea=F==null?void 0:F.letterSpacing)!=null?ea:0,ft=(ta=p==null?void 0:p.render)==null?void 0:ta.tint,ro=typeof ft=="string"?ft:ft?`#${ft.toString(16).padStart(6,"0")}`:"#CCCCCC",Se=document.createElement("div");Se.textContent=ao,Se.style.cssText=`
357
357
  font-family: ${te(ti)};
358
358
  font-size: ${so}px;
359
359
  font-weight: ${ne(ti)};
@@ -364,7 +364,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
364
364
  position: absolute;
365
365
  transform: translate(-50%, -50%);
366
366
  white-space: nowrap;
367
- `;let lo=Vt+Jn/2+20,co=f-y-10,po=Math.min(lo+((na=ei.animation_start_y_offset)!=null?na:5),co);Se.style.top=`${po}px`,Se.style.left="50%";let Yt=Me(Se);Yt.element=Se,Yt.animationStartYOffset=(ia=ei.animation_start_y_offset)!=null?ia:5,k.appendChild(Se);let Xt=((aa=c==null?void 0:c.gameplay)==null?void 0:aa.tuning)||{},uo=(sa=Xt.hand_offset_x)!=null?sa:50,ho=(oa=Xt.hand_offset_y)!=null?oa:50,go=(la=(ra=c==null?void 0:c.transform)==null?void 0:ra.scale)!=null?la:.1875,mo=(ca=Xt.hand_scale_multiplier)!=null?ca:2.5,fo=new qe.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),We=new qe.Sprite(fo),ni=go*mo*100;return We.scale.set(ni,ni,1),We.position.set(uo,Vt+ho,0),We.material.opacity=0,We.visible=!1,{panel:R,logo:X,title:Un,subtitle:Ut,footer:qt,ctaButton:Wt,ctaText:Qn,ctaHint:Yt,hand:We}}function Ss(t,e,n){var E,C,P,_,L,k,R,j;let i=e.objects.get("ui_endgame_1"),a=((E=i==null?void 0:i.gameplay)==null?void 0:E.tuning)||{},s=(C=a.animation_duration_ms)!=null?C:800,o=(P=a.fade_in_duration_ms)!=null?P:600,r=(_=a.scale_animation_intensity)!=null?_:.1,l=(L=a.logo_animation_delay_ms)!=null?L:100,d=(k=a.title_animation_delay_ms)!=null?k:200,p=(R=a.footer_animation_delay_ms)!=null?R:300,c=(j=a.cta_animation_delay_ms)!=null?j:400,{panel:h,logo:u,title:m,subtitle:g,footer:w,ctaButton:v,ctaText:b,ctaHint:f}=t;h.visible=!0,h.element.style.visibility="visible";let y=Date.now(),S=()=>{let be=Date.now()-y,q=Math.min(be/o,1),Y=1-Math.pow(1-q,3);h.alpha=Y,h.element.style.opacity=Y.toString();let Ie=1+r*(1-Y);h.element.style.transform=`translate(-50%, -50%) scale(${Ie})`,q<1?requestAnimationFrame(S):(setTimeout(()=>Jr(u,s,e),l),setTimeout(()=>{Zr(m,s),setTimeout(()=>Qr(g,s),50)},d),setTimeout(()=>el(w,s),p),setTimeout(()=>{tl(v,b,s),setTimeout(()=>nl(f,s),50),n&&n()},c))};S()}function Jr(t,e,n){var h,u,m,g,w;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(u=(((h=i==null?void 0:i.gameplay)==null?void 0:h.tuning)||{}).animation_start_scale)!=null?u:1.2,o=Date.now(),r=t.material.opacity,l=(m=t.targetAlpha)!=null?m:1,d=(g=t.baseScaleX)!=null?g:t.scale.x,p=(w=t.baseScaleY)!=null?w:t.scale.y,c=()=>{let v=Date.now()-o,b=Math.min(v/e,1),f=1-Math.pow(1-b,2);t.material.opacity=r+(l-r)*f;let y=s+(1-s)*f;t.scale.set(d*y,p*y,1),b<1&&requestAnimationFrame(c)};c()}function Zr(t,e){let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=parseFloat(t.element.style.top||"0"),s=()=>{let o=Date.now()-n,r=Math.min(o/e,1),l=1-Math.pow(1-r,2);t.element.style.opacity=(i+(1-i)*l).toString(),t.element.style.top=`${a-20*(1-l)}px`,r<1&&requestAnimationFrame(s)};s()}function Qr(t,e){var r;let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=parseFloat(t.element.style.top||"0"),s=a-((r=t.animationStartYOffset)!=null?r:-10),o=()=>{let l=Date.now()-n,d=Math.min(l/e,1),p=1-Math.pow(1-d,2);t.element.style.opacity=(i+(1-i)*p).toString(),t.element.style.top=`${a+(s-a)*p}px`,d<1&&requestAnimationFrame(o)};o()}function el(t,e){var o;let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=(o=t.targetAlpha)!=null?o:1,s=()=>{let r=Date.now()-n,l=Math.min(r/e,1),d=1-Math.pow(1-l,2);t.element.style.opacity=(i+(a-i)*d).toString(),l<1&&requestAnimationFrame(s)};s()}function tl(t,e,n){let i=Date.now(),a=parseFloat(t.element.style.opacity||"0"),s=()=>{let o=Date.now()-i,r=Math.min(o/n,1),l=1-Math.pow(1-r,2);t.element.style.opacity=(a+(1-a)*l).toString(),e.element.style.opacity=(a+(1-a)*l).toString(),t.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-l)})`,r<1&&requestAnimationFrame(s)};s()}function nl(t,e){var r;let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=parseFloat(t.element.style.top||"0"),s=a-((r=t.animationStartYOffset)!=null?r:5),o=()=>{let l=Date.now()-n,d=Math.min(l/e,1),p=1-Math.pow(1-d,2);t.element.style.opacity=(i+(1-i)*p).toString(),t.element.style.top=`${a+(s-a)*p}px`,d<1&&requestAnimationFrame(o)};o()}function Es(t,e,n,i){var p,c,h,u;let a=n.objects.get("ui_endgame_hand_1"),s=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},o=(c=s.click_animation_duration_ms)!=null?c:600,r=(h=s.click_delay_ms)!=null?h:2e3,l=(u=s.click_repeat_delay_ms)!=null?u:3e3,d=()=>{var C,P;t.visible=!0,t.material.opacity=1;let m=t.position.x,g=t.position.y,w=(C=s.hand_offset_x)!=null?C:50,v=(P=s.hand_offset_y)!=null?P:50,b=e.element.getBoundingClientRect(),f=w,y=v,S=Date.now(),E=()=>{var Y,Ie,dt;let _=Date.now()-S,L=Math.min(_/o,1),k=L<.5?2*L*L:1-Math.pow(-2*L+2,2)/2;t.position.set(m+(f-m)*k,g+(y-g)*k,0);let R=(Ie=(Y=a==null?void 0:a.transform)==null?void 0:Y.scale)!=null?Ie:.1875,j=(dt=s.hand_scale_multiplier)!=null?dt:2.5,be=R*j*100,q=be+be*.2*Math.sin(L*Math.PI);t.scale.set(q,q,1),L<1?requestAnimationFrame(E):(e.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{e.element.style.transform="translate(-50%, -50%) scale(1)",i()},100),setTimeout(()=>{t.material.opacity=0,setTimeout(()=>{t.position.set(m,g,0),d()},l)},500))};E()};setTimeout(d,r)}var Ft=he(require("three"),1);function Cs(t,e,n){var u,m,g,w,v,b,f;let i=e.objects.get("hand_tutorial_1"),a=((u=i==null?void 0:i.gameplay)==null?void 0:u.tuning)||{},s=(i==null?void 0:i.render)||{},o=(i==null?void 0:i.transform)||{},r=new Ft.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),l=new Ft.Sprite(r),d=o.position||{},p=(m=d==null?void 0:d.z)!=null?m:0;l.position.set(n.x+((g=d==null?void 0:d.x)!=null?g:0),n.y+((w=d==null?void 0:d.y)!=null?w:0),p),l.material.opacity=s.alpha!==void 0&&s.alpha!==null?s.alpha:0,l.visible=s.visible!==void 0&&s.visible!==null?s.visible:!1;let c=(v=a.hand_scale_multiplier)!=null?v:2.5,h=(b=o.scale)!=null?b:.1875;return l.scale.set(h*c*100,h*c*100,1),l.renderOrder=(f=s.z_index)!=null?f:99999,l}function As(t){var m,g,w,v,b,f,y,S,E;let e=t.objects.get("ui_tutorial_1"),n=e==null?void 0:e.ui,i=(e==null?void 0:e.render)||{},a=((m=t.engine.runtime)==null?void 0:m.ui_styles)||{},s=((g=t.engine.runtime)==null?void 0:g.ui)||{},o=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||a.label_font_size||52,d=(v=n==null?void 0:n.letterSpacing)!=null?v:(w=a.label_letter_spacing)!=null?w:-1,p=(n==null?void 0:n.align)||"center",c=i.tint,h=typeof c=="string"?c:c?`#${c.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",u=document.createElement("div");return u.textContent=o,u.style.cssText=`
367
+ `;let lo=Vt+Jn/2+20,co=f-y-10,po=Math.min(lo+((na=ei.animation_start_y_offset)!=null?na:5),co);Se.style.top=`${po}px`,Se.style.left="50%";let Yt=Pe(Se);Yt.element=Se,Yt.animationStartYOffset=(ia=ei.animation_start_y_offset)!=null?ia:5,k.appendChild(Se);let Xt=((aa=c==null?void 0:c.gameplay)==null?void 0:aa.tuning)||{},uo=(sa=Xt.hand_offset_x)!=null?sa:50,ho=(oa=Xt.hand_offset_y)!=null?oa:50,go=(la=(ra=c==null?void 0:c.transform)==null?void 0:ra.scale)!=null?la:.1875,mo=(ca=Xt.hand_scale_multiplier)!=null?ca:2.5,fo=new qe.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),We=new qe.Sprite(fo),ni=go*mo*100;return We.scale.set(ni,ni,1),We.position.set(uo,Vt+ho,0),We.material.opacity=0,We.visible=!1,{panel:R,logo:X,title:Un,subtitle:Ut,footer:qt,ctaButton:Wt,ctaText:Qn,ctaHint:Yt,hand:We}}function Ss(t,e,n){var E,C,I,_,L,k,R,j;let i=e.objects.get("ui_endgame_1"),a=((E=i==null?void 0:i.gameplay)==null?void 0:E.tuning)||{},s=(C=a.animation_duration_ms)!=null?C:800,o=(I=a.fade_in_duration_ms)!=null?I:600,r=(_=a.scale_animation_intensity)!=null?_:.1,l=(L=a.logo_animation_delay_ms)!=null?L:100,d=(k=a.title_animation_delay_ms)!=null?k:200,p=(R=a.footer_animation_delay_ms)!=null?R:300,c=(j=a.cta_animation_delay_ms)!=null?j:400,{panel:h,logo:u,title:m,subtitle:g,footer:w,ctaButton:v,ctaText:b,ctaHint:f}=t;h.visible=!0,h.element.style.visibility="visible";let y=Date.now(),S=()=>{let be=Date.now()-y,q=Math.min(be/o,1),Y=1-Math.pow(1-q,3);h.alpha=Y,h.element.style.opacity=Y.toString();let Me=1+r*(1-Y);h.element.style.transform=`translate(-50%, -50%) scale(${Me})`,q<1?requestAnimationFrame(S):(setTimeout(()=>Jr(u,s,e),l),setTimeout(()=>{Zr(m,s),setTimeout(()=>Qr(g,s),50)},d),setTimeout(()=>el(w,s),p),setTimeout(()=>{tl(v,b,s),setTimeout(()=>nl(f,s),50),n&&n()},c))};S()}function Jr(t,e,n){var h,u,m,g,w;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(u=(((h=i==null?void 0:i.gameplay)==null?void 0:h.tuning)||{}).animation_start_scale)!=null?u:1.2,o=Date.now(),r=t.material.opacity,l=(m=t.targetAlpha)!=null?m:1,d=(g=t.baseScaleX)!=null?g:t.scale.x,p=(w=t.baseScaleY)!=null?w:t.scale.y,c=()=>{let v=Date.now()-o,b=Math.min(v/e,1),f=1-Math.pow(1-b,2);t.material.opacity=r+(l-r)*f;let y=s+(1-s)*f;t.scale.set(d*y,p*y,1),b<1&&requestAnimationFrame(c)};c()}function Zr(t,e){let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=parseFloat(t.element.style.top||"0"),s=()=>{let o=Date.now()-n,r=Math.min(o/e,1),l=1-Math.pow(1-r,2);t.element.style.opacity=(i+(1-i)*l).toString(),t.element.style.top=`${a-20*(1-l)}px`,r<1&&requestAnimationFrame(s)};s()}function Qr(t,e){var r;let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=parseFloat(t.element.style.top||"0"),s=a-((r=t.animationStartYOffset)!=null?r:-10),o=()=>{let l=Date.now()-n,d=Math.min(l/e,1),p=1-Math.pow(1-d,2);t.element.style.opacity=(i+(1-i)*p).toString(),t.element.style.top=`${a+(s-a)*p}px`,d<1&&requestAnimationFrame(o)};o()}function el(t,e){var o;let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=(o=t.targetAlpha)!=null?o:1,s=()=>{let r=Date.now()-n,l=Math.min(r/e,1),d=1-Math.pow(1-l,2);t.element.style.opacity=(i+(a-i)*d).toString(),l<1&&requestAnimationFrame(s)};s()}function tl(t,e,n){let i=Date.now(),a=parseFloat(t.element.style.opacity||"0"),s=()=>{let o=Date.now()-i,r=Math.min(o/n,1),l=1-Math.pow(1-r,2);t.element.style.opacity=(a+(1-a)*l).toString(),e.element.style.opacity=(a+(1-a)*l).toString(),t.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-l)})`,r<1&&requestAnimationFrame(s)};s()}function nl(t,e){var r;let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=parseFloat(t.element.style.top||"0"),s=a-((r=t.animationStartYOffset)!=null?r:5),o=()=>{let l=Date.now()-n,d=Math.min(l/e,1),p=1-Math.pow(1-d,2);t.element.style.opacity=(i+(1-i)*p).toString(),t.element.style.top=`${a+(s-a)*p}px`,d<1&&requestAnimationFrame(o)};o()}function Es(t,e,n,i){var p,c,h,u;let a=n.objects.get("ui_endgame_hand_1"),s=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},o=(c=s.click_animation_duration_ms)!=null?c:600,r=(h=s.click_delay_ms)!=null?h:2e3,l=(u=s.click_repeat_delay_ms)!=null?u:3e3,d=()=>{var C,I;t.visible=!0,t.material.opacity=1;let m=t.position.x,g=t.position.y,w=(C=s.hand_offset_x)!=null?C:50,v=(I=s.hand_offset_y)!=null?I:50,b=e.element.getBoundingClientRect(),f=w,y=v,S=Date.now(),E=()=>{var Y,Me,dt;let _=Date.now()-S,L=Math.min(_/o,1),k=L<.5?2*L*L:1-Math.pow(-2*L+2,2)/2;t.position.set(m+(f-m)*k,g+(y-g)*k,0);let R=(Me=(Y=a==null?void 0:a.transform)==null?void 0:Y.scale)!=null?Me:.1875,j=(dt=s.hand_scale_multiplier)!=null?dt:2.5,be=R*j*100,q=be+be*.2*Math.sin(L*Math.PI);t.scale.set(q,q,1),L<1?requestAnimationFrame(E):(e.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{e.element.style.transform="translate(-50%, -50%) scale(1)",i()},100),setTimeout(()=>{t.material.opacity=0,setTimeout(()=>{t.position.set(m,g,0),d()},l)},500))};E()};setTimeout(d,r)}var Ft=he(require("three"),1);function Cs(t,e,n){var u,m,g,w,v,b,f;let i=e.objects.get("hand_tutorial_1"),a=((u=i==null?void 0:i.gameplay)==null?void 0:u.tuning)||{},s=(i==null?void 0:i.render)||{},o=(i==null?void 0:i.transform)||{},r=new Ft.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),l=new Ft.Sprite(r),d=o.position||{},p=(m=d==null?void 0:d.z)!=null?m:0;l.position.set(n.x+((g=d==null?void 0:d.x)!=null?g:0),n.y+((w=d==null?void 0:d.y)!=null?w:0),p),l.material.opacity=s.alpha!==void 0&&s.alpha!==null?s.alpha:0,l.visible=s.visible!==void 0&&s.visible!==null?s.visible:!1;let c=(v=a.hand_scale_multiplier)!=null?v:2.5,h=(b=o.scale)!=null?b:.1875;return l.scale.set(h*c*100,h*c*100,1),l.renderOrder=(f=s.z_index)!=null?f:99999,l}function As(t){var m,g,w,v,b,f,y,S,E;let e=t.objects.get("ui_tutorial_1"),n=e==null?void 0:e.ui,i=(e==null?void 0:e.render)||{},a=((m=t.engine.runtime)==null?void 0:m.ui_styles)||{},s=((g=t.engine.runtime)==null?void 0:g.ui)||{},o=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||a.label_font_size||52,d=(v=n==null?void 0:n.letterSpacing)!=null?v:(w=a.label_letter_spacing)!=null?w:-1,p=(n==null?void 0:n.align)||"center",c=i.tint,h=typeof c=="string"?c:c?`#${c.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",u=document.createElement("div");return u.textContent=o,u.style.cssText=`
368
368
  font-family: ${te(r)};
369
369
  font-size: ${l}px;
370
370
  font-weight: ${ne(r)};
@@ -379,4 +379,4 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
379
379
  position: absolute;
380
380
  transform: translate(-50%, -50%);
381
381
  white-space: nowrap;
382
- `,u}function Ts(t,e,n,i,a){var l,d,p,c,h,u,m;let s=a.objects.get("hand_tutorial_1"),o=((l=s==null?void 0:s.gameplay)==null?void 0:l.tuning)||{},r=(s==null?void 0:s.transform)||{};if(!i){let g=(d=o.animation_duration)!=null?d:1.5,w=n%g/g,v=w<.5?2*w*w:-1+(4-2*w)*w,b=(p=o.x_offset)!=null?p:0,f=(c=o.y_offset)!=null?c:0,y=(h=o.animation_range)!=null?h:40,S=y*.7,E=y,C=e.x+b+S,P=e.y+f+E,_=C+S,L=P+E;t.position.set(C+(_-C)*v,P+(L-P)*v,0);let k=(u=r.scale)!=null?u:.1875,R=(m=o.hand_scale_multiplier)!=null?m:2.5,j=k*R*100;t.scale.set(j,j,1)}}var Ve=he(require("three"),1),Ls=new Ve.TextureLoader,Dn=null,Nn=null;async function ks(){if(Dn)return Dn;if(!Nn){let n=(()=>{if(typeof window!="undefined")try{return new URL("inline-assets.js",window.location.href).href}catch{return"./inline-assets.js"}return"./inline-assets.js"})();Nn=fetch(n).then(i=>{if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.text()}).then(i=>{let a=i.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)return new Function("return "+a[1])();throw new Error("INLINE_ASSETS export not found")}).then(i=>i?i.INLINE_ASSETS?i.INLINE_ASSETS:(console.warn("[assets] Module does not have INLINE_ASSETS export. Module keys:",Object.keys(i)),{}):(console.warn("[assets] Module import returned undefined"),{})).catch(i=>(console.warn("[assets] Failed to load inline-assets.js:",i),{}))}let t=await Nn;return Dn=t||{},t||{}}async function Fn(t,e,n=16777215,i=!1){try{let s=(await ks())[t];return await Ls.loadAsync(s||t)}catch{console.warn(`Asset missing: ${t}. Using placeholder.`);let s=document.createElement("canvas");s.width=64,s.height=64;let o=s.getContext("2d");return o&&(o.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?o.fillRect(0,0,30,60):(o.beginPath(),o.arc(32,32,30,0,Math.PI*2),o.fill(),o.fillRect(27,32,10,40))),new Ve.CanvasTexture(s)}}async function Ps(t,e,n){var g,w;let a=(await ks())[t]||t,s;try{s=await Ls.loadAsync(a),console.log("[character] loaded sheet",{path:t,sourceUsed:a})}catch(v){let y=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");s=await Fn(t,e,parseInt(y,16),!0),console.warn("[character] fallback loadAsset used",{path:t,err:v})}if(!s)return[];let o=n.gameplay.character_sheet||{},r=(g=o.cols)!=null?g:3,l=(w=o.rows)!=null?w:2,d=s.image,p=(d==null?void 0:d.width)||0,c=(d==null?void 0:d.height)||0,h=p/r,u=c/l;if(!Number.isFinite(h)||!Number.isFinite(u)||h<=0||u<=0)return[s];let m=[];for(let v=0;v<l;v++)for(let b=0;b<r;b++){let f=document.createElement("canvas");f.width=h,f.height=u;let y=f.getContext("2d");y&&d&&y.drawImage(d,b*h,v*u,h,u,0,0,h,u),m.push(new Ve.CanvasTexture(f))}return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function Ms(t,e){var c,h,u,m;let n=e.gameplay.brush||{},i=e.theme.brush_color||"#ffffff",a=(c=n.radius)!=null?c:20,s=(h=n.inner_radius)!=null?h:15,o=(u=n.alpha)!=null?u:.8,r=(m=n.inner_alpha)!=null?m:.3,l=n.inner_color||"#ffffff",d=document.createElement("canvas");d.width=a*2,d.height=a*2;let p=d.getContext("2d");return p&&(p.clearRect(0,0,d.width,d.height),p.beginPath(),p.arc(a,a,a,0,Math.PI*2),p.fillStyle=i,p.globalAlpha=o,p.fill(),p.beginPath(),p.arc(a,a,s,0,Math.PI*2),p.fillStyle=l,p.globalAlpha=r,p.fill()),new Ve.CanvasTexture(d)}0&&(module.exports={AspectClass,GameObject,GameObjectManager,Renderer,ResponsiveUISystem,Transform,animateHandClick,animatePanelEntrance,createBrushTexture,createEndGamePanel,createHandTutorial,createThreeBase,createTutorialLabel,getAspectClass,getRegisteredFontIds,loadAsset,loadCharacterFrames,registerFont,resolveFont,resolveFontWeight,updateHandAnimation});
382
+ `,u}function Ts(t,e,n,i,a){var l,d,p,c,h,u,m;let s=a.objects.get("hand_tutorial_1"),o=((l=s==null?void 0:s.gameplay)==null?void 0:l.tuning)||{},r=(s==null?void 0:s.transform)||{};if(!i){let g=(d=o.animation_duration)!=null?d:1.5,w=n%g/g,v=w<.5?2*w*w:-1+(4-2*w)*w,b=(p=o.x_offset)!=null?p:0,f=(c=o.y_offset)!=null?c:0,y=(h=o.animation_range)!=null?h:40,S=y*.7,E=y,C=e.x+b+S,I=e.y+f+E,_=C+S,L=I+E;t.position.set(C+(_-C)*v,I+(L-I)*v,0);let k=(u=r.scale)!=null?u:.1875,R=(m=o.hand_scale_multiplier)!=null?m:2.5,j=k*R*100;t.scale.set(j,j,1)}}var Ve=he(require("three"),1),Ls=new Ve.TextureLoader,Dn=null,Nn=null;async function ks(){if(Dn)return Dn;if(!Nn){let n=(()=>{if(typeof window!="undefined")try{return new URL("inline-assets.js",window.location.href).href}catch{return"./inline-assets.js"}return"./inline-assets.js"})();Nn=fetch(n).then(i=>{if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.text()}).then(i=>{let a=i.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)return new Function("return "+a[1])();throw new Error("INLINE_ASSETS export not found")}).then(i=>i?i.INLINE_ASSETS?i.INLINE_ASSETS:(console.warn("[assets] Module does not have INLINE_ASSETS export. Module keys:",Object.keys(i)),{}):(console.warn("[assets] Module import returned undefined"),{})).catch(i=>(console.warn("[assets] Failed to load inline-assets.js:",i),{}))}let t=await Nn;return Dn=t||{},t||{}}async function Fn(t,e,n=16777215,i=!1){try{let s=(await ks())[t];return await Ls.loadAsync(s||t)}catch{console.warn(`Asset missing: ${t}. Using placeholder.`);let s=document.createElement("canvas");s.width=64,s.height=64;let o=s.getContext("2d");return o&&(o.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?o.fillRect(0,0,30,60):(o.beginPath(),o.arc(32,32,30,0,Math.PI*2),o.fill(),o.fillRect(27,32,10,40))),new Ve.CanvasTexture(s)}}async function Is(t,e,n){var g,w;let a=(await ks())[t]||t,s;try{s=await Ls.loadAsync(a),console.log("[character] loaded sheet",{path:t,sourceUsed:a})}catch(v){let y=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");s=await Fn(t,e,parseInt(y,16),!0),console.warn("[character] fallback loadAsset used",{path:t,err:v})}if(!s)return[];let o=n.gameplay.character_sheet||{},r=(g=o.cols)!=null?g:3,l=(w=o.rows)!=null?w:2,d=s.image,p=(d==null?void 0:d.width)||0,c=(d==null?void 0:d.height)||0,h=p/r,u=c/l;if(!Number.isFinite(h)||!Number.isFinite(u)||h<=0||u<=0)return[s];let m=[];for(let v=0;v<l;v++)for(let b=0;b<r;b++){let f=document.createElement("canvas");f.width=h,f.height=u;let y=f.getContext("2d");y&&d&&y.drawImage(d,b*h,v*u,h,u,0,0,h,u),m.push(new Ve.CanvasTexture(f))}return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function Ps(t,e){var c,h,u,m;let n=e.gameplay.brush||{},i=e.theme.brush_color||"#ffffff",a=(c=n.radius)!=null?c:20,s=(h=n.inner_radius)!=null?h:15,o=(u=n.alpha)!=null?u:.8,r=(m=n.inner_alpha)!=null?m:.3,l=n.inner_color||"#ffffff",d=document.createElement("canvas");d.width=a*2,d.height=a*2;let p=d.getContext("2d");return p&&(p.clearRect(0,0,d.width,d.height),p.beginPath(),p.arc(a,a,a,0,Math.PI*2),p.fillStyle=i,p.globalAlpha=o,p.fill(),p.beginPath(),p.arc(a,a,s,0,Math.PI*2),p.fillStyle=l,p.globalAlpha=r,p.fill()),new Ve.CanvasTexture(d)}0&&(module.exports={AspectClass,GameObject,GameObjectManager,Renderer,ResponsiveUISystem,Transform,animateHandClick,animatePanelEntrance,createBrushTexture,createEndGamePanel,createHandTutorial,createThreeBase,createTutorialLabel,getAspectClass,getRegisteredFontIds,loadAsset,loadCharacterFrames,registerFont,resolveFont,resolveFontWeight,updateHandAnimation});