handler-playable-sdk 0.4.37 → 0.4.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-2ALSYWZ5.js → chunk-FCKOPGOW.js} +2 -2
- package/dist/cli/brand-dna.mjs +1 -1
- package/dist/cli/canva-import.mjs +1 -1
- package/dist/cli/cleanup-assets.mjs +1 -1
- package/dist/cli/fix-scales.mjs +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/screen-helper.mjs +1 -1
- package/dist/cli/setup-library.mjs +1 -1
- package/dist/cli/student-helper.mjs +1 -1
- package/dist/cli/sync-screens.mjs +1 -1
- package/dist/cli/validate-assets.mjs +1 -1
- package/dist/cli/validate.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.css +1 -0
- package/dist/index.js +1 -1
- package/dist/pixi/index.cjs +1 -1
- package/dist/pixi/index.css +1 -0
- package/dist/pixi/index.js +1 -1
- package/dist/three/index.cjs +12 -12
- package/dist/three/index.css +1 -0
- package/dist/three/index.js +1 -1
- package/package.json +1 -1
package/dist/three/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var mo=Object.create;var ft=Object.defineProperty;var bo=Object.getOwnPropertyDescriptor;var yo=Object.getOwnPropertyNames;var vo=Object.getPrototypeOf,xo=Object.prototype.hasOwnProperty;var ie=(t,e)=>()=>(t&&(e=t(t=0)),e);var oa=(t,e)=>{for(var n in e)ft(t,n,{get:e[n],enumerable:!0})},sa=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of yo(e))!xo.call(t,a)&&a!==n&&ft(t,a,{get:()=>e[a],enumerable:!(i=bo(e,a))||i.enumerable});return t};var ae=(t,e,n)=>(n=t!=null?mo(vo(t)):{},sa(e||!t||!t.__esModule?ft(n,"default",{value:t,enumerable:!0}):n,t)),wo=t=>sa(ft({},"__esModule",{value:!0}),t);var re,nn=ie(()=>{"use strict";re=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()}};re.store=new Map});function ko(){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 Mo(){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 Po(){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 Oo(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${C}`),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(!(C==="publish"&&X!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),oe;if(!an){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),an=(async()=>{try{try{let r=await import(e+"?t="+Date.now());if(r.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(r.INLINE_ASSETS)),r.INLINE_ASSETS}catch(r){console.warn("[AssetLoader] ES module import failed, trying text parse:",r)}let 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 r=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let o=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(o)),o}catch(r){return console.warn("[AssetLoader] Failed to parse inline assets:",r),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",i.substring(0,500)),{}}catch(n){return console.warn("[AssetLoader] Failed to load inline assets:",n),{}}})()}return oe=await an,console.log("[AssetLoader] Final inline assets cache:",Object.keys(oe)),oe}function rn(t){return t===null||typeof t!="object"||(Object.freeze(t),Object.values(t).forEach(e=>rn(e))),t}function Ro(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),se.Texture.from(i)}function on(t,e){Na.set(t,e)}var se,za,Fa,Ee,C,X,he,oe,an,Na,Se,vt=ie(()=>{"use strict";se=require("pixi.js");nn();za=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Fa=ko(),Ee=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,C=Fa?"publish":za,X=Ee==null?void 0:Ee.assetsInlined;Ee!=null&&Ee.buildMode&&(C=Ee.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${C}`));he=Po();he!=null&&he.buildMode&&(C=he.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${C}`));(he==null?void 0:he.assetsInlined)!==void 0&&(X=he.assetsInlined);Mo().then(t=>{t!=null&&t.buildMode&&t.buildMode!==C&&(C=t.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${C}`)),(t==null?void 0:t.assetsInlined)!==void 0&&(X=t.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${za}, Runtime: ${Fa?"publish":"dev"}, Effective: ${C}`);oe={},an=null;Na=new Map;Se=class{static async load(e,n,i,a){let r=`${e}:${n.path}`,o=re.get(r);if(o!==void 0)return o;console.log(`[AssetLoader] Loading asset: ${e}, type: ${n.type}, Effective mode: ${C}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let s=await Oo(),l=s[e];if(!l&&a&&(l=s[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 g=c[c.length-1].split(".")[0];s[g]&&(l=s[g],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${g}`))}}if(console.log("[AssetLoader] Inline data for",e,":",l?"FOUND":"NOT FOUND"),C==="publish"&&X!==!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=Na.get(n.type);if(p)try{let c=await p(n.path,l,e,i);return re.set(r,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=rn(c);break;default:throw new Error(`Unknown asset type: ${n.type}`)}return re.set(r,c),c}catch(c){return this.handleFailure(e,n.type,c)}}static async loadImage(e,n){let i=C==="publish",a=i&&X!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${C}, 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 se.Assets.load(n)}catch(r){throw console.error("[AssetLoader] Failed to load texture from data URI:",r),r}}if(n&&typeof n=="string"&&n.startsWith("data:"))try{return await se.Assets.load(n)}catch(r){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",r),await se.Assets.load(e)}return await se.Assets.load(e)}static async loadJSON(e,n){let i=C==="publish",a=i&&X!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${C}, 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 r=await fetch(e);if(!r.ok)throw new Error(`JSON fetch failed: ${e}`);return r.json()}static handleFailure(e,n,i){if(C==="dev"){let r=n==="image"?Ro():rn({__placeholder:!0,type:n});return re.set(e+":"+((i==null?void 0:i.path)||"missing"),r),r}throw i}};on("image",async(t,e)=>{let n=C==="publish",i=n&&X!==!1,a=C==="brand",r=n&&X===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${C}, 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 se.Assets.load(e)}let o=t;return(a||r)&&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}"`))),se.Assets.load(e||o)});on("json",async(t,e)=>{let n=C==="publish",i=n&&X!==!1,a=C==="brand",r=n&&X===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${C}, 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||r)&&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 s=await fetch(o);if(!s.ok)throw new Error(`JSON fetch failed: ${t}`);return s.json()})});var ln,zo,xt,Xe=ie(()=>{"use strict";vt();ln=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=[],r=[];for(let[s,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 g=(c=l.identity)==null?void 0:c.id;console.log(`[AssetTextures] Loading ${d.type}: ${s} (${g})`);let u=await Se.load(s,d,n,g);this.textures.set(s,u),console.log(`[AssetTextures] \u2713 Loaded: ${s}`)}catch(g){console.error(`[AssetTextures] \u2717 Failed to load: ${s}`,g)}finally{this.attempted.add(s);try{for(let g of Array.from(this.waiters))g()}catch{}}};i.has(s)?a.push(p()):r.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(r),console.log("[AssetTextures] All textures loaded:",Array.from(this.textures.keys()))})(),this.readyPromise}async priorityReady(){return this.priorityReadyPromise?this.priorityReadyPromise:Promise.resolve()}async waitFor(e,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(s=>typeof s=="string"&&s))).filter(s=>{var l,d,p,c;try{let g=(p=(d=(l=this.config)==null?void 0:l.objects)==null?void 0:d.get)==null?void 0:p.call(d,s);return!!((c=g==null?void 0:g.render)!=null&&c.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let r=()=>a.every(s=>this.textures.has(s)||this.attempted.has(s));if(r())return;let o=typeof n.timeoutMs=="number"?n.timeoutMs:15e3;await new Promise(s=>{let l=!1,d=()=>{l||r()&&(l=!0,this.waiters.delete(d),s())};this.waiters.add(d),d(),o>0&&setTimeout(()=>{l||(l=!0,this.waiters.delete(d),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),s())},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())}},zo=new ln,xt=new Proxy(zo,{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 ss,fe=ie(()=>{"use strict";ss="handler_preview_override_mode";if(typeof window!="undefined"){let t=window.localStorage.getItem(ss);window.__enableConfigOverrides=t===null?!0:t==="true"}});var Wa,Te,Ec,un=ie(()=>{"use strict";fe();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);Ec=Te==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var gn=ie(()=>{"use strict"});var Ya=ie(()=>{"use strict";gn();un()});var hn=ie(()=>{"use strict";un();gn();Ya()});var tr={};oa(tr,{AssetEditorModal:()=>wn});var wn,En=ie(()=>{"use strict";wn=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 mo=Object.create;var ft=Object.defineProperty;var bo=Object.getOwnPropertyDescriptor;var yo=Object.getOwnPropertyNames;var vo=Object.getPrototypeOf,xo=Object.prototype.hasOwnProperty;var ie=(t,e)=>()=>(t&&(e=t(t=0)),e);var oa=(t,e)=>{for(var n in e)ft(t,n,{get:e[n],enumerable:!0})},sa=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of yo(e))!xo.call(t,a)&&a!==n&&ft(t,a,{get:()=>e[a],enumerable:!(i=bo(e,a))||i.enumerable});return t};var ae=(t,e,n)=>(n=t!=null?mo(vo(t)):{},sa(e||!t||!t.__esModule?ft(n,"default",{value:t,enumerable:!0}):n,t)),wo=t=>sa(ft({},"__esModule",{value:!0}),t);var re,nn=ie(()=>{"use strict";re=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()}};re.store=new Map});function ko(){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 Mo(){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 Po(){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: ${C}`),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(!(C==="publish"&&X!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),oe;if(!an){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),an=(async()=>{try{try{let r=await import(e+"?t="+Date.now());if(r.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(r.INLINE_ASSETS)),r.INLINE_ASSETS}catch(r){console.warn("[AssetLoader] ES module import failed, trying text parse:",r)}let 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 r=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let o=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(o)),o}catch(r){return console.warn("[AssetLoader] Failed to parse inline assets:",r),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",i.substring(0,500)),{}}catch(n){return console.warn("[AssetLoader] Failed to load inline assets:",n),{}}})()}return oe=await an,console.log("[AssetLoader] Final inline assets cache:",Object.keys(oe)),oe}function rn(t){return t===null||typeof t!="object"||(Object.freeze(t),Object.values(t).forEach(e=>rn(e))),t}function Oo(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),se.Texture.from(i)}function on(t,e){Na.set(t,e)}var se,za,Fa,Ee,C,X,he,oe,an,Na,Se,vt=ie(()=>{"use strict";se=require("pixi.js");nn();za=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Fa=ko(),Ee=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,C=Fa?"publish":za,X=Ee==null?void 0:Ee.assetsInlined;Ee!=null&&Ee.buildMode&&(C=Ee.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${C}`));he=Po();he!=null&&he.buildMode&&(C=he.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${C}`));(he==null?void 0:he.assetsInlined)!==void 0&&(X=he.assetsInlined);Mo().then(t=>{t!=null&&t.buildMode&&t.buildMode!==C&&(C=t.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${C}`)),(t==null?void 0:t.assetsInlined)!==void 0&&(X=t.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${za}, Runtime: ${Fa?"publish":"dev"}, Effective: ${C}`);oe={},an=null;Na=new Map;Se=class{static async load(e,n,i,a){let r=`${e}:${n.path}`,o=re.get(r);if(o!==void 0)return o;console.log(`[AssetLoader] Loading asset: ${e}, type: ${n.type}, Effective mode: ${C}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let s=await Ro(),l=s[e];if(!l&&a&&(l=s[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 g=c[c.length-1].split(".")[0];s[g]&&(l=s[g],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${g}`))}}if(console.log("[AssetLoader] Inline data for",e,":",l?"FOUND":"NOT FOUND"),C==="publish"&&X!==!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=Na.get(n.type);if(p)try{let c=await p(n.path,l,e,i);return re.set(r,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=rn(c);break;default:throw new Error(`Unknown asset type: ${n.type}`)}return re.set(r,c),c}catch(c){return this.handleFailure(e,n.type,c)}}static async loadImage(e,n){let i=C==="publish",a=i&&X!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${C}, 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 se.Assets.load(n)}catch(r){throw console.error("[AssetLoader] Failed to load texture from data URI:",r),r}}if(n&&typeof n=="string"&&n.startsWith("data:"))try{return await se.Assets.load(n)}catch(r){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",r),await se.Assets.load(e)}return await se.Assets.load(e)}static async loadJSON(e,n){let i=C==="publish",a=i&&X!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${C}, 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 r=await fetch(e);if(!r.ok)throw new Error(`JSON fetch failed: ${e}`);return r.json()}static handleFailure(e,n,i){if(C==="dev"){let r=n==="image"?Oo():rn({__placeholder:!0,type:n});return re.set(e+":"+((i==null?void 0:i.path)||"missing"),r),r}throw i}};on("image",async(t,e)=>{let n=C==="publish",i=n&&X!==!1,a=C==="brand",r=n&&X===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${C}, 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 se.Assets.load(e)}let o=t;return(a||r)&&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}"`))),se.Assets.load(e||o)});on("json",async(t,e)=>{let n=C==="publish",i=n&&X!==!1,a=C==="brand",r=n&&X===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${C}, 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||r)&&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 s=await fetch(o);if(!s.ok)throw new Error(`JSON fetch failed: ${t}`);return s.json()})});var ln,zo,xt,Xe=ie(()=>{"use strict";vt();ln=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=[],r=[];for(let[s,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 g=(c=l.identity)==null?void 0:c.id;console.log(`[AssetTextures] Loading ${d.type}: ${s} (${g})`);let u=await Se.load(s,d,n,g);this.textures.set(s,u),console.log(`[AssetTextures] \u2713 Loaded: ${s}`)}catch(g){console.error(`[AssetTextures] \u2717 Failed to load: ${s}`,g)}finally{this.attempted.add(s);try{for(let g of Array.from(this.waiters))g()}catch{}}};i.has(s)?a.push(p()):r.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(r),console.log("[AssetTextures] All textures loaded:",Array.from(this.textures.keys()))})(),this.readyPromise}async priorityReady(){return this.priorityReadyPromise?this.priorityReadyPromise:Promise.resolve()}async waitFor(e,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(s=>typeof s=="string"&&s))).filter(s=>{var l,d,p,c;try{let g=(p=(d=(l=this.config)==null?void 0:l.objects)==null?void 0:d.get)==null?void 0:p.call(d,s);return!!((c=g==null?void 0:g.render)!=null&&c.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let r=()=>a.every(s=>this.textures.has(s)||this.attempted.has(s));if(r())return;let o=typeof n.timeoutMs=="number"?n.timeoutMs:15e3;await new Promise(s=>{let l=!1,d=()=>{l||r()&&(l=!0,this.waiters.delete(d),s())};this.waiters.add(d),d(),o>0&&setTimeout(()=>{l||(l=!0,this.waiters.delete(d),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),s())},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())}},zo=new ln,xt=new Proxy(zo,{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 ss,fe=ie(()=>{"use strict";ss="handler_preview_override_mode";if(typeof window!="undefined"){let t=window.localStorage.getItem(ss);window.__enableConfigOverrides=t===null?!0:t==="true"}});var Wa,Te,Ec,un=ie(()=>{"use strict";fe();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);Ec=Te==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var gn=ie(()=>{"use strict"});var Ya=ie(()=>{"use strict";gn();un()});var hn=ie(()=>{"use strict";un();gn();Ya()});var tr={};oa(tr,{AssetEditorModal:()=>wn});var wn,En=ie(()=>{"use strict";wn=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>
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
<button class="debug-btn primary" data-modal-apply>Apply</button>
|
|
44
44
|
</div>
|
|
45
45
|
</div>
|
|
46
|
-
`,this.modal=i}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(o=>{o.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(o=>{o.addEventListener("click",s=>{let d=s.target.dataset.tab;d&&this.switchTab(d)})});let i=this.modal.querySelector("[data-ai-generate]");i==null||i.addEventListener("click",()=>{this.openAiEditor("generate")});let a=this.modal.querySelector("[data-ai-edit]");a==null||a.addEventListener("click",()=>{this.openAiEditor("edit")});let r=this.modal.querySelector("[data-modal-apply]");r==null||r.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",o=>{o.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let n=window.__openAiEditor;if(typeof n!="function"){alert("AI Editor not available. Please check your setup.");return}let i="";e==="edit"&&this.currentAsset?i=`Edit this image: ${this.currentObjectId}`:i=`Create an image for: ${this.currentObjectId}`,n(this.currentObjectId||"unknown",i,this.currentAsset,{path:this.currentPath,onApply:a=>{this.onApplyCallback&&this.onApplyCallback(a),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var Xs={};oa(Xs,{AspectClass:()=>In,GameObject:()=>st,GameObjectManager:()=>$t,Renderer:()=>ot,ResponsiveUISystem:()=>Ge,Transform:()=>rt,animateHandClick:()=>xr,animatePanelEntrance:()=>vr,createBrushTexture:()=>Lr,createEndGamePanel:()=>yr,createHandTutorial:()=>wr,createThreeBase:()=>fr,createTutorialLabel:()=>Er,getAspectClass:()=>Dt,getRegisteredFontIds:()=>br,loadAsset:()=>$n,loadCharacterFrames:()=>Tr,registerFont:()=>mr,resolveFont:()=>Z,resolveFontWeight:()=>Q,updateHandAnimation:()=>Sr});module.exports=wo(Xs);var V=ae(require("three"),1);var ge={};function mt(t,e,n=!1){ge[t]||(ge[t]=[]),ge[t].push({fn:e,once:n})}function Xt(t,e){if(ge[t]){if(!e){delete ge[t];return}ge[t]=ge[t].filter(n=>n.fn!==e)}}function bt(t,...e){let n=ge[t];if(n)for(let i of[...n])i.fn(...e),i.once&&Xt(t,i.fn)}function B(t,e){mt(t,e,!0)}var M=null,W=[],Pe=null;function da(t){M=t,W=[],Pe!==null&&(clearTimeout(Pe),Pe=null)}function pa(){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 la(t,e,n,i){let a=JSON.stringify(e);if(n==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(t,new Blob([a],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function Jt(t,e){let n=pa();if(e&&n.endpoint){if(W.push(t),W.length>n.maxQueue&&(W=W.slice(W.length-n.maxQueue)),W.length>=n.batchSize){ca();return}Pe===null&&(Pe=window.setTimeout(()=>{Pe=null,ca()},n.flushIntervalMs))}}async function ca(){let t=pa();if(!t.endpoint||W.length===0)return;let e=W.splice(0,t.batchSize);await la(t.endpoint,{events:e},t.transport,t.debug),W.length>0&&await la(t.endpoint,{events:W.splice(0,t.batchSize)},t.transport,t.debug)}function ua(t){return Math.max(0,Math.min(1,t))}function Eo(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 Ve(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function So(t,e){let n=t==null?void 0:t[e];return typeof n=="number"?n:0}function ga(t,e,n){try{t[e]=n}catch{}}function Ao(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 ha(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 fa(t,e){let n=Ao(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 ma(){let t=new Set,e=new WeakMap,n=null,i=()=>{if(n!=null)return;n=requestAnimationFrame(()=>{n=null,s(),t.size>0&&i()})},a=p=>{var g;t.add(p);let c=(g=e.get(p.target))!=null?g:new Set;c.add(p),e.set(p.target,c),i()},r=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,r(p))},s=()=>{var c,g;let p=Ve();for(let u of Array.from(t)){if(u.killed||u.paused)continue;let b=p-u.startMs-u.delayMs;if(b<0)continue;let h=u.durationMs>0?b/u.durationMs:1,x=ua(h),v=u.repeat>=0?u.repeat+1:1,y=u.repeat>0?Math.min(Math.floor(h),v-1):0;if(u.repeat>0&&h>=1){let E=h-y;x=ua(E)}let f=u.ease(x);u.yoyo&&y%2===1&&(f=1-f);for(let E of u.props)ga(u.target,E.key,E.from+(E.to-E.from)*f);u.scaleFrom&&u.scaleTo&&ha(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(h>=v){o(u);try{(g=u.onComplete)==null||g.call(u)}catch{}}}},l=(p,c,g)=>{var E;let u=Math.max(0,(typeof c.duration=="number"?c.duration:.5)*1e3),b=Math.max(0,(typeof c.delay=="number"?c.delay:0)*1e3+((E=g==null?void 0:g.delayMsOverride)!=null?E:0)),h=Eo(c.ease),x=typeof c.repeat=="number"?Math.max(0,c.repeat|0):0,v=c.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),f=[];for(let S of Object.keys(c)){if(y.has(S))continue;let A=c[S];typeof A=="number"&&f.push({key:S,from:So(p,S),to:A})}let m=fa(p,c);return{target:p,startMs:Ve(),delayMs:b,durationMs:u,ease:h,props:f,scaleFrom:m.from,scaleTo:m.to,repeat:x,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 g=l(p,c);return a(g),{kill:()=>o(g),pause:()=>{g.paused||(g.paused=!0,g.pauseAtMs=Ve())},resume:()=>{var h;if(!g.paused)return;let u=(h=g.pauseAtMs)!=null?h:Ve(),b=Ve()-u;g.startMs+=b,g.paused=!1,g.pauseAtMs=null},isActive:()=>!g.killed&&!g.paused}},fromTo(p,c,g){return d.set(p,c),d.to(p,g)},set(p,c){if(!p||!c)return;for(let u of Object.keys(c)){let b=c[u];u==="scale"||u==="scaleX"||u==="scaleY"||typeof b=="number"&&ga(p,u,b)}let g=fa(p,c);g.to&&ha(p,g.to)},killTweensOf(p){let c=e.get(p);if(c)for(let g of Array.from(c))o(g)},timeline(p={}){let c=[],g=0,u=!1,b=[],h=y=>{if(typeof y=="number")return Math.max(0,y*1e3);let f=typeof y=="string"?y.trim():"";return f.startsWith("+=")?g+Math.max(0,Number(f.slice(2))*1e3||0):f?Math.max(0,Number(f)*1e3||0):g},x=y=>{c.push(y);let f=Math.max(0,(typeof y.vars.duration=="number"?y.vars.duration:.5)*1e3);g=Math.max(g,y.atMs+f)},v={to(y,f,m){return x({kind:"to",target:y,vars:f,atMs:h(m)}),v},fromTo(y,f,m,E){return x({kind:"fromTo",target:y,vars:m,from:f,atMs:h(E)}),v},play(){var y,f;if(u)return v;u=!0,b=[];for(let m of c)m.kind==="fromTo"&&d.set(m.target,(y=m.from)!=null?y:{}),b.push(d.to(m.target,{...m.vars,delay:m.atMs/1e3+((f=m.vars.delay)!=null?f:0)}));return v},pause(){for(let y of b)y.pause();return v},kill(){for(let y of b)y.kill();b=[],u=!1}};return p.paused||v.play(),v}};return d}function ba(){if(typeof window=="undefined")return;let t=window;if(!t.gsap)try{t.gsap=ma()}catch{}}var ya={name:"handler-playable-sdk",version:"0.4.37",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && chmod +x dist/cli/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var G=0,To=G++,va=G++,xa=G++,wa=G++,Ea=G++,Sa=G++,Aa=G++,Ca=G++,Ta=G++,La=G++,_a=G++,ka=G++,T=To;function Ma(){return T===va}function Pa(){return T===xa}function Oa(){return T===wa}function Ra(){return T===Ea}function Oe(){return T===Sa}function Re(){return T===Aa}function Ia(){return T===Ca}function ja(){return T===Ta}function Da(){return T===La}function Zt(){return T===_a}function Qt(){return T===ka}function $a(){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=va;return}catch{}else if(t==="dapi")try{dapi.isReady(),T=xa;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(T=wa)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(T=Ea)}catch{}else if(e==="mintegral")window.gameReady&&(T=Sa);else if(e==="tapjoy")window.TJ_API&&(T=Aa);else if(e==="tiktok")window.openAppStore&&(T=Ca);else if(e==="smadex")try{window.smxTracking&&(T=Ta)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(T=La)}catch{}else e==="vungle"?T=_a:(t==="nucleo"||e==="nucleo")&&(T=ka)}var yt=ae(require("lottie-web"),1),Ha=yt.default;typeof window!="undefined"&&(window.lottie=yt.default,window.__baseLottie=yt.default);var Lo=require("pixi.js");var en=require("pixi.js");var _o=null;function tn(t){_o=t}vt();nn();var Ye=require("pixi.js");vt();var Io=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",sn=Io;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&&(sn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${sn}`))}}catch{}function jo(t){var n,i,a,r,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:(r=t.y)!=null?r:.5};if(typeof t=="string"){let s=t.trim().toLowerCase();return(o=e[s])!=null?o:{x:.5,y:.5}}return null}var Ae=class{static async create(e,n,i){var l,d,p,c,g,u,b;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${sn}`);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 h=new Ye.Container;return this.applyTransform(h,n==null?void 0:n.transform,n),h}let r=(d=n==null?void 0:n.identity)==null?void 0:d.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${a.type}, path: ${a.path}`);let o=await Se.load(e,a,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(p=o==null?void 0:o.constructor)==null?void 0:p.name}`);let s;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),s=new Ye.Sprite(o),console.log("[ObjectFactory] Created object:",s,"type:",(c=s==null?void 0:s.constructor)==null?void 0:c.name),this.applyTransform(s,n==null?void 0:n.transform,n);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(g=o==null?void 0:o.constructor)==null?void 0:g.name,o),o&&(((u=o.constructor)==null?void 0:u.name)==="Container"||o instanceof Ye.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],x=!1;for(let v of h)try{let y=await fetch(v);if(y.ok){s=await y.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",v,"type:",(b=s==null?void 0:s.constructor)==null?void 0:b.name),x=!0;break}}catch{continue}x||(console.error("[ObjectFactory] Failed to reload JSON from any path"),s=o)}else s=o;else s=o,s&&typeof s=="object"&&("x"in s||"position"in s)&&this.applyTransform(s,n==null?void 0:n.transform,n);return s}static applyTransform(e,n,i){var a,r,o,s;if(!(!n||!e)&&(n.position&&("x"in e&&"y"in e?(e.x=(a=n.position.x)!=null?a:0,e.y=(r=n.position.y)!=null?r:0):"position"in e&&e.position&&e.position.set((o=n.position.x)!=null?o:0,(s=n.position.y)!=null?s: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=jo(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 Ho=ae(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=Ho);Xe();var wt=require("pixi.js");Xe();var cn=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 r=>{var s;let o=this.registry.get(r);if(!o){console.warn("[Assets] No config found for object:",r);return}try{let l=await Ae.create(r,o,this.app);this.instanceCache.set(r,l),console.log("[Assets] Loaded object:",r,(s=l==null?void 0:l.constructor)==null?void 0:s.name)}catch(l){console.error("[Assets] Failed to load object:",r,l)}})))};return this.readyPromise=(async()=>{await i(n);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let n=this.registry.get(e);if(n){let i=await Ae.create(e,n,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},Fo=new cn,No=new Proxy(Fo,{get(t,e){if(e in t&&typeof t[e]=="function")return t[e].bind(t);if(t.get(e))return t.get(e)}});Xe();var Ba=require("pixi.js"),le={width:400,height:600,designWidth:400,scaleFactor:1},St={scale:1,position:1},pn=[];function Uo(t,e,n,i,a,r,o){pn.push({element:t,originalScale:r,positionHelper:e,heightPercent:a}),e(t,n,i,a,r,o,!1)}function qo(){pn.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 dn(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),St.scale=le.scaleFactor,St.position=1,console.log(`[SCREEN] Global multipliers - scale: ${St.scale.toFixed(3)}`),qo()}var Ze={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 Wo(t,e,n){let i=Ze[t];i&&i[e]!==void 0&&(i[e]=n,console.log(`Updated ${t}.${e} = ${n}`))}function Vo(){return Ze}var Yo={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 Et(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function At(t,e={x:.5,y:.5}){var n;if(Array.isArray(t))return{x:Et(t[0],e.x),y:Et(t[1],e.y)};if(t&&typeof t=="object"){let i=t;return{x:Et(i.x,e.x),y:Et(i.y,e.y)}}if(typeof t=="string"){let i=t.trim().toLowerCase();return(n=Yo[i])!=null?n:e}return e}function Ga(t,e,n,i={}){var u,b,h,x,v,y;let a=At(n),r=(u=i.inset)!=null?u:{},o=(b=i.padding)!=null?b:{x:0,y:0},s=((h=r.left)!=null?h:0)+o.x,l=((x=r.right)!=null?x:0)+o.x,d=((v=r.top)!=null?v:0)+o.y,p=((y=r.bottom)!=null?y:0)+o.y,c=Math.max(0,t-s-l),g=Math.max(0,e-d-p);return{x:s+c*a.x,y:d+g*a.y}}function Ua(t,e,n,i={}){var h,x,v,y,f,m;let a=(h=i.inset)!=null?h:{},r=(x=i.padding)!=null?x:{x:0,y:0},o=((v=a.left)!=null?v:0)+r.x,s=((y=a.right)!=null?y:0)+r.x,l=((f=a.top)!=null?f:0)+r.y,d=((m=a.bottom)!=null?m:0)+r.y,p=Math.max(0,t-o-s),c=Math.max(0,e-l-d),g=At(n,{x:.5,y:.5}),u=Math.min(Math.max(g.x,0),1),b=Math.min(Math.max(g.y,0),1);return{x:o+p*u,y:l+c*b}}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,dn(i,a))};window.addEventListener("resize",n),window.addEventListener("orientationchange",()=>{setTimeout(n,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",n),window.mraid.addEventListener("sizeChange",n)),dn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Wo,window.getDebugConfig=Vo,window.copyConfig=rs,window.applyConfig=Je,window.applyConfigForRatio=os,window.positionAtBottom=qa,window.positionAtTop=Jo,window.positionAtCenter=Zo,window.positionAtLeft=Qo,window.positionAtRight=es,window.positionAtBottomLeft=ts,window.positionAtBottomRight=ns,window.positionAtTopLeft=is,window.positionAtTopRight=as,window.applyPositionContract=Xo,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 Ct(t,e,n=0){return t*e+n}function Tt(t,e,n=0){return t*(1-e)+n}function Lt(t,e,n=0){return t*e+n}function _t(t,e,n=0){return t*(1-e)+n}function U(t,e=0){return t/2+e}function Ko(t,e){return t*e}function Xo(t,e,n,i){var o,s,l,d,p,c,g,u,b,h,x,v,y,f,m,E,S,A,k,O;let a=0,r=0;switch(i.type){case"top":a=U(e,(s=(o=i.offset)==null?void 0:o.x)!=null?s:0),r=Ct(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),r=Tt(n,i.percent,(u=(g=i.offset)==null?void 0:g.y)!=null?u:0);break;case"left":a=Lt(e,i.percent,(h=(b=i.offset)==null?void 0:b.x)!=null?h:0),r=U(n,(v=(x=i.offset)==null?void 0:x.y)!=null?v:0);break;case"right":a=_t(e,i.percent,(f=(y=i.offset)==null?void 0:y.x)!=null?f:0),r=U(n,(E=(m=i.offset)==null?void 0:m.y)!=null?E:0);break;case"center":a=U(e,(A=(S=i.offset)==null?void 0:S.x)!=null?A:0),r=U(n,(O=(k=i.offset)==null?void 0:k.y)!=null?O:0);break}t.position?t.position.set(a,r):(t.x=a,t.y=r),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 qa(t,e,n,i=.2,a=1,r=!0,o=!1){let s=Ko(n,i),l=Tt(n,i/2);ce(t,U(e),l);let d=r?a*le.scaleFactor:a;de(t,d),o&&!pn.find(p=>p.element===t)&&Uo(t,qa,e,n,i,a,r)}function Jo(t,e,n,i=.1,a=1){ce(t,U(e),Ct(n,i)),de(t,a)}function Zo(t,e,n,i=0,a=0,r=1){ce(t,U(e,i),U(n,a)),de(t,r)}function Qo(t,e,n,i=.1,a=1){ce(t,Lt(e,i),U(n)),de(t,a)}function es(t,e,n,i=.1,a=1){ce(t,_t(e,i),U(n)),de(t,a)}function ts(t,e,n,i=.05,a=.05,r=1){ce(t,Lt(e,a),Tt(n,i)),de(t,r)}function ns(t,e,n,i=.05,a=.05,r=1){ce(t,_t(e,a),Tt(n,i)),de(t,r)}function is(t,e,n,i=.05,a=.05,r=1){ce(t,Lt(e,a),Ct(n,i)),de(t,r)}function as(t,e,n,i=.05,a=.05,r=1){ce(t,_t(e,a),Ct(n,i)),de(t,r)}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 Ce={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 rs(t){return t&&Ce[t]?JSON.parse(JSON.stringify(Ce[t])):JSON.parse(JSON.stringify(Ze))}function Je(t){Object.keys(t).forEach(e=>{let n=e;Ze[n]&&t[n]&&Object.assign(Ze[n],t[n])}),console.log("Config applied:",t)}function os(t,e){let n=t/e;n>1.6?(Je(Ce.wide),console.log("Applied WIDE config for ratio:",n)):n<.7?(Je(Ce.tall),console.log("Applied TALL config for ratio:",n)):n>.8&&n<1.2?(Je(Ce.square),console.log("Applied SQUARE config for ratio:",n)):(Je(Ce.default),console.log("Applied DEFAULT config for ratio:",n))}if(typeof window!="undefined"){let t=window;t.configPresets=Ce,t.resolveAnchorVec2=t.resolveAnchorVec2||At,t.resolveScreenAnchorPoint=t.resolveScreenAnchorPoint||Ga,t.resolveScreenRatioPoint=t.resolveScreenRatioPoint||Ua}hn();function P(t,e){let n=(a,r)=>r===0?a:n(r,a%r),i=n(t,e);return`${t/i}:${e/i}`}var Bc=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:P(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:P(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:P(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:P(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:P(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:P(360,780)}],Gc=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:P(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:P(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:P(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:P(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:P(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:P(412,915)}],Uc=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:P(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:P(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:P(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:P(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:P(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:P(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:P(768,1024),mraidScale:.7}];var qc=[...Ka];var hs=Ka[0];fe();var xs=ae(require("jszip"),1);function bs(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 ys(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 vs(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 fn(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 r=await bs(a),o=await vs(r),s=ys(r);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",s.mimeType),{base64:s.base64,mimeType:s.mimeType,dataUrl:r,width:(e=o==null?void 0:o.width)!=null?e:0,height:(n=o==null?void 0:o.height)!=null?n:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function kt(t,e=30){try{console.log("[ImageUtils] Removing background color...");let n=await new Promise((c,g)=>{let u=new Image;u.onload=()=>c(u),u.onerror=()=>g(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 r=a.getImageData(0,0,i.width,i.height),o=r.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 g=o[c],u=o[c+1],b=o[c+2],h=!1;for(let x of l)if(Math.sqrt(Math.pow(g-x.r,2)+Math.pow(u-x.g,2)+Math.pow(b-x.b,2))<e){h=!0;break}h&&(o[c+3]=0,d++)}return console.log(`[ImageUtils] Removed background from ${d} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),i.toDataURL("image/png")}catch(n){return console.error("[ImageUtils] Error removing background:",n),t}}var Xa=require("@google/genai");async function mn(t,e,n=[],i={}){var a,r,o,s,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 y=n[v];if(!y.base64||!y.mimeType)throw new Error(`Image ${v+1} is missing required data`);if(y.base64.length<1e3&&console.warn(`Image ${v+1} data appears very small, may be corrupted`),!y.mimeType.startsWith("image/"))throw new Error(`Image ${v+1} has invalid MIME type: ${y.mimeType}`)}let c=new Xa.GoogleGenAI({apiKey:t}),g="gemini-2.5-flash",u=[e];n.length>0&&n.forEach((v,y)=>{u.push({inlineData:{data:v.base64,mimeType:v.mimeType}}),console.log(`[Gemini] Added image ${y+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 b=await c.models.generateContent({model:g,contents:u}),h="",x=(o=(r=(a=b.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:o.parts;if(x)for(let v of x)v.text&&(h+=v.text);if(!h.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${h.length}`),h}catch(c){throw console.error("[Gemini] API error:",c),(s=c.message)!=null&&s.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(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 Ja=require("@google/genai");async function Mt(t,e,n=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Ja.GoogleGenAI({apiKey:t}),r=[{text:e}];n.length>0&&n.forEach((s,l)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${l}`),r.push({inlineData:{mimeType:s.mimeType,data:s.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let s of o.candidates[0].content.parts)if(s.text)console.log(s.text);else if(s.inlineData){let l=s.inlineData.data,d=s.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 ws=require("pixi.js");Xe();fe();var Qa=require("pixi.js");var Es=require("pixi.js");fe();function ks(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 Ms(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 Ps(t){return`
|
|
46
|
+
`,this.modal=i}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(o=>{o.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(o=>{o.addEventListener("click",s=>{let d=s.target.dataset.tab;d&&this.switchTab(d)})});let i=this.modal.querySelector("[data-ai-generate]");i==null||i.addEventListener("click",()=>{this.openAiEditor("generate")});let a=this.modal.querySelector("[data-ai-edit]");a==null||a.addEventListener("click",()=>{this.openAiEditor("edit")});let r=this.modal.querySelector("[data-modal-apply]");r==null||r.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",o=>{o.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let n=window.__openAiEditor;if(typeof n!="function"){alert("AI Editor not available. Please check your setup.");return}let i="";e==="edit"&&this.currentAsset?i=`Edit this image: ${this.currentObjectId}`:i=`Create an image for: ${this.currentObjectId}`,n(this.currentObjectId||"unknown",i,this.currentAsset,{path:this.currentPath,onApply:a=>{this.onApplyCallback&&this.onApplyCallback(a),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var Xs={};oa(Xs,{AspectClass:()=>In,GameObject:()=>st,GameObjectManager:()=>$t,Renderer:()=>ot,ResponsiveUISystem:()=>Ge,Transform:()=>rt,animateHandClick:()=>xr,animatePanelEntrance:()=>vr,createBrushTexture:()=>Lr,createEndGamePanel:()=>yr,createHandTutorial:()=>wr,createThreeBase:()=>fr,createTutorialLabel:()=>Er,getAspectClass:()=>Dt,getRegisteredFontIds:()=>br,loadAsset:()=>$n,loadCharacterFrames:()=>Tr,registerFont:()=>mr,resolveFont:()=>Z,resolveFontWeight:()=>Q,updateHandAnimation:()=>Sr});module.exports=wo(Xs);var V=ae(require("three"),1);var ge={};function mt(t,e,n=!1){ge[t]||(ge[t]=[]),ge[t].push({fn:e,once:n})}function Xt(t,e){if(ge[t]){if(!e){delete ge[t];return}ge[t]=ge[t].filter(n=>n.fn!==e)}}function bt(t,...e){let n=ge[t];if(n)for(let i of[...n])i.fn(...e),i.once&&Xt(t,i.fn)}function B(t,e){mt(t,e,!0)}var M=null,W=[],Pe=null;function da(t){M=t,W=[],Pe!==null&&(clearTimeout(Pe),Pe=null)}function pa(){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 la(t,e,n,i){let a=JSON.stringify(e);if(n==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(t,new Blob([a],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function Jt(t,e){let n=pa();if(e&&n.endpoint){if(W.push(t),W.length>n.maxQueue&&(W=W.slice(W.length-n.maxQueue)),W.length>=n.batchSize){ca();return}Pe===null&&(Pe=window.setTimeout(()=>{Pe=null,ca()},n.flushIntervalMs))}}async function ca(){let t=pa();if(!t.endpoint||W.length===0)return;let e=W.splice(0,t.batchSize);await la(t.endpoint,{events:e},t.transport,t.debug),W.length>0&&await la(t.endpoint,{events:W.splice(0,t.batchSize)},t.transport,t.debug)}function ua(t){return Math.max(0,Math.min(1,t))}function Eo(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 Ve(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function So(t,e){let n=t==null?void 0:t[e];return typeof n=="number"?n:0}function ga(t,e,n){try{t[e]=n}catch{}}function Ao(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 ha(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 fa(t,e){let n=Ao(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 ma(){let t=new Set,e=new WeakMap,n=null,i=()=>{if(n!=null)return;n=requestAnimationFrame(()=>{n=null,s(),t.size>0&&i()})},a=p=>{var g;t.add(p);let c=(g=e.get(p.target))!=null?g:new Set;c.add(p),e.set(p.target,c),i()},r=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,r(p))},s=()=>{var c,g;let p=Ve();for(let u of Array.from(t)){if(u.killed||u.paused)continue;let b=p-u.startMs-u.delayMs;if(b<0)continue;let h=u.durationMs>0?b/u.durationMs:1,x=ua(h),v=u.repeat>=0?u.repeat+1:1,y=u.repeat>0?Math.min(Math.floor(h),v-1):0;if(u.repeat>0&&h>=1){let E=h-y;x=ua(E)}let f=u.ease(x);u.yoyo&&y%2===1&&(f=1-f);for(let E of u.props)ga(u.target,E.key,E.from+(E.to-E.from)*f);u.scaleFrom&&u.scaleTo&&ha(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(h>=v){o(u);try{(g=u.onComplete)==null||g.call(u)}catch{}}}},l=(p,c,g)=>{var E;let u=Math.max(0,(typeof c.duration=="number"?c.duration:.5)*1e3),b=Math.max(0,(typeof c.delay=="number"?c.delay:0)*1e3+((E=g==null?void 0:g.delayMsOverride)!=null?E:0)),h=Eo(c.ease),x=typeof c.repeat=="number"?Math.max(0,c.repeat|0):0,v=c.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),f=[];for(let S of Object.keys(c)){if(y.has(S))continue;let A=c[S];typeof A=="number"&&f.push({key:S,from:So(p,S),to:A})}let m=fa(p,c);return{target:p,startMs:Ve(),delayMs:b,durationMs:u,ease:h,props:f,scaleFrom:m.from,scaleTo:m.to,repeat:x,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 g=l(p,c);return a(g),{kill:()=>o(g),pause:()=>{g.paused||(g.paused=!0,g.pauseAtMs=Ve())},resume:()=>{var h;if(!g.paused)return;let u=(h=g.pauseAtMs)!=null?h:Ve(),b=Ve()-u;g.startMs+=b,g.paused=!1,g.pauseAtMs=null},isActive:()=>!g.killed&&!g.paused}},fromTo(p,c,g){return d.set(p,c),d.to(p,g)},set(p,c){if(!p||!c)return;for(let u of Object.keys(c)){let b=c[u];u==="scale"||u==="scaleX"||u==="scaleY"||typeof b=="number"&&ga(p,u,b)}let g=fa(p,c);g.to&&ha(p,g.to)},killTweensOf(p){let c=e.get(p);if(c)for(let g of Array.from(c))o(g)},timeline(p={}){let c=[],g=0,u=!1,b=[],h=y=>{if(typeof y=="number")return Math.max(0,y*1e3);let f=typeof y=="string"?y.trim():"";return f.startsWith("+=")?g+Math.max(0,Number(f.slice(2))*1e3||0):f?Math.max(0,Number(f)*1e3||0):g},x=y=>{c.push(y);let f=Math.max(0,(typeof y.vars.duration=="number"?y.vars.duration:.5)*1e3);g=Math.max(g,y.atMs+f)},v={to(y,f,m){return x({kind:"to",target:y,vars:f,atMs:h(m)}),v},fromTo(y,f,m,E){return x({kind:"fromTo",target:y,vars:m,from:f,atMs:h(E)}),v},play(){var y,f;if(u)return v;u=!0,b=[];for(let m of c)m.kind==="fromTo"&&d.set(m.target,(y=m.from)!=null?y:{}),b.push(d.to(m.target,{...m.vars,delay:m.atMs/1e3+((f=m.vars.delay)!=null?f:0)}));return v},pause(){for(let y of b)y.pause();return v},kill(){for(let y of b)y.kill();b=[],u=!1}};return p.paused||v.play(),v}};return d}function ba(){if(typeof window=="undefined")return;let t=window;if(!t.gsap)try{t.gsap=ma()}catch{}}var ya={name:"handler-playable-sdk",version:"0.4.39",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && chmod +x dist/cli/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var G=0,To=G++,va=G++,xa=G++,wa=G++,Ea=G++,Sa=G++,Aa=G++,Ca=G++,Ta=G++,La=G++,_a=G++,ka=G++,T=To;function Ma(){return T===va}function Pa(){return T===xa}function Ra(){return T===wa}function Oa(){return T===Ea}function Re(){return T===Sa}function Oe(){return T===Aa}function Ia(){return T===Ca}function ja(){return T===Ta}function Da(){return T===La}function Zt(){return T===_a}function Qt(){return T===ka}function $a(){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=va;return}catch{}else if(t==="dapi")try{dapi.isReady(),T=xa;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(T=wa)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(T=Ea)}catch{}else if(e==="mintegral")window.gameReady&&(T=Sa);else if(e==="tapjoy")window.TJ_API&&(T=Aa);else if(e==="tiktok")window.openAppStore&&(T=Ca);else if(e==="smadex")try{window.smxTracking&&(T=Ta)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(T=La)}catch{}else e==="vungle"?T=_a:(t==="nucleo"||e==="nucleo")&&(T=ka)}var yt=ae(require("lottie-web"),1),Ha=yt.default;typeof window!="undefined"&&(window.lottie=yt.default,window.__baseLottie=yt.default);var Lo=require("pixi.js");var en=require("pixi.js");var _o=null;function tn(t){_o=t}vt();nn();var Ye=require("pixi.js");vt();var Io=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",sn=Io;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&&(sn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${sn}`))}}catch{}function jo(t){var n,i,a,r,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:(r=t.y)!=null?r:.5};if(typeof t=="string"){let s=t.trim().toLowerCase();return(o=e[s])!=null?o:{x:.5,y:.5}}return null}var Ae=class{static async create(e,n,i){var l,d,p,c,g,u,b;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${sn}`);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 h=new Ye.Container;return this.applyTransform(h,n==null?void 0:n.transform,n),h}let r=(d=n==null?void 0:n.identity)==null?void 0:d.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${a.type}, path: ${a.path}`);let o=await Se.load(e,a,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(p=o==null?void 0:o.constructor)==null?void 0:p.name}`);let s;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),s=new Ye.Sprite(o),console.log("[ObjectFactory] Created object:",s,"type:",(c=s==null?void 0:s.constructor)==null?void 0:c.name),this.applyTransform(s,n==null?void 0:n.transform,n);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(g=o==null?void 0:o.constructor)==null?void 0:g.name,o),o&&(((u=o.constructor)==null?void 0:u.name)==="Container"||o instanceof Ye.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],x=!1;for(let v of h)try{let y=await fetch(v);if(y.ok){s=await y.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",v,"type:",(b=s==null?void 0:s.constructor)==null?void 0:b.name),x=!0;break}}catch{continue}x||(console.error("[ObjectFactory] Failed to reload JSON from any path"),s=o)}else s=o;else s=o,s&&typeof s=="object"&&("x"in s||"position"in s)&&this.applyTransform(s,n==null?void 0:n.transform,n);return s}static applyTransform(e,n,i){var a,r,o,s;if(!(!n||!e)&&(n.position&&("x"in e&&"y"in e?(e.x=(a=n.position.x)!=null?a:0,e.y=(r=n.position.y)!=null?r:0):"position"in e&&e.position&&e.position.set((o=n.position.x)!=null?o:0,(s=n.position.y)!=null?s: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=jo(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 Ho=ae(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=Ho);Xe();var wt=require("pixi.js");Xe();var cn=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 r=>{var s;let o=this.registry.get(r);if(!o){console.warn("[Assets] No config found for object:",r);return}try{let l=await Ae.create(r,o,this.app);this.instanceCache.set(r,l),console.log("[Assets] Loaded object:",r,(s=l==null?void 0:l.constructor)==null?void 0:s.name)}catch(l){console.error("[Assets] Failed to load object:",r,l)}})))};return this.readyPromise=(async()=>{await i(n);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let n=this.registry.get(e);if(n){let i=await Ae.create(e,n,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},Fo=new cn,No=new Proxy(Fo,{get(t,e){if(e in t&&typeof t[e]=="function")return t[e].bind(t);if(t.get(e))return t.get(e)}});Xe();var Ba=require("pixi.js"),le={width:400,height:600,designWidth:400,scaleFactor:1},St={scale:1,position:1},pn=[];function Uo(t,e,n,i,a,r,o){pn.push({element:t,originalScale:r,positionHelper:e,heightPercent:a}),e(t,n,i,a,r,o,!1)}function qo(){pn.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 dn(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),St.scale=le.scaleFactor,St.position=1,console.log(`[SCREEN] Global multipliers - scale: ${St.scale.toFixed(3)}`),qo()}var Ze={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 Wo(t,e,n){let i=Ze[t];i&&i[e]!==void 0&&(i[e]=n,console.log(`Updated ${t}.${e} = ${n}`))}function Vo(){return Ze}var Yo={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 Et(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function At(t,e={x:.5,y:.5}){var n;if(Array.isArray(t))return{x:Et(t[0],e.x),y:Et(t[1],e.y)};if(t&&typeof t=="object"){let i=t;return{x:Et(i.x,e.x),y:Et(i.y,e.y)}}if(typeof t=="string"){let i=t.trim().toLowerCase();return(n=Yo[i])!=null?n:e}return e}function Ga(t,e,n,i={}){var u,b,h,x,v,y;let a=At(n),r=(u=i.inset)!=null?u:{},o=(b=i.padding)!=null?b:{x:0,y:0},s=((h=r.left)!=null?h:0)+o.x,l=((x=r.right)!=null?x:0)+o.x,d=((v=r.top)!=null?v:0)+o.y,p=((y=r.bottom)!=null?y:0)+o.y,c=Math.max(0,t-s-l),g=Math.max(0,e-d-p);return{x:s+c*a.x,y:d+g*a.y}}function Ua(t,e,n,i={}){var h,x,v,y,f,m;let a=(h=i.inset)!=null?h:{},r=(x=i.padding)!=null?x:{x:0,y:0},o=((v=a.left)!=null?v:0)+r.x,s=((y=a.right)!=null?y:0)+r.x,l=((f=a.top)!=null?f:0)+r.y,d=((m=a.bottom)!=null?m:0)+r.y,p=Math.max(0,t-o-s),c=Math.max(0,e-l-d),g=At(n,{x:.5,y:.5}),u=Math.min(Math.max(g.x,0),1),b=Math.min(Math.max(g.y,0),1);return{x:o+p*u,y:l+c*b}}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,dn(i,a))};window.addEventListener("resize",n),window.addEventListener("orientationchange",()=>{setTimeout(n,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",n),window.mraid.addEventListener("sizeChange",n)),dn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Wo,window.getDebugConfig=Vo,window.copyConfig=rs,window.applyConfig=Je,window.applyConfigForRatio=os,window.positionAtBottom=qa,window.positionAtTop=Jo,window.positionAtCenter=Zo,window.positionAtLeft=Qo,window.positionAtRight=es,window.positionAtBottomLeft=ts,window.positionAtBottomRight=ns,window.positionAtTopLeft=is,window.positionAtTopRight=as,window.applyPositionContract=Xo,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 Ct(t,e,n=0){return t*e+n}function Tt(t,e,n=0){return t*(1-e)+n}function Lt(t,e,n=0){return t*e+n}function _t(t,e,n=0){return t*(1-e)+n}function U(t,e=0){return t/2+e}function Ko(t,e){return t*e}function Xo(t,e,n,i){var o,s,l,d,p,c,g,u,b,h,x,v,y,f,m,E,S,A,k,R;let a=0,r=0;switch(i.type){case"top":a=U(e,(s=(o=i.offset)==null?void 0:o.x)!=null?s:0),r=Ct(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),r=Tt(n,i.percent,(u=(g=i.offset)==null?void 0:g.y)!=null?u:0);break;case"left":a=Lt(e,i.percent,(h=(b=i.offset)==null?void 0:b.x)!=null?h:0),r=U(n,(v=(x=i.offset)==null?void 0:x.y)!=null?v:0);break;case"right":a=_t(e,i.percent,(f=(y=i.offset)==null?void 0:y.x)!=null?f:0),r=U(n,(E=(m=i.offset)==null?void 0:m.y)!=null?E:0);break;case"center":a=U(e,(A=(S=i.offset)==null?void 0:S.x)!=null?A:0),r=U(n,(R=(k=i.offset)==null?void 0:k.y)!=null?R:0);break}t.position?t.position.set(a,r):(t.x=a,t.y=r),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 qa(t,e,n,i=.2,a=1,r=!0,o=!1){let s=Ko(n,i),l=Tt(n,i/2);ce(t,U(e),l);let d=r?a*le.scaleFactor:a;de(t,d),o&&!pn.find(p=>p.element===t)&&Uo(t,qa,e,n,i,a,r)}function Jo(t,e,n,i=.1,a=1){ce(t,U(e),Ct(n,i)),de(t,a)}function Zo(t,e,n,i=0,a=0,r=1){ce(t,U(e,i),U(n,a)),de(t,r)}function Qo(t,e,n,i=.1,a=1){ce(t,Lt(e,i),U(n)),de(t,a)}function es(t,e,n,i=.1,a=1){ce(t,_t(e,i),U(n)),de(t,a)}function ts(t,e,n,i=.05,a=.05,r=1){ce(t,Lt(e,a),Tt(n,i)),de(t,r)}function ns(t,e,n,i=.05,a=.05,r=1){ce(t,_t(e,a),Tt(n,i)),de(t,r)}function is(t,e,n,i=.05,a=.05,r=1){ce(t,Lt(e,a),Ct(n,i)),de(t,r)}function as(t,e,n,i=.05,a=.05,r=1){ce(t,_t(e,a),Ct(n,i)),de(t,r)}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 Ce={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 rs(t){return t&&Ce[t]?JSON.parse(JSON.stringify(Ce[t])):JSON.parse(JSON.stringify(Ze))}function Je(t){Object.keys(t).forEach(e=>{let n=e;Ze[n]&&t[n]&&Object.assign(Ze[n],t[n])}),console.log("Config applied:",t)}function os(t,e){let n=t/e;n>1.6?(Je(Ce.wide),console.log("Applied WIDE config for ratio:",n)):n<.7?(Je(Ce.tall),console.log("Applied TALL config for ratio:",n)):n>.8&&n<1.2?(Je(Ce.square),console.log("Applied SQUARE config for ratio:",n)):(Je(Ce.default),console.log("Applied DEFAULT config for ratio:",n))}if(typeof window!="undefined"){let t=window;t.configPresets=Ce,t.resolveAnchorVec2=t.resolveAnchorVec2||At,t.resolveScreenAnchorPoint=t.resolveScreenAnchorPoint||Ga,t.resolveScreenRatioPoint=t.resolveScreenRatioPoint||Ua}hn();function P(t,e){let n=(a,r)=>r===0?a:n(r,a%r),i=n(t,e);return`${t/i}:${e/i}`}var Bc=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:P(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:P(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:P(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:P(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:P(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:P(360,780)}],Gc=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:P(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:P(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:P(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:P(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:P(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:P(412,915)}],Uc=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:P(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:P(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:P(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:P(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:P(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:P(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:P(768,1024),mraidScale:.7}];var qc=[...Ka];var hs=Ka[0];fe();var xs=ae(require("jszip"),1);function bs(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 ys(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 vs(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 fn(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 r=await bs(a),o=await vs(r),s=ys(r);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",s.mimeType),{base64:s.base64,mimeType:s.mimeType,dataUrl:r,width:(e=o==null?void 0:o.width)!=null?e:0,height:(n=o==null?void 0:o.height)!=null?n:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function kt(t,e=30){try{console.log("[ImageUtils] Removing background color...");let n=await new Promise((c,g)=>{let u=new Image;u.onload=()=>c(u),u.onerror=()=>g(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 r=a.getImageData(0,0,i.width,i.height),o=r.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 g=o[c],u=o[c+1],b=o[c+2],h=!1;for(let x of l)if(Math.sqrt(Math.pow(g-x.r,2)+Math.pow(u-x.g,2)+Math.pow(b-x.b,2))<e){h=!0;break}h&&(o[c+3]=0,d++)}return console.log(`[ImageUtils] Removed background from ${d} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),i.toDataURL("image/png")}catch(n){return console.error("[ImageUtils] Error removing background:",n),t}}var Xa=require("@google/genai");async function mn(t,e,n=[],i={}){var a,r,o,s,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 y=n[v];if(!y.base64||!y.mimeType)throw new Error(`Image ${v+1} is missing required data`);if(y.base64.length<1e3&&console.warn(`Image ${v+1} data appears very small, may be corrupted`),!y.mimeType.startsWith("image/"))throw new Error(`Image ${v+1} has invalid MIME type: ${y.mimeType}`)}let c=new Xa.GoogleGenAI({apiKey:t}),g="gemini-2.5-flash",u=[e];n.length>0&&n.forEach((v,y)=>{u.push({inlineData:{data:v.base64,mimeType:v.mimeType}}),console.log(`[Gemini] Added image ${y+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 b=await c.models.generateContent({model:g,contents:u}),h="",x=(o=(r=(a=b.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:o.parts;if(x)for(let v of x)v.text&&(h+=v.text);if(!h.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${h.length}`),h}catch(c){throw console.error("[Gemini] API error:",c),(s=c.message)!=null&&s.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(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 Ja=require("@google/genai");async function Mt(t,e,n=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Ja.GoogleGenAI({apiKey:t}),r=[{text:e}];n.length>0&&n.forEach((s,l)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${l}`),r.push({inlineData:{mimeType:s.mimeType,data:s.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let s of o.candidates[0].content.parts)if(s.text)console.log(s.text);else if(s.inlineData){let l=s.inlineData.data,d=s.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 ws=require("pixi.js");Xe();fe();var Qa=require("pixi.js");var Es=require("pixi.js");fe();function ks(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 Ms(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 Ps(t){return`
|
|
47
47
|
Analyze these screenshots of a brand or game and extract its "Brand DNA".
|
|
48
48
|
|
|
49
49
|
Provide a concise summary (2-3 sentences) covering:
|
|
@@ -62,7 +62,7 @@ ADDITIONAL RULES/NOTES:
|
|
|
62
62
|
${t}`:""}
|
|
63
63
|
`.trim()}function er(){let t=[],e="",n=null;return{async addSources(i){let a=[];for(let r of i){let o=await ks(r),s=Ms(o),l={id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,name:r.name,base64:s.base64,mimeType:s.mimeType,dataUrl:o};t.push(l),a.push(l)}return a},getSources(){return t.slice()},async analyze(i,a,r){if(t.length===0)throw new Error("No screenshots to analyze.");let o=Ps(a),s=t.map(g=>({base64:g.base64,mimeType:g.mimeType})),l=await mn(i,o,s,{model:r}),d=e,p=[],c=l.split(`
|
|
64
64
|
`);for(let g of c)if(g.toLowerCase().startsWith("summary:"))d=g.slice(8).trim();else if(g.toLowerCase().includes("palette:")){let u=g.match(/#[0-9A-Fa-f]{6}/g);u&&u.forEach(b=>{p.includes(b.toUpperCase())||p.push(b.toUpperCase())})}return(!d||d===e)&&(d=l.split(`
|
|
65
|
-
Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),n={summary:d,palette:p.slice(0,10)},n},setSummary(i){e=i,n&&(n={...n,summary:i})},getResult(){return n}}}var Le="handler_api_key_";var je=class{static setKey(e,n,i){try{let a={key:this.encryptKey(n),created:Date.now(),lastUsed:Date.now(),label:i||e},r=`${Le}${e}`;localStorage.setItem(r,JSON.stringify(a))}catch(a){console.error("[ApiKeyStorage] Failed to store API key:",a)}}static getKey(e){try{let n=`${Le}${e}`,i=localStorage.getItem(n);if(!i)return null;let a=JSON.parse(i);return a.lastUsed=Date.now(),localStorage.setItem(n,JSON.stringify(a)),this.decryptKey(a.key)}catch(n){return console.error("[ApiKeyStorage] Failed to retrieve API key:",n),null}}static hasKey(e){let n=`${Le}${e}`;return localStorage.getItem(n)!==null}static removeKey(e){try{let n=`${Le}${e}`;localStorage.removeItem(n)}catch(n){console.error("[ApiKeyStorage] Failed to remove API key:",n)}}static getStoredServices(){let e=[];try{for(let n=0;n<localStorage.length;n++){let i=localStorage.key(n);if(i&&i.startsWith(Le)){let a=i.substring(Le.length),r=localStorage.getItem(i);if(r){let o=JSON.parse(r);e.push({service:a,label:o.label,created:o.created,lastUsed:o.lastUsed})}}}}catch(n){console.error("[ApiKeyStorage] Failed to get stored services:",n)}return e.sort((n,i)=>i.lastUsed-n.lastUsed)}static clearAll(){try{let e=[];for(let n=0;n<localStorage.length;n++){let i=localStorage.key(n);i&&i.startsWith(Le)&&e.push(i)}e.forEach(n=>localStorage.removeItem(n))}catch(e){console.error("[ApiKeyStorage] Failed to clear API keys:",e)}}static encryptKey(e){try{let i="handler_preview_salt_2024"+e;return btoa(i)}catch(n){return console.warn("[ApiKeyStorage] Encryption failed, storing as-is:",n),e}}static decryptKey(e){try{let n=atob(e),i="handler_preview_salt_2024";return n.startsWith(i)?n.substring(i.length):n}catch(n){return console.warn("[ApiKeyStorage] Decryption failed, returning as-is:",n),e}}},bn=()=>je.getKey("gemini"),yn=(t,e)=>je.setKey("gemini",t,e),
|
|
65
|
+
Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),n={summary:d,palette:p.slice(0,10)},n},setSummary(i){e=i,n&&(n={...n,summary:i})},getResult(){return n}}}var Le="handler_api_key_";var je=class{static setKey(e,n,i){try{let a={key:this.encryptKey(n),created:Date.now(),lastUsed:Date.now(),label:i||e},r=`${Le}${e}`;localStorage.setItem(r,JSON.stringify(a))}catch(a){console.error("[ApiKeyStorage] Failed to store API key:",a)}}static getKey(e){try{let n=`${Le}${e}`,i=localStorage.getItem(n);if(!i)return null;let a=JSON.parse(i);return a.lastUsed=Date.now(),localStorage.setItem(n,JSON.stringify(a)),this.decryptKey(a.key)}catch(n){return console.error("[ApiKeyStorage] Failed to retrieve API key:",n),null}}static hasKey(e){let n=`${Le}${e}`;return localStorage.getItem(n)!==null}static removeKey(e){try{let n=`${Le}${e}`;localStorage.removeItem(n)}catch(n){console.error("[ApiKeyStorage] Failed to remove API key:",n)}}static getStoredServices(){let e=[];try{for(let n=0;n<localStorage.length;n++){let i=localStorage.key(n);if(i&&i.startsWith(Le)){let a=i.substring(Le.length),r=localStorage.getItem(i);if(r){let o=JSON.parse(r);e.push({service:a,label:o.label,created:o.created,lastUsed:o.lastUsed})}}}}catch(n){console.error("[ApiKeyStorage] Failed to get stored services:",n)}return e.sort((n,i)=>i.lastUsed-n.lastUsed)}static clearAll(){try{let e=[];for(let n=0;n<localStorage.length;n++){let i=localStorage.key(n);i&&i.startsWith(Le)&&e.push(i)}e.forEach(n=>localStorage.removeItem(n))}catch(e){console.error("[ApiKeyStorage] Failed to clear API keys:",e)}}static encryptKey(e){try{let i="handler_preview_salt_2024"+e;return btoa(i)}catch(n){return console.warn("[ApiKeyStorage] Encryption failed, storing as-is:",n),e}}static decryptKey(e){try{let n=atob(e),i="handler_preview_salt_2024";return n.startsWith(i)?n.substring(i.length):n}catch(n){return console.warn("[ApiKeyStorage] Decryption failed, returning as-is:",n),e}}},bn=()=>je.getKey("gemini"),yn=(t,e)=>je.setKey("gemini",t,e),Rs=()=>je.hasKey("gemini");window.ApiKeyStorage=je;window.getGeminiApiKey=bn;window.setGeminiApiKey=yn;window.hasGeminiApiKey=Rs;var xn=class{constructor(){this.modal=null;this.options=null;this.analyzer=er();this.currentPrompt="";this.isGenerating=!1;this.generatedImages=[];this.selectedImageIndex=-1;this.promptInput=null;this.generateBtn=null;this.loadingEl=null;this.galleryEl=null;this.previewEl=null}open(e){this.options=e,this.currentPrompt=e.initialPrompt||"",this.generatedImages=[],this.selectedImageIndex=-1,this.isGenerating=!1,this.createModal(),document.body.appendChild(this.modal),setTimeout(()=>{var n,i;(n=this.promptInput)==null||n.focus(),(i=this.promptInput)==null||i.select()},100)}createModal(){var n;let e=document.createElement("div");e.className="ai-modal",e.innerHTML=`
|
|
66
66
|
<div class="ai-modal-card">
|
|
67
67
|
<div class="ai-modal-header">
|
|
68
68
|
<div class="ai-modal-actions">
|
|
@@ -226,7 +226,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
226
226
|
<button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
|
|
227
227
|
</div>
|
|
228
228
|
</div>
|
|
229
|
-
`,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,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(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,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 r=8;[[e,n],[e+i-r,n],[e,n+a-r],[e+i-r,n+a-r]].forEach(([s,l])=>{var d;(d=this.ctx)==null||d.fillRect(s,l,r,r)})}updatePreview(){if(!this.modal||!this.image)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;let a=i/this.cropWidth,r=i/this.cropHeight,o=Math.min(a,r),s=this.cropWidth*o,l=this.cropHeight*o,d=(i-s)/2,p=(i-l)/2;n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,d,p,s,l)}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 An().open(t)};fe();fe();var nr=ae(require("lottie-web"),1);tn(Ha);typeof window!="undefined"&&!window.lottie&&(window.lottie=nr.default);hn();fe();var Cn=ya.version,Is=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"]);ba();var cr={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"},dr=Math.random().toString(36).slice(2),He=null,De={...cr},pr="web_embed",kn={},et,Tn=!1,Qe=!1,nt=!1,ur=!1,Rn=1,Ot=0,jt=!1,pe=!1,$e="",ze=Math.floor(window.innerWidth),Fe=Math.floor(window.innerHeight),Mn=ze>Fe,ue=!1,tt=!1,ir=!1,ar=!1,Ln=!1,Rt=null,_e=null,Pn=!1,On=!1,Pt=new Map;function gr(){if(!_e)return null;let t=Date.now()-_e;return!Number.isFinite(t)||t<0?null:t}function _n(t){if(Pn)return;let e=gr();e!==null&&(Pn=!0,w("session_time",{duration_ms:e,reason:t}))}function rr(){if(He)return He;let t=document.createElement("div");return t.id="handler-root",t.setAttribute("data-handler-root","true"),document.body.appendChild(t),He=t,t}function It(t){switch(t){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return t}}function hr(t,e){return{event_name:t,ts:Date.now(),session_id:dr,deployment_id:De.deployment_id,variant_id:De.variant_id,export_profile_id:De.profile_id,instance_id:De.instance_id||"default",env:pr==="mraid"?"mraid":"web",attribution:et,payload:e}}function w(t,e){let n=It(t),i=hr(n,e);Jt(i,!!kn.analytics),bt(n,i),n!==t&&bt(t,i)}function it(){Rt&&(Rt(ze,Fe),Rt=null)}function Ne(t){Rn=t,w("volume",t)}function Be(t){t&&(ur=!0),!nt&&(nt=!0,w("pause"),Ne(0))}function at(t){!t&&ur||nt&&(nt=!1,w("resume"),Ne(Rn))}function me(t,e){ze=Math.floor(t||window.innerWidth),Fe=Math.floor(e||window.innerHeight),Mn=ze>Fe,w("resize",{width:ze,height:Fe})}function js(){if(Ma())try{let t=mraid.getMaxSize();me(t.width,t.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?at():Be()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();me(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();Ne(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&Ne(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),jt=!0,mraid.isViewable()&&mraid.getState()!=="hidden")ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it();else{let n=()=>{ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it()};mraid.addEventListener("ready",n)}}catch(t){console.warn("MRAID hook skipped",t)}}function Ds(){if(Pa())try{let t=dapi.getScreenSize();me(t.width,t.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?at():Be()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();me(n.width||i.width,n.height||i.height)});let e=dapi.getAudioVolume();if(Ne(e?1:0),dapi.addEventListener("audioVolumeChange",n=>Ne(n?1:0)),jt=!0,dapi.isViewable())ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it();else{let n=()=>{ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it()};dapi.addEventListener("ready",n)}}catch(t){console.warn("DAPI hook skipped",t)}}function or(){let t=()=>{ue||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it(),tt&&(tt=!1,J.start()))};window.addEventListener("resize",()=>me()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(at(),t()):Be()}),document.readyState==="complete"||document.readyState==="interactive"?t():window.addEventListener("load",t),jt=!0}function $s(){let t=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(ir=!0),!(ir&&e instanceof MouseEvent)&&(Ot+=1,On||(On=!0,w("first_interaction",{count:Ot})),w("interaction",Ot))};document.addEventListener("mousedown",t),document.addEventListener("touchstart",t)}function sr(t){var i,a,r,o,s,l,d,p,c,g,u,b;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(Re())(r=(a=window.TJ_API)==null?void 0:a.click)==null||r.call(a);else if(Oa())(s=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||s.call(o);else if(Da())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(ja())try{(c=(p=window.smxTracking)==null?void 0:p.redirect)==null||c.call(p)}catch(h){console.warn("Smadex redirect failed",h)}else if(Ra()){let h=window.ExitApi;h&&typeof h.exit=="function"?h.exit(t||$e||""):t&&window.open(t)}else Oe()?(g=window.install)==null||g.call(window):Ia()?(u=window.openAppStore)==null||u.call(window):Zt()?(b=parent==null?void 0:parent.postMessage)==null||b.call(parent,"download","*"):t&&window.open(t)}function Hs(){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),mt("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.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 zs(){if(!Re())return;let t=window.TJ_API;t&&t.setPlayableAPI&&t.setPlayableAPI({skipAd:()=>{try{J.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function lr(){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 Fs(){Oe()&&(window.mintGameStart=()=>{at(!0),me()},window.mintGameClose=()=>{Be(!0)})}function Ns(){if(!Qt())return;let t=window.NUC;!t||!t.trigger||(J.on("cta_click",()=>{var e,n;return(n=(e=t.trigger).convert)==null?void 0:n.call(e,$e)}),J.on("complete",()=>{var e,n;return(n=(e=t.trigger).tryAgain)==null?void 0:n.call(e)}))}var J={init(t={},e){var n;if(pr=t.profile||"web_embed",kn=t.consent||{},De={...cr,...t.ids||{}},He=t.rootEl||He,et=void 0,da((n=t.telemetry)!=null&&n.endpoint?t.telemetry:null),_e=null,Pn=!1,On=!1,Pt.clear(),$e=t.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Rt=e),w("init"),document.body.oncontextmenu=()=>!1,rr(),Gs(He),$a(),js(),Ds(),!jt){if(document.readyState==="complete")or();else if(!ar){ar=!0;let i=()=>{or(),window.removeEventListener("load",i),document.removeEventListener("DOMContentLoaded",i)};window.addEventListener("load",i),document.addEventListener("DOMContentLoaded",i)}}$s(),Hs(),zs(),Fs(),Ns(),console.log(`%c @handler/playable-sdk %c v${Cn} `,"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&&(w("boot"),w("view"),w("ready"),tt&&(tt=!1,J.start()),pe=!0),pe=ue},getRoot(){return rr()},get version(){return Cn},get maxWidth(){return ze},get maxHeight(){return Fe},get isLandscape(){return Mn},get isReady(){return pe},get isStarted(){return Tn},get isPaused(){return nt},get isFinished(){return Qe},get volume(){return Rn},get interactions(){return Ot},on(t,e){mt(It(t),e)},off(t,e){Xt(It(t),e)},start(){var t,e;if(!Tn){if(!ue){tt=!0;return}if(Tn=!0,_e||(_e=Date.now()),w("start"),me(),Oe())Be(),(t=window.gameReady)==null||t.call(window);else if(Re()){let n=window.TJ_API;(e=n==null?void 0:n.setPlayableBuild)==null||e.call(n,{orientation:Mn?"landscape":"portrait",buildID:Cn})}}},finish(){var t,e;Qe||(Qe=!0,w("complete"),_n("complete"),Oe()?(t=window.gameEnd)==null||t.call(window):Zt()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Re()&&lr())},install(t){if(!Qe){Qe=!0,Re()?(lr(),setTimeout(()=>J.install(t),300)):(w("complete"),setTimeout(()=>J.install(t),0));return}Ln||(Ln=!0,setTimeout(()=>Ln=!1,500),w("cta_click"),w("conversion"),_n("cta"),sr(t||$e))},emit(t,e){let n=It(t);if(!Is.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=hr(n,e);Jt(i,!!kn.analytics),bt(n,i)},gameStart(){J.start()},gameEnd(){J.finish()},ctaClick(t,e){w("cta_click",{url:t||$e,manual:!0}),(e==null?void 0:e.open)!==!1&&sr(t||$e)},ctaShow(t){w("cta_show",t)},ctaDismiss(t){w("cta_dismiss",t)},getGameTimeMs(){return gr()},endSession(t="manual"){_n(t)},setAttribution(t){et=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(Bs(`${dr}:${t}`))%e.length,i=e[n];return et={...et||{},experiment_id:t},De.variant_id=i,w("ab_assign",{experiment_id:t,variant_id:i}),i},levelStart(t,e){_e||(_e=Date.now()),w("level_start",{level_id:t,...e})},levelComplete(t,e){w("level_complete",{level_id:t,...e})},levelFail(t,e){w("level_fail",{level_id:t,...e})},checkpoint(t,e){w("checkpoint",{checkpoint_id:t,...e})},reward(t,e){w("reward",{reward_id:t,...e})},tutorialStart(t,e){w("tutorial_start",{step_id:t,...e})},tutorialComplete(t,e){w("tutorial_complete",{step_id:t,...e})},tutorialSkip(t,e){w("tutorial_skip",{step_id:t,...e})},timerStart(t){t&&Pt.set(t,Date.now())},timerEnd(t,e="custom",n){if(!t)return;let i=Pt.get(t);if(!i)return;Pt.delete(t);let a=Date.now()-i;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){w("engagement",{action:"timer",key:t,duration_ms:a,...n});return}w(e,{key:t,duration_ms:a,...n})}},fps(t,e){w("fps",{value:t,...e})},memory(t,e){w("memory",{bytes:t,...e})},assetLoadStart(t,e){w("asset_load_start",{asset_id:t,...e})},assetLoadComplete(t,e){w("asset_load_complete",{asset_id:t,...e})},reportError(t,e,n){w("error",{code:t,message:e,...n})},retry(){var t,e,n;if(Oe())(t=window.gameRetry)==null||t.call(window);else if(Qt()){let i=window.NUC;(n=(e=i==null?void 0:i.trigger)==null?void 0:e.tryAgain)==null||n.call(e)}w("engagement",{action:"retry"})},pause(){Be(!0)},resume(){at(!0)},resize(t,e){me(t,e)}},Ie=J;function Bs(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 Gs(t){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
|
|
229
|
+
`,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,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(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,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 r=8;[[e,n],[e+i-r,n],[e,n+a-r],[e+i-r,n+a-r]].forEach(([s,l])=>{var d;(d=this.ctx)==null||d.fillRect(s,l,r,r)})}updatePreview(){if(!this.modal||!this.image)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;let a=i/this.cropWidth,r=i/this.cropHeight,o=Math.min(a,r),s=this.cropWidth*o,l=this.cropHeight*o,d=(i-s)/2,p=(i-l)/2;n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,d,p,s,l)}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 An().open(t)};fe();fe();var nr=ae(require("lottie-web"),1);tn(Ha);typeof window!="undefined"&&!window.lottie&&(window.lottie=nr.default);hn();fe();var Cn=ya.version,Is=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"]);ba();var cr={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"},dr=Math.random().toString(36).slice(2),He=null,De={...cr},pr="web_embed",kn={},et,Tn=!1,Qe=!1,nt=!1,ur=!1,On=1,Rt=0,jt=!1,pe=!1,$e="",ze=Math.floor(window.innerWidth),Fe=Math.floor(window.innerHeight),Mn=ze>Fe,ue=!1,tt=!1,ir=!1,ar=!1,Ln=!1,Ot=null,_e=null,Pn=!1,Rn=!1,Pt=new Map;function gr(){if(!_e)return null;let t=Date.now()-_e;return!Number.isFinite(t)||t<0?null:t}function _n(t){if(Pn)return;let e=gr();e!==null&&(Pn=!0,w("session_time",{duration_ms:e,reason:t}))}function rr(){if(He)return He;let t=document.createElement("div");return t.id="handler-root",t.setAttribute("data-handler-root","true"),document.body.appendChild(t),He=t,t}function It(t){switch(t){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return t}}function hr(t,e){return{event_name:t,ts:Date.now(),session_id:dr,deployment_id:De.deployment_id,variant_id:De.variant_id,export_profile_id:De.profile_id,instance_id:De.instance_id||"default",env:pr==="mraid"?"mraid":"web",attribution:et,payload:e}}function w(t,e){let n=It(t),i=hr(n,e);Jt(i,!!kn.analytics),bt(n,i),n!==t&&bt(t,i)}function it(){Ot&&(Ot(ze,Fe),Ot=null)}function Ne(t){On=t,w("volume",t)}function Be(t){t&&(ur=!0),!nt&&(nt=!0,w("pause"),Ne(0))}function at(t){!t&&ur||nt&&(nt=!1,w("resume"),Ne(On))}function me(t,e){ze=Math.floor(t||window.innerWidth),Fe=Math.floor(e||window.innerHeight),Mn=ze>Fe,w("resize",{width:ze,height:Fe})}function js(){if(Ma())try{let t=mraid.getMaxSize();me(t.width,t.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?at():Be()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();me(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();Ne(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&Ne(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),jt=!0,mraid.isViewable()&&mraid.getState()!=="hidden")ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it();else{let n=()=>{ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it()};mraid.addEventListener("ready",n)}}catch(t){console.warn("MRAID hook skipped",t)}}function Ds(){if(Pa())try{let t=dapi.getScreenSize();me(t.width,t.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?at():Be()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();me(n.width||i.width,n.height||i.height)});let e=dapi.getAudioVolume();if(Ne(e?1:0),dapi.addEventListener("audioVolumeChange",n=>Ne(n?1:0)),jt=!0,dapi.isViewable())ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it();else{let n=()=>{ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it()};dapi.addEventListener("ready",n)}}catch(t){console.warn("DAPI hook skipped",t)}}function or(){let t=()=>{ue||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(ue=!0,w("boot"),w("view"),w("ready"),pe=!0,it(),tt&&(tt=!1,J.start()))};window.addEventListener("resize",()=>me()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(at(),t()):Be()}),document.readyState==="complete"||document.readyState==="interactive"?t():window.addEventListener("load",t),jt=!0}function $s(){let t=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(ir=!0),!(ir&&e instanceof MouseEvent)&&(Rt+=1,Rn||(Rn=!0,w("first_interaction",{count:Rt})),w("interaction",Rt))};document.addEventListener("mousedown",t),document.addEventListener("touchstart",t)}function sr(t){var i,a,r,o,s,l,d,p,c,g,u,b;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())(r=(a=window.TJ_API)==null?void 0:a.click)==null||r.call(a);else if(Ra())(s=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||s.call(o);else if(Da())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(ja())try{(c=(p=window.smxTracking)==null?void 0:p.redirect)==null||c.call(p)}catch(h){console.warn("Smadex redirect failed",h)}else if(Oa()){let h=window.ExitApi;h&&typeof h.exit=="function"?h.exit(t||$e||""):t&&window.open(t)}else Re()?(g=window.install)==null||g.call(window):Ia()?(u=window.openAppStore)==null||u.call(window):Zt()?(b=parent==null?void 0:parent.postMessage)==null||b.call(parent,"download","*"):t&&window.open(t)}function Hs(){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),mt("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.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 zs(){if(!Oe())return;let t=window.TJ_API;t&&t.setPlayableAPI&&t.setPlayableAPI({skipAd:()=>{try{J.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function lr(){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 Fs(){Re()&&(window.mintGameStart=()=>{at(!0),me()},window.mintGameClose=()=>{Be(!0)})}function Ns(){if(!Qt())return;let t=window.NUC;!t||!t.trigger||(J.on("cta_click",()=>{var e,n;return(n=(e=t.trigger).convert)==null?void 0:n.call(e,$e)}),J.on("complete",()=>{var e,n;return(n=(e=t.trigger).tryAgain)==null?void 0:n.call(e)}))}var J={init(t={},e){var n;if(pr=t.profile||"web_embed",kn=t.consent||{},De={...cr,...t.ids||{}},He=t.rootEl||He,et=void 0,da((n=t.telemetry)!=null&&n.endpoint?t.telemetry:null),_e=null,Pn=!1,Rn=!1,Pt.clear(),$e=t.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Ot=e),w("init"),document.body.oncontextmenu=()=>!1,rr(),Gs(He),$a(),js(),Ds(),!jt){if(document.readyState==="complete")or();else if(!ar){ar=!0;let i=()=>{or(),window.removeEventListener("load",i),document.removeEventListener("DOMContentLoaded",i)};window.addEventListener("load",i),document.addEventListener("DOMContentLoaded",i)}}$s(),Hs(),zs(),Fs(),Ns(),console.log(`%c @handler/playable-sdk %c v${Cn} `,"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&&(w("boot"),w("view"),w("ready"),tt&&(tt=!1,J.start()),pe=!0),pe=ue},getRoot(){return rr()},get version(){return Cn},get maxWidth(){return ze},get maxHeight(){return Fe},get isLandscape(){return Mn},get isReady(){return pe},get isStarted(){return Tn},get isPaused(){return nt},get isFinished(){return Qe},get volume(){return On},get interactions(){return Rt},on(t,e){mt(It(t),e)},off(t,e){Xt(It(t),e)},start(){var t,e;if(!Tn){if(!ue){tt=!0;return}if(Tn=!0,_e||(_e=Date.now()),w("start"),me(),Re())Be(),(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:Mn?"landscape":"portrait",buildID:Cn})}}},finish(){var t,e;Qe||(Qe=!0,w("complete"),_n("complete"),Re()?(t=window.gameEnd)==null||t.call(window):Zt()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Oe()&&lr())},install(t){if(!Qe){Qe=!0,Oe()?(lr(),setTimeout(()=>J.install(t),300)):(w("complete"),setTimeout(()=>J.install(t),0));return}Ln||(Ln=!0,setTimeout(()=>Ln=!1,500),w("cta_click"),w("conversion"),_n("cta"),sr(t||$e))},emit(t,e){let n=It(t);if(!Is.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=hr(n,e);Jt(i,!!kn.analytics),bt(n,i)},gameStart(){J.start()},gameEnd(){J.finish()},ctaClick(t,e){w("cta_click",{url:t||$e,manual:!0}),(e==null?void 0:e.open)!==!1&&sr(t||$e)},ctaShow(t){w("cta_show",t)},ctaDismiss(t){w("cta_dismiss",t)},getGameTimeMs(){return gr()},endSession(t="manual"){_n(t)},setAttribution(t){et=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(Bs(`${dr}:${t}`))%e.length,i=e[n];return et={...et||{},experiment_id:t},De.variant_id=i,w("ab_assign",{experiment_id:t,variant_id:i}),i},levelStart(t,e){_e||(_e=Date.now()),w("level_start",{level_id:t,...e})},levelComplete(t,e){w("level_complete",{level_id:t,...e})},levelFail(t,e){w("level_fail",{level_id:t,...e})},checkpoint(t,e){w("checkpoint",{checkpoint_id:t,...e})},reward(t,e){w("reward",{reward_id:t,...e})},tutorialStart(t,e){w("tutorial_start",{step_id:t,...e})},tutorialComplete(t,e){w("tutorial_complete",{step_id:t,...e})},tutorialSkip(t,e){w("tutorial_skip",{step_id:t,...e})},timerStart(t){t&&Pt.set(t,Date.now())},timerEnd(t,e="custom",n){if(!t)return;let i=Pt.get(t);if(!i)return;Pt.delete(t);let a=Date.now()-i;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){w("engagement",{action:"timer",key:t,duration_ms:a,...n});return}w(e,{key:t,duration_ms:a,...n})}},fps(t,e){w("fps",{value:t,...e})},memory(t,e){w("memory",{bytes:t,...e})},assetLoadStart(t,e){w("asset_load_start",{asset_id:t,...e})},assetLoadComplete(t,e){w("asset_load_complete",{asset_id:t,...e})},reportError(t,e,n){w("error",{code:t,message:e,...n})},retry(){var t,e,n;if(Re())(t=window.gameRetry)==null||t.call(window);else if(Qt()){let i=window.NUC;(n=(e=i==null?void 0:i.trigger)==null?void 0:e.tryAgain)==null||n.call(e)}w("engagement",{action:"retry"})},pause(){Be(!0)},resume(){at(!0)},resize(t,e){me(t,e)}},Ie=J;function Bs(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 Gs(t){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
|
|
230
230
|
(function(){
|
|
231
231
|
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
232
232
|
function unlock(){
|
|
@@ -265,13 +265,13 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
265
265
|
overflow: hidden !important;
|
|
266
266
|
`,t.appendChild(o);let s=document.createElement("div");s.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(s);let l=new V.Scene,{width:d,height:p}=n(),c=new V.AmbientLight(16777215,.6);l.add(c);let g=new V.DirectionalLight(16777215,.8);g.position.set(5,5,5),g.castShadow=!1,l.add(g);let u=new V.DirectionalLight(16777215,.3);u.position.set(-5,0,5),l.add(u);let b=new V.PerspectiveCamera(55,d/p,.1,100);b.position.set(0,0,3.2),b.lookAt(0,0,0),b.updateMatrixWorld();let h=new V.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});h.setPixelRatio(window.devicePixelRatio||1),h.setSize(d,p),h.setClearColor(0,0),h.domElement.style.position="absolute",h.domElement.style.top="0",h.domElement.style.left="0",h.domElement.style.right="0",h.domElement.style.bottom="0",h.domElement.style.width="100%",h.domElement.style.height="100%",h.domElement.style.minWidth="100%",h.domElement.style.minHeight="100%",h.domElement.style.maxWidth="100%",h.domElement.style.maxHeight="100%",h.domElement.style.display="block",h.domElement.style.pointerEvents="auto",h.domElement.style.margin="0",h.domElement.style.padding="0",h.domElement.style.boxSizing="border-box",s.appendChild(h.domElement);let x=f=>{var _;let m=t.getBoundingClientRect(),E=window.getComputedStyle(t);console.log("[THREE-BASE] applySize called:",{providedSize:f,rootRect:{width:m.width,height:m.height},clientSize:{width:t.clientWidth,height:t.clientHeight},styleSize:{width:t.style.width,height:t.style.height},computedStyle:{width:E.width,height:E.height,transform:E.transform,scale:E.scale},rendererCurrentSize:{width:h.domElement.width,height:h.domElement.height},rendererStyleSize:{width:h.domElement.style.width,height:h.domElement.style.height},stackTrace:(_=new Error().stack)==null?void 0:_.split(`
|
|
267
267
|
`).slice(1,4).join(`
|
|
268
|
-
`)});let S=m.width,A=m.height;if((S<=0||!isFinite(S))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:m.width,clientWidth:t.clientWidth}),S=t.clientWidth||window.innerWidth||320),(A<=0||!isFinite(A))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:m.height,clientHeight:t.clientHeight}),A=t.clientHeight||window.innerHeight||480),typeof(f==null?void 0:f.width)=="number"&&f.width>0){let j=Math.abs(f.width-m.width),
|
|
268
|
+
`)});let S=m.width,A=m.height;if((S<=0||!isFinite(S))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:m.width,clientWidth:t.clientWidth}),S=t.clientWidth||window.innerWidth||320),(A<=0||!isFinite(A))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:m.height,clientHeight:t.clientHeight}),A=t.clientHeight||window.innerHeight||480),typeof(f==null?void 0:f.width)=="number"&&f.width>0){let j=Math.abs(f.width-m.width),O=m.width*.1;j>O?console.warn("[THREE-BASE] Provided width ignored (too different from container):",{provided:f.width,container:m.width,difference:j,tolerance:O,willUse:"container size (boundingRect)"}):(S=f.width,console.log("[THREE-BASE] Using provided width (within tolerance):",{provided:f.width,container:m.width}))}if(typeof(f==null?void 0:f.height)=="number"&&f.height>0){let j=Math.abs(f.height-m.height),O=m.height*.1;j>O?console.warn("[THREE-BASE] Provided height ignored (too different from container):",{provided:f.height,container:m.height,difference:j,tolerance:O,willUse:"container size (boundingRect)"}):(A=f.height,console.log("[THREE-BASE] Using provided height (within tolerance):",{provided:f.height,container:m.height}))}(S<=0||A<=0||!isFinite(S)||!isFinite(A))&&(console.warn("[THREE-BASE] Invalid size in applySize, using fallback",{newWidth:S,newHeight:A,size:f,rootRect:m}),S=m.width||t.clientWidth||320,A=m.height||t.clientHeight||480);let k=Math.floor(S),R=Math.floor(A);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:k,finalHeight:R,aspectRatio:k/R,beforeRendererSize:{width:h.domElement.width,height:h.domElement.height},beforeRendererStyle:{width:h.domElement.style.width,height:h.domElement.style.height}}),h.setSize(k,R),h.setPixelRatio(window.devicePixelRatio||1),b.aspect=k/R,b.updateProjectionMatrix();let L=t.getBoundingClientRect();console.log("[THREE-BASE] applySize after setting:",{rendererSize:{width:h.domElement.width,height:h.domElement.height},rendererStyle:{width:h.domElement.style.width,height:h.domElement.style.height},containerRect:{width:L.width,height:L.height},cameraAspect:b.aspect,matches:{width:Math.abs(h.domElement.width-L.width)<1,height:Math.abs(h.domElement.height-L.height)<1},sizeDifference:{width:h.domElement.width-L.width,height:h.domElement.height-L.height}})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{x()})});let v=!1;Ie.on("pause",()=>{v=!0,document.querySelectorAll("audio").forEach(m=>m.pause())}),Ie.on("resume",()=>{v=!1,document.querySelectorAll("audio").forEach(m=>{m.currentTime>0&&!m.ended&&m.play().catch(()=>{})})});let y=new Ge(t,o);return Ie.on("resize",({payload:f})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:f,timestamp:Date.now(),rootRect:t.getBoundingClientRect()}),x({width:f==null?void 0:f.width,height:f==null?void 0:f.height}),y.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()}),x(),y.updateLayout()}),{scene:l,camera:b,renderer:h,uiSystem:y,applySize:x}}var D=ae(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}},ot=class{constructor(e){var n,i,a,r;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=(r=e==null?void 0:e.tint)!=null?r:null}update(e){e.z_index!==void 0&&(this.z_index=e.z_index),e.alpha!==void 0&&(this.alpha=e.alpha),e.visible!==void 0&&(this.visible=e.visible),e.tint!==void 0&&(this.tint=e.tint)}syncToThree(e){if(e.renderOrder=this.z_index,e.visible=this.visible,e instanceof D.Mesh&&e.material&&(Array.isArray(e.material)?e.material.forEach(n=>{n instanceof D.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):e.material instanceof D.Material&&(e.material.opacity=this.alpha,e.material.transparent=this.alpha<1)),this.tint!==null&&e instanceof D.Mesh&&e.material){let n=typeof this.tint=="string"?new D.Color(this.tint):new D.Color(this.tint);Array.isArray(e.material)?e.material.forEach(i=>{(i instanceof D.MeshBasicMaterial||i instanceof D.MeshStandardMaterial)&&i.color.copy(n)}):(e.material instanceof D.MeshBasicMaterial||e.material instanceof D.MeshStandardMaterial)&&e.material.color.copy(n)}}},st=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 ot(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)}},$t=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 st(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 Ht={"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 Z(t){let e=Ht[t];return e?e.family:(console.warn(`Font ID "${t}" not found in registry, using fallback`),"Arial, sans-serif")}function Q(t){var n;let e=Ht[t];return e&&(n=e.weight)!=null?n:"400"}function mr(t,e){Ht[t]=e}function br(){return Object.keys(Ht)}var Ue=ae(require("three"),1);function ke(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 yr(t,e,n,i){var Qn,ei,ti,ni,ii,ai,ri,oi,si,li,ci,di,pi,ui,gi,hi,fi,mi,bi,yi,vi,xi,wi,Ei,Si,Ai,Ci,Ti,Li,_i,ki,Mi,Pi,Ri,Oi,Ii,ji,Di,$i,Hi,zi,Fi,Ni,Bi,Gi,Ui,qi,Wi,Vi,Yi,Ki,Xi,Ji,Zi,Qi,ea,ta,na,ia,aa,ra;let a=t.objects.get("ui_endgame_1"),r=t.objects.get("ui_endgame_logo_1"),o=t.objects.get("ui_endgame_title_1"),s=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"),g=t.engine.runtime||{},u=((Qn=a==null?void 0:a.gameplay)==null?void 0:Qn.tuning)||{},b=(a==null?void 0:a.render)||{},h=i.getBoundingClientRect(),x=h.width>0?h.width*.9:320,v=h.height>0?h.height*.85:400,y=Math.min((ei=u.panel_width)!=null?ei:320,x),f=Math.min((ti=u.panel_height)!=null?ti:400,v),m=(ni=u.panel_padding)!=null?ni:32,E=(ii=u.panel_radius)!=null?ii:24,S=b.background_color||u.panel_bg_color||"#1a0a0a",A=b.background_alpha!==void 0&&b.background_alpha!==null?b.background_alpha:(ai=u.panel_bg_alpha)!=null?ai:.98,k=b.border_color||u.panel_border_color||"#ffffff",R=(ri=u.panel_border_width)!=null?ri:2,L=(oi=u.panel_border_alpha)!=null?oi:.3,_=document.createElement("div");_.style.cssText=`
|
|
269
269
|
position: absolute;
|
|
270
270
|
width: ${y}px;
|
|
271
271
|
height: ${f}px;
|
|
272
272
|
background: ${S};
|
|
273
273
|
opacity: ${A};
|
|
274
|
-
border: ${
|
|
274
|
+
border: ${R}px solid ${k};
|
|
275
275
|
border-opacity: ${L};
|
|
276
276
|
border-radius: ${E}px;
|
|
277
277
|
display: block;
|
|
@@ -284,10 +284,10 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
284
284
|
z-index: 1000;
|
|
285
285
|
box-sizing: border-box;
|
|
286
286
|
padding: ${m}px;
|
|
287
|
-
`,i.appendChild(_);let j=ke(_);j.element=_;let
|
|
287
|
+
`,i.appendChild(_);let j=ke(_);j.element=_;let O=((si=r==null?void 0:r.gameplay)==null?void 0:si.tuning)||{},be=(r==null?void 0:r.transform)||{},q=(li=O.logo_size)!=null?li:56,Y=(ci=be.scale)!=null?ci:1,Me=(pi=(di=be.offset)==null?void 0:di.y)!=null?pi:-130,lt=(ui=O.logo_alpha)!=null?ui:1,_r=new Ue.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),K=new Ue.Sprite(_r);K.position.set(0,Me,0),K.material.opacity=0;let ct=0,dt=0;if(n){let $=n.image;ct=($==null?void 0:$.width)||100,dt=($==null?void 0:$.height)||100}if(ct>0&&dt>0){let $=ct/dt,Yt,Kt;$>1?(Yt=q,Kt=q/$):(Kt=q,Yt=q*$);let ho=Yt/ct*Y,fo=Kt/dt*Y;K.scale.set(ho,fo,1)}else{let $=q/100*Y;K.scale.set($,$,1)}K.targetAlpha=lt,K.baseScaleX=K.scale.x,K.baseScaleY=K.scale.y;let H=o==null?void 0:o.ui,ee=((gi=o==null?void 0:o.gameplay)==null?void 0:gi.tuning)||{},kr=(H==null?void 0:H.text)||"MISSION ACCOMPLISHED",Hn=(H==null?void 0:H.font)||"brand.heading",Ft=(H==null?void 0:H.fontSize)||24,Mr=(hi=H==null?void 0:H.letterSpacing)!=null?hi:1,pt=(fi=o==null?void 0:o.render)==null?void 0:fi.tint,Pr=typeof pt=="string"?pt:pt?`#${pt.toString(16).padStart(6,"0")}`:"#00FF88",Rr=y-m*2-30,Or=ee.font_weight_override?ee.font_weight_override:Q(Hn),ye=document.createElement("div");ye.textContent=kr,ye.style.cssText=`
|
|
288
288
|
font-family: ${Z(Hn)};
|
|
289
289
|
font-size: ${Ft}px;
|
|
290
|
-
font-weight: ${
|
|
290
|
+
font-weight: ${Or};
|
|
291
291
|
color: ${Pr};
|
|
292
292
|
text-align: center;
|
|
293
293
|
letter-spacing: ${Mr}px;
|
|
@@ -297,7 +297,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
297
297
|
position: absolute;
|
|
298
298
|
transform: translate(-50%, -50%);
|
|
299
299
|
white-space: nowrap;
|
|
300
|
-
max-width: ${
|
|
300
|
+
max-width: ${Rr}px;
|
|
301
301
|
`;let zn=m+30,Ir=((wi=u.title_offset_y)!=null?wi:zn+Ft/2)+((Ei=ee.animation_start_y_offset)!=null?Ei:-20);ye.style.top=`${Ir}px`,ye.style.left="50%";let Fn=ke(ye);Fn.element=ye,_.appendChild(ye);let z=s==null?void 0:s.ui,Nn=((Si=s==null?void 0:s.gameplay)==null?void 0:Si.tuning)||{},jr=(z==null?void 0:z.text)||"RESCUE COMPLETE",Bn=(z==null?void 0:z.font)||"brand.body",Nt=(z==null?void 0:z.fontSize)||11,Dr=(Ai=z==null?void 0:z.letterSpacing)!=null?Ai:.5,ut=(Ci=s==null?void 0:s.render)==null?void 0:Ci.tint,$r=typeof ut=="string"?ut:ut?`#${ut.toString(16).padStart(6,"0")}`:"#B0B0B0",ve=document.createElement("div");ve.textContent=jr,ve.style.cssText=`
|
|
302
302
|
font-family: ${Z(Bn)};
|
|
303
303
|
font-size: ${Nt}px;
|
|
@@ -309,7 +309,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
309
309
|
position: absolute;
|
|
310
310
|
transform: translate(-50%, -50%);
|
|
311
311
|
white-space: nowrap;
|
|
312
|
-
`;let Gn=zn+Ft+15,Hr=((Ti=u.subtitle_offset_y)!=null?Ti:Gn+Nt/2)+((Li=Nn.animation_start_y_offset)!=null?Li:-10);ve.style.top=`${Hr}px`,ve.style.left="50%";let Bt=ke(ve);Bt.element=ve,Bt.animationStartYOffset=(_i=Nn.animation_start_y_offset)!=null?_i:-10,_.appendChild(ve);let te=l==null?void 0:l.ui,Un=((ki=l==null?void 0:l.gameplay)==null?void 0:ki.tuning)||{},zr=(te==null?void 0:te.text)||((Mi=g.ui)==null?void 0:Mi.cta_hint)||"Continue the adventure!",qn=(te==null?void 0:te.font)||"brand.body",Wn=(te==null?void 0:te.fontSize)||16,gt=(Pi=l==null?void 0:l.render)==null?void 0:Pi.tint,Fr=typeof gt=="string"?gt:gt?`#${gt.toString(16).padStart(6,"0")}`:"#FFFFFF",Nr=(
|
|
312
|
+
`;let Gn=zn+Ft+15,Hr=((Ti=u.subtitle_offset_y)!=null?Ti:Gn+Nt/2)+((Li=Nn.animation_start_y_offset)!=null?Li:-10);ve.style.top=`${Hr}px`,ve.style.left="50%";let Bt=ke(ve);Bt.element=ve,Bt.animationStartYOffset=(_i=Nn.animation_start_y_offset)!=null?_i:-10,_.appendChild(ve);let te=l==null?void 0:l.ui,Un=((ki=l==null?void 0:l.gameplay)==null?void 0:ki.tuning)||{},zr=(te==null?void 0:te.text)||((Mi=g.ui)==null?void 0:Mi.cta_hint)||"Continue the adventure!",qn=(te==null?void 0:te.font)||"brand.body",Wn=(te==null?void 0:te.fontSize)||16,gt=(Pi=l==null?void 0:l.render)==null?void 0:Pi.tint,Fr=typeof gt=="string"?gt:gt?`#${gt.toString(16).padStart(6,"0")}`:"#FFFFFF",Nr=(Ri=Un.max_width)!=null?Ri:y-m*2,Br=(Oi=Un.line_height)!=null?Oi:1.4,xe=document.createElement("div");xe.textContent=zr,xe.style.cssText=`
|
|
313
313
|
font-family: ${Z(qn)};
|
|
314
314
|
font-size: ${Wn}px;
|
|
315
315
|
font-weight: ${Q(qn)};
|
|
@@ -344,7 +344,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
344
344
|
position: absolute;
|
|
345
345
|
transform: translate(-50%, -50%);
|
|
346
346
|
white-space: nowrap;
|
|
347
|
-
`;let ro=Ut+Vn/2+20,oo=f-m-10,so=Math.min(ro+((Zi=Xn.animation_start_y_offset)!=null?Zi:5),oo);we.style.top=`${so}px`,we.style.left="50%";let Wt=ke(we);Wt.element=we,Wt.animationStartYOffset=(Qi=Xn.animation_start_y_offset)!=null?Qi:5,_.appendChild(we);let Vt=((ea=c==null?void 0:c.gameplay)==null?void 0:ea.tuning)||{},lo=(ta=Vt.hand_offset_x)!=null?ta:50,co=(na=Vt.hand_offset_y)!=null?na:50,po=(aa=(ia=c==null?void 0:c.transform)==null?void 0:ia.scale)!=null?aa:.1875,uo=(ra=Vt.hand_scale_multiplier)!=null?ra:2.5,go=new Ue.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),We=new Ue.Sprite(go),Zn=po*uo*100;return We.scale.set(Zn,Zn,1),We.position.set(lo,Ut+co,0),We.material.opacity=0,We.visible=!1,{panel:j,logo:K,title:Fn,subtitle:Bt,footer:Gt,ctaButton:qt,ctaText:Kn,ctaHint:Wt,hand:We}}function vr(t,e,n){var S,A,k,
|
|
347
|
+
`;let ro=Ut+Vn/2+20,oo=f-m-10,so=Math.min(ro+((Zi=Xn.animation_start_y_offset)!=null?Zi:5),oo);we.style.top=`${so}px`,we.style.left="50%";let Wt=ke(we);Wt.element=we,Wt.animationStartYOffset=(Qi=Xn.animation_start_y_offset)!=null?Qi:5,_.appendChild(we);let Vt=((ea=c==null?void 0:c.gameplay)==null?void 0:ea.tuning)||{},lo=(ta=Vt.hand_offset_x)!=null?ta:50,co=(na=Vt.hand_offset_y)!=null?na:50,po=(aa=(ia=c==null?void 0:c.transform)==null?void 0:ia.scale)!=null?aa:.1875,uo=(ra=Vt.hand_scale_multiplier)!=null?ra:2.5,go=new Ue.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),We=new Ue.Sprite(go),Zn=po*uo*100;return We.scale.set(Zn,Zn,1),We.position.set(lo,Ut+co,0),We.material.opacity=0,We.visible=!1,{panel:j,logo:K,title:Fn,subtitle:Bt,footer:Gt,ctaButton:qt,ctaText:Kn,ctaHint:Wt,hand:We}}function vr(t,e,n){var S,A,k,R,L,_,j,O;let i=e.objects.get("ui_endgame_1"),a=((S=i==null?void 0:i.gameplay)==null?void 0:S.tuning)||{},r=(A=a.animation_duration_ms)!=null?A:800,o=(k=a.fade_in_duration_ms)!=null?k:600,s=(R=a.scale_animation_intensity)!=null?R:.1,l=(L=a.logo_animation_delay_ms)!=null?L:100,d=(_=a.title_animation_delay_ms)!=null?_:200,p=(j=a.footer_animation_delay_ms)!=null?j:300,c=(O=a.cta_animation_delay_ms)!=null?O:400,{panel:g,logo:u,title:b,subtitle:h,footer:x,ctaButton:v,ctaText:y,ctaHint:f}=t;g.visible=!0,g.element.style.visibility="visible";let m=Date.now(),E=()=>{let be=Date.now()-m,q=Math.min(be/o,1),Y=1-Math.pow(1-q,3);g.alpha=Y,g.element.style.opacity=Y.toString();let Me=1+s*(1-Y);g.element.style.transform=`translate(-50%, -50%) scale(${Me})`,q<1?requestAnimationFrame(E):(setTimeout(()=>Us(u,r,e),l),setTimeout(()=>{qs(b,r),setTimeout(()=>Ws(h,r),50)},d),setTimeout(()=>Vs(x,r),p),setTimeout(()=>{Ys(v,y,r),setTimeout(()=>Ks(f,r),50),n&&n()},c))};E()}function Us(t,e,n){var g,u,b,h,x;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),r=(u=(((g=i==null?void 0:i.gameplay)==null?void 0:g.tuning)||{}).animation_start_scale)!=null?u:1.2,o=Date.now(),s=t.material.opacity,l=(b=t.targetAlpha)!=null?b:1,d=(h=t.baseScaleX)!=null?h:t.scale.x,p=(x=t.baseScaleY)!=null?x:t.scale.y,c=()=>{let v=Date.now()-o,y=Math.min(v/e,1),f=1-Math.pow(1-y,2);t.material.opacity=s+(l-s)*f;let m=r+(1-r)*f;t.scale.set(d*m,p*m,1),y<1&&requestAnimationFrame(c)};c()}function qs(t,e){let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=parseFloat(t.element.style.top||"0"),r=()=>{let o=Date.now()-n,s=Math.min(o/e,1),l=1-Math.pow(1-s,2);t.element.style.opacity=(i+(1-i)*l).toString(),t.element.style.top=`${a-20*(1-l)}px`,s<1&&requestAnimationFrame(r)};r()}function Ws(t,e){var s;let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=parseFloat(t.element.style.top||"0"),r=a-((s=t.animationStartYOffset)!=null?s:-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+(r-a)*p}px`,d<1&&requestAnimationFrame(o)};o()}function Vs(t,e){var o;let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=(o=t.targetAlpha)!=null?o:1,r=()=>{let s=Date.now()-n,l=Math.min(s/e,1),d=1-Math.pow(1-l,2);t.element.style.opacity=(i+(a-i)*d).toString(),l<1&&requestAnimationFrame(r)};r()}function Ys(t,e,n){let i=Date.now(),a=parseFloat(t.element.style.opacity||"0"),r=()=>{let o=Date.now()-i,s=Math.min(o/n,1),l=1-Math.pow(1-s,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)})`,s<1&&requestAnimationFrame(r)};r()}function Ks(t,e){var s;let n=Date.now(),i=parseFloat(t.element.style.opacity||"0"),a=parseFloat(t.element.style.top||"0"),r=a-((s=t.animationStartYOffset)!=null?s: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+(r-a)*p}px`,d<1&&requestAnimationFrame(o)};o()}function xr(t,e,n,i){var p,c,g,u;let a=n.objects.get("ui_endgame_hand_1"),r=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},o=(c=r.click_animation_duration_ms)!=null?c:600,s=(g=r.click_delay_ms)!=null?g:2e3,l=(u=r.click_repeat_delay_ms)!=null?u:3e3,d=()=>{var A,k;t.visible=!0,t.material.opacity=1;let b=t.position.x,h=t.position.y,x=(A=r.hand_offset_x)!=null?A:50,v=(k=r.hand_offset_y)!=null?k:50,y=e.element.getBoundingClientRect(),f=x,m=v,E=Date.now(),S=()=>{var Y,Me,lt;let R=Date.now()-E,L=Math.min(R/o,1),_=L<.5?2*L*L:1-Math.pow(-2*L+2,2)/2;t.position.set(b+(f-b)*_,h+(m-h)*_,0);let j=(Me=(Y=a==null?void 0:a.transform)==null?void 0:Y.scale)!=null?Me:.1875,O=(lt=r.hand_scale_multiplier)!=null?lt:2.5,be=j*O*100,q=be+be*.2*Math.sin(L*Math.PI);t.scale.set(q,q,1),L<1?requestAnimationFrame(S):(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(b,h,0),d()},l)},500))};S()};setTimeout(d,s)}var zt=ae(require("three"),1);function wr(t,e,n){var u,b,h,x,v,y,f;let i=e.objects.get("hand_tutorial_1"),a=((u=i==null?void 0:i.gameplay)==null?void 0:u.tuning)||{},r=(i==null?void 0:i.render)||{},o=(i==null?void 0:i.transform)||{},s=new zt.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),l=new zt.Sprite(s),d=o.position||{},p=(b=d==null?void 0:d.z)!=null?b:0;l.position.set(n.x+((h=d==null?void 0:d.x)!=null?h:0),n.y+((x=d==null?void 0:d.y)!=null?x:0),p),l.material.opacity=r.alpha!==void 0&&r.alpha!==null?r.alpha:0,l.visible=r.visible!==void 0&&r.visible!==null?r.visible:!1;let c=(v=a.hand_scale_multiplier)!=null?v:2.5,g=(y=o.scale)!=null?y:.1875;return l.scale.set(g*c*100,g*c*100,1),l.renderOrder=(f=r.z_index)!=null?f:99999,l}function Er(t){var b,h,x,v,y,f,m,E,S;let e=t.objects.get("ui_tutorial_1"),n=e==null?void 0:e.ui,i=(e==null?void 0:e.render)||{},a=((b=t.engine.runtime)==null?void 0:b.ui_styles)||{},r=((h=t.engine.runtime)==null?void 0:h.ui)||{},o=(n==null?void 0:n.text)||r.tutorial_label||r.label_text||"CLEAN!",s=(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:(x=a.label_letter_spacing)!=null?x:-1,p=(n==null?void 0:n.align)||"center",c=i.tint,g=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=`
|
|
348
348
|
font-family: ${Z(s)};
|
|
349
349
|
font-size: ${l}px;
|
|
350
350
|
font-weight: ${Q(s)};
|
|
@@ -359,4 +359,4 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
359
359
|
position: absolute;
|
|
360
360
|
transform: translate(-50%, -50%);
|
|
361
361
|
white-space: nowrap;
|
|
362
|
-
`,u}function Sr(t,e,n,i,a){var l,d,p,c,g,u,b;let r=a.objects.get("hand_tutorial_1"),o=((l=r==null?void 0:r.gameplay)==null?void 0:l.tuning)||{},s=(r==null?void 0:r.transform)||{};if(!i){let h=(d=o.animation_duration)!=null?d:1.5,x=n%h/h,v=x<.5?2*x*x:-1+(4-2*x)*x,y=(p=o.x_offset)!=null?p:0,f=(c=o.y_offset)!=null?c:0,m=(g=o.animation_range)!=null?g:40,E=m*.7,S=m,A=e.x+y+E,k=e.y+f+S,
|
|
362
|
+
`,u}function Sr(t,e,n,i,a){var l,d,p,c,g,u,b;let r=a.objects.get("hand_tutorial_1"),o=((l=r==null?void 0:r.gameplay)==null?void 0:l.tuning)||{},s=(r==null?void 0:r.transform)||{};if(!i){let h=(d=o.animation_duration)!=null?d:1.5,x=n%h/h,v=x<.5?2*x*x:-1+(4-2*x)*x,y=(p=o.x_offset)!=null?p:0,f=(c=o.y_offset)!=null?c:0,m=(g=o.animation_range)!=null?g:40,E=m*.7,S=m,A=e.x+y+E,k=e.y+f+S,R=A+E,L=k+S;t.position.set(A+(R-A)*v,k+(L-k)*v,0);let _=(u=s.scale)!=null?u:.1875,j=(b=o.hand_scale_multiplier)!=null?b:2.5,O=_*j*100;t.scale.set(O,O,1)}}var qe=ae(require("three"),1),Ar=new qe.TextureLoader,jn=null,Dn=null;async function Cr(){if(jn)return jn;if(!Dn){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"})();Dn=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 Dn;return jn=t||{},t||{}}async function $n(t,e,n=16777215,i=!1){try{let r=(await Cr())[t];return await Ar.loadAsync(r||t)}catch{console.warn(`Asset missing: ${t}. Using placeholder.`);let r=document.createElement("canvas");r.width=64,r.height=64;let o=r.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 qe.CanvasTexture(r)}}async function Tr(t,e,n){var h,x;let a=(await Cr())[t]||t,r;try{r=await Ar.loadAsync(a),console.log("[character] loaded sheet",{path:t,sourceUsed:a})}catch(v){let m=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");r=await $n(t,e,parseInt(m,16),!0),console.warn("[character] fallback loadAsset used",{path:t,err:v})}if(!r)return[];let o=n.gameplay.character_sheet||{},s=(h=o.cols)!=null?h:3,l=(x=o.rows)!=null?x:2,d=r.image,p=(d==null?void 0:d.width)||0,c=(d==null?void 0:d.height)||0,g=p/s,u=c/l;if(!Number.isFinite(g)||!Number.isFinite(u)||g<=0||u<=0)return[r];let b=[];for(let v=0;v<l;v++)for(let y=0;y<s;y++){let f=document.createElement("canvas");f.width=g,f.height=u;let m=f.getContext("2d");m&&d&&m.drawImage(d,y*g,v*u,g,u,0,0,g,u),b.push(new qe.CanvasTexture(f))}return b.length>2&&b.push(...b.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:b.length}),b}function Lr(t,e){var c,g,u,b;let n=e.gameplay.brush||{},i=e.theme.brush_color||"#ffffff",a=(c=n.radius)!=null?c:20,r=(g=n.inner_radius)!=null?g:15,o=(u=n.alpha)!=null?u:.8,s=(b=n.inner_alpha)!=null?b:.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,r,0,Math.PI*2),p.fillStyle=l,p.globalAlpha=s,p.fill()),new qe.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});
|