handler-playable-sdk 0.3.19 → 0.3.21

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/index.cjs CHANGED
@@ -44,7 +44,7 @@
44
44
  <button class="debug-btn primary" data-modal-apply>Apply</button>
45
45
  </div>
46
46
  </div>
47
- `,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let c=o.target.dataset.tab;c&&this.switchTab(c)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let r=this.modal.querySelector("[data-ai-edit]");r==null||r.addEventListener("click",()=>{this.openAiEditor("edit")});let a=this.modal.querySelector("[data-modal-apply]");a==null||a.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",s=>{s.target===this.modal&&this.close()})}switchTab(t){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab")===t)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab-panel")===t)})}openAiEditor(t){let i=window.__openAiEditor;if(typeof i!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";t==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,i(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:r=>{this.onApplyCallback&&this.onApplyCallback(r),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 r0={};nn(r0,{ConfigWatcher:()=>Ft,DebugPanel:()=>tr,DefaultReloadStrategy:()=>hn,Handler:()=>Re,PreviewShell:()=>ts,applyConfigOverride:()=>mt,applyConfigOverrides:()=>bt,applyConfigsToDisk:()=>kr,applyDefaults:()=>Bt,baseLottie:()=>ys,bootstrap:()=>Yw,clearConfigOverrides:()=>un,clearConfigOverridesForObject:()=>wd,configOverrideManager:()=>_d,createPreviewShell:()=>pc,deepClone:()=>ne,default:()=>jt,defaultPreset:()=>Dr,deviceGroups:()=>Gs,devicePresets:()=>qs,diffConfigs:()=>Ns,exportConfigsAsJSON:()=>Ms,getConfigOverrides:()=>de,getConfigStateSummary:()=>Tr,getOverrideMode:()=>dn,getPresetById:()=>Ht,getPresetsByCategory:()=>Wm,loadAllObjectConfigs:()=>Mr,loadComponentSchemas:()=>Ir,loadEngineConfig:()=>Rr,loadGamePromptConfig:()=>js,loadObjectCentricConfig:()=>Qe,loadObjectConfig:()=>yt,loadSceneConfig:()=>Pr,rehydrateObject:()=>Bs,removeConfigOverride:()=>Cr,resetToApplied:()=>pn,resetToOriginal:()=>Lr,setBootstrapDependencies:()=>Gw,setOverrideMode:()=>Is,setupHotReload:()=>$s,setupLiveEditBridge:()=>is,toLegacyFormat:()=>Ds,validateObjectConfig:()=>fi});module.exports=Qg(r0);var ft={};function pr(e,t,i=!1){ft[e]||(ft[e]=[]),ft[e].push({fn:t,once:i})}function hs(e,t){if(ft[e]){if(!t){delete ft[e];return}ft[e]=ft[e].filter(i=>i.fn!==t)}}function fr(e,...t){let i=ft[e];if(i)for(let n of[...i])n.fn(...t),n.once&&hs(e,n.fn)}function be(e,t){pr(e,t,!0)}var ee=null,Ce=[],ci=null;function Ic(e){ee=e,Ce=[],ci!==null&&(clearTimeout(ci),ci=null)}function Mc(){var e,t,i;return{endpoint:(ee==null?void 0:ee.endpoint)||"",transport:(ee==null?void 0:ee.transport)||"beacon",batchSize:(e=ee==null?void 0:ee.batchSize)!=null?e:10,flushIntervalMs:(t=ee==null?void 0:ee.flushIntervalMs)!=null?t:300,maxQueue:(i=ee==null?void 0:ee.maxQueue)!=null?i:200,debug:!!(ee!=null&&ee.debug)}}async function Lc(e,t,i,n){let r=JSON.stringify(t);if(i==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(e,new Blob([r],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",a,t);return}catch(a){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",t)}catch(a){n&&console.warn("[handler.telemetry] fetch failed",a)}}function gs(e,t){let i=Mc();if(t&&i.endpoint){if(Ce.push(e),Ce.length>i.maxQueue&&(Ce=Ce.slice(Ce.length-i.maxQueue)),Ce.length>=i.batchSize){Oc();return}ci===null&&(ci=window.setTimeout(()=>{ci=null,Oc()},i.flushIntervalMs))}}async function Oc(){let e=Mc();if(!e.endpoint||Ce.length===0)return;let t=Ce.splice(0,e.batchSize);await Lc(e.endpoint,{events:t},e.transport,e.debug),Ce.length>0&&await Lc(e.endpoint,{events:Ce.splice(0,e.batchSize)},e.transport,e.debug)}function Rc(e){return Math.max(0,Math.min(1,e))}function em(e){let t=String(e!=null?e:"power2.out");if(t==="linear")return i=>i;if(t==="sine.inOut")return i=>.5-Math.cos(Math.PI*i)/2;if(t==="power2.out"||t==="easeOutQuad")return i=>1-(1-i)*(1-i);if(t.startsWith("back.out")){let i=t.match(/back\.out\(([\d.]+)\)/),n=i?Number(i[1]):1.8;return r=>1+(n+1)*Math.pow(r-1,3)+n*Math.pow(r-1,2)}return i=>1-(1-i)*(1-i)}function rn(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function tm(e,t){let i=e==null?void 0:e[t];return typeof i=="number"?i:0}function Pc(e,t,i){try{e[t]=i}catch{}}function im(e){let t=e==null?void 0:e.scale;if(!t)return null;let i=typeof t.x=="number"?t.x:1,n=typeof t.y=="number"?t.y:1;return{x:i,y:n}}function jc(e,t){let i=e==null?void 0:e.scale;if(i)try{typeof i.set=="function"?i.set(t.x,t.y):(typeof i.x=="number"&&(i.x=t.x),typeof i.y=="number"&&(i.y=t.y))}catch{}}function Dc(e,t){let i=im(e);if(!i)return{from:null,to:null};let n=null,r=null;return typeof t.scale=="number"?(n=t.scale,r=t.scale):t.scale&&typeof t.scale=="object"&&(typeof t.scale.x=="number"&&(n=t.scale.x),typeof t.scale.y=="number"&&(r=t.scale.y)),typeof t.scaleX=="number"&&(n=t.scaleX),typeof t.scaleY=="number"&&(r=t.scaleY),n===null&&r===null?{from:null,to:null}:{from:{x:i.x,y:i.y},to:{x:n!=null?n:i.x,y:r!=null?r:i.y}}}function zc(){let e=new Set,t=new WeakMap,i=null,n=()=>{if(i!=null)return;i=requestAnimationFrame(()=>{i=null,o(),e.size>0&&n()})},r=d=>{var p;e.add(d);let u=(p=t.get(d.target))!=null?p:new Set;u.add(d),t.set(d.target,u),n()},a=d=>{e.delete(d);let u=t.get(d.target);u&&(u.delete(d),u.size===0&&t.delete(d.target))},s=d=>{d.killed||(d.killed=!0,a(d))},o=()=>{var u,p;let d=rn();for(let f of Array.from(e)){if(f.killed||f.paused)continue;let m=d-f.startMs-f.delayMs;if(m<0)continue;let h=f.durationMs>0?m/f.durationMs:1,g=Rc(h),b=f.repeat>=0?f.repeat+1:1,y=f.repeat>0?Math.min(Math.floor(h),b-1):0;if(f.repeat>0&&h>=1){let w=h-y;g=Rc(w)}let v=f.ease(g);f.yoyo&&y%2===1&&(v=1-v);for(let w of f.props)Pc(f.target,w.key,w.from+(w.to-w.from)*v);f.scaleFrom&&f.scaleTo&&jc(f.target,{x:f.scaleFrom.x+(f.scaleTo.x-f.scaleFrom.x)*v,y:f.scaleFrom.y+(f.scaleTo.y-f.scaleFrom.y)*v});try{(u=f.onUpdate)==null||u.call(f)}catch{}if(h>=b){s(f);try{(p=f.onComplete)==null||p.call(f)}catch{}}}},l=(d,u,p)=>{var w;let f=Math.max(0,(typeof u.duration=="number"?u.duration:.5)*1e3),m=Math.max(0,(typeof u.delay=="number"?u.delay:0)*1e3+((w=p==null?void 0:p.delayMsOverride)!=null?w:0)),h=em(u.ease),g=typeof u.repeat=="number"?Math.max(0,u.repeat|0):0,b=u.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let S of Object.keys(u)){if(y.has(S))continue;let A=u[S];typeof A=="number"&&v.push({key:S,from:tm(d,S),to:A})}let x=Dc(d,u);return{target:d,startMs:rn(),delayMs:m,durationMs:f,ease:h,props:v,scaleFrom:x.from,scaleTo:x.to,repeat:g,yoyo:b,onUpdate:typeof u.onUpdate=="function"?u.onUpdate:void 0,onComplete:typeof u.onComplete=="function"?u.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(d,u){let p=l(d,u);return r(p),{kill:()=>s(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=rn())},resume:()=>{var h;if(!p.paused)return;let f=(h=p.pauseAtMs)!=null?h:rn(),m=rn()-f;p.startMs+=m,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(d,u,p){return c.set(d,u),c.to(d,p)},set(d,u){if(!d||!u)return;for(let f of Object.keys(u)){let m=u[f];f==="scale"||f==="scaleX"||f==="scaleY"||typeof m=="number"&&Pc(d,f,m)}let p=Dc(d,u);p.to&&jc(d,p.to)},killTweensOf(d){let u=t.get(d);if(u)for(let p of Array.from(u))s(p)},timeline(d={}){let u=[],p=0,f=!1,m=[],h=y=>{if(typeof y=="number")return Math.max(0,y*1e3);let v=typeof y=="string"?y.trim():"";return v.startsWith("+=")?p+Math.max(0,Number(v.slice(2))*1e3||0):v?Math.max(0,Number(v)*1e3||0):p},g=y=>{u.push(y);let v=Math.max(0,(typeof y.vars.duration=="number"?y.vars.duration:.5)*1e3);p=Math.max(p,y.atMs+v)},b={to(y,v,x){return g({kind:"to",target:y,vars:v,atMs:h(x)}),b},fromTo(y,v,x,w){return g({kind:"fromTo",target:y,vars:x,from:v,atMs:h(w)}),b},play(){var y,v;if(f)return b;f=!0,m=[];for(let x of u)x.kind==="fromTo"&&c.set(x.target,(y=x.from)!=null?y:{}),m.push(c.to(x.target,{...x.vars,delay:x.atMs/1e3+((v=x.vars.delay)!=null?v:0)}));return b},pause(){for(let y of m)y.pause();return b},kill(){for(let y of m)y.kill();m=[],f=!1}};return d.paused||b.play(),b}};return c}function Nc(){if(typeof window=="undefined")return;let e=window;if(!e.gsap)try{e.gsap=zc()}catch{}}var Bc={name:"handler-playable-sdk",version:"0.3.19",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"}},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","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 --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks",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",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","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",sharp:"^0.34.5"}};var ye=0,rm=ye++,Fc=ye++,Hc=ye++,$c=ye++,Uc=ye++,qc=ye++,Gc=ye++,Wc=ye++,Yc=ye++,Vc=ye++,Kc=ye++,Xc=ye++,K=rm;function Zc(){return K===Fc}function Jc(){return K===Hc}function Qc(){return K===$c}function ed(){return K===Uc}function di(){return K===qc}function ui(){return K===Gc}function td(){return K===Wc}function id(){return K===Yc}function nd(){return K===Vc}function ms(){return K===Kc}function bs(){return K===Xc}function rd(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),K=Fc;return}catch{}else if(e==="dapi")try{dapi.isReady(),K=Hc;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(K=$c)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(K=Uc)}catch{}else if(t==="mintegral")window.gameReady&&(K=qc);else if(t==="tapjoy")window.TJ_API&&(K=Gc);else if(t==="tiktok")window.openAppStore&&(K=Wc);else if(t==="smadex")try{window.smxTracking&&(K=Yc)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(K=Vc)}catch{}else t==="vungle"?K=Kc:(e==="nucleo"||t==="nucleo")&&(K=Xc)}var hr=li(require("lottie-web"),1),ys=hr.default;typeof window!="undefined"&&(window.lottie=hr.default,window.__baseLottie=hr.default);var am=require("pixi.js");var vs=require("pixi.js");var sm=null;function xs(e){sm=e}gr();ws();var an=require("pixi.js");gr();var pm=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",As=pm;if(typeof window!="undefined")try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);t!=null&&t.buildMode&&(As=t.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${As}`))}}catch{}var gt=class{static async create(t,i,n){var l,c,d,u,p,f,m;console.log(`[ObjectFactory] create() called for: ${t}, __BUILD_MODE__: ${As}`);let r=(l=i==null?void 0:i.render)==null?void 0:l.asset;if(!r){console.log(`[ObjectFactory] No asset definition for: ${t}, returning empty container`);let h=new an.Container;return this.applyTransform(h,i==null?void 0:i.transform),h}let a=(c=i==null?void 0:i.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${t}, configId: ${a}, type: ${r.type}, path: ${r.path}`);let s=await zt.load(t,r,n,a);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${t}, rawAsset type: ${(d=s==null?void 0:s.constructor)==null?void 0:d.name}`);let o;if(r.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",t),o=new an.Sprite(s),console.log("[ObjectFactory] Created object:",o,"type:",(u=o==null?void 0:o.constructor)==null?void 0:u.name),this.applyTransform(o,i==null?void 0:i.transform);else if(r.type==="json")if(console.log("[ObjectFactory] JSON asset for",t,"rawAsset type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name,s),s&&(((f=s.constructor)==null?void 0:f.name)==="Container"||s instanceof an.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[r.path,`/assets/${r.path}`,`assets/${r.path}`,`../assets/${r.path}`],g=!1;for(let b of h)try{let y=await fetch(b);if(y.ok){o=await y.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=o==null?void 0:o.constructor)==null?void 0:m.name),g=!0;break}}catch{continue}g||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=s)}else o=s;else o=s,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,i==null?void 0:i.transform);return o}static applyTransform(t,i){var n,r,a,s;!i||!t||(i.position&&("x"in t&&"y"in t?(t.x=(n=i.position.x)!=null?n:0,t.y=(r=i.position.y)!=null?r:0):"position"in t&&t.position&&t.position.set((a=i.position.x)!=null?a:0,(s=i.position.y)!=null?s:0)),i.scale!==void 0&&"scale"in t&&t.scale&&(typeof t.scale=="object"&&"set"in t.scale?t.scale.set(i.scale):t.scale=i.scale),i.rotation!==void 0&&"rotation"in t&&(t.rotation=i.rotation),i.anchor&&"anchor"in t&&t.anchor&&Array.isArray(i.anchor)&&("set"in t.anchor?t.anchor.set(i.anchor[0],i.anchor[1]):(t.anchor.x=i.anchor[0],t.anchor.y=i.anchor[1])))}};var sn=class{constructor(){this.config=null}init(t){this.config=t}get(t){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(t)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(t){return this.config?this.config.objects.has(t):!1}};var gm=li(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=gm);pi();var mr=require("pixi.js");pi();var ks=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new sn}init(t,i){this.registry.init(t),this.app=i}updateConfig(t){this.registry.init(t),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let i=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));if(i.length===0)return;let n=async r=>{r.length&&(console.log("[Assets] Loading objects:",r),await Promise.all(r.map(async a=>{var o;let s=this.registry.get(a);if(!s){console.warn("[Assets] No config found for object:",a);return}try{let l=await gt.create(a,s,this.app);this.instanceCache.set(a,l),console.log("[Assets] Loaded object:",a,(o=l==null?void 0:l.constructor)==null?void 0:o.name)}catch(l){console.error("[Assets] Failed to load object:",a,l)}})))};return this.readyPromise=(async()=>{await n(i);let r=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));r.length>0&&(console.warn("[Assets] Retrying missing assets:",r),await n(r)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(t){let i=this.registry.get(t);if(i){let n=await gt.create(t,i,this.app);this.instanceCache.set(t,n)}}get(t){return this.instanceCache.get(t)}},mm=new ks,bm=new Proxy(mm,{get(e,t){if(t in e&&typeof e[t]=="function")return e[t].bind(e);if(e.get(t))return e.get(t)}});pi();var dd=require("pixi.js"),Xe={width:400,height:600,designWidth:400,scaleFactor:1},yr={scale:1,position:1},Os=[];function vm(e,t,i,n,r,a,s){Os.push({element:e,originalScale:a,positionHelper:t,heightPercent:r}),t(e,i,n,r,a,s,!1)}function xm(){Os.forEach(({element:e,originalScale:t,positionHelper:i,heightPercent:n})=>{let r=t*Xe.scaleFactor;i(e,Xe.width,Xe.height,n,r,!0,!1)})}function Ls(e,t){console.log(`[SCREEN] updateScreenState called: ${e}x${t}`),Xe.width=e,Xe.height=t,Xe.scaleFactor=Math.min(e/Xe.designWidth,1.15),yr.scale=Xe.scaleFactor,yr.position=1,console.log(`[SCREEN] Global multipliers - scale: ${yr.scale.toFixed(3)}`),xm()}var ln={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 wm(e,t,i){let n=ln[e];n&&n[t]!==void 0&&(n[t]=i,console.log(`Updated ${e}.${t} = ${i}`))}function _m(){return ln}var Em={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 br(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function vr(e,t={x:.5,y:.5}){var i;if(Array.isArray(e))return{x:br(e[0],t.x),y:br(e[1],t.y)};if(e&&typeof e=="object"){let n=e;return{x:br(n.x,t.x),y:br(n.y,t.y)}}if(typeof e=="string"){let n=e.trim().toLowerCase();return(i=Em[n])!=null?i:t}return t}function ud(e,t,i,n={}){var f,m,h,g,b,y;let r=vr(i),a=(f=n.inset)!=null?f:{},s=(m=n.padding)!=null?m:{x:0,y:0},o=((h=a.left)!=null?h:0)+s.x,l=((g=a.right)!=null?g:0)+s.x,c=((b=a.top)!=null?b:0)+s.y,d=((y=a.bottom)!=null?y:0)+s.y,u=Math.max(0,e-o-l),p=Math.max(0,t-c-d);return{x:o+u*r.x,y:c+p*r.y}}function pd(e,t,i,n={}){var h,g,b,y,v,x;let r=(h=n.inset)!=null?h:{},a=(g=n.padding)!=null?g:{x:0,y:0},s=((b=r.left)!=null?b:0)+a.x,o=((y=r.right)!=null?y:0)+a.x,l=((v=r.top)!=null?v:0)+a.y,c=((x=r.bottom)!=null?x:0)+a.y,d=Math.max(0,e-s-o),u=Math.max(0,t-l-c),p=vr(i,{x:.5,y:.5}),f=Math.min(Math.max(p.x,0),1),m=Math.min(Math.max(p.y,0),1);return{x:s+d*f,y:l+u*m}}if(typeof window!="undefined"){let e=window.innerWidth,t=window.innerHeight,i=()=>{let n=window.innerWidth,r=window.innerHeight;(n!==e||r!==t)&&(e=n,t=r,Ls(n,r))};window.addEventListener("resize",i),window.addEventListener("orientationchange",()=>{setTimeout(i,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",i),window.mraid.addEventListener("sizeChange",i)),Ls(window.innerWidth,window.innerHeight),window.updateDebugConfig=wm,window.getDebugConfig=_m,window.copyConfig=Pm,window.applyConfig=on,window.applyConfigForRatio=jm,window.positionAtBottom=fd,window.positionAtTop=Cm,window.positionAtCenter=Tm,window.positionAtLeft=km,window.positionAtRight=Lm,window.positionAtBottomLeft=Om,window.positionAtBottomRight=Im,window.positionAtTopLeft=Mm,window.positionAtTopRight=Rm,window.applyPositionContract=Am,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 xr(e,t,i=0){return e*t+i}function wr(e,t,i=0){return e*(1-t)+i}function _r(e,t,i=0){return e*t+i}function Er(e,t,i=0){return e*(1-t)+i}function ve(e,t=0){return e/2+t}function Sm(e,t){return e*t}function Am(e,t,i,n){var s,o,l,c,d,u,p,f,m,h,g,b,y,v,x,w,S,A,_,T;let r=0,a=0;switch(n.type){case"top":r=ve(t,(o=(s=n.offset)==null?void 0:s.x)!=null?o:0),a=xr(i,n.percent,(c=(l=n.offset)==null?void 0:l.y)!=null?c:0);break;case"bottom":r=ve(t,(u=(d=n.offset)==null?void 0:d.x)!=null?u:0),a=wr(i,n.percent,(f=(p=n.offset)==null?void 0:p.y)!=null?f:0);break;case"left":r=_r(t,n.percent,(h=(m=n.offset)==null?void 0:m.x)!=null?h:0),a=ve(i,(b=(g=n.offset)==null?void 0:g.y)!=null?b:0);break;case"right":r=Er(t,n.percent,(v=(y=n.offset)==null?void 0:y.x)!=null?v:0),a=ve(i,(w=(x=n.offset)==null?void 0:x.y)!=null?w:0);break;case"center":r=ve(t,(A=(S=n.offset)==null?void 0:S.x)!=null?A:0),a=ve(i,(T=(_=n.offset)==null?void 0:_.y)!=null?T:0);break}e.position?e.position.set(r,a):(e.x=r,e.y=a),n.scale!==void 0&&n.scale!==1&&e.scale&&(typeof e.scale.set=="function"?e.scale.set(n.scale,n.scale):(e.scale.x=n.scale,e.scale.y=n.scale))}function fd(e,t,i,n=.2,r=1,a=!0,s=!1){let o=Sm(i,n),l=wr(i,n/2);Ze(e,ve(t),l);let c=a?r*Xe.scaleFactor:r;Je(e,c),s&&!Os.find(d=>d.element===e)&&vm(e,fd,t,i,n,r,a)}function Cm(e,t,i,n=.1,r=1){Ze(e,ve(t),xr(i,n)),Je(e,r)}function Tm(e,t,i,n=0,r=0,a=1){Ze(e,ve(t,n),ve(i,r)),Je(e,a)}function km(e,t,i,n=.1,r=1){Ze(e,_r(t,n),ve(i)),Je(e,r)}function Lm(e,t,i,n=.1,r=1){Ze(e,Er(t,n),ve(i)),Je(e,r)}function Om(e,t,i,n=.05,r=.05,a=1){Ze(e,_r(t,r),wr(i,n)),Je(e,a)}function Im(e,t,i,n=.05,r=.05,a=1){Ze(e,Er(t,r),wr(i,n)),Je(e,a)}function Mm(e,t,i,n=.05,r=.05,a=1){Ze(e,_r(t,r),xr(i,n)),Je(e,a)}function Rm(e,t,i,n=.05,r=.05,a=1){Ze(e,Er(t,r),xr(i,n)),Je(e,a)}function Ze(e,t,i){e&&e.position?typeof e.position.set=="function"?e.position.set(t,i):(e.position.x=t,e.position.y=i):e&&(e.x=t,e.y=i)}function Je(e,t){t!==1&&e&&e.scale&&(typeof e.scale.set=="function"?e.scale.set(t,t):e.scale.x!==void 0&&e.scale.y!==void 0&&(e.scale.x=t,e.scale.y=t))}var Nt={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 Pm(e){return e&&Nt[e]?JSON.parse(JSON.stringify(Nt[e])):JSON.parse(JSON.stringify(ln))}function on(e){Object.keys(e).forEach(t=>{let i=t;ln[i]&&e[i]&&Object.assign(ln[i],e[i])}),console.log("Config applied:",e)}function jm(e,t){let i=e/t;i>1.6?(on(Nt.wide),console.log("Applied WIDE config for ratio:",i)):i<.7?(on(Nt.tall),console.log("Applied TALL config for ratio:",i)):i>.8&&i<1.2?(on(Nt.square),console.log("Applied SQUARE config for ratio:",i)):(on(Nt.default),console.log("Applied DEFAULT config for ratio:",i))}if(typeof window!="undefined"){let e=window;e.configPresets=Nt,e.resolveAnchorVec2=e.resolveAnchorVec2||vr,e.resolveScreenAnchorPoint=e.resolveScreenAnchorPoint||ud,e.resolveScreenRatioPoint=e.resolveScreenRatioPoint||pd}jr();function te(e,t){let i=(r,a)=>a===0?r:i(a,r%a),n=i(e,t);return`${e/n}:${t/n}`}var M_=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:te(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:te(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:te(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:te(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:te(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:te(360,780)}],R_=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:te(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:te(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:te(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:te(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:te(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:te(412,915)}],P_=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:te(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:te(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:te(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:te(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:te(800,1280)}],Us=[{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:te(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:te(768,1024),mraidScale:.7}];var qs=[...Us],Gs=[{category:"playable",label:"Playable Ad",devices:Us}],Dr=Us[0];function Ht(e){return qs.find(t=>t.id===e)||Dr}function Wm(e){return qs.filter(t=>t.category===e)}var zr=class{constructor(){this.root=null;this.listContainer=null;this.searchInput=null;this.selectedId=null;this.options=null;this.retryTimer=null;this.screenFilter="all"}getScreenFilterStorageKey(){return`handler_preview_screen_filter::${typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default"}`}render(){return`
47
+ `,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let c=o.target.dataset.tab;c&&this.switchTab(c)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let r=this.modal.querySelector("[data-ai-edit]");r==null||r.addEventListener("click",()=>{this.openAiEditor("edit")});let a=this.modal.querySelector("[data-modal-apply]");a==null||a.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",s=>{s.target===this.modal&&this.close()})}switchTab(t){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab")===t)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab-panel")===t)})}openAiEditor(t){let i=window.__openAiEditor;if(typeof i!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";t==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,i(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:r=>{this.onApplyCallback&&this.onApplyCallback(r),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 r0={};nn(r0,{ConfigWatcher:()=>Ft,DebugPanel:()=>tr,DefaultReloadStrategy:()=>hn,Handler:()=>Re,PreviewShell:()=>ts,applyConfigOverride:()=>mt,applyConfigOverrides:()=>bt,applyConfigsToDisk:()=>kr,applyDefaults:()=>Bt,baseLottie:()=>ys,bootstrap:()=>Yw,clearConfigOverrides:()=>un,clearConfigOverridesForObject:()=>wd,configOverrideManager:()=>_d,createPreviewShell:()=>pc,deepClone:()=>ne,default:()=>jt,defaultPreset:()=>Dr,deviceGroups:()=>Gs,devicePresets:()=>qs,diffConfigs:()=>Ns,exportConfigsAsJSON:()=>Ms,getConfigOverrides:()=>de,getConfigStateSummary:()=>Tr,getOverrideMode:()=>dn,getPresetById:()=>Ht,getPresetsByCategory:()=>Wm,loadAllObjectConfigs:()=>Mr,loadComponentSchemas:()=>Ir,loadEngineConfig:()=>Rr,loadGamePromptConfig:()=>js,loadObjectCentricConfig:()=>Qe,loadObjectConfig:()=>yt,loadSceneConfig:()=>Pr,rehydrateObject:()=>Bs,removeConfigOverride:()=>Cr,resetToApplied:()=>pn,resetToOriginal:()=>Lr,setBootstrapDependencies:()=>Gw,setOverrideMode:()=>Is,setupHotReload:()=>$s,setupLiveEditBridge:()=>is,toLegacyFormat:()=>Ds,validateObjectConfig:()=>fi});module.exports=Qg(r0);var ft={};function pr(e,t,i=!1){ft[e]||(ft[e]=[]),ft[e].push({fn:t,once:i})}function hs(e,t){if(ft[e]){if(!t){delete ft[e];return}ft[e]=ft[e].filter(i=>i.fn!==t)}}function fr(e,...t){let i=ft[e];if(i)for(let n of[...i])n.fn(...t),n.once&&hs(e,n.fn)}function be(e,t){pr(e,t,!0)}var ee=null,Ce=[],ci=null;function Ic(e){ee=e,Ce=[],ci!==null&&(clearTimeout(ci),ci=null)}function Mc(){var e,t,i;return{endpoint:(ee==null?void 0:ee.endpoint)||"",transport:(ee==null?void 0:ee.transport)||"beacon",batchSize:(e=ee==null?void 0:ee.batchSize)!=null?e:10,flushIntervalMs:(t=ee==null?void 0:ee.flushIntervalMs)!=null?t:300,maxQueue:(i=ee==null?void 0:ee.maxQueue)!=null?i:200,debug:!!(ee!=null&&ee.debug)}}async function Lc(e,t,i,n){let r=JSON.stringify(t);if(i==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(e,new Blob([r],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",a,t);return}catch(a){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",t)}catch(a){n&&console.warn("[handler.telemetry] fetch failed",a)}}function gs(e,t){let i=Mc();if(t&&i.endpoint){if(Ce.push(e),Ce.length>i.maxQueue&&(Ce=Ce.slice(Ce.length-i.maxQueue)),Ce.length>=i.batchSize){Oc();return}ci===null&&(ci=window.setTimeout(()=>{ci=null,Oc()},i.flushIntervalMs))}}async function Oc(){let e=Mc();if(!e.endpoint||Ce.length===0)return;let t=Ce.splice(0,e.batchSize);await Lc(e.endpoint,{events:t},e.transport,e.debug),Ce.length>0&&await Lc(e.endpoint,{events:Ce.splice(0,e.batchSize)},e.transport,e.debug)}function Rc(e){return Math.max(0,Math.min(1,e))}function em(e){let t=String(e!=null?e:"power2.out");if(t==="linear")return i=>i;if(t==="sine.inOut")return i=>.5-Math.cos(Math.PI*i)/2;if(t==="power2.out"||t==="easeOutQuad")return i=>1-(1-i)*(1-i);if(t.startsWith("back.out")){let i=t.match(/back\.out\(([\d.]+)\)/),n=i?Number(i[1]):1.8;return r=>1+(n+1)*Math.pow(r-1,3)+n*Math.pow(r-1,2)}return i=>1-(1-i)*(1-i)}function rn(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function tm(e,t){let i=e==null?void 0:e[t];return typeof i=="number"?i:0}function Pc(e,t,i){try{e[t]=i}catch{}}function im(e){let t=e==null?void 0:e.scale;if(!t)return null;let i=typeof t.x=="number"?t.x:1,n=typeof t.y=="number"?t.y:1;return{x:i,y:n}}function jc(e,t){let i=e==null?void 0:e.scale;if(i)try{typeof i.set=="function"?i.set(t.x,t.y):(typeof i.x=="number"&&(i.x=t.x),typeof i.y=="number"&&(i.y=t.y))}catch{}}function Dc(e,t){let i=im(e);if(!i)return{from:null,to:null};let n=null,r=null;return typeof t.scale=="number"?(n=t.scale,r=t.scale):t.scale&&typeof t.scale=="object"&&(typeof t.scale.x=="number"&&(n=t.scale.x),typeof t.scale.y=="number"&&(r=t.scale.y)),typeof t.scaleX=="number"&&(n=t.scaleX),typeof t.scaleY=="number"&&(r=t.scaleY),n===null&&r===null?{from:null,to:null}:{from:{x:i.x,y:i.y},to:{x:n!=null?n:i.x,y:r!=null?r:i.y}}}function zc(){let e=new Set,t=new WeakMap,i=null,n=()=>{if(i!=null)return;i=requestAnimationFrame(()=>{i=null,o(),e.size>0&&n()})},r=d=>{var p;e.add(d);let u=(p=t.get(d.target))!=null?p:new Set;u.add(d),t.set(d.target,u),n()},a=d=>{e.delete(d);let u=t.get(d.target);u&&(u.delete(d),u.size===0&&t.delete(d.target))},s=d=>{d.killed||(d.killed=!0,a(d))},o=()=>{var u,p;let d=rn();for(let f of Array.from(e)){if(f.killed||f.paused)continue;let m=d-f.startMs-f.delayMs;if(m<0)continue;let h=f.durationMs>0?m/f.durationMs:1,g=Rc(h),b=f.repeat>=0?f.repeat+1:1,y=f.repeat>0?Math.min(Math.floor(h),b-1):0;if(f.repeat>0&&h>=1){let w=h-y;g=Rc(w)}let v=f.ease(g);f.yoyo&&y%2===1&&(v=1-v);for(let w of f.props)Pc(f.target,w.key,w.from+(w.to-w.from)*v);f.scaleFrom&&f.scaleTo&&jc(f.target,{x:f.scaleFrom.x+(f.scaleTo.x-f.scaleFrom.x)*v,y:f.scaleFrom.y+(f.scaleTo.y-f.scaleFrom.y)*v});try{(u=f.onUpdate)==null||u.call(f)}catch{}if(h>=b){s(f);try{(p=f.onComplete)==null||p.call(f)}catch{}}}},l=(d,u,p)=>{var w;let f=Math.max(0,(typeof u.duration=="number"?u.duration:.5)*1e3),m=Math.max(0,(typeof u.delay=="number"?u.delay:0)*1e3+((w=p==null?void 0:p.delayMsOverride)!=null?w:0)),h=em(u.ease),g=typeof u.repeat=="number"?Math.max(0,u.repeat|0):0,b=u.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let S of Object.keys(u)){if(y.has(S))continue;let A=u[S];typeof A=="number"&&v.push({key:S,from:tm(d,S),to:A})}let x=Dc(d,u);return{target:d,startMs:rn(),delayMs:m,durationMs:f,ease:h,props:v,scaleFrom:x.from,scaleTo:x.to,repeat:g,yoyo:b,onUpdate:typeof u.onUpdate=="function"?u.onUpdate:void 0,onComplete:typeof u.onComplete=="function"?u.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(d,u){let p=l(d,u);return r(p),{kill:()=>s(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=rn())},resume:()=>{var h;if(!p.paused)return;let f=(h=p.pauseAtMs)!=null?h:rn(),m=rn()-f;p.startMs+=m,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(d,u,p){return c.set(d,u),c.to(d,p)},set(d,u){if(!d||!u)return;for(let f of Object.keys(u)){let m=u[f];f==="scale"||f==="scaleX"||f==="scaleY"||typeof m=="number"&&Pc(d,f,m)}let p=Dc(d,u);p.to&&jc(d,p.to)},killTweensOf(d){let u=t.get(d);if(u)for(let p of Array.from(u))s(p)},timeline(d={}){let u=[],p=0,f=!1,m=[],h=y=>{if(typeof y=="number")return Math.max(0,y*1e3);let v=typeof y=="string"?y.trim():"";return v.startsWith("+=")?p+Math.max(0,Number(v.slice(2))*1e3||0):v?Math.max(0,Number(v)*1e3||0):p},g=y=>{u.push(y);let v=Math.max(0,(typeof y.vars.duration=="number"?y.vars.duration:.5)*1e3);p=Math.max(p,y.atMs+v)},b={to(y,v,x){return g({kind:"to",target:y,vars:v,atMs:h(x)}),b},fromTo(y,v,x,w){return g({kind:"fromTo",target:y,vars:x,from:v,atMs:h(w)}),b},play(){var y,v;if(f)return b;f=!0,m=[];for(let x of u)x.kind==="fromTo"&&c.set(x.target,(y=x.from)!=null?y:{}),m.push(c.to(x.target,{...x.vars,delay:x.atMs/1e3+((v=x.vars.delay)!=null?v:0)}));return b},pause(){for(let y of m)y.pause();return b},kill(){for(let y of m)y.kill();m=[],f=!1}};return d.paused||b.play(),b}};return c}function Nc(){if(typeof window=="undefined")return;let e=window;if(!e.gsap)try{e.gsap=zc()}catch{}}var Bc={name:"handler-playable-sdk",version:"0.3.21",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"}},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","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 --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks",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",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","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",sharp:"^0.34.5"}};var ye=0,rm=ye++,Fc=ye++,Hc=ye++,$c=ye++,Uc=ye++,qc=ye++,Gc=ye++,Wc=ye++,Yc=ye++,Vc=ye++,Kc=ye++,Xc=ye++,K=rm;function Zc(){return K===Fc}function Jc(){return K===Hc}function Qc(){return K===$c}function ed(){return K===Uc}function di(){return K===qc}function ui(){return K===Gc}function td(){return K===Wc}function id(){return K===Yc}function nd(){return K===Vc}function ms(){return K===Kc}function bs(){return K===Xc}function rd(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),K=Fc;return}catch{}else if(e==="dapi")try{dapi.isReady(),K=Hc;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(K=$c)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(K=Uc)}catch{}else if(t==="mintegral")window.gameReady&&(K=qc);else if(t==="tapjoy")window.TJ_API&&(K=Gc);else if(t==="tiktok")window.openAppStore&&(K=Wc);else if(t==="smadex")try{window.smxTracking&&(K=Yc)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(K=Vc)}catch{}else t==="vungle"?K=Kc:(e==="nucleo"||t==="nucleo")&&(K=Xc)}var hr=li(require("lottie-web"),1),ys=hr.default;typeof window!="undefined"&&(window.lottie=hr.default,window.__baseLottie=hr.default);var am=require("pixi.js");var vs=require("pixi.js");var sm=null;function xs(e){sm=e}gr();ws();var an=require("pixi.js");gr();var pm=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",As=pm;if(typeof window!="undefined")try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);t!=null&&t.buildMode&&(As=t.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${As}`))}}catch{}var gt=class{static async create(t,i,n){var l,c,d,u,p,f,m;console.log(`[ObjectFactory] create() called for: ${t}, __BUILD_MODE__: ${As}`);let r=(l=i==null?void 0:i.render)==null?void 0:l.asset;if(!r){console.log(`[ObjectFactory] No asset definition for: ${t}, returning empty container`);let h=new an.Container;return this.applyTransform(h,i==null?void 0:i.transform),h}let a=(c=i==null?void 0:i.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${t}, configId: ${a}, type: ${r.type}, path: ${r.path}`);let s=await zt.load(t,r,n,a);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${t}, rawAsset type: ${(d=s==null?void 0:s.constructor)==null?void 0:d.name}`);let o;if(r.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",t),o=new an.Sprite(s),console.log("[ObjectFactory] Created object:",o,"type:",(u=o==null?void 0:o.constructor)==null?void 0:u.name),this.applyTransform(o,i==null?void 0:i.transform);else if(r.type==="json")if(console.log("[ObjectFactory] JSON asset for",t,"rawAsset type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name,s),s&&(((f=s.constructor)==null?void 0:f.name)==="Container"||s instanceof an.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[r.path,`/assets/${r.path}`,`assets/${r.path}`,`../assets/${r.path}`],g=!1;for(let b of h)try{let y=await fetch(b);if(y.ok){o=await y.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=o==null?void 0:o.constructor)==null?void 0:m.name),g=!0;break}}catch{continue}g||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=s)}else o=s;else o=s,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,i==null?void 0:i.transform);return o}static applyTransform(t,i){var n,r,a,s;!i||!t||(i.position&&("x"in t&&"y"in t?(t.x=(n=i.position.x)!=null?n:0,t.y=(r=i.position.y)!=null?r:0):"position"in t&&t.position&&t.position.set((a=i.position.x)!=null?a:0,(s=i.position.y)!=null?s:0)),i.scale!==void 0&&"scale"in t&&t.scale&&(typeof t.scale=="object"&&"set"in t.scale?t.scale.set(i.scale):t.scale=i.scale),i.rotation!==void 0&&"rotation"in t&&(t.rotation=i.rotation),i.anchor&&"anchor"in t&&t.anchor&&Array.isArray(i.anchor)&&("set"in t.anchor?t.anchor.set(i.anchor[0],i.anchor[1]):(t.anchor.x=i.anchor[0],t.anchor.y=i.anchor[1])))}};var sn=class{constructor(){this.config=null}init(t){this.config=t}get(t){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(t)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(t){return this.config?this.config.objects.has(t):!1}};var gm=li(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=gm);pi();var mr=require("pixi.js");pi();var ks=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new sn}init(t,i){this.registry.init(t),this.app=i}updateConfig(t){this.registry.init(t),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let i=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));if(i.length===0)return;let n=async r=>{r.length&&(console.log("[Assets] Loading objects:",r),await Promise.all(r.map(async a=>{var o;let s=this.registry.get(a);if(!s){console.warn("[Assets] No config found for object:",a);return}try{let l=await gt.create(a,s,this.app);this.instanceCache.set(a,l),console.log("[Assets] Loaded object:",a,(o=l==null?void 0:l.constructor)==null?void 0:o.name)}catch(l){console.error("[Assets] Failed to load object:",a,l)}})))};return this.readyPromise=(async()=>{await n(i);let r=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));r.length>0&&(console.warn("[Assets] Retrying missing assets:",r),await n(r)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(t){let i=this.registry.get(t);if(i){let n=await gt.create(t,i,this.app);this.instanceCache.set(t,n)}}get(t){return this.instanceCache.get(t)}},mm=new ks,bm=new Proxy(mm,{get(e,t){if(t in e&&typeof e[t]=="function")return e[t].bind(e);if(e.get(t))return e.get(t)}});pi();var dd=require("pixi.js"),Xe={width:400,height:600,designWidth:400,scaleFactor:1},yr={scale:1,position:1},Os=[];function vm(e,t,i,n,r,a,s){Os.push({element:e,originalScale:a,positionHelper:t,heightPercent:r}),t(e,i,n,r,a,s,!1)}function xm(){Os.forEach(({element:e,originalScale:t,positionHelper:i,heightPercent:n})=>{let r=t*Xe.scaleFactor;i(e,Xe.width,Xe.height,n,r,!0,!1)})}function Ls(e,t){console.log(`[SCREEN] updateScreenState called: ${e}x${t}`),Xe.width=e,Xe.height=t,Xe.scaleFactor=Math.min(e/Xe.designWidth,1.15),yr.scale=Xe.scaleFactor,yr.position=1,console.log(`[SCREEN] Global multipliers - scale: ${yr.scale.toFixed(3)}`),xm()}var ln={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 wm(e,t,i){let n=ln[e];n&&n[t]!==void 0&&(n[t]=i,console.log(`Updated ${e}.${t} = ${i}`))}function _m(){return ln}var Em={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 br(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function vr(e,t={x:.5,y:.5}){var i;if(Array.isArray(e))return{x:br(e[0],t.x),y:br(e[1],t.y)};if(e&&typeof e=="object"){let n=e;return{x:br(n.x,t.x),y:br(n.y,t.y)}}if(typeof e=="string"){let n=e.trim().toLowerCase();return(i=Em[n])!=null?i:t}return t}function ud(e,t,i,n={}){var f,m,h,g,b,y;let r=vr(i),a=(f=n.inset)!=null?f:{},s=(m=n.padding)!=null?m:{x:0,y:0},o=((h=a.left)!=null?h:0)+s.x,l=((g=a.right)!=null?g:0)+s.x,c=((b=a.top)!=null?b:0)+s.y,d=((y=a.bottom)!=null?y:0)+s.y,u=Math.max(0,e-o-l),p=Math.max(0,t-c-d);return{x:o+u*r.x,y:c+p*r.y}}function pd(e,t,i,n={}){var h,g,b,y,v,x;let r=(h=n.inset)!=null?h:{},a=(g=n.padding)!=null?g:{x:0,y:0},s=((b=r.left)!=null?b:0)+a.x,o=((y=r.right)!=null?y:0)+a.x,l=((v=r.top)!=null?v:0)+a.y,c=((x=r.bottom)!=null?x:0)+a.y,d=Math.max(0,e-s-o),u=Math.max(0,t-l-c),p=vr(i,{x:.5,y:.5}),f=Math.min(Math.max(p.x,0),1),m=Math.min(Math.max(p.y,0),1);return{x:s+d*f,y:l+u*m}}if(typeof window!="undefined"){let e=window.innerWidth,t=window.innerHeight,i=()=>{let n=window.innerWidth,r=window.innerHeight;(n!==e||r!==t)&&(e=n,t=r,Ls(n,r))};window.addEventListener("resize",i),window.addEventListener("orientationchange",()=>{setTimeout(i,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",i),window.mraid.addEventListener("sizeChange",i)),Ls(window.innerWidth,window.innerHeight),window.updateDebugConfig=wm,window.getDebugConfig=_m,window.copyConfig=Pm,window.applyConfig=on,window.applyConfigForRatio=jm,window.positionAtBottom=fd,window.positionAtTop=Cm,window.positionAtCenter=Tm,window.positionAtLeft=km,window.positionAtRight=Lm,window.positionAtBottomLeft=Om,window.positionAtBottomRight=Im,window.positionAtTopLeft=Mm,window.positionAtTopRight=Rm,window.applyPositionContract=Am,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 xr(e,t,i=0){return e*t+i}function wr(e,t,i=0){return e*(1-t)+i}function _r(e,t,i=0){return e*t+i}function Er(e,t,i=0){return e*(1-t)+i}function ve(e,t=0){return e/2+t}function Sm(e,t){return e*t}function Am(e,t,i,n){var s,o,l,c,d,u,p,f,m,h,g,b,y,v,x,w,S,A,_,T;let r=0,a=0;switch(n.type){case"top":r=ve(t,(o=(s=n.offset)==null?void 0:s.x)!=null?o:0),a=xr(i,n.percent,(c=(l=n.offset)==null?void 0:l.y)!=null?c:0);break;case"bottom":r=ve(t,(u=(d=n.offset)==null?void 0:d.x)!=null?u:0),a=wr(i,n.percent,(f=(p=n.offset)==null?void 0:p.y)!=null?f:0);break;case"left":r=_r(t,n.percent,(h=(m=n.offset)==null?void 0:m.x)!=null?h:0),a=ve(i,(b=(g=n.offset)==null?void 0:g.y)!=null?b:0);break;case"right":r=Er(t,n.percent,(v=(y=n.offset)==null?void 0:y.x)!=null?v:0),a=ve(i,(w=(x=n.offset)==null?void 0:x.y)!=null?w:0);break;case"center":r=ve(t,(A=(S=n.offset)==null?void 0:S.x)!=null?A:0),a=ve(i,(T=(_=n.offset)==null?void 0:_.y)!=null?T:0);break}e.position?e.position.set(r,a):(e.x=r,e.y=a),n.scale!==void 0&&n.scale!==1&&e.scale&&(typeof e.scale.set=="function"?e.scale.set(n.scale,n.scale):(e.scale.x=n.scale,e.scale.y=n.scale))}function fd(e,t,i,n=.2,r=1,a=!0,s=!1){let o=Sm(i,n),l=wr(i,n/2);Ze(e,ve(t),l);let c=a?r*Xe.scaleFactor:r;Je(e,c),s&&!Os.find(d=>d.element===e)&&vm(e,fd,t,i,n,r,a)}function Cm(e,t,i,n=.1,r=1){Ze(e,ve(t),xr(i,n)),Je(e,r)}function Tm(e,t,i,n=0,r=0,a=1){Ze(e,ve(t,n),ve(i,r)),Je(e,a)}function km(e,t,i,n=.1,r=1){Ze(e,_r(t,n),ve(i)),Je(e,r)}function Lm(e,t,i,n=.1,r=1){Ze(e,Er(t,n),ve(i)),Je(e,r)}function Om(e,t,i,n=.05,r=.05,a=1){Ze(e,_r(t,r),wr(i,n)),Je(e,a)}function Im(e,t,i,n=.05,r=.05,a=1){Ze(e,Er(t,r),wr(i,n)),Je(e,a)}function Mm(e,t,i,n=.05,r=.05,a=1){Ze(e,_r(t,r),xr(i,n)),Je(e,a)}function Rm(e,t,i,n=.05,r=.05,a=1){Ze(e,Er(t,r),xr(i,n)),Je(e,a)}function Ze(e,t,i){e&&e.position?typeof e.position.set=="function"?e.position.set(t,i):(e.position.x=t,e.position.y=i):e&&(e.x=t,e.y=i)}function Je(e,t){t!==1&&e&&e.scale&&(typeof e.scale.set=="function"?e.scale.set(t,t):e.scale.x!==void 0&&e.scale.y!==void 0&&(e.scale.x=t,e.scale.y=t))}var Nt={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 Pm(e){return e&&Nt[e]?JSON.parse(JSON.stringify(Nt[e])):JSON.parse(JSON.stringify(ln))}function on(e){Object.keys(e).forEach(t=>{let i=t;ln[i]&&e[i]&&Object.assign(ln[i],e[i])}),console.log("Config applied:",e)}function jm(e,t){let i=e/t;i>1.6?(on(Nt.wide),console.log("Applied WIDE config for ratio:",i)):i<.7?(on(Nt.tall),console.log("Applied TALL config for ratio:",i)):i>.8&&i<1.2?(on(Nt.square),console.log("Applied SQUARE config for ratio:",i)):(on(Nt.default),console.log("Applied DEFAULT config for ratio:",i))}if(typeof window!="undefined"){let e=window;e.configPresets=Nt,e.resolveAnchorVec2=e.resolveAnchorVec2||vr,e.resolveScreenAnchorPoint=e.resolveScreenAnchorPoint||ud,e.resolveScreenRatioPoint=e.resolveScreenRatioPoint||pd}jr();function te(e,t){let i=(r,a)=>a===0?r:i(a,r%a),n=i(e,t);return`${e/n}:${t/n}`}var M_=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:te(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:te(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:te(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:te(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:te(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:te(360,780)}],R_=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:te(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:te(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:te(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:te(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:te(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:te(412,915)}],P_=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:te(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:te(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:te(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:te(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:te(800,1280)}],Us=[{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:te(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:te(768,1024),mraidScale:.7}];var qs=[...Us],Gs=[{category:"playable",label:"Playable Ad",devices:Us}],Dr=Us[0];function Ht(e){return qs.find(t=>t.id===e)||Dr}function Wm(e){return qs.filter(t=>t.category===e)}var zr=class{constructor(){this.root=null;this.listContainer=null;this.searchInput=null;this.selectedId=null;this.options=null;this.retryTimer=null;this.screenFilter="all"}getScreenFilterStorageKey(){return`handler_preview_screen_filter::${typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default"}`}render(){return`
48
48
  <div class="scene-panel scene-objects panel-accent-teal" data-panel="scene-objects" style="left:16px; top:72px;">
49
49
  <div class="scene-panel-header" data-panel-handle>
50
50
  <div class="panel-title">
@@ -511,7 +511,7 @@
511
511
  ${a.join("")}
512
512
  </div>
513
513
  </div>
514
- `}attachEventListeners(){var c,d,u,p;if(!this.contentContainer)return;let t=this.contentContainer.querySelectorAll("[data-property-path]"),i=Ym((f,m,h)=>{var g,b;this.updateManager.updateProperty(f,m,h),(b=(g=this.options)==null?void 0:g.onPropertyChange)==null||b.call(g,f,m,h)},300);t.forEach(f=>{let m=h=>{var v,x;let g=h.target,b=g.dataset.propertyPath,y=g.dataset.objectId;if(b&&y){let w=g.value;if(g.type==="checkbox")w=g.checked;else if(g.type==="number"&&(w=parseFloat(g.value),isNaN(w)))return;g.type==="text"||g.type==="range"||g.tagName==="TEXTAREA"?i(y,b,w):(this.updateManager.updateProperty(y,b,w),(x=(v=this.options)==null?void 0:v.onPropertyChange)==null||x.call(v,y,b,w))}};f.dataset.logicIdSelector==="true"?f.addEventListener("change",async h=>{let g=h.target,b=g.dataset.propertyPath,y=g.dataset.objectId;b&&y&&(await this.updateManager.updateProperty(y,b,g.value),setTimeout(()=>{this.selectedObjectId&&this.loadObject(this.selectedObjectId)},300))}):(f.addEventListener("change",m),(f.tagName==="INPUT"||f.tagName==="TEXTAREA")&&f.addEventListener("input",m))}),this.contentContainer.querySelectorAll("[data-action]").forEach(f=>{f.addEventListener("click",m=>{let h=m.target,g=h.dataset.action,b=h.dataset.path,y=h.dataset.object;g&&b&&y&&this.quickActions.handleAction(g,y,b)})}),this.contentContainer.querySelectorAll("[data-section-toggle]").forEach(f=>{f.addEventListener("click",m=>{var b,y;let h=m.target,g=h.dataset.sectionToggle||((b=h.closest("[data-section-toggle]"))==null?void 0:b.getAttribute("data-section-toggle"));if(g){let v=(y=this.contentContainer)==null?void 0:y.querySelector(`[data-section="${g}"]`);v==null||v.classList.toggle("collapsed")}})});let a=(c=this.root)==null?void 0:c.querySelector("[data-inspector-advanced]");a==null||a.addEventListener("click",()=>{this.showAdvanced=!this.showAdvanced,this.selectedObjectId&&this.loadObject(this.selectedObjectId)});let s=(d=this.root)==null?void 0:d.querySelector("[data-convert-toggle]");s==null||s.addEventListener("click",()=>{var m;let f=(m=this.root)==null?void 0:m.querySelector("[data-convert-menu]");f==null||f.classList.toggle("hidden")});let o=(u=this.contentContainer)==null?void 0:u.querySelector("[data-inspector-add-component-btn]"),l=(p=this.contentContainer)==null?void 0:p.querySelector("[data-inspector-component-select]");o==null||o.addEventListener("click",async()=>{let f=l.value;f&&this.selectedObjectId&&await this.addComponent(this.selectedObjectId,f)})}async addComponent(t,i){console.log("[InspectorPanel] Adding component:",i,"to:",t);let n=window.getEditableObjectConfig,r=n==null?void 0:n(t);if(!r){console.error("[InspectorPanel] Failed to get config for:",t);return}let a=window.__editableConfig,s=a==null?void 0:a.schemas,o=null;s instanceof Map?o=s.get(i):s&&typeof s=="object"&&(o=s[i]),o||console.warn("[InspectorPanel] Schema not found for component:",i);let l=(o==null?void 0:o.defaults)||{enabled:!0};r[i]={...l},await this.updateManager.updateProperty(t,i,r[i]),this.loadObject(t),console.log("[InspectorPanel] Component added successfully")}isSectionMeaningful(t,i,n){var a,s;if(["identity","transform","render"].includes(t))return!0;if(!i||typeof i!="object"||t==="ui"&&((s=(a=n.render)==null?void 0:a.asset)==null?void 0:s.type)==="image")return!1;if(t==="interaction")return i.clickable===!0||i.draggable===!0;if(i.enabled===!0||i.active===!0||i.visible===!0)return!0;if(t==="ui")return!!(i.text||i.font||i.fontSize);let r=Object.keys(i);return r.length===0||r.length===1&&r[0]==="enabled"&&i.enabled===!1?!1:["audio","effects","physics","motion","gameplay"].includes(t)?i.enabled===!0:!0}showError(t){this.contentContainer&&(this.contentContainer.innerHTML=`
514
+ `}attachEventListeners(){var c,d,u,p;if(!this.contentContainer)return;let t=this.contentContainer.querySelectorAll("[data-property-path]"),i=Ym((f,m,h)=>{var g,b;this.updateManager.updateProperty(f,m,h),(b=(g=this.options)==null?void 0:g.onPropertyChange)==null||b.call(g,f,m,h)},300);t.forEach(f=>{let m=h=>{var v,x;let g=h.target,b=g.dataset.propertyPath,y=g.dataset.objectId;if(b&&y){let w=g.value;if(g.type==="checkbox")w=g.checked;else if(g.type==="number"&&(w=parseFloat(g.value),isNaN(w)))return;g.type==="text"||g.type==="range"||g.tagName==="TEXTAREA"?i(y,b,w):(this.updateManager.updateProperty(y,b,w),(x=(v=this.options)==null?void 0:v.onPropertyChange)==null||x.call(v,y,b,w))}};console.log("[Inspector] Checking input:",f.tagName,"path:",f.dataset.propertyPath,"logicIdSelector:",f.dataset.logicIdSelector),f.dataset.logicIdSelector==="true"?(console.log("[Inspector] Found logic ID selector, attaching refresh handler"),f.addEventListener("change",async h=>{let g=h.target,b=g.dataset.propertyPath,y=g.dataset.objectId;console.log("[Inspector] Logic ID changed to:",g.value,"path:",b),b&&y&&(await this.updateManager.updateProperty(y,b,g.value),console.log("[Inspector] Property updated, refreshing in 500ms..."),setTimeout(()=>{console.log("[Inspector] Refreshing inspector now"),this.selectedObjectId&&this.loadObject(this.selectedObjectId)},500))})):(f.addEventListener("change",m),(f.tagName==="INPUT"||f.tagName==="TEXTAREA")&&f.addEventListener("input",m))}),this.contentContainer.querySelectorAll("[data-action]").forEach(f=>{f.addEventListener("click",m=>{let h=m.target,g=h.dataset.action,b=h.dataset.path,y=h.dataset.object;g&&b&&y&&this.quickActions.handleAction(g,y,b)})}),this.contentContainer.querySelectorAll("[data-section-toggle]").forEach(f=>{f.addEventListener("click",m=>{var b,y;let h=m.target,g=h.dataset.sectionToggle||((b=h.closest("[data-section-toggle]"))==null?void 0:b.getAttribute("data-section-toggle"));if(g){let v=(y=this.contentContainer)==null?void 0:y.querySelector(`[data-section="${g}"]`);v==null||v.classList.toggle("collapsed")}})});let a=(c=this.root)==null?void 0:c.querySelector("[data-inspector-advanced]");a==null||a.addEventListener("click",()=>{this.showAdvanced=!this.showAdvanced,this.selectedObjectId&&this.loadObject(this.selectedObjectId)});let s=(d=this.root)==null?void 0:d.querySelector("[data-convert-toggle]");s==null||s.addEventListener("click",()=>{var m;let f=(m=this.root)==null?void 0:m.querySelector("[data-convert-menu]");f==null||f.classList.toggle("hidden")});let o=(u=this.contentContainer)==null?void 0:u.querySelector("[data-inspector-add-component-btn]"),l=(p=this.contentContainer)==null?void 0:p.querySelector("[data-inspector-component-select]");o==null||o.addEventListener("click",async()=>{let f=l.value;f&&this.selectedObjectId&&await this.addComponent(this.selectedObjectId,f)})}async addComponent(t,i){console.log("[InspectorPanel] Adding component:",i,"to:",t);let n=window.getEditableObjectConfig,r=n==null?void 0:n(t);if(!r){console.error("[InspectorPanel] Failed to get config for:",t);return}let a=window.__editableConfig,s=a==null?void 0:a.schemas,o=null;s instanceof Map?o=s.get(i):s&&typeof s=="object"&&(o=s[i]),o||console.warn("[InspectorPanel] Schema not found for component:",i);let l=(o==null?void 0:o.defaults)||{enabled:!0};r[i]={...l},await this.updateManager.updateProperty(t,i,r[i]),this.loadObject(t),console.log("[InspectorPanel] Component added successfully")}isSectionMeaningful(t,i,n){var a,s;if(["identity","transform","render"].includes(t))return!0;if(!i||typeof i!="object"||t==="ui"&&((s=(a=n.render)==null?void 0:a.asset)==null?void 0:s.type)==="image")return!1;if(t==="interaction")return i.clickable===!0||i.draggable===!0;if(i.enabled===!0||i.active===!0||i.visible===!0)return!0;if(t==="ui")return!!(i.text||i.font||i.fontSize);let r=Object.keys(i);return r.length===0||r.length===1&&r[0]==="enabled"&&i.enabled===!1?!1:["audio","effects","physics","motion","gameplay"].includes(t)?i.enabled===!0:!0}showError(t){this.contentContainer&&(this.contentContainer.innerHTML=`
515
515
  <div class="inspector-empty">
516
516
  <span class="inspector-empty-icon">\u26A0\uFE0F</span>
517
517
  <span class="inspector-empty-text">${t}</span>
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{E as F,F as G,G as H,H as I,I as J,J as K,K as L,L as M,M as N,N as O,O as P,P as Q,Q as R,a}from"./chunk-MSFWHTLG.js";import"./chunk-I5OOVR5U.js";import{a as q,b as r,c as s,d as t,e as u,f as v,g as w,h as x,i as y,j as z,k as A,l as B,m as C,n as D,o as E}from"./chunk-LV4HGC5G.js";import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p}from"./chunk-ZLL42OOV.js";import"./chunk-E6WJCS24.js";import"./chunk-Q7FPWOA3.js";export{B as ConfigWatcher,K as DebugPanel,A as DefaultReloadStrategy,Q as Handler,L as PreviewShell,d as applyConfigOverride,e as applyConfigOverrides,n as applyConfigsToDisk,x as applyDefaults,a as baseLottie,P as bootstrap,f as clearConfigOverrides,g as clearConfigOverridesForObject,j as configOverrideManager,M as createPreviewShell,k as deepClone,R as default,H as defaultPreset,G as deviceGroups,F as devicePresets,C as diffConfigs,l as exportConfigsAsJSON,i as getConfigOverrides,m as getConfigStateSummary,b as getOverrideMode,I as getPresetById,J as getPresetsByCategory,s as loadAllObjectConfigs,q as loadComponentSchemas,t as loadEngineConfig,u as loadGamePromptConfig,y as loadObjectCentricConfig,r as loadObjectConfig,v as loadSceneConfig,D as rehydrateObject,h as removeConfigOverride,o as resetToApplied,p as resetToOriginal,O as setBootstrapDependencies,c as setOverrideMode,E as setupHotReload,N as setupLiveEditBridge,z as toLegacyFormat,w as validateObjectConfig};
1
+ import{E as F,F as G,G as H,H as I,I as J,J as K,K as L,L as M,M as N,N as O,O as P,P as Q,Q as R,a}from"./chunk-5UGLDQKG.js";import"./chunk-I5OOVR5U.js";import{a as q,b as r,c as s,d as t,e as u,f as v,g as w,h as x,i as y,j as z,k as A,l as B,m as C,n as D,o as E}from"./chunk-LV4HGC5G.js";import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p}from"./chunk-ZLL42OOV.js";import"./chunk-E6WJCS24.js";import"./chunk-Q7FPWOA3.js";export{B as ConfigWatcher,K as DebugPanel,A as DefaultReloadStrategy,Q as Handler,L as PreviewShell,d as applyConfigOverride,e as applyConfigOverrides,n as applyConfigsToDisk,x as applyDefaults,a as baseLottie,P as bootstrap,f as clearConfigOverrides,g as clearConfigOverridesForObject,j as configOverrideManager,M as createPreviewShell,k as deepClone,R as default,H as defaultPreset,G as deviceGroups,F as devicePresets,C as diffConfigs,l as exportConfigsAsJSON,i as getConfigOverrides,m as getConfigStateSummary,b as getOverrideMode,I as getPresetById,J as getPresetsByCategory,s as loadAllObjectConfigs,q as loadComponentSchemas,t as loadEngineConfig,u as loadGamePromptConfig,y as loadObjectCentricConfig,r as loadObjectConfig,v as loadSceneConfig,D as rehydrateObject,h as removeConfigOverride,o as resetToApplied,p as resetToOriginal,O as setBootstrapDependencies,c as setOverrideMode,E as setupHotReload,N as setupLiveEditBridge,z as toLegacyFormat,w as validateObjectConfig};
@@ -44,7 +44,7 @@
44
44
  <button class="debug-btn primary" data-modal-apply>Apply</button>
45
45
  </div>
46
46
  </div>
47
- `,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let l=o.target.dataset.tab;l&&this.switchTab(l)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let r=this.modal.querySelector("[data-ai-edit]");r==null||r.addEventListener("click",()=>{this.openAiEditor("edit")});let a=this.modal.querySelector("[data-modal-apply]");a==null||a.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",s=>{s.target===this.modal&&this.close()})}switchTab(t){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab")===t)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab-panel")===t)})}openAiEditor(t){let i=window.__openAiEditor;if(typeof i!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";t==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,i(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:r=>{this.onApplyCallback&&this.onApplyCallback(r),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 Fv={};rl(Fv,{AssetCache:()=>Be,AssetLoader:()=>xt,AssetSystem:()=>Qr,AssetTextures:()=>wt,Assets:()=>jf,BaseSystem:()=>Oi,GameEngine:()=>Jr,GameObject:()=>Dn,GameObjectManager:()=>ki,ObjectFactory:()=>_t,Renderer:()=>jn,RuntimeObjectRegistry:()=>Ii,Transform:()=>Pn,applyScreenAnchor:()=>ia,basePixi:()=>If,clearResponsiveElements:()=>zf,createPixiBase:()=>Xr,getRegisteredFontIds:()=>Tf,globalResponsiveMultipliers:()=>Nn,initAssetTextures:()=>Ur,initAssets:()=>Df,layout:()=>Bf,playLottieOverlay:()=>Lf,registerFont:()=>Cf,registerType:()=>Hr,resolveAnchorVec2:()=>Bn,resolveFont:()=>Sf,resolveFontWeight:()=>Af,resolveScreenAnchorPoint:()=>Mi,resolveScreenRatioPoint:()=>Ri,runInitSequence:()=>Ff,setLottieInstance:()=>qr,spawnSceneFromConfig:()=>Rf,updateScreenState:()=>ta});module.exports=Wf(Fv);var Ef=require("pixi.js");var st={};function Gn(e,t,i=!1){st[e]||(st[e]=[]),st[e].push({fn:t,once:i})}function ca(e,t){if(st[e]){if(!t){delete st[e];return}st[e]=st[e].filter(i=>i.fn!==t)}}function Wn(e,...t){let i=st[e];if(i)for(let n of[...i])n.fn(...t),n.once&&ca(e,n.fn)}function ge(e,t){Gn(e,t,!0)}var X=null,Ee=[],qt=null;function ll(e){X=e,Ee=[],qt!==null&&(clearTimeout(qt),qt=null)}function cl(){var e,t,i;return{endpoint:(X==null?void 0:X.endpoint)||"",transport:(X==null?void 0:X.transport)||"beacon",batchSize:(e=X==null?void 0:X.batchSize)!=null?e:10,flushIntervalMs:(t=X==null?void 0:X.flushIntervalMs)!=null?t:300,maxQueue:(i=X==null?void 0:X.maxQueue)!=null?i:200,debug:!!(X!=null&&X.debug)}}async function sl(e,t,i,n){let r=JSON.stringify(t);if(i==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(e,new Blob([r],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",a,t);return}catch(a){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",t)}catch(a){n&&console.warn("[handler.telemetry] fetch failed",a)}}function da(e,t){let i=cl();if(t&&i.endpoint){if(Ee.push(e),Ee.length>i.maxQueue&&(Ee=Ee.slice(Ee.length-i.maxQueue)),Ee.length>=i.batchSize){ol();return}qt===null&&(qt=window.setTimeout(()=>{qt=null,ol()},i.flushIntervalMs))}}async function ol(){let e=cl();if(!e.endpoint||Ee.length===0)return;let t=Ee.splice(0,e.batchSize);await sl(e.endpoint,{events:t},e.transport,e.debug),Ee.length>0&&await sl(e.endpoint,{events:Ee.splice(0,e.batchSize)},e.transport,e.debug)}function dl(e){return Math.max(0,Math.min(1,e))}function Yf(e){let t=String(e!=null?e:"power2.out");if(t==="linear")return i=>i;if(t==="sine.inOut")return i=>.5-Math.cos(Math.PI*i)/2;if(t==="power2.out"||t==="easeOutQuad")return i=>1-(1-i)*(1-i);if(t.startsWith("back.out")){let i=t.match(/back\.out\(([\d.]+)\)/),n=i?Number(i[1]):1.8;return r=>1+(n+1)*Math.pow(r-1,3)+n*Math.pow(r-1,2)}return i=>1-(1-i)*(1-i)}function $i(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Vf(e,t){let i=e==null?void 0:e[t];return typeof i=="number"?i:0}function ul(e,t,i){try{e[t]=i}catch{}}function Kf(e){let t=e==null?void 0:e.scale;if(!t)return null;let i=typeof t.x=="number"?t.x:1,n=typeof t.y=="number"?t.y:1;return{x:i,y:n}}function pl(e,t){let i=e==null?void 0:e.scale;if(i)try{typeof i.set=="function"?i.set(t.x,t.y):(typeof i.x=="number"&&(i.x=t.x),typeof i.y=="number"&&(i.y=t.y))}catch{}}function fl(e,t){let i=Kf(e);if(!i)return{from:null,to:null};let n=null,r=null;return typeof t.scale=="number"?(n=t.scale,r=t.scale):t.scale&&typeof t.scale=="object"&&(typeof t.scale.x=="number"&&(n=t.scale.x),typeof t.scale.y=="number"&&(r=t.scale.y)),typeof t.scaleX=="number"&&(n=t.scaleX),typeof t.scaleY=="number"&&(r=t.scaleY),n===null&&r===null?{from:null,to:null}:{from:{x:i.x,y:i.y},to:{x:n!=null?n:i.x,y:r!=null?r:i.y}}}function hl(){let e=new Set,t=new WeakMap,i=null,n=()=>{if(i!=null)return;i=requestAnimationFrame(()=>{i=null,o(),e.size>0&&n()})},r=c=>{var u;e.add(c);let f=(u=t.get(c.target))!=null?u:new Set;f.add(c),t.set(c.target,f),n()},a=c=>{e.delete(c);let f=t.get(c.target);f&&(f.delete(c),f.size===0&&t.delete(c.target))},s=c=>{c.killed||(c.killed=!0,a(c))},o=()=>{var f,u;let c=$i();for(let p of Array.from(e)){if(p.killed||p.paused)continue;let v=c-p.startMs-p.delayMs;if(v<0)continue;let m=p.durationMs>0?v/p.durationMs:1,w=dl(m),g=p.repeat>=0?p.repeat+1:1,h=p.repeat>0?Math.min(Math.floor(m),g-1):0;if(p.repeat>0&&m>=1){let b=m-h;w=dl(b)}let x=p.ease(w);p.yoyo&&h%2===1&&(x=1-x);for(let b of p.props)ul(p.target,b.key,b.from+(b.to-b.from)*x);p.scaleFrom&&p.scaleTo&&pl(p.target,{x:p.scaleFrom.x+(p.scaleTo.x-p.scaleFrom.x)*x,y:p.scaleFrom.y+(p.scaleTo.y-p.scaleFrom.y)*x});try{(f=p.onUpdate)==null||f.call(p)}catch{}if(m>=g){s(p);try{(u=p.onComplete)==null||u.call(p)}catch{}}}},d=(c,f,u)=>{var b;let p=Math.max(0,(typeof f.duration=="number"?f.duration:.5)*1e3),v=Math.max(0,(typeof f.delay=="number"?f.delay:0)*1e3+((b=u==null?void 0:u.delayMsOverride)!=null?b:0)),m=Yf(f.ease),w=typeof f.repeat=="number"?Math.max(0,f.repeat|0):0,g=f.yoyo===!0,h=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),x=[];for(let C of Object.keys(f)){if(h.has(C))continue;let S=f[C];typeof S=="number"&&x.push({key:C,from:Vf(c,C),to:S})}let y=fl(c,f);return{target:c,startMs:$i(),delayMs:v,durationMs:p,ease:m,props:x,scaleFrom:y.from,scaleTo:y.to,repeat:w,yoyo:g,onUpdate:typeof f.onUpdate=="function"?f.onUpdate:void 0,onComplete:typeof f.onComplete=="function"?f.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},l={to(c,f){let u=d(c,f);return r(u),{kill:()=>s(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=$i())},resume:()=>{var m;if(!u.paused)return;let p=(m=u.pauseAtMs)!=null?m:$i(),v=$i()-p;u.startMs+=v,u.paused=!1,u.pauseAtMs=null},isActive:()=>!u.killed&&!u.paused}},fromTo(c,f,u){return l.set(c,f),l.to(c,u)},set(c,f){if(!c||!f)return;for(let p of Object.keys(f)){let v=f[p];p==="scale"||p==="scaleX"||p==="scaleY"||typeof v=="number"&&ul(c,p,v)}let u=fl(c,f);u.to&&pl(c,u.to)},killTweensOf(c){let f=t.get(c);if(f)for(let u of Array.from(f))s(u)},timeline(c={}){let f=[],u=0,p=!1,v=[],m=h=>{if(typeof h=="number")return Math.max(0,h*1e3);let x=typeof h=="string"?h.trim():"";return x.startsWith("+=")?u+Math.max(0,Number(x.slice(2))*1e3||0):x?Math.max(0,Number(x)*1e3||0):u},w=h=>{f.push(h);let x=Math.max(0,(typeof h.vars.duration=="number"?h.vars.duration:.5)*1e3);u=Math.max(u,h.atMs+x)},g={to(h,x,y){return w({kind:"to",target:h,vars:x,atMs:m(y)}),g},fromTo(h,x,y,b){return w({kind:"fromTo",target:h,vars:y,from:x,atMs:m(b)}),g},play(){var h,x;if(p)return g;p=!0,v=[];for(let y of f)y.kind==="fromTo"&&l.set(y.target,(h=y.from)!=null?h:{}),v.push(l.to(y.target,{...y.vars,delay:y.atMs/1e3+((x=y.vars.delay)!=null?x:0)}));return g},pause(){for(let h of v)h.pause();return g},kill(){for(let h of v)h.kill();v=[],p=!1}};return c.paused||g.play(),g}};return l}function gl(){if(typeof window=="undefined")return;let e=window;if(!e.gsap)try{e.gsap=hl()}catch{}}var ml={name:"handler-playable-sdk",version:"0.3.19",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"}},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","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 --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks",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",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","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",sharp:"^0.34.5"}};var me=0,Zf=me++,bl=me++,yl=me++,vl=me++,xl=me++,wl=me++,_l=me++,El=me++,Sl=me++,Al=me++,Cl=me++,Tl=me++,q=Zf;function kl(){return q===bl}function Ll(){return q===yl}function Ol(){return q===vl}function Il(){return q===xl}function Gt(){return q===wl}function Wt(){return q===_l}function Ml(){return q===El}function Rl(){return q===Sl}function Pl(){return q===Al}function ua(){return q===Cl}function pa(){return q===Tl}function jl(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),q=bl;return}catch{}else if(e==="dapi")try{dapi.isReady(),q=yl;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(q=vl)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(q=xl)}catch{}else if(t==="mintegral")window.gameReady&&(q=wl);else if(t==="tapjoy")window.TJ_API&&(q=_l);else if(t==="tiktok")window.openAppStore&&(q=El);else if(t==="smadex")try{window.smxTracking&&(q=Sl)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(q=Al)}catch{}else t==="vungle"?q=Cl:(e==="nucleo"||t==="nucleo")&&(q=Tl)}var Yn=qn(require("lottie-web"),1),Dl=Yn.default;typeof window!="undefined"&&(window.lottie=Yn.default,window.__baseLottie=Yn.default);ga();function Z(e,t){let i=(r,a)=>a===0?r:i(a,r%a),n=i(e,t);return`${e/n}:${t/n}`}var vx=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:Z(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:Z(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:Z(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:Z(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:Z(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:Z(360,780)}],xx=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:Z(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:Z(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:Z(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:Z(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:Z(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:Z(412,915)}],wx=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:Z(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:Z(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:Z(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:Z(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:Z(800,1280)}],Fl=[{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:Z(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:Z(768,1024),mraidScale:.7}];var _x=[...Fl];var ah=Fl[0];ot();var qy=qn(Jp(),1);function Hy(e){return new Promise((t,i)=>{let n=new FileReader;n.onerror=()=>i(new Error("FileReader failed")),n.onload=()=>t(String(n.result||"")),n.readAsDataURL(e)})}function $y(e){var r;let[t,i]=e.split(","),n=t==null?void 0:t.match(/data:(.*?);base64/);return{base64:i!=null?i:"",mimeType:(r=n==null?void 0:n[1])!=null?r:"image/png"}}async function Uy(e){return await new Promise(t=>{let i=new Image;i.onload=()=>t({width:i.naturalWidth||i.width,height:i.naturalHeight||i.height}),i.onerror=()=>t(null),i.src=e})}async function ao(e){var t,i;try{console.log("[ImageUtils] Fetching image data from URL:",e);let n=await fetch(e);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,e),null;let r=await n.blob();console.log("[ImageUtils] Blob received, size:",r.size,"type:",r.type);let a=await Hy(r),s=await Uy(a),o=$y(a);return console.log("[ImageUtils] Success resolution:",s==null?void 0:s.width,"x",s==null?void 0:s.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:a,width:(t=s==null?void 0:s.width)!=null?t:0,height:(i=s==null?void 0:s.height)!=null?i:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function Br(e,t=30){try{console.log("[ImageUtils] Removing background color...");let i=await new Promise((f,u)=>{let p=new Image;p.onload=()=>f(p),p.onerror=()=>u(new Error("Failed to load image")),p.src=e}),n=document.createElement("canvas");n.width=i.width,n.height=i.height;let r=n.getContext("2d");if(!r)return console.error("[ImageUtils] Failed to get canvas context"),e;r.drawImage(i,0,0);let a=r.getImageData(0,0,n.width,n.height),s=a.data,d=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(f=>({r:s[f.offset],g:s[f.offset+1],b:s[f.offset+2]})),l=0;for(let f=0;f<s.length;f+=4){let u=s[f],p=s[f+1],v=s[f+2],m=!1;for(let w of d)if(Math.sqrt(Math.pow(u-w.r,2)+Math.pow(p-w.g,2)+Math.pow(v-w.b,2))<t){m=!0;break}m&&(s[f+3]=0,l++)}return console.log(`[ImageUtils] Removed background from ${l} pixels (4-corner sampling, tolerance: ${t})`),r.putImageData(a,0,0),n.toDataURL("image/png")}catch(i){return console.error("[ImageUtils] Error removing background:",i),e}}var Qp=require("@google/genai");async function so(e,t,i=[],n={}){var r,a,s,o,d,l,c;try{if(!(e!=null&&e.trim()))throw new Error("Gemini API key is required");if(!(t!=null&&t.trim()))throw new Error("Prompt is required");for(let g=0;g<i.length;g++){let h=i[g];if(!h.base64||!h.mimeType)throw new Error(`Image ${g+1} is missing required data`);if(h.base64.length<1e3&&console.warn(`Image ${g+1} data appears very small, may be corrupted`),!h.mimeType.startsWith("image/"))throw new Error(`Image ${g+1} has invalid MIME type: ${h.mimeType}`)}let f=new Qp.GoogleGenAI({apiKey:e}),u="gemini-2.5-flash",p=[t];i.length>0&&i.forEach((g,h)=>{p.push({inlineData:{data:g.base64,mimeType:g.mimeType}}),console.log(`[Gemini] Added image ${h+1}: ${g.mimeType}, size: ${Math.round(g.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${i.length} images and prompt length: ${t.length}`);let v=await f.models.generateContent({model:u,contents:p}),m="",w=(s=(a=(r=v.candidates)==null?void 0:r[0])==null?void 0:a.content)==null?void 0:s.parts;if(w)for(let g of w)g.text&&(m+=g.text);if(!m.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${m.length}`),m}catch(f){throw console.error("[Gemini] API error:",f),(o=f.message)!=null&&o.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(d=f.message)!=null&&d.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(l=f.message)!=null&&l.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(c=f.message)!=null&&c.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):f}}var ef=require("@google/genai");async function Fr(e,t,i=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let r=new ef.GoogleGenAI({apiKey:e}),a=[{text:t}];i.length>0&&i.forEach((o,d)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${d}`),a.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let s=await r.models.generateContent({model:"gemini-2.5-flash-image",contents:a});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!s.candidates||!s.candidates[0]||!s.candidates[0].content||!s.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of s.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let d=o.inlineData.data,l=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${l};base64,${d}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(r){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(r,Object.getOwnPropertyNames(r),2)),r}}var Xy=require("pixi.js");An();ot();var of=require("pixi.js");var Zy=require("pixi.js");ot();function rv(e){return new Promise((t,i)=>{let n=new FileReader;n.onerror=()=>i(new Error("FileReader failed")),n.onload=()=>t(String(n.result||"")),n.readAsDataURL(e)})}function av(e){var r;let[t,i]=e.split(","),n=t==null?void 0:t.match(/data:(.*?);base64/);return{base64:i!=null?i:"",mimeType:(r=n==null?void 0:n[1])!=null?r:"image/png"}}function sv(e){return`
47
+ `,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let l=o.target.dataset.tab;l&&this.switchTab(l)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let r=this.modal.querySelector("[data-ai-edit]");r==null||r.addEventListener("click",()=>{this.openAiEditor("edit")});let a=this.modal.querySelector("[data-modal-apply]");a==null||a.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",s=>{s.target===this.modal&&this.close()})}switchTab(t){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab")===t)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab-panel")===t)})}openAiEditor(t){let i=window.__openAiEditor;if(typeof i!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";t==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,i(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:r=>{this.onApplyCallback&&this.onApplyCallback(r),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 Fv={};rl(Fv,{AssetCache:()=>Be,AssetLoader:()=>xt,AssetSystem:()=>Qr,AssetTextures:()=>wt,Assets:()=>jf,BaseSystem:()=>Oi,GameEngine:()=>Jr,GameObject:()=>Dn,GameObjectManager:()=>ki,ObjectFactory:()=>_t,Renderer:()=>jn,RuntimeObjectRegistry:()=>Ii,Transform:()=>Pn,applyScreenAnchor:()=>ia,basePixi:()=>If,clearResponsiveElements:()=>zf,createPixiBase:()=>Xr,getRegisteredFontIds:()=>Tf,globalResponsiveMultipliers:()=>Nn,initAssetTextures:()=>Ur,initAssets:()=>Df,layout:()=>Bf,playLottieOverlay:()=>Lf,registerFont:()=>Cf,registerType:()=>Hr,resolveAnchorVec2:()=>Bn,resolveFont:()=>Sf,resolveFontWeight:()=>Af,resolveScreenAnchorPoint:()=>Mi,resolveScreenRatioPoint:()=>Ri,runInitSequence:()=>Ff,setLottieInstance:()=>qr,spawnSceneFromConfig:()=>Rf,updateScreenState:()=>ta});module.exports=Wf(Fv);var Ef=require("pixi.js");var st={};function Gn(e,t,i=!1){st[e]||(st[e]=[]),st[e].push({fn:t,once:i})}function ca(e,t){if(st[e]){if(!t){delete st[e];return}st[e]=st[e].filter(i=>i.fn!==t)}}function Wn(e,...t){let i=st[e];if(i)for(let n of[...i])n.fn(...t),n.once&&ca(e,n.fn)}function ge(e,t){Gn(e,t,!0)}var X=null,Ee=[],qt=null;function ll(e){X=e,Ee=[],qt!==null&&(clearTimeout(qt),qt=null)}function cl(){var e,t,i;return{endpoint:(X==null?void 0:X.endpoint)||"",transport:(X==null?void 0:X.transport)||"beacon",batchSize:(e=X==null?void 0:X.batchSize)!=null?e:10,flushIntervalMs:(t=X==null?void 0:X.flushIntervalMs)!=null?t:300,maxQueue:(i=X==null?void 0:X.maxQueue)!=null?i:200,debug:!!(X!=null&&X.debug)}}async function sl(e,t,i,n){let r=JSON.stringify(t);if(i==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(e,new Blob([r],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",a,t);return}catch(a){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",t)}catch(a){n&&console.warn("[handler.telemetry] fetch failed",a)}}function da(e,t){let i=cl();if(t&&i.endpoint){if(Ee.push(e),Ee.length>i.maxQueue&&(Ee=Ee.slice(Ee.length-i.maxQueue)),Ee.length>=i.batchSize){ol();return}qt===null&&(qt=window.setTimeout(()=>{qt=null,ol()},i.flushIntervalMs))}}async function ol(){let e=cl();if(!e.endpoint||Ee.length===0)return;let t=Ee.splice(0,e.batchSize);await sl(e.endpoint,{events:t},e.transport,e.debug),Ee.length>0&&await sl(e.endpoint,{events:Ee.splice(0,e.batchSize)},e.transport,e.debug)}function dl(e){return Math.max(0,Math.min(1,e))}function Yf(e){let t=String(e!=null?e:"power2.out");if(t==="linear")return i=>i;if(t==="sine.inOut")return i=>.5-Math.cos(Math.PI*i)/2;if(t==="power2.out"||t==="easeOutQuad")return i=>1-(1-i)*(1-i);if(t.startsWith("back.out")){let i=t.match(/back\.out\(([\d.]+)\)/),n=i?Number(i[1]):1.8;return r=>1+(n+1)*Math.pow(r-1,3)+n*Math.pow(r-1,2)}return i=>1-(1-i)*(1-i)}function $i(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Vf(e,t){let i=e==null?void 0:e[t];return typeof i=="number"?i:0}function ul(e,t,i){try{e[t]=i}catch{}}function Kf(e){let t=e==null?void 0:e.scale;if(!t)return null;let i=typeof t.x=="number"?t.x:1,n=typeof t.y=="number"?t.y:1;return{x:i,y:n}}function pl(e,t){let i=e==null?void 0:e.scale;if(i)try{typeof i.set=="function"?i.set(t.x,t.y):(typeof i.x=="number"&&(i.x=t.x),typeof i.y=="number"&&(i.y=t.y))}catch{}}function fl(e,t){let i=Kf(e);if(!i)return{from:null,to:null};let n=null,r=null;return typeof t.scale=="number"?(n=t.scale,r=t.scale):t.scale&&typeof t.scale=="object"&&(typeof t.scale.x=="number"&&(n=t.scale.x),typeof t.scale.y=="number"&&(r=t.scale.y)),typeof t.scaleX=="number"&&(n=t.scaleX),typeof t.scaleY=="number"&&(r=t.scaleY),n===null&&r===null?{from:null,to:null}:{from:{x:i.x,y:i.y},to:{x:n!=null?n:i.x,y:r!=null?r:i.y}}}function hl(){let e=new Set,t=new WeakMap,i=null,n=()=>{if(i!=null)return;i=requestAnimationFrame(()=>{i=null,o(),e.size>0&&n()})},r=c=>{var u;e.add(c);let f=(u=t.get(c.target))!=null?u:new Set;f.add(c),t.set(c.target,f),n()},a=c=>{e.delete(c);let f=t.get(c.target);f&&(f.delete(c),f.size===0&&t.delete(c.target))},s=c=>{c.killed||(c.killed=!0,a(c))},o=()=>{var f,u;let c=$i();for(let p of Array.from(e)){if(p.killed||p.paused)continue;let v=c-p.startMs-p.delayMs;if(v<0)continue;let m=p.durationMs>0?v/p.durationMs:1,w=dl(m),g=p.repeat>=0?p.repeat+1:1,h=p.repeat>0?Math.min(Math.floor(m),g-1):0;if(p.repeat>0&&m>=1){let b=m-h;w=dl(b)}let x=p.ease(w);p.yoyo&&h%2===1&&(x=1-x);for(let b of p.props)ul(p.target,b.key,b.from+(b.to-b.from)*x);p.scaleFrom&&p.scaleTo&&pl(p.target,{x:p.scaleFrom.x+(p.scaleTo.x-p.scaleFrom.x)*x,y:p.scaleFrom.y+(p.scaleTo.y-p.scaleFrom.y)*x});try{(f=p.onUpdate)==null||f.call(p)}catch{}if(m>=g){s(p);try{(u=p.onComplete)==null||u.call(p)}catch{}}}},d=(c,f,u)=>{var b;let p=Math.max(0,(typeof f.duration=="number"?f.duration:.5)*1e3),v=Math.max(0,(typeof f.delay=="number"?f.delay:0)*1e3+((b=u==null?void 0:u.delayMsOverride)!=null?b:0)),m=Yf(f.ease),w=typeof f.repeat=="number"?Math.max(0,f.repeat|0):0,g=f.yoyo===!0,h=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),x=[];for(let C of Object.keys(f)){if(h.has(C))continue;let S=f[C];typeof S=="number"&&x.push({key:C,from:Vf(c,C),to:S})}let y=fl(c,f);return{target:c,startMs:$i(),delayMs:v,durationMs:p,ease:m,props:x,scaleFrom:y.from,scaleTo:y.to,repeat:w,yoyo:g,onUpdate:typeof f.onUpdate=="function"?f.onUpdate:void 0,onComplete:typeof f.onComplete=="function"?f.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},l={to(c,f){let u=d(c,f);return r(u),{kill:()=>s(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=$i())},resume:()=>{var m;if(!u.paused)return;let p=(m=u.pauseAtMs)!=null?m:$i(),v=$i()-p;u.startMs+=v,u.paused=!1,u.pauseAtMs=null},isActive:()=>!u.killed&&!u.paused}},fromTo(c,f,u){return l.set(c,f),l.to(c,u)},set(c,f){if(!c||!f)return;for(let p of Object.keys(f)){let v=f[p];p==="scale"||p==="scaleX"||p==="scaleY"||typeof v=="number"&&ul(c,p,v)}let u=fl(c,f);u.to&&pl(c,u.to)},killTweensOf(c){let f=t.get(c);if(f)for(let u of Array.from(f))s(u)},timeline(c={}){let f=[],u=0,p=!1,v=[],m=h=>{if(typeof h=="number")return Math.max(0,h*1e3);let x=typeof h=="string"?h.trim():"";return x.startsWith("+=")?u+Math.max(0,Number(x.slice(2))*1e3||0):x?Math.max(0,Number(x)*1e3||0):u},w=h=>{f.push(h);let x=Math.max(0,(typeof h.vars.duration=="number"?h.vars.duration:.5)*1e3);u=Math.max(u,h.atMs+x)},g={to(h,x,y){return w({kind:"to",target:h,vars:x,atMs:m(y)}),g},fromTo(h,x,y,b){return w({kind:"fromTo",target:h,vars:y,from:x,atMs:m(b)}),g},play(){var h,x;if(p)return g;p=!0,v=[];for(let y of f)y.kind==="fromTo"&&l.set(y.target,(h=y.from)!=null?h:{}),v.push(l.to(y.target,{...y.vars,delay:y.atMs/1e3+((x=y.vars.delay)!=null?x:0)}));return g},pause(){for(let h of v)h.pause();return g},kill(){for(let h of v)h.kill();v=[],p=!1}};return c.paused||g.play(),g}};return l}function gl(){if(typeof window=="undefined")return;let e=window;if(!e.gsap)try{e.gsap=hl()}catch{}}var ml={name:"handler-playable-sdk",version:"0.3.21",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"}},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","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 --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks",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",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","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",sharp:"^0.34.5"}};var me=0,Zf=me++,bl=me++,yl=me++,vl=me++,xl=me++,wl=me++,_l=me++,El=me++,Sl=me++,Al=me++,Cl=me++,Tl=me++,q=Zf;function kl(){return q===bl}function Ll(){return q===yl}function Ol(){return q===vl}function Il(){return q===xl}function Gt(){return q===wl}function Wt(){return q===_l}function Ml(){return q===El}function Rl(){return q===Sl}function Pl(){return q===Al}function ua(){return q===Cl}function pa(){return q===Tl}function jl(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),q=bl;return}catch{}else if(e==="dapi")try{dapi.isReady(),q=yl;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(q=vl)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(q=xl)}catch{}else if(t==="mintegral")window.gameReady&&(q=wl);else if(t==="tapjoy")window.TJ_API&&(q=_l);else if(t==="tiktok")window.openAppStore&&(q=El);else if(t==="smadex")try{window.smxTracking&&(q=Sl)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(q=Al)}catch{}else t==="vungle"?q=Cl:(e==="nucleo"||t==="nucleo")&&(q=Tl)}var Yn=qn(require("lottie-web"),1),Dl=Yn.default;typeof window!="undefined"&&(window.lottie=Yn.default,window.__baseLottie=Yn.default);ga();function Z(e,t){let i=(r,a)=>a===0?r:i(a,r%a),n=i(e,t);return`${e/n}:${t/n}`}var vx=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:Z(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:Z(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:Z(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:Z(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:Z(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:Z(360,780)}],xx=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:Z(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:Z(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:Z(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:Z(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:Z(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:Z(412,915)}],wx=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:Z(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:Z(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:Z(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:Z(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:Z(800,1280)}],Fl=[{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:Z(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:Z(768,1024),mraidScale:.7}];var _x=[...Fl];var ah=Fl[0];ot();var qy=qn(Jp(),1);function Hy(e){return new Promise((t,i)=>{let n=new FileReader;n.onerror=()=>i(new Error("FileReader failed")),n.onload=()=>t(String(n.result||"")),n.readAsDataURL(e)})}function $y(e){var r;let[t,i]=e.split(","),n=t==null?void 0:t.match(/data:(.*?);base64/);return{base64:i!=null?i:"",mimeType:(r=n==null?void 0:n[1])!=null?r:"image/png"}}async function Uy(e){return await new Promise(t=>{let i=new Image;i.onload=()=>t({width:i.naturalWidth||i.width,height:i.naturalHeight||i.height}),i.onerror=()=>t(null),i.src=e})}async function ao(e){var t,i;try{console.log("[ImageUtils] Fetching image data from URL:",e);let n=await fetch(e);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,e),null;let r=await n.blob();console.log("[ImageUtils] Blob received, size:",r.size,"type:",r.type);let a=await Hy(r),s=await Uy(a),o=$y(a);return console.log("[ImageUtils] Success resolution:",s==null?void 0:s.width,"x",s==null?void 0:s.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:a,width:(t=s==null?void 0:s.width)!=null?t:0,height:(i=s==null?void 0:s.height)!=null?i:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function Br(e,t=30){try{console.log("[ImageUtils] Removing background color...");let i=await new Promise((f,u)=>{let p=new Image;p.onload=()=>f(p),p.onerror=()=>u(new Error("Failed to load image")),p.src=e}),n=document.createElement("canvas");n.width=i.width,n.height=i.height;let r=n.getContext("2d");if(!r)return console.error("[ImageUtils] Failed to get canvas context"),e;r.drawImage(i,0,0);let a=r.getImageData(0,0,n.width,n.height),s=a.data,d=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(f=>({r:s[f.offset],g:s[f.offset+1],b:s[f.offset+2]})),l=0;for(let f=0;f<s.length;f+=4){let u=s[f],p=s[f+1],v=s[f+2],m=!1;for(let w of d)if(Math.sqrt(Math.pow(u-w.r,2)+Math.pow(p-w.g,2)+Math.pow(v-w.b,2))<t){m=!0;break}m&&(s[f+3]=0,l++)}return console.log(`[ImageUtils] Removed background from ${l} pixels (4-corner sampling, tolerance: ${t})`),r.putImageData(a,0,0),n.toDataURL("image/png")}catch(i){return console.error("[ImageUtils] Error removing background:",i),e}}var Qp=require("@google/genai");async function so(e,t,i=[],n={}){var r,a,s,o,d,l,c;try{if(!(e!=null&&e.trim()))throw new Error("Gemini API key is required");if(!(t!=null&&t.trim()))throw new Error("Prompt is required");for(let g=0;g<i.length;g++){let h=i[g];if(!h.base64||!h.mimeType)throw new Error(`Image ${g+1} is missing required data`);if(h.base64.length<1e3&&console.warn(`Image ${g+1} data appears very small, may be corrupted`),!h.mimeType.startsWith("image/"))throw new Error(`Image ${g+1} has invalid MIME type: ${h.mimeType}`)}let f=new Qp.GoogleGenAI({apiKey:e}),u="gemini-2.5-flash",p=[t];i.length>0&&i.forEach((g,h)=>{p.push({inlineData:{data:g.base64,mimeType:g.mimeType}}),console.log(`[Gemini] Added image ${h+1}: ${g.mimeType}, size: ${Math.round(g.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${i.length} images and prompt length: ${t.length}`);let v=await f.models.generateContent({model:u,contents:p}),m="",w=(s=(a=(r=v.candidates)==null?void 0:r[0])==null?void 0:a.content)==null?void 0:s.parts;if(w)for(let g of w)g.text&&(m+=g.text);if(!m.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${m.length}`),m}catch(f){throw console.error("[Gemini] API error:",f),(o=f.message)!=null&&o.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(d=f.message)!=null&&d.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(l=f.message)!=null&&l.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(c=f.message)!=null&&c.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):f}}var ef=require("@google/genai");async function Fr(e,t,i=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let r=new ef.GoogleGenAI({apiKey:e}),a=[{text:t}];i.length>0&&i.forEach((o,d)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${d}`),a.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let s=await r.models.generateContent({model:"gemini-2.5-flash-image",contents:a});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!s.candidates||!s.candidates[0]||!s.candidates[0].content||!s.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of s.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let d=o.inlineData.data,l=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${l};base64,${d}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(r){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(r,Object.getOwnPropertyNames(r),2)),r}}var Xy=require("pixi.js");An();ot();var of=require("pixi.js");var Zy=require("pixi.js");ot();function rv(e){return new Promise((t,i)=>{let n=new FileReader;n.onerror=()=>i(new Error("FileReader failed")),n.onload=()=>t(String(n.result||"")),n.readAsDataURL(e)})}function av(e){var r;let[t,i]=e.split(","),n=t==null?void 0:t.match(/data:(.*?);base64/);return{base64:i!=null?i:"",mimeType:(r=n==null?void 0:n[1])!=null?r:"image/png"}}function sv(e){return`
48
48
  Analyze these screenshots of a brand or game and extract its "Brand DNA".
49
49
 
50
50
  Provide a concise summary (2-3 sentences) covering:
@@ -1 +1 @@
1
- (function(_0x4d0876,_0x61e1e9){var a0_0x5555d6={_0x4a58ca:0x303,_0x5ba964:'XDS)',_0x50f371:0x304,_0x1d4031:0x2f9,_0x205dbb:0x5e,_0x4f504e:'go9v',_0x363437:0x5c,_0x31c4ee:0x68,_0x4a38f9:0x66,_0x5d34c:0xd0,_0x53c05d:0xe6,_0x403ae1:0xd8,_0x5a96e8:'rqnq',_0x185d67:0xd5,_0x3dc312:0xbf,_0x985ae2:0xca,_0x44e7b3:'gLVZ',_0x4cd38d:0xdb,_0x2e9fe9:0xee,_0x21d1a8:0xe8,_0x2b2b70:0xdf,_0x2e236f:'iw@]',_0x17a9ef:0xdc,_0x47646a:0x306,_0x2791f8:'sPUa',_0x5bb3b8:0x312,_0x4b26af:0x30b,_0x1e12c0:0x2ff,_0x4e6165:0x305,_0x35ffe1:0x302,_0x56f502:'70*e',_0x1d4072:0x6f,_0x283534:0x74,_0x1fa379:0xd6,_0x1bb1b9:'AJ!W',_0x1c1dce:0xe0,_0x42fbf1:'O[EJ',_0xf17047:0x6d,_0x2ce362:0x61},a0_0x45c5fa={_0x16cf7b:0x219},a0_0x566b12={_0x4db024:0x7f},a0_0x47286f={_0xa93149:0x1b9};function _0xc6ac40(_0x24d8d2,_0x489a1c,_0x46973b,_0x44596d,_0xc86ebf){return a0_0x5120(_0x46973b- -a0_0x47286f._0xa93149,_0x44596d);}function _0x4de535(_0x338f0d,_0x2cd3b5,_0x5117c9,_0x3b8896,_0x3be9dc){return a0_0x5120(_0x3b8896- -a0_0x566b12._0x4db024,_0x2cd3b5);}function _0x2f1abf(_0xe9ee15,_0xe97513,_0x16fc74,_0x3eed83,_0x298d09){return a0_0x5120(_0xe9ee15-a0_0x45c5fa._0x16cf7b,_0xe97513);}var _0x4367fc=_0x4d0876();while(!![]){try{var _0x5b5c15=-parseInt(_0x2f1abf(a0_0x5555d6._0x4a58ca,a0_0x5555d6._0x5ba964,a0_0x5555d6._0x50f371,0x30c,a0_0x5555d6._0x1d4031))/(0x1ff6*-0x1+-0x1631+0x1b14*0x2)*(parseInt(_0x4de535(a0_0x5555d6._0x205dbb,a0_0x5555d6._0x4f504e,a0_0x5555d6._0x363437,a0_0x5555d6._0x31c4ee,a0_0x5555d6._0x4a38f9))/(-0xb99*0x1+-0xc8+-0x3*-0x421))+-parseInt(_0xc6ac40(-a0_0x5555d6._0x5d34c,-a0_0x5555d6._0x53c05d,-a0_0x5555d6._0x403ae1,a0_0x5555d6._0x5a96e8,-a0_0x5555d6._0x185d67))/(-0xbef+0x1de7+-0x11f5)+-parseInt(_0xc6ac40(-a0_0x5555d6._0x3dc312,-a0_0x5555d6._0x985ae2,-0xcd,a0_0x5555d6._0x44e7b3,-a0_0x5555d6._0x4cd38d))/(-0x4f*-0x9+-0x1*0x74f+0x48c)+parseInt(_0xc6ac40(-a0_0x5555d6._0x2e9fe9,-a0_0x5555d6._0x21d1a8,-a0_0x5555d6._0x2b2b70,a0_0x5555d6._0x2e236f,-a0_0x5555d6._0x17a9ef))/(0x1e1*0x1+0x2625+0x4d*-0x85)+parseInt(_0x2f1abf(a0_0x5555d6._0x47646a,a0_0x5555d6._0x2791f8,a0_0x5555d6._0x5bb3b8,a0_0x5555d6._0x4b26af,0x305))/(0x9*-0x428+0x863+0x5cf*0x5)*(-parseInt(_0x2f1abf(a0_0x5555d6._0x1e12c0,'TXvt',a0_0x5555d6._0x4e6165,a0_0x5555d6._0x4a58ca,a0_0x5555d6._0x35ffe1))/(-0x1ed6+-0x3*-0x901+0x22*0x1d))+-parseInt(_0x4de535(0x74,a0_0x5555d6._0x56f502,a0_0x5555d6._0x1d4072,a0_0x5555d6._0x283534,0x81))/(-0x1542+-0x1471+0x29bb)+parseInt(_0xc6ac40(-a0_0x5555d6._0x2b2b70,-0xd3,-a0_0x5555d6._0x1fa379,a0_0x5555d6._0x1bb1b9,-a0_0x5555d6._0x1c1dce))/(-0x156*-0x1+-0x2*-0x329+-0x79f)*(parseInt(_0x4de535(0x63,a0_0x5555d6._0x42fbf1,a0_0x5555d6._0xf17047,a0_0x5555d6._0x2ce362,0x68))/(0x94e+-0x129*-0x20+-0x2e64));if(_0x5b5c15===_0x61e1e9)break;else _0x4367fc['push'](_0x4367fc['shift']());}catch(_0x3954b6){_0x4367fc['push'](_0x4367fc['shift']());}}}(a0_0x3122,-0x826ff+0xbeb*0xa7+-0x67*-0xbe9));var a0_0x1b7a59=(function(){var _0x49922e=!![];return function(_0x51790f,_0x1dcab2){var a0_0xf62398={_0x2edaf5:'rchg',_0x2ff0bc:0x214,_0x3c6be1:0x222,_0x32c691:0x21a},a0_0x5b4bfd={_0x5e0756:0x2f6},_0x546c91=_0x49922e?function(){function _0x3a6816(_0x6c64a9,_0x50560b,_0x2f0029,_0x1a02f0,_0x53d4ee){return a0_0x5120(_0x1a02f0- -a0_0x5b4bfd._0x5e0756,_0x6c64a9);}if(_0x1dcab2){var _0x10929b=_0x1dcab2[_0x3a6816(a0_0xf62398._0x2edaf5,-a0_0xf62398._0x2ff0bc,-a0_0xf62398._0x3c6be1,-a0_0xf62398._0x32c691,-0x217)](_0x51790f,arguments);return _0x1dcab2=null,_0x10929b;}}:function(){};return _0x49922e=![],_0x546c91;};}()),a0_0x1a8cff=a0_0x1b7a59(this,function(){var a0_0x3ef29a={_0x31e28c:0x160,_0xeba606:0x157,_0x575c8b:0x162,_0x43886b:'c5No',_0x56a81c:'F#Co',_0x1775bc:0x411,_0x5543f5:0x410,_0x227273:0x41c,_0x306c66:0x166,_0x46760d:0x159,_0x505f03:0x153,_0x47b2f7:0x14b,_0x4e9fd9:'sOu^',_0x2655de:0x172,_0x509698:0x16e,_0x24cca0:0x163,_0xa58c31:']n$F',_0x1ad7b4:0x15f,_0xed35dc:0x16c,_0x4b9125:'%2v9',_0x2acac7:0x3fb,_0x3e2f2e:0x402,_0x5a4a28:0x3fc,_0x16bf30:'xKRN',_0x3f5348:0x40b,_0x4f477c:0x417,_0x529f7d:0x413,_0x37d605:'XDS)',_0x4d0065:0x468,_0x194c29:0x46e,_0x257bcc:0x475,_0x2b5c49:0x469,_0x4f62f8:'mSj*',_0x222e3d:0x40a,_0x51a186:0x408,_0xc057a9:0x3fd,_0x23644c:0x3fe,_0x4ca2c6:')o2D',_0x40fdcb:0x461,_0x48f2d3:'4$Lq',_0x1fe840:0x457,_0x17fd42:0x46d,_0x48c251:0x465},a0_0x5cb08c={_0x304880:0x381},_0x1e9e67={};_0x1e9e67[_0x24b2c3(0x16c,a0_0x3ef29a._0x31e28c,a0_0x3ef29a._0xeba606,a0_0x3ef29a._0x575c8b,a0_0x3ef29a._0x43886b)]=_0x527df5(a0_0x3ef29a._0x56a81c,a0_0x3ef29a._0x1775bc,0x40e,a0_0x3ef29a._0x5543f5,a0_0x3ef29a._0x227273)+_0x24b2c3(a0_0x3ef29a._0x306c66,a0_0x3ef29a._0x46760d,a0_0x3ef29a._0x505f03,a0_0x3ef29a._0x47b2f7,a0_0x3ef29a._0x4e9fd9)+'+$';function _0x24b2c3(_0x19ed4e,_0x22d578,_0x3194a1,_0x5a101e,_0x2c0a04){return a0_0x5120(_0x22d578-0x7e,_0x2c0a04);}function _0x527df5(_0x144e25,_0x3b2c78,_0x5b9d79,_0x45c5d8,_0x92fdeb){return a0_0x5120(_0x45c5d8-0x31f,_0x144e25);}var _0x16f126=_0x1e9e67;function _0x33567d(_0x3a4ab8,_0x3bb0d6,_0x22a1fe,_0x4ce19e,_0x34d900){return a0_0x5120(_0x34d900-a0_0x5cb08c._0x304880,_0x3a4ab8);}return a0_0x1a8cff[_0x24b2c3(a0_0x3ef29a._0x2655de,a0_0x3ef29a._0x509698,a0_0x3ef29a._0x24cca0,0x16d,a0_0x3ef29a._0xa58c31)+_0x24b2c3(a0_0x3ef29a._0x1ad7b4,a0_0x3ef29a._0xed35dc,0x16a,a0_0x3ef29a._0x1ad7b4,a0_0x3ef29a._0x4b9125)]()[_0x527df5(a0_0x3ef29a._0x4e9fd9,a0_0x3ef29a._0x2acac7,a0_0x3ef29a._0x3e2f2e,a0_0x3ef29a._0x5a4a28,0x3f6)+'h'](_0x16f126[_0x527df5(a0_0x3ef29a._0x16bf30,a0_0x3ef29a._0x3f5348,a0_0x3ef29a._0x4f477c,a0_0x3ef29a._0x529f7d,0x40c)])['toStr'+_0x33567d(a0_0x3ef29a._0x37d605,a0_0x3ef29a._0x4d0065,a0_0x3ef29a._0x194c29,a0_0x3ef29a._0x257bcc,a0_0x3ef29a._0x2b5c49)]()['const'+_0x527df5(a0_0x3ef29a._0x4f62f8,a0_0x3ef29a._0x222e3d,a0_0x3ef29a._0x51a186,a0_0x3ef29a._0xc057a9,a0_0x3ef29a._0x23644c)+'r'](a0_0x1a8cff)[_0x33567d(a0_0x3ef29a._0x4ca2c6,0x468,0x46d,a0_0x3ef29a._0x40fdcb,0x46a)+'h'](_0x16f126[_0x33567d(a0_0x3ef29a._0x48f2d3,a0_0x3ef29a._0x1fe840,a0_0x3ef29a._0x17fd42,0x46b,a0_0x3ef29a._0x48c251)]);});a0_0x1a8cff();import{A as a0_0x466f30,B as a0_0x518a4d,C as a0_0x4997c3,D as a0_0x17cbf0,b as a0_0x327a2d,c as a0_0x58ac95,d as a0_0x132784,e as a0_0x261e1f,f as a0_0x57fffc,g as a0_0x53c622,h as a0_0x2ef715,i as a0_0x1d945e,j as a0_0x7f4228,k as a0_0x20a98a,l as a0_0x4e4f1d,m as a0_0x5cf60a,n as a0_0x1a4e62,o as a0_0x391bb2,p as a0_0x41a992,q as a0_0x8b85f,r as a0_0x2c7d83,s as a0_0x47ea35,t as a0_0x1d0a56,u as a0_0x59c9c0,v as a0_0x46fd46,w as a0_0x2594d5,x as a0_0x4923bd,y as a0_0x1807fd,z as a0_0x3aff92}from'../chunk-MSFWHTLG.js';import{a as a0_0xee0dd2,b as a0_0x433bf3,c as a0_0xc33f8,d as a0_0x4fc4d9,e as a0_0xa55e7}from'../chunk-I5OOVR5U.js';import'../chunk-LV4HGC5G.js';import'../chunk-ZLL42OOV.js';import'../chunk-E6WJCS24.js';import'../chunk-Q7FPWOA3.js';export{a0_0xee0dd2 as AssetCache,a0_0xc33f8 as AssetLoader,a0_0x59c9c0 as AssetSystem,a0_0x4fc4d9 as AssetTextures,a0_0x47ea35 as Assets,a0_0x391bb2 as BaseSystem,a0_0x1a4e62 as GameEngine,a0_0x261e1f as GameObject,a0_0x57fffc as GameObjectManager,a0_0x5cf60a as ObjectFactory,a0_0x132784 as Renderer,a0_0x41a992 as RuntimeObjectRegistry,a0_0x58ac95 as Transform,a0_0x518a4d as applyScreenAnchor,a0_0x8b85f as basePixi,a0_0x2594d5 as clearResponsiveElements,a0_0x327a2d as createPixiBase,a0_0x7f4228 as getRegisteredFontIds,a0_0x46fd46 as globalResponsiveMultipliers,a0_0xa55e7 as initAssetTextures,a0_0x1d0a56 as initAssets,a0_0x4997c3 as layout,a0_0x4e4f1d as playLottieOverlay,a0_0x1d945e as registerFont,a0_0x433bf3 as registerType,a0_0x1807fd as resolveAnchorVec2,a0_0x53c622 as resolveFont,a0_0x2ef715 as resolveFontWeight,a0_0x3aff92 as resolveScreenAnchorPoint,a0_0x466f30 as resolveScreenRatioPoint,a0_0x17cbf0 as runInitSequence,a0_0x20a98a as setLottieInstance,a0_0x2c7d83 as spawnSceneFromConfig,a0_0x4923bd as updateScreenState};function a0_0x5120(_0x31faf7,_0x5e3f0e){_0x31faf7=_0x31faf7-(-0x1*-0x1343+-0x969+0x481*-0x2);var _0x49168b=a0_0x3122();var _0x561157=_0x49168b[_0x31faf7];if(a0_0x5120['gaEGea']===undefined){var _0x27beec=function(_0x35b4e6){var _0x36fd8d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0xd1e15b='',_0x448794='',_0x4d8cab=_0xd1e15b+_0x27beec;for(var _0xa0d08a=-0x17*-0x19d+0x26a6+0x1d9*-0x29,_0x50a837,_0x2f0335,_0x3e0770=0x194*0x12+0x50*-0x5f+0x148;_0x2f0335=_0x35b4e6['charAt'](_0x3e0770++);~_0x2f0335&&(_0x50a837=_0xa0d08a%(-0x21d3+-0xb3c*-0x1+0x1*0x169b)?_0x50a837*(0x207c+0x12*0xe7+-0x2da*0x11)+_0x2f0335:_0x2f0335,_0xa0d08a++%(-0x1*0x2551+0xcb9*-0x3+-0x25c*-0x20))?_0xd1e15b+=_0x4d8cab['charCodeAt'](_0x3e0770+(0x10ef*0x2+-0x1630+-0xba4))-(0x166*-0x17+0xd0e+0x1326)!==-0x1df*0xd+0x2270+-0xa1d?String['fromCharCode'](0xbb*0xd+0x4*0x111+-0x4*0x331&_0x50a837>>(-(0x1b8c+-0x1*-0x21b5+0x3d3f*-0x1)*_0xa0d08a&0x3*0x73+-0x417*-0x1+0x7*-0xc6)):_0xa0d08a:0xda5+-0xcbb*-0x1+-0x1a60){_0x2f0335=_0x36fd8d['indexOf'](_0x2f0335);}for(var _0x254714=0x21a5+-0x1*-0x11ad+-0x3352,_0x5b937c=_0xd1e15b['length'];_0x254714<_0x5b937c;_0x254714++){_0x448794+='%'+('00'+_0xd1e15b['charCodeAt'](_0x254714)['toString'](0xe6b*-0x1+0x254e+0x1*-0x16d3))['slice'](-(0x419*-0x7+0x12a3+-0x35a*-0x3));}return decodeURIComponent(_0x448794);};var _0x39ec6e=function(_0x4d442d,_0x15bdb2){var _0x16bd2e=[],_0xd97a5d=0x18f*-0xf+-0x7d7+0x1f38,_0x2544b4,_0x2bb11d='';_0x4d442d=_0x27beec(_0x4d442d);var _0x3151e0;for(_0x3151e0=0x208e*-0x1+-0xc50+0x2*0x166f;_0x3151e0<-0x20*0x135+0xb*-0x3d+0x2a3f;_0x3151e0++){_0x16bd2e[_0x3151e0]=_0x3151e0;}for(_0x3151e0=-0x13a*-0x11+-0x1362*0x1+-0x178*0x1;_0x3151e0<0x1535+-0x93a*-0x3+-0x2fe3;_0x3151e0++){_0xd97a5d=(_0xd97a5d+_0x16bd2e[_0x3151e0]+_0x15bdb2['charCodeAt'](_0x3151e0%_0x15bdb2['length']))%(-0x1446+-0x16a2+0x2be8),_0x2544b4=_0x16bd2e[_0x3151e0],_0x16bd2e[_0x3151e0]=_0x16bd2e[_0xd97a5d],_0x16bd2e[_0xd97a5d]=_0x2544b4;}_0x3151e0=0x10ed+-0x16*0xa4+-0x2d5,_0xd97a5d=0x182*-0x1+-0xa9c+0x3*0x40a;for(var _0x3766c8=-0x1a57+-0x317*-0x7+-0x25b*-0x2;_0x3766c8<_0x4d442d['length'];_0x3766c8++){_0x3151e0=(_0x3151e0+(-0x18*-0x139+-0x1a7c+0x2b*-0x11))%(-0x1bf5+0xdc7+0x3a*0x43),_0xd97a5d=(_0xd97a5d+_0x16bd2e[_0x3151e0])%(0x35f+0x13*-0x12a+-0xf*-0x151),_0x2544b4=_0x16bd2e[_0x3151e0],_0x16bd2e[_0x3151e0]=_0x16bd2e[_0xd97a5d],_0x16bd2e[_0xd97a5d]=_0x2544b4,_0x2bb11d+=String['fromCharCode'](_0x4d442d['charCodeAt'](_0x3766c8)^_0x16bd2e[(_0x16bd2e[_0x3151e0]+_0x16bd2e[_0xd97a5d])%(0xe97*0x2+-0x2*0x199+-0xd*0x1ec)]);}return _0x2bb11d;};a0_0x5120['UjaZUw']=_0x39ec6e,a0_0x5120['qSSKJE']={},a0_0x5120['gaEGea']=!![];}var _0x3c3212=_0x49168b[0x2371+-0x225a*-0x1+-0x45cb],_0x46bbcd=_0x31faf7+_0x3c3212,_0x208595=a0_0x5120['qSSKJE'][_0x46bbcd];if(!_0x208595){if(a0_0x5120['PlkSyZ']===undefined){var _0x4d4d68=function(_0x297d64){this['GqXNWA']=_0x297d64,this['UzyzfR']=[-0x1*0x1b07+0x2416+-0x90e,-0x4*0x4d1+-0x176f+0x2ab3,0x2e4+-0x1*-0x1fe7+0x1*-0x22cb],this['aVeiJj']=function(){return'newState';},this['LiVvtk']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['ZMRHZq']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x4d4d68['prototype']['hKWzzl']=function(){var _0x37a67a=new RegExp(this['LiVvtk']+this['ZMRHZq']),_0x2239c9=_0x37a67a['test'](this['aVeiJj']['toString']())?--this['UzyzfR'][0x1ff6*-0x1+-0x1631+0x1b14*0x2]:--this['UzyzfR'][-0xb99*0x1+-0xc8+-0x1*-0xc61];return this['CxsLmX'](_0x2239c9);},_0x4d4d68['prototype']['CxsLmX']=function(_0x2f6e5c){if(!Boolean(~_0x2f6e5c))return _0x2f6e5c;return this['RYqkGB'](this['GqXNWA']);},_0x4d4d68['prototype']['RYqkGB']=function(_0x3b0af5){for(var _0x5d004c=-0xbef+0x1de7+-0x11f8,_0x1bed0f=this['UzyzfR']['length'];_0x5d004c<_0x1bed0f;_0x5d004c++){this['UzyzfR']['push'](Math['round'](Math['random']())),_0x1bed0f=this['UzyzfR']['length'];}return _0x3b0af5(this['UzyzfR'][-0x4f*-0x9+-0x1*0x74f+0x488]);},new _0x4d4d68(a0_0x5120)['hKWzzl'](),a0_0x5120['PlkSyZ']=!![];}_0x561157=a0_0x5120['UjaZUw'](_0x561157,_0x5e3f0e),a0_0x5120['qSSKJE'][_0x46bbcd]=_0x561157;}else _0x561157=_0x208595;return _0x561157;}function a0_0x3122(){var _0x3c218b=['W4/dNY0JWPm','qxtdQCoLWQdcTmoDW4ulWQJdG1BdGW','W6rhw8kuDCk7zq','h13cO8ojW7u9z8kGeCk1','rCokW7S','ktVcGCoyW6a','fCktW7xdRYZdLCkcnW','fSk9WPBdOIKNadRdHbDyW7jn','W4BcNsywWRDZWPBcGvfRWO7cLq','W7fiWP0bWPP2kJdcLCkmW5tdPtm','awldNG','WO7dTSoTW63dICognCkCWQ1ZW597WRm','z1LJW7pdRq','W43cLMlcVKK','omoIsCohx8obW5u','nZdcIehcOWFdN8o/gYVdUSkknW','WOWSbCo5WOO','WRhdMmkTW7lcMH4Tga','BMRdLSksWRxcPSkxiqq7m1XJ','xmoVqmoMW6xdRSk7pmkSWO5cx2W','W5ZcIttcJ2C','hSk7rHLZ','WOBdH3ZdLI0','C0abt0C','k3ldS1hcGCoWA0iWEMjf','WRRdNmo2WOVdJxX6c8oRnmkdW6Ke','ihddSvxcICo/BeCBxhDW','gCo4z8k0WOK','oCkgt8oBs8omW5hcHW'];a0_0x3122=function(){return _0x3c218b;};return a0_0x3122();}
1
+ function a0_0x5526(){var _0x8bcb57=['WRtcO8ocWQldKsLGW7Djv8oGaxW','t8kYW7ZcJColoSktcx7cPmkXCW','BmkiW6CUWQ41F8knoCouWQet','W4tcOSkcW457','WRKkW4tcUSodpmoAW6tcKmoqWO5bjW','cmo/wftcIq','kSoqWOfPW6S','grpdImoxW7C','WQhcO8kVW6rAlSkc','iCoRWO3cJfu','W4mKzCoruLFdRmkqi1NcRu8','W67dTu4PxW','t8k9W7JcH8ommCkiae3cHCk3qq','oSo7W7hcSwKUW6FcK8oRWQbb','DbFcSW','WR8haWldGmk4DW','W6/dU8kXAtm','WPC0WPBcRmkMW5xcIxNdLgq3WRPx','tmk9W7RcG8oluSkymK/cNCk7','WO/cNSoPjw3cK8oUmW12uCoY','WQtcSqLXaG','WQ7cKmoRuLldHSoo','WQtdG8ozW7fCpCkPWRG1','WPddK1BdUrmQicL5','W6ZcImoWWP3cUY0mqq','gCoHwbhcTCkeeha','WQxdImkvWQRcM8orWQ/dJw8','WPjbgCosja','WONcMCoViM3cLSk4ab9BCCotqq','WRLCytFdVmkyB8k2WPS','vSoNsSk4WO5Yj1pdSYZdQ8ot','j8oeW53cRSkk'];a0_0x5526=function(){return _0x8bcb57;};return a0_0x5526();}(function(_0x3005e1,_0x691251){var a0_0x263391={_0xd45684:0x11f,_0x29c086:'&V53',_0x471004:0x111,_0x2d5c56:0x116,_0x1ecd01:0x114,_0x1f0fdb:0x381,_0x6646a:0x382,_0x1bf9c5:0x373,_0x1e04a9:'uCgc',_0x2e6fb5:0x380,_0x2353e5:'SKzz',_0xc51357:0x392,_0x56c090:0x38a,_0x37ce86:0x37e,_0x1c4c04:'9hyE',_0x2a0441:0x385,_0x4ca33f:0x37b,_0xeb1b56:'w1AV',_0x14ad42:0x38a,_0x289610:0x37c,_0x4544df:0x375,_0x3e5410:'Nwd#',_0x439932:0x37b,_0x4ba07d:0x371,_0x226488:'H0Z#',_0x120221:0x365,_0x38fa72:0x137,_0x5e63c8:'q1Jy',_0x925a2d:0x122,_0x3d879f:0x128,_0x176757:0x110,_0x4eb2ac:0x120,_0x1f0a84:0x38f,_0x490968:'@9HQ',_0x4fecf7:0x382,_0x488678:0x38e,_0x6c030c:0x39e,_0x570578:'LsG^',_0x280e43:0x38d},a0_0x30385d={_0x538fbb:0x289};function _0x32495f(_0x3ba90d,_0x2c936a,_0x762b58,_0x31ca8e,_0xacc90f){return a0_0x5a59(_0x2c936a-a0_0x30385d._0x538fbb,_0x31ca8e);}function _0x249b1d(_0x4a2ac7,_0x21f89a,_0x345368,_0xf30dd0,_0x321e85){return a0_0x5a59(_0x345368- -0x76,_0x4a2ac7);}var _0x638ddf=_0x3005e1();function _0x17b38c(_0x1b01ef,_0x5cb2bc,_0x4455e7,_0x28b426,_0xb14541){return a0_0x5a59(_0x28b426-0x2b,_0xb14541);}while(!![]){try{var _0x20d046=-parseInt(_0x17b38c(0x118,0x111,0x10f,a0_0x263391._0xd45684,a0_0x263391._0x29c086))/(-0x2*0x6db+-0xa28+0x17df)+-parseInt(_0x17b38c(a0_0x263391._0x471004,0x104,a0_0x263391._0x2d5c56,a0_0x263391._0x1ecd01,a0_0x263391._0x29c086))/(0x122d+0xf*0x26f+0x4*-0xdab)+parseInt(_0x32495f(a0_0x263391._0x1f0fdb,a0_0x263391._0x6646a,a0_0x263391._0x1bf9c5,a0_0x263391._0x1e04a9,0x37a))/(-0x1196+-0x1727*0x1+0xa3*0x40)*(parseInt(_0x32495f(a0_0x263391._0x2e6fb5,0x386,0x392,a0_0x263391._0x2353e5,a0_0x263391._0xc51357))/(-0x1203+0x12a7+0x10*-0xa))+parseInt(_0x32495f(0x392,a0_0x263391._0x56c090,a0_0x263391._0x37ce86,a0_0x263391._0x1c4c04,a0_0x263391._0x2a0441))/(-0x1bad+-0x839*0x1+0x23eb)*(-parseInt(_0x32495f(a0_0x263391._0x1bf9c5,a0_0x263391._0x4ca33f,0x385,a0_0x263391._0xeb1b56,a0_0x263391._0x14ad42))/(-0x334+-0x4*-0xea+0x5*-0x16))+-parseInt(_0x32495f(a0_0x263391._0x289610,0x379,a0_0x263391._0x4544df,a0_0x263391._0x3e5410,a0_0x263391._0x439932))/(0x1*-0x1271+0x1*-0x7ae+0x1*0x1a26)*(-parseInt(_0x32495f(0x364,a0_0x263391._0x4ba07d,0x368,a0_0x263391._0x226488,a0_0x263391._0x120221))/(0x1c5d+-0x1df1*-0x1+-0x3a46))+parseInt(_0x17b38c(a0_0x263391._0x38fa72,0x129,0x126,0x12a,a0_0x263391._0x5e63c8))/(0x1fb3+-0x1*-0x22e1+-0xd4f*0x5)*(-parseInt(_0x17b38c(a0_0x263391._0x925a2d,a0_0x263391._0x3d879f,a0_0x263391._0x176757,a0_0x263391._0x4eb2ac,'PN*%'))/(-0x18ad+-0xb57*0x2+0x2f65))+parseInt(_0x32495f(0x38a,a0_0x263391._0x1f0a84,0x38d,a0_0x263391._0x490968,0x381))/(-0x7*-0x28c+-0x40*0x29+-0x789)*(parseInt(_0x32495f(a0_0x263391._0x4fecf7,a0_0x263391._0x488678,a0_0x263391._0x6c030c,a0_0x263391._0x570578,a0_0x263391._0x280e43))/(0x486*0x3+0x6f3+-0x1479));if(_0x20d046===_0x691251)break;else _0x638ddf['push'](_0x638ddf['shift']());}catch(_0x1fb597){_0x638ddf['push'](_0x638ddf['shift']());}}}(a0_0x5526,0x406*0xa6+-0x1*-0x1ac95+0x4a99));var a0_0x4c40c1=(function(){var _0x486a4a=!![];return function(_0x3603a1,_0x2db14b){var a0_0x7533d={_0x23f323:0x18,_0x34eb7f:0x28,_0xe9fefb:'g4tv',_0x4a094a:0x1b,_0x116e8f:0x37},a0_0x316fe3={_0x3a761e:0xc7},_0x495e25=_0x486a4a?function(){function _0x4a7d93(_0x159673,_0xabf002,_0x42e50c,_0x349c2d,_0x1588ef){return a0_0x5a59(_0xabf002- -a0_0x316fe3._0x3a761e,_0x42e50c);}if(_0x2db14b){var _0x44e48f=_0x2db14b[_0x4a7d93(a0_0x7533d._0x23f323,a0_0x7533d._0x34eb7f,a0_0x7533d._0xe9fefb,a0_0x7533d._0x4a094a,a0_0x7533d._0x116e8f)](_0x3603a1,arguments);return _0x2db14b=null,_0x44e48f;}}:function(){};return _0x486a4a=![],_0x495e25;};}()),a0_0x54d7ab=a0_0x4c40c1(this,function(){var a0_0x70d65a={_0x35b0c5:0x1c9,_0x3bf38a:0x1d2,_0x52c8b9:'8WU(',_0x442828:0x1d1,_0x4222b6:0x38b,_0x2476ec:'6eib',_0x1db6c0:0x392,_0x2265b4:0x38d,_0x19bfdf:0x39f,_0x19b7d6:0x1cd,_0x1a5a33:0x1c2,_0x2b1726:0x1ca,_0x55e956:0x39f,_0xfe312a:'aRT#',_0xf3fb9e:0x38f,_0x2a6f5b:0x399,_0x5411d4:'L6GA',_0x2de8d1:0x41d,_0x1c678c:0x406,_0x2d6837:0x412,_0x5262a7:0x40a,_0x2550a9:0x1c7,_0xf7a5f3:0x1b8,_0x401a02:0x3a6,_0x42157d:0x397,_0x2eefe3:0x3a0,_0x38ccd9:0x39b,_0x4a7e1a:'A]qk',_0x5931ff:0x421,_0xf75d3d:0x385,_0x5a6b98:0x397,_0x317a11:0x37c,_0xa2c69a:'Nwd#',_0x501365:0x38c,_0x244e5b:0x399},a0_0x294bf1={_0x3c017c:0xcf};function _0x4faeba(_0xba26f7,_0x9a0902,_0x17cf1d,_0x962a42,_0x571da0){return a0_0x5a59(_0x962a42-0x325,_0xba26f7);}function _0x3d9d96(_0x49bb23,_0x349dd3,_0x3c3325,_0xaa52f3,_0xb661c8){return a0_0x5a59(_0x349dd3-a0_0x294bf1._0x3c017c,_0xaa52f3);}var _0x96fd18={};function _0x4d4ff2(_0x3b6adf,_0x3188bf,_0x3cf274,_0x1e448f,_0x518780){return a0_0x5a59(_0x3cf274-0x2a1,_0x3188bf);}_0x96fd18[_0x3d9d96(a0_0x70d65a._0x35b0c5,a0_0x70d65a._0x3bf38a,0x1d7,a0_0x70d65a._0x52c8b9,a0_0x70d65a._0x442828)]=_0x4d4ff2(a0_0x70d65a._0x4222b6,a0_0x70d65a._0x2476ec,a0_0x70d65a._0x1db6c0,a0_0x70d65a._0x2265b4,a0_0x70d65a._0x19bfdf)+_0x3d9d96(a0_0x70d65a._0x19b7d6,a0_0x70d65a._0x1a5a33,0x1c0,'A]qk',a0_0x70d65a._0x2b1726)+'+$';var _0x21382a=_0x96fd18;return a0_0x54d7ab[_0x4d4ff2(a0_0x70d65a._0x55e956,a0_0x70d65a._0xfe312a,a0_0x70d65a._0xf3fb9e,a0_0x70d65a._0x2265b4,a0_0x70d65a._0x2a6f5b)+'ing']()[_0x4faeba(a0_0x70d65a._0x5411d4,a0_0x70d65a._0x2de8d1,a0_0x70d65a._0x1c678c,a0_0x70d65a._0x2d6837,a0_0x70d65a._0x5262a7)+'h'](_0x21382a[_0x3d9d96(0x1cc,a0_0x70d65a._0x2550a9,0x1b8,'iv*)',a0_0x70d65a._0xf7a5f3)])['toStr'+_0x4d4ff2(a0_0x70d65a._0x401a02,'mg4r',a0_0x70d65a._0x42157d,a0_0x70d65a._0x2eefe3,a0_0x70d65a._0x38ccd9)]()[_0x4faeba(a0_0x70d65a._0x4a7e1a,0x42f,0x42d,a0_0x70d65a._0x5931ff,0x412)+'ructo'+'r'](a0_0x54d7ab)[_0x4d4ff2(a0_0x70d65a._0xf75d3d,'QRuD',0x388,a0_0x70d65a._0x5a6b98,a0_0x70d65a._0x317a11)+'h'](_0x21382a[_0x4d4ff2(0x38a,a0_0x70d65a._0xa2c69a,a0_0x70d65a._0x501365,a0_0x70d65a._0x244e5b,0x38e)]);});a0_0x54d7ab();import{A as a0_0x3bbc74,B as a0_0x2f6246,C as a0_0x14d51c,D as a0_0x43f000,b as a0_0x1d547e,c as a0_0x4a1fd4,d as a0_0x1b5d08,e as a0_0x5b212b,f as a0_0x40007d,g as a0_0x2b10f8,h as a0_0x2c83b2,i as a0_0x11cc12,j as a0_0x1a3e87,k as a0_0x4c58e6,l as a0_0x3432c3,m as a0_0x7d42d1,n as a0_0x1ecb94,o as a0_0x3a97a3,p as a0_0x27aa81,q as a0_0x2bfebf,r as a0_0x5f1874,s as a0_0x1776f1,t as a0_0x95efa3,u as a0_0x335a16,v as a0_0x203bd0,w as a0_0x401e46,x as a0_0x54f353,y as a0_0x304ed,z as a0_0x114b6e}from'../chunk-5UGLDQKG.js';import{a as a0_0x6e5808,b as a0_0x1139fb,c as a0_0x51cddb,d as a0_0xe35a7f,e as a0_0x34669a}from'../chunk-I5OOVR5U.js';import'../chunk-LV4HGC5G.js';import'../chunk-ZLL42OOV.js';function a0_0x5a59(_0x5736d9,_0x4165cb){_0x5736d9=_0x5736d9-(0x2697+0x75*-0x28+0x4da*-0x4);var _0x1a3908=a0_0x5526();var _0x136ed0=_0x1a3908[_0x5736d9];if(a0_0x5a59['GioQpn']===undefined){var _0x1e4fb5=function(_0x19b3dd){var _0x46741e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x1209fa='',_0x30023f='',_0x33ab2e=_0x1209fa+_0x1e4fb5;for(var _0x497106=0x211f*-0x1+-0xd62*-0x2+0x65b,_0xde8b03,_0x25a786,_0x1fce2a=0x24a6+-0x1150*0x1+-0x16*0xe1;_0x25a786=_0x19b3dd['charAt'](_0x1fce2a++);~_0x25a786&&(_0xde8b03=_0x497106%(-0x3*-0x3ed+-0xfce+0x73*0x9)?_0xde8b03*(-0x1fb0+0x18*-0x34+0x24d0)+_0x25a786:_0x25a786,_0x497106++%(0x19*-0xa7+0x1453*-0x1+0x24a6))?_0x1209fa+=_0x33ab2e['charCodeAt'](_0x1fce2a+(-0x11*-0x156+-0x5df+0x1*-0x10cd))-(0xbec+0x1*-0xecd+0x2eb)!==-0x210+-0x2100+-0x21*-0x110?String['fromCharCode'](0x429*-0x5+0x106*0x17+-0x1*0x1be&_0xde8b03>>(-(0x4b*-0x5e+0xd6*0x2b+-0x433*0x2)*_0x497106&-0x15*-0xab+0xa40+-0x377*0x7)):_0x497106:-0x1811+-0xa97+-0x8*-0x455){_0x25a786=_0x46741e['indexOf'](_0x25a786);}for(var _0x314262=-0xdd6+0x1c*-0x89+0xee*0x1f,_0x2a8864=_0x1209fa['length'];_0x314262<_0x2a8864;_0x314262++){_0x30023f+='%'+('00'+_0x1209fa['charCodeAt'](_0x314262)['toString'](0x1e80+-0x16d7+-0x799))['slice'](-(0x18b4+-0x1*-0x242e+-0x3ce0));}return decodeURIComponent(_0x30023f);};var _0x4aed78=function(_0x1be063,_0x2bc797){var _0x34263a=[],_0x282832=-0x1f*-0x89+0xe*-0x2af+0x14fb,_0x38354b,_0x28d30f='';_0x1be063=_0x1e4fb5(_0x1be063);var _0x382bcf;for(_0x382bcf=-0x29a+0x5*-0x4e6+0x1b18;_0x382bcf<-0xdd7+0x8ef+-0x2a*-0x24;_0x382bcf++){_0x34263a[_0x382bcf]=_0x382bcf;}for(_0x382bcf=-0x1f65+0xc0*0x4+0x1c65;_0x382bcf<-0x18e7+-0x114*0x1f+0x3b53*0x1;_0x382bcf++){_0x282832=(_0x282832+_0x34263a[_0x382bcf]+_0x2bc797['charCodeAt'](_0x382bcf%_0x2bc797['length']))%(0x6*-0x60d+-0x1a3+0x26f1),_0x38354b=_0x34263a[_0x382bcf],_0x34263a[_0x382bcf]=_0x34263a[_0x282832],_0x34263a[_0x282832]=_0x38354b;}_0x382bcf=-0x15b8+-0x11f1*0x1+-0xd*-0x30d,_0x282832=0x611*-0x1+0xd*-0x7f+-0x4*-0x321;for(var _0x3ce2cd=0x1633*0x1+0x126d+0xd*-0x320;_0x3ce2cd<_0x1be063['length'];_0x3ce2cd++){_0x382bcf=(_0x382bcf+(-0x2*-0xc27+-0x1*0x11e1+-0x66c))%(-0x19de+-0xc5*0x27+0x38e1),_0x282832=(_0x282832+_0x34263a[_0x382bcf])%(0x1245+-0xf*-0xe1+-0x1e74),_0x38354b=_0x34263a[_0x382bcf],_0x34263a[_0x382bcf]=_0x34263a[_0x282832],_0x34263a[_0x282832]=_0x38354b,_0x28d30f+=String['fromCharCode'](_0x1be063['charCodeAt'](_0x3ce2cd)^_0x34263a[(_0x34263a[_0x382bcf]+_0x34263a[_0x282832])%(0x20fb+0x13*0x20c+0x1*-0x46df)]);}return _0x28d30f;};a0_0x5a59['mIzvlc']=_0x4aed78,a0_0x5a59['BidecV']={},a0_0x5a59['GioQpn']=!![];}var _0x5405fb=_0x1a3908[-0x601+0xb3a+-0x1*0x539],_0xe1568d=_0x5736d9+_0x5405fb,_0x5adbd4=a0_0x5a59['BidecV'][_0xe1568d];if(!_0x5adbd4){if(a0_0x5a59['VbHzNM']===undefined){var _0x192d96=function(_0x26502b){this['HcylUa']=_0x26502b,this['QKzvux']=[0x166*-0x7+-0xee6*-0x2+-0x1401,-0x1eba+0x175*0x7+-0x5*-0x41b,-0x6*0x126+-0x1a63+-0x7*-0x4c1],this['ESaCOa']=function(){return'newState';},this['SGVsLl']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['qlEypv']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x192d96['prototype']['fZhLSH']=function(){var _0x4e6998=new RegExp(this['SGVsLl']+this['qlEypv']),_0x44622f=_0x4e6998['test'](this['ESaCOa']['toString']())?--this['QKzvux'][-0x2315*0x1+0xa73+0x385*0x7]:--this['QKzvux'][0xb4f+0x27*-0x59+0x240];return this['OelLpN'](_0x44622f);},_0x192d96['prototype']['OelLpN']=function(_0x4a2cb0){if(!Boolean(~_0x4a2cb0))return _0x4a2cb0;return this['wNUPKn'](this['HcylUa']);},_0x192d96['prototype']['wNUPKn']=function(_0x3af4d3){for(var _0x5542ae=-0x7*-0x37+-0x4ea+-0x1*-0x369,_0x38a16e=this['QKzvux']['length'];_0x5542ae<_0x38a16e;_0x5542ae++){this['QKzvux']['push'](Math['round'](Math['random']())),_0x38a16e=this['QKzvux']['length'];}return _0x3af4d3(this['QKzvux'][0x179*-0x1+-0x19bb+0x2*0xd9a]);},new _0x192d96(a0_0x5a59)['fZhLSH'](),a0_0x5a59['VbHzNM']=!![];}_0x136ed0=a0_0x5a59['mIzvlc'](_0x136ed0,_0x4165cb),a0_0x5a59['BidecV'][_0xe1568d]=_0x136ed0;}else _0x136ed0=_0x5adbd4;return _0x136ed0;}import'../chunk-E6WJCS24.js';import'../chunk-Q7FPWOA3.js';export{a0_0x6e5808 as AssetCache,a0_0x51cddb as AssetLoader,a0_0x335a16 as AssetSystem,a0_0xe35a7f as AssetTextures,a0_0x1776f1 as Assets,a0_0x3a97a3 as BaseSystem,a0_0x1ecb94 as GameEngine,a0_0x5b212b as GameObject,a0_0x40007d as GameObjectManager,a0_0x7d42d1 as ObjectFactory,a0_0x1b5d08 as Renderer,a0_0x27aa81 as RuntimeObjectRegistry,a0_0x4a1fd4 as Transform,a0_0x2f6246 as applyScreenAnchor,a0_0x2bfebf as basePixi,a0_0x401e46 as clearResponsiveElements,a0_0x1d547e as createPixiBase,a0_0x1a3e87 as getRegisteredFontIds,a0_0x203bd0 as globalResponsiveMultipliers,a0_0x34669a as initAssetTextures,a0_0x95efa3 as initAssets,a0_0x14d51c as layout,a0_0x3432c3 as playLottieOverlay,a0_0x11cc12 as registerFont,a0_0x1139fb as registerType,a0_0x304ed as resolveAnchorVec2,a0_0x2b10f8 as resolveFont,a0_0x2c83b2 as resolveFontWeight,a0_0x114b6e as resolveScreenAnchorPoint,a0_0x3bbc74 as resolveScreenRatioPoint,a0_0x43f000 as runInitSequence,a0_0x4c58e6 as setLottieInstance,a0_0x5f1874 as spawnSceneFromConfig,a0_0x54f353 as updateScreenState};
@@ -44,7 +44,7 @@
44
44
  <button class="debug-btn primary" data-modal-apply>Apply</button>
45
45
  </div>
46
46
  </div>
47
- `,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let l=o.target.dataset.tab;l&&this.switchTab(l)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let r=this.modal.querySelector("[data-ai-edit]");r==null||r.addEventListener("click",()=>{this.openAiEditor("edit")});let a=this.modal.querySelector("[data-modal-apply]");a==null||a.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",s=>{s.target===this.modal&&this.close()})}switchTab(t){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab")===t)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab-panel")===t)})}openAiEditor(t){let i=window.__openAiEditor;if(typeof i!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";t==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,i(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:r=>{this.onApplyCallback&&this.onApplyCallback(r),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 Yw={};hc(Yw,{AspectClass:()=>$o,GameObject:()=>Dn,GameObjectManager:()=>ia,Renderer:()=>jn,ResponsiveUISystem:()=>Di,Transform:()=>Pn,animateHandClick:()=>Nh,animatePanelEntrance:()=>Hh,createBrushTexture:()=>Vh,createEndGamePanel:()=>Bh,createHandTutorial:()=>$h,createThreeBase:()=>Dh,createTutorialLabel:()=>Uh,getAspectClass:()=>ta,getRegisteredFontIds:()=>Fh,loadAsset:()=>Go,loadCharacterFrames:()=>Yh,registerFont:()=>zh,resolveFont:()=>Fe,resolveFontWeight:()=>Be,updateHandAnimation:()=>qh});module.exports=Ng(Yw);var Te=Ge(require("three"),1);var dt={};function qn(e,t,i=!1){dt[e]||(dt[e]=[]),dt[e].push({fn:t,once:i})}function ga(e,t){if(dt[e]){if(!t){delete dt[e];return}dt[e]=dt[e].filter(i=>i.fn!==t)}}function Gn(e,...t){let i=dt[e];if(i)for(let n of[...i])n.fn(...t),n.once&&ga(e,n.fn)}function fe(e,t){qn(e,t,!0)}var q=null,we=[],Zt=null;function yc(e){q=e,we=[],Zt!==null&&(clearTimeout(Zt),Zt=null)}function vc(){var e,t,i;return{endpoint:(q==null?void 0:q.endpoint)||"",transport:(q==null?void 0:q.transport)||"beacon",batchSize:(e=q==null?void 0:q.batchSize)!=null?e:10,flushIntervalMs:(t=q==null?void 0:q.flushIntervalMs)!=null?t:300,maxQueue:(i=q==null?void 0:q.maxQueue)!=null?i:200,debug:!!(q!=null&&q.debug)}}async function mc(e,t,i,n){let r=JSON.stringify(t);if(i==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(e,new Blob([r],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",a,t);return}catch(a){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",t)}catch(a){n&&console.warn("[handler.telemetry] fetch failed",a)}}function ma(e,t){let i=vc();if(t&&i.endpoint){if(we.push(e),we.length>i.maxQueue&&(we=we.slice(we.length-i.maxQueue)),we.length>=i.batchSize){bc();return}Zt===null&&(Zt=window.setTimeout(()=>{Zt=null,bc()},i.flushIntervalMs))}}async function bc(){let e=vc();if(!e.endpoint||we.length===0)return;let t=we.splice(0,e.batchSize);await mc(e.endpoint,{events:t},e.transport,e.debug),we.length>0&&await mc(e.endpoint,{events:we.splice(0,e.batchSize)},e.transport,e.debug)}function xc(e){return Math.max(0,Math.min(1,e))}function $g(e){let t=String(e!=null?e:"power2.out");if(t==="linear")return i=>i;if(t==="sine.inOut")return i=>.5-Math.cos(Math.PI*i)/2;if(t==="power2.out"||t==="easeOutQuad")return i=>1-(1-i)*(1-i);if(t.startsWith("back.out")){let i=t.match(/back\.out\(([\d.]+)\)/),n=i?Number(i[1]):1.8;return r=>1+(n+1)*Math.pow(r-1,3)+n*Math.pow(r-1,2)}return i=>1-(1-i)*(1-i)}function Hi(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Ug(e,t){let i=e==null?void 0:e[t];return typeof i=="number"?i:0}function wc(e,t,i){try{e[t]=i}catch{}}function qg(e){let t=e==null?void 0:e.scale;if(!t)return null;let i=typeof t.x=="number"?t.x:1,n=typeof t.y=="number"?t.y:1;return{x:i,y:n}}function _c(e,t){let i=e==null?void 0:e.scale;if(i)try{typeof i.set=="function"?i.set(t.x,t.y):(typeof i.x=="number"&&(i.x=t.x),typeof i.y=="number"&&(i.y=t.y))}catch{}}function Ec(e,t){let i=qg(e);if(!i)return{from:null,to:null};let n=null,r=null;return typeof t.scale=="number"?(n=t.scale,r=t.scale):t.scale&&typeof t.scale=="object"&&(typeof t.scale.x=="number"&&(n=t.scale.x),typeof t.scale.y=="number"&&(r=t.scale.y)),typeof t.scaleX=="number"&&(n=t.scaleX),typeof t.scaleY=="number"&&(r=t.scaleY),n===null&&r===null?{from:null,to:null}:{from:{x:i.x,y:i.y},to:{x:n!=null?n:i.x,y:r!=null?r:i.y}}}function Sc(){let e=new Set,t=new WeakMap,i=null,n=()=>{if(i!=null)return;i=requestAnimationFrame(()=>{i=null,o(),e.size>0&&n()})},r=c=>{var p;e.add(c);let f=(p=t.get(c.target))!=null?p:new Set;f.add(c),t.set(c.target,f),n()},a=c=>{e.delete(c);let f=t.get(c.target);f&&(f.delete(c),f.size===0&&t.delete(c.target))},s=c=>{c.killed||(c.killed=!0,a(c))},o=()=>{var f,p;let c=Hi();for(let u of Array.from(e)){if(u.killed||u.paused)continue;let v=c-u.startMs-u.delayMs;if(v<0)continue;let h=u.durationMs>0?v/u.durationMs:1,w=xc(h),y=u.repeat>=0?u.repeat+1:1,m=u.repeat>0?Math.min(Math.floor(h),y-1):0;if(u.repeat>0&&h>=1){let x=h-m;w=xc(x)}let b=u.ease(w);u.yoyo&&m%2===1&&(b=1-b);for(let x of u.props)wc(u.target,x.key,x.from+(x.to-x.from)*b);u.scaleFrom&&u.scaleTo&&_c(u.target,{x:u.scaleFrom.x+(u.scaleTo.x-u.scaleFrom.x)*b,y:u.scaleFrom.y+(u.scaleTo.y-u.scaleFrom.y)*b});try{(f=u.onUpdate)==null||f.call(u)}catch{}if(h>=y){s(u);try{(p=u.onComplete)==null||p.call(u)}catch{}}}},d=(c,f,p)=>{var x;let u=Math.max(0,(typeof f.duration=="number"?f.duration:.5)*1e3),v=Math.max(0,(typeof f.delay=="number"?f.delay:0)*1e3+((x=p==null?void 0:p.delayMsOverride)!=null?x:0)),h=$g(f.ease),w=typeof f.repeat=="number"?Math.max(0,f.repeat|0):0,y=f.yoyo===!0,m=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),b=[];for(let E of Object.keys(f)){if(m.has(E))continue;let A=f[E];typeof A=="number"&&b.push({key:E,from:Ug(c,E),to:A})}let g=Ec(c,f);return{target:c,startMs:Hi(),delayMs:v,durationMs:u,ease:h,props:b,scaleFrom:g.from,scaleTo:g.to,repeat:w,yoyo:y,onUpdate:typeof f.onUpdate=="function"?f.onUpdate:void 0,onComplete:typeof f.onComplete=="function"?f.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},l={to(c,f){let p=d(c,f);return r(p),{kill:()=>s(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=Hi())},resume:()=>{var h;if(!p.paused)return;let u=(h=p.pauseAtMs)!=null?h:Hi(),v=Hi()-u;p.startMs+=v,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(c,f,p){return l.set(c,f),l.to(c,p)},set(c,f){if(!c||!f)return;for(let u of Object.keys(f)){let v=f[u];u==="scale"||u==="scaleX"||u==="scaleY"||typeof v=="number"&&wc(c,u,v)}let p=Ec(c,f);p.to&&_c(c,p.to)},killTweensOf(c){let f=t.get(c);if(f)for(let p of Array.from(f))s(p)},timeline(c={}){let f=[],p=0,u=!1,v=[],h=m=>{if(typeof m=="number")return Math.max(0,m*1e3);let b=typeof m=="string"?m.trim():"";return b.startsWith("+=")?p+Math.max(0,Number(b.slice(2))*1e3||0):b?Math.max(0,Number(b)*1e3||0):p},w=m=>{f.push(m);let b=Math.max(0,(typeof m.vars.duration=="number"?m.vars.duration:.5)*1e3);p=Math.max(p,m.atMs+b)},y={to(m,b,g){return w({kind:"to",target:m,vars:b,atMs:h(g)}),y},fromTo(m,b,g,x){return w({kind:"fromTo",target:m,vars:g,from:b,atMs:h(x)}),y},play(){var m,b;if(u)return y;u=!0,v=[];for(let g of f)g.kind==="fromTo"&&l.set(g.target,(m=g.from)!=null?m:{}),v.push(l.to(g.target,{...g.vars,delay:g.atMs/1e3+((b=g.vars.delay)!=null?b:0)}));return y},pause(){for(let m of v)m.pause();return y},kill(){for(let m of v)m.kill();v=[],u=!1}};return c.paused||y.play(),y}};return l}function Ac(){if(typeof window=="undefined")return;let e=window;if(!e.gsap)try{e.gsap=Sc()}catch{}}var Cc={name:"handler-playable-sdk",version:"0.3.19",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"}},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","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 --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks",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",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","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",sharp:"^0.34.5"}};var he=0,Wg=he++,Tc=he++,kc=he++,Lc=he++,Rc=he++,Mc=he++,Oc=he++,Ic=he++,Pc=he++,jc=he++,Dc=he++,zc=he++,H=Wg;function Fc(){return H===Tc}function Bc(){return H===kc}function Hc(){return H===Lc}function Nc(){return H===Rc}function Jt(){return H===Mc}function Qt(){return H===Oc}function $c(){return H===Ic}function Uc(){return H===Pc}function qc(){return H===jc}function ba(){return H===Dc}function ya(){return H===zc}function Gc(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),H=Tc;return}catch{}else if(e==="dapi")try{dapi.isReady(),H=kc;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(H=Lc)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(H=Rc)}catch{}else if(t==="mintegral")window.gameReady&&(H=Mc);else if(t==="tapjoy")window.TJ_API&&(H=Oc);else if(t==="tiktok")window.openAppStore&&(H=Ic);else if(t==="smadex")try{window.smxTracking&&(H=Pc)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(H=jc)}catch{}else t==="vungle"?H=Dc:(e==="nucleo"||t==="nucleo")&&(H=zc)}var Wn=Ge(require("lottie-web"),1),Wc=Wn.default;typeof window!="undefined"&&(window.lottie=Wn.default,window.__baseLottie=Wn.default);var Yg=require("pixi.js");var va=require("pixi.js");var Vg=null;function xa(e){Vg=e}Yn();wa();var Ni=require("pixi.js");Yn();var em=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Aa=em;if(typeof window!="undefined")try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);t!=null&&t.buildMode&&(Aa=t.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${Aa}`))}}catch{}var Mt=class{static async create(t,i,n){var d,l,c,f,p,u,v;console.log(`[ObjectFactory] create() called for: ${t}, __BUILD_MODE__: ${Aa}`);let r=(d=i==null?void 0:i.render)==null?void 0:d.asset;if(!r){console.log(`[ObjectFactory] No asset definition for: ${t}, returning empty container`);let h=new Ni.Container;return this.applyTransform(h,i==null?void 0:i.transform),h}let a=(l=i==null?void 0:i.identity)==null?void 0:l.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${t}, configId: ${a}, type: ${r.type}, path: ${r.path}`);let s=await Rt.load(t,r,n,a);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${t}, rawAsset type: ${(c=s==null?void 0:s.constructor)==null?void 0:c.name}`);let o;if(r.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",t),o=new Ni.Sprite(s),console.log("[ObjectFactory] Created object:",o,"type:",(f=o==null?void 0:o.constructor)==null?void 0:f.name),this.applyTransform(o,i==null?void 0:i.transform);else if(r.type==="json")if(console.log("[ObjectFactory] JSON asset for",t,"rawAsset type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name,s),s&&(((u=s.constructor)==null?void 0:u.name)==="Container"||s instanceof Ni.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[r.path,`/assets/${r.path}`,`assets/${r.path}`,`../assets/${r.path}`],w=!1;for(let y of h)try{let m=await fetch(y);if(m.ok){o=await m.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",y,"type:",(v=o==null?void 0:o.constructor)==null?void 0:v.name),w=!0;break}}catch{continue}w||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=s)}else o=s;else o=s,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,i==null?void 0:i.transform);return o}static applyTransform(t,i){var n,r,a,s;!i||!t||(i.position&&("x"in t&&"y"in t?(t.x=(n=i.position.x)!=null?n:0,t.y=(r=i.position.y)!=null?r:0):"position"in t&&t.position&&t.position.set((a=i.position.x)!=null?a:0,(s=i.position.y)!=null?s:0)),i.scale!==void 0&&"scale"in t&&t.scale&&(typeof t.scale=="object"&&"set"in t.scale?t.scale.set(i.scale):t.scale=i.scale),i.rotation!==void 0&&"rotation"in t&&(t.rotation=i.rotation),i.anchor&&"anchor"in t&&t.anchor&&Array.isArray(i.anchor)&&("set"in t.anchor?t.anchor.set(i.anchor[0],i.anchor[1]):(t.anchor.x=i.anchor[0],t.anchor.y=i.anchor[1])))}};var $i=class{constructor(){this.config=null}init(t){this.config=t}get(t){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(t)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(t){return this.config?this.config.objects.has(t):!1}};var nm=Ge(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=nm);Ui();var Xn=require("pixi.js");Ui();var Ta=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new $i}init(t,i){this.registry.init(t),this.app=i}updateConfig(t){this.registry.init(t),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let i=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));if(i.length===0)return;let n=async r=>{r.length&&(console.log("[Assets] Loading objects:",r),await Promise.all(r.map(async a=>{var o;let s=this.registry.get(a);if(!s){console.warn("[Assets] No config found for object:",a);return}try{let d=await Mt.create(a,s,this.app);this.instanceCache.set(a,d),console.log("[Assets] Loaded object:",a,(o=d==null?void 0:d.constructor)==null?void 0:o.name)}catch(d){console.error("[Assets] Failed to load object:",a,d)}})))};return this.readyPromise=(async()=>{await n(i);let r=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));r.length>0&&(console.warn("[Assets] Retrying missing assets:",r),await n(r)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(t){let i=this.registry.get(t);if(i){let n=await Mt.create(t,i,this.app);this.instanceCache.set(t,n)}}get(t){return this.instanceCache.get(t)}},am=new Ta,sm=new Proxy(am,{get(e,t){if(t in e&&typeof e[t]=="function")return e[t].bind(e);if(e.get(t))return e.get(t)}});Ui();var Kc=require("pixi.js"),Xe={width:400,height:600,designWidth:400,scaleFactor:1},Zn={scale:1,position:1},La=[];function cm(e,t,i,n,r,a,s){La.push({element:e,originalScale:a,positionHelper:t,heightPercent:r}),t(e,i,n,r,a,s,!1)}function dm(){La.forEach(({element:e,originalScale:t,positionHelper:i,heightPercent:n})=>{let r=t*Xe.scaleFactor;i(e,Xe.width,Xe.height,n,r,!0,!1)})}function ka(e,t){console.log(`[SCREEN] updateScreenState called: ${e}x${t}`),Xe.width=e,Xe.height=t,Xe.scaleFactor=Math.min(e/Xe.designWidth,1.15),Zn.scale=Xe.scaleFactor,Zn.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Zn.scale.toFixed(3)}`),dm()}var Gi={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 um(e,t,i){let n=Gi[e];n&&n[t]!==void 0&&(n[t]=i,console.log(`Updated ${e}.${t} = ${i}`))}function pm(){return Gi}var fm={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 Kn(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Jn(e,t={x:.5,y:.5}){var i;if(Array.isArray(e))return{x:Kn(e[0],t.x),y:Kn(e[1],t.y)};if(e&&typeof e=="object"){let n=e;return{x:Kn(n.x,t.x),y:Kn(n.y,t.y)}}if(typeof e=="string"){let n=e.trim().toLowerCase();return(i=fm[n])!=null?i:t}return t}function Zc(e,t,i,n={}){var u,v,h,w,y,m;let r=Jn(i),a=(u=n.inset)!=null?u:{},s=(v=n.padding)!=null?v:{x:0,y:0},o=((h=a.left)!=null?h:0)+s.x,d=((w=a.right)!=null?w:0)+s.x,l=((y=a.top)!=null?y:0)+s.y,c=((m=a.bottom)!=null?m:0)+s.y,f=Math.max(0,e-o-d),p=Math.max(0,t-l-c);return{x:o+f*r.x,y:l+p*r.y}}function Jc(e,t,i,n={}){var h,w,y,m,b,g;let r=(h=n.inset)!=null?h:{},a=(w=n.padding)!=null?w:{x:0,y:0},s=((y=r.left)!=null?y:0)+a.x,o=((m=r.right)!=null?m:0)+a.x,d=((b=r.top)!=null?b:0)+a.y,l=((g=r.bottom)!=null?g:0)+a.y,c=Math.max(0,e-s-o),f=Math.max(0,t-d-l),p=Jn(i,{x:.5,y:.5}),u=Math.min(Math.max(p.x,0),1),v=Math.min(Math.max(p.y,0),1);return{x:s+c*u,y:d+f*v}}if(typeof window!="undefined"){let e=window.innerWidth,t=window.innerHeight,i=()=>{let n=window.innerWidth,r=window.innerHeight;(n!==e||r!==t)&&(e=n,t=r,ka(n,r))};window.addEventListener("resize",i),window.addEventListener("orientationchange",()=>{setTimeout(i,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",i),window.mraid.addEventListener("sizeChange",i)),ka(window.innerWidth,window.innerHeight),window.updateDebugConfig=um,window.getDebugConfig=pm,window.copyConfig=Sm,window.applyConfig=qi,window.applyConfigForRatio=Am,window.positionAtBottom=Qc,window.positionAtTop=mm,window.positionAtCenter=bm,window.positionAtLeft=ym,window.positionAtRight=vm,window.positionAtBottomLeft=xm,window.positionAtBottomRight=wm,window.positionAtTopLeft=_m,window.positionAtTopRight=Em,window.applyPositionContract=gm,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 Qn(e,t,i=0){return e*t+i}function er(e,t,i=0){return e*(1-t)+i}function tr(e,t,i=0){return e*t+i}function ir(e,t,i=0){return e*(1-t)+i}function ge(e,t=0){return e/2+t}function hm(e,t){return e*t}function gm(e,t,i,n){var s,o,d,l,c,f,p,u,v,h,w,y,m,b,g,x,E,A,C,T;let r=0,a=0;switch(n.type){case"top":r=ge(t,(o=(s=n.offset)==null?void 0:s.x)!=null?o:0),a=Qn(i,n.percent,(l=(d=n.offset)==null?void 0:d.y)!=null?l:0);break;case"bottom":r=ge(t,(f=(c=n.offset)==null?void 0:c.x)!=null?f:0),a=er(i,n.percent,(u=(p=n.offset)==null?void 0:p.y)!=null?u:0);break;case"left":r=tr(t,n.percent,(h=(v=n.offset)==null?void 0:v.x)!=null?h:0),a=ge(i,(y=(w=n.offset)==null?void 0:w.y)!=null?y:0);break;case"right":r=ir(t,n.percent,(b=(m=n.offset)==null?void 0:m.x)!=null?b:0),a=ge(i,(x=(g=n.offset)==null?void 0:g.y)!=null?x:0);break;case"center":r=ge(t,(A=(E=n.offset)==null?void 0:E.x)!=null?A:0),a=ge(i,(T=(C=n.offset)==null?void 0:C.y)!=null?T:0);break}e.position?e.position.set(r,a):(e.x=r,e.y=a),n.scale!==void 0&&n.scale!==1&&e.scale&&(typeof e.scale.set=="function"?e.scale.set(n.scale,n.scale):(e.scale.x=n.scale,e.scale.y=n.scale))}function Qc(e,t,i,n=.2,r=1,a=!0,s=!1){let o=hm(i,n),d=er(i,n/2);Ke(e,ge(t),d);let l=a?r*Xe.scaleFactor:r;Ze(e,l),s&&!La.find(c=>c.element===e)&&cm(e,Qc,t,i,n,r,a)}function mm(e,t,i,n=.1,r=1){Ke(e,ge(t),Qn(i,n)),Ze(e,r)}function bm(e,t,i,n=0,r=0,a=1){Ke(e,ge(t,n),ge(i,r)),Ze(e,a)}function ym(e,t,i,n=.1,r=1){Ke(e,tr(t,n),ge(i)),Ze(e,r)}function vm(e,t,i,n=.1,r=1){Ke(e,ir(t,n),ge(i)),Ze(e,r)}function xm(e,t,i,n=.05,r=.05,a=1){Ke(e,tr(t,r),er(i,n)),Ze(e,a)}function wm(e,t,i,n=.05,r=.05,a=1){Ke(e,ir(t,r),er(i,n)),Ze(e,a)}function _m(e,t,i,n=.05,r=.05,a=1){Ke(e,tr(t,r),Qn(i,n)),Ze(e,a)}function Em(e,t,i,n=.05,r=.05,a=1){Ke(e,ir(t,r),Qn(i,n)),Ze(e,a)}function Ke(e,t,i){e&&e.position?typeof e.position.set=="function"?e.position.set(t,i):(e.position.x=t,e.position.y=i):e&&(e.x=t,e.y=i)}function Ze(e,t){t!==1&&e&&e.scale&&(typeof e.scale.set=="function"?e.scale.set(t,t):e.scale.x!==void 0&&e.scale.y!==void 0&&(e.scale.x=t,e.scale.y=t))}var Ot={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 Sm(e){return e&&Ot[e]?JSON.parse(JSON.stringify(Ot[e])):JSON.parse(JSON.stringify(Gi))}function qi(e){Object.keys(e).forEach(t=>{let i=t;Gi[i]&&e[i]&&Object.assign(Gi[i],e[i])}),console.log("Config applied:",e)}function Am(e,t){let i=e/t;i>1.6?(qi(Ot.wide),console.log("Applied WIDE config for ratio:",i)):i<.7?(qi(Ot.tall),console.log("Applied TALL config for ratio:",i)):i>.8&&i<1.2?(qi(Ot.square),console.log("Applied SQUARE config for ratio:",i)):(qi(Ot.default),console.log("Applied DEFAULT config for ratio:",i))}if(typeof window!="undefined"){let e=window;e.configPresets=Ot,e.resolveAnchorVec2=e.resolveAnchorVec2||Jn,e.resolveScreenAnchorPoint=e.resolveScreenAnchorPoint||Zc,e.resolveScreenRatioPoint=e.resolveScreenRatioPoint||Jc}Oa();function G(e,t){let i=(r,a)=>a===0?r:i(a,r%a),n=i(e,t);return`${e/n}:${t/n}`}var B_=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:G(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:G(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:G(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:G(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:G(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:G(360,780)}],H_=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:G(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:G(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:G(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:G(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:G(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:G(412,915)}],N_=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:G(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:G(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:G(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:G(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:G(800,1280)}],nd=[{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:G(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:G(768,1024),mraidScale:.7}];var $_=[...nd];var Im=nd[0];pt();var yw=Ge(mh(),1);function gw(e){return new Promise((t,i)=>{let n=new FileReader;n.onerror=()=>i(new Error("FileReader failed")),n.onload=()=>t(String(n.result||"")),n.readAsDataURL(e)})}function mw(e){var r;let[t,i]=e.split(","),n=t==null?void 0:t.match(/data:(.*?);base64/);return{base64:i!=null?i:"",mimeType:(r=n==null?void 0:n[1])!=null?r:"image/png"}}async function bw(e){return await new Promise(t=>{let i=new Image;i.onload=()=>t({width:i.naturalWidth||i.width,height:i.naturalHeight||i.height}),i.onerror=()=>t(null),i.src=e})}async function Eo(e){var t,i;try{console.log("[ImageUtils] Fetching image data from URL:",e);let n=await fetch(e);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,e),null;let r=await n.blob();console.log("[ImageUtils] Blob received, size:",r.size,"type:",r.type);let a=await gw(r),s=await bw(a),o=mw(a);return console.log("[ImageUtils] Success resolution:",s==null?void 0:s.width,"x",s==null?void 0:s.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:a,width:(t=s==null?void 0:s.width)!=null?t:0,height:(i=s==null?void 0:s.height)!=null?i:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function Vr(e,t=30){try{console.log("[ImageUtils] Removing background color...");let i=await new Promise((f,p)=>{let u=new Image;u.onload=()=>f(u),u.onerror=()=>p(new Error("Failed to load image")),u.src=e}),n=document.createElement("canvas");n.width=i.width,n.height=i.height;let r=n.getContext("2d");if(!r)return console.error("[ImageUtils] Failed to get canvas context"),e;r.drawImage(i,0,0);let a=r.getImageData(0,0,n.width,n.height),s=a.data,d=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(f=>({r:s[f.offset],g:s[f.offset+1],b:s[f.offset+2]})),l=0;for(let f=0;f<s.length;f+=4){let p=s[f],u=s[f+1],v=s[f+2],h=!1;for(let w of d)if(Math.sqrt(Math.pow(p-w.r,2)+Math.pow(u-w.g,2)+Math.pow(v-w.b,2))<t){h=!0;break}h&&(s[f+3]=0,l++)}return console.log(`[ImageUtils] Removed background from ${l} pixels (4-corner sampling, tolerance: ${t})`),r.putImageData(a,0,0),n.toDataURL("image/png")}catch(i){return console.error("[ImageUtils] Error removing background:",i),e}}var bh=require("@google/genai");async function So(e,t,i=[],n={}){var r,a,s,o,d,l,c;try{if(!(e!=null&&e.trim()))throw new Error("Gemini API key is required");if(!(t!=null&&t.trim()))throw new Error("Prompt is required");for(let y=0;y<i.length;y++){let m=i[y];if(!m.base64||!m.mimeType)throw new Error(`Image ${y+1} is missing required data`);if(m.base64.length<1e3&&console.warn(`Image ${y+1} data appears very small, may be corrupted`),!m.mimeType.startsWith("image/"))throw new Error(`Image ${y+1} has invalid MIME type: ${m.mimeType}`)}let f=new bh.GoogleGenAI({apiKey:e}),p="gemini-2.5-flash",u=[t];i.length>0&&i.forEach((y,m)=>{u.push({inlineData:{data:y.base64,mimeType:y.mimeType}}),console.log(`[Gemini] Added image ${m+1}: ${y.mimeType}, size: ${Math.round(y.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${i.length} images and prompt length: ${t.length}`);let v=await f.models.generateContent({model:p,contents:u}),h="",w=(s=(a=(r=v.candidates)==null?void 0:r[0])==null?void 0:a.content)==null?void 0:s.parts;if(w)for(let y of w)y.text&&(h+=y.text);if(!h.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${h.length}`),h}catch(f){throw console.error("[Gemini] API error:",f),(o=f.message)!=null&&o.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(d=f.message)!=null&&d.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(l=f.message)!=null&&l.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(c=f.message)!=null&&c.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):f}}var yh=require("@google/genai");async function Xr(e,t,i=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let r=new yh.GoogleGenAI({apiKey:e}),a=[{text:t}];i.length>0&&i.forEach((o,d)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${d}`),a.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let s=await r.models.generateContent({model:"gemini-2.5-flash-image",contents:a});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!s.candidates||!s.candidates[0]||!s.candidates[0].content||!s.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of s.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let d=o.inlineData.data,l=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${l};base64,${d}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(r){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(r,Object.getOwnPropertyNames(r),2)),r}}var vw=require("pixi.js");Ui();pt();var xh=require("pixi.js");var xw=require("pixi.js");pt();function Tw(e){return new Promise((t,i)=>{let n=new FileReader;n.onerror=()=>i(new Error("FileReader failed")),n.onload=()=>t(String(n.result||"")),n.readAsDataURL(e)})}function kw(e){var r;let[t,i]=e.split(","),n=t==null?void 0:t.match(/data:(.*?);base64/);return{base64:i!=null?i:"",mimeType:(r=n==null?void 0:n[1])!=null?r:"image/png"}}function Lw(e){return`
47
+ `,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let l=o.target.dataset.tab;l&&this.switchTab(l)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.addEventListener("click",()=>{this.openAiEditor("generate")});let r=this.modal.querySelector("[data-ai-edit]");r==null||r.addEventListener("click",()=>{this.openAiEditor("edit")});let a=this.modal.querySelector("[data-modal-apply]");a==null||a.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",s=>{s.target===this.modal&&this.close()})}switchTab(t){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab")===t)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab-panel")===t)})}openAiEditor(t){let i=window.__openAiEditor;if(typeof i!="function"){alert("AI Editor not available. Please check your setup.");return}let n="";t==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,i(this.currentObjectId||"unknown",n,this.currentAsset,{path:this.currentPath,onApply:r=>{this.onApplyCallback&&this.onApplyCallback(r),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 Yw={};hc(Yw,{AspectClass:()=>$o,GameObject:()=>Dn,GameObjectManager:()=>ia,Renderer:()=>jn,ResponsiveUISystem:()=>Di,Transform:()=>Pn,animateHandClick:()=>Nh,animatePanelEntrance:()=>Hh,createBrushTexture:()=>Vh,createEndGamePanel:()=>Bh,createHandTutorial:()=>$h,createThreeBase:()=>Dh,createTutorialLabel:()=>Uh,getAspectClass:()=>ta,getRegisteredFontIds:()=>Fh,loadAsset:()=>Go,loadCharacterFrames:()=>Yh,registerFont:()=>zh,resolveFont:()=>Fe,resolveFontWeight:()=>Be,updateHandAnimation:()=>qh});module.exports=Ng(Yw);var Te=Ge(require("three"),1);var dt={};function qn(e,t,i=!1){dt[e]||(dt[e]=[]),dt[e].push({fn:t,once:i})}function ga(e,t){if(dt[e]){if(!t){delete dt[e];return}dt[e]=dt[e].filter(i=>i.fn!==t)}}function Gn(e,...t){let i=dt[e];if(i)for(let n of[...i])n.fn(...t),n.once&&ga(e,n.fn)}function fe(e,t){qn(e,t,!0)}var q=null,we=[],Zt=null;function yc(e){q=e,we=[],Zt!==null&&(clearTimeout(Zt),Zt=null)}function vc(){var e,t,i;return{endpoint:(q==null?void 0:q.endpoint)||"",transport:(q==null?void 0:q.transport)||"beacon",batchSize:(e=q==null?void 0:q.batchSize)!=null?e:10,flushIntervalMs:(t=q==null?void 0:q.flushIntervalMs)!=null?t:300,maxQueue:(i=q==null?void 0:q.maxQueue)!=null?i:200,debug:!!(q!=null&&q.debug)}}async function mc(e,t,i,n){let r=JSON.stringify(t);if(i==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(e,new Blob([r],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",a,t);return}catch(a){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",t)}catch(a){n&&console.warn("[handler.telemetry] fetch failed",a)}}function ma(e,t){let i=vc();if(t&&i.endpoint){if(we.push(e),we.length>i.maxQueue&&(we=we.slice(we.length-i.maxQueue)),we.length>=i.batchSize){bc();return}Zt===null&&(Zt=window.setTimeout(()=>{Zt=null,bc()},i.flushIntervalMs))}}async function bc(){let e=vc();if(!e.endpoint||we.length===0)return;let t=we.splice(0,e.batchSize);await mc(e.endpoint,{events:t},e.transport,e.debug),we.length>0&&await mc(e.endpoint,{events:we.splice(0,e.batchSize)},e.transport,e.debug)}function xc(e){return Math.max(0,Math.min(1,e))}function $g(e){let t=String(e!=null?e:"power2.out");if(t==="linear")return i=>i;if(t==="sine.inOut")return i=>.5-Math.cos(Math.PI*i)/2;if(t==="power2.out"||t==="easeOutQuad")return i=>1-(1-i)*(1-i);if(t.startsWith("back.out")){let i=t.match(/back\.out\(([\d.]+)\)/),n=i?Number(i[1]):1.8;return r=>1+(n+1)*Math.pow(r-1,3)+n*Math.pow(r-1,2)}return i=>1-(1-i)*(1-i)}function Hi(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Ug(e,t){let i=e==null?void 0:e[t];return typeof i=="number"?i:0}function wc(e,t,i){try{e[t]=i}catch{}}function qg(e){let t=e==null?void 0:e.scale;if(!t)return null;let i=typeof t.x=="number"?t.x:1,n=typeof t.y=="number"?t.y:1;return{x:i,y:n}}function _c(e,t){let i=e==null?void 0:e.scale;if(i)try{typeof i.set=="function"?i.set(t.x,t.y):(typeof i.x=="number"&&(i.x=t.x),typeof i.y=="number"&&(i.y=t.y))}catch{}}function Ec(e,t){let i=qg(e);if(!i)return{from:null,to:null};let n=null,r=null;return typeof t.scale=="number"?(n=t.scale,r=t.scale):t.scale&&typeof t.scale=="object"&&(typeof t.scale.x=="number"&&(n=t.scale.x),typeof t.scale.y=="number"&&(r=t.scale.y)),typeof t.scaleX=="number"&&(n=t.scaleX),typeof t.scaleY=="number"&&(r=t.scaleY),n===null&&r===null?{from:null,to:null}:{from:{x:i.x,y:i.y},to:{x:n!=null?n:i.x,y:r!=null?r:i.y}}}function Sc(){let e=new Set,t=new WeakMap,i=null,n=()=>{if(i!=null)return;i=requestAnimationFrame(()=>{i=null,o(),e.size>0&&n()})},r=c=>{var p;e.add(c);let f=(p=t.get(c.target))!=null?p:new Set;f.add(c),t.set(c.target,f),n()},a=c=>{e.delete(c);let f=t.get(c.target);f&&(f.delete(c),f.size===0&&t.delete(c.target))},s=c=>{c.killed||(c.killed=!0,a(c))},o=()=>{var f,p;let c=Hi();for(let u of Array.from(e)){if(u.killed||u.paused)continue;let v=c-u.startMs-u.delayMs;if(v<0)continue;let h=u.durationMs>0?v/u.durationMs:1,w=xc(h),y=u.repeat>=0?u.repeat+1:1,m=u.repeat>0?Math.min(Math.floor(h),y-1):0;if(u.repeat>0&&h>=1){let x=h-m;w=xc(x)}let b=u.ease(w);u.yoyo&&m%2===1&&(b=1-b);for(let x of u.props)wc(u.target,x.key,x.from+(x.to-x.from)*b);u.scaleFrom&&u.scaleTo&&_c(u.target,{x:u.scaleFrom.x+(u.scaleTo.x-u.scaleFrom.x)*b,y:u.scaleFrom.y+(u.scaleTo.y-u.scaleFrom.y)*b});try{(f=u.onUpdate)==null||f.call(u)}catch{}if(h>=y){s(u);try{(p=u.onComplete)==null||p.call(u)}catch{}}}},d=(c,f,p)=>{var x;let u=Math.max(0,(typeof f.duration=="number"?f.duration:.5)*1e3),v=Math.max(0,(typeof f.delay=="number"?f.delay:0)*1e3+((x=p==null?void 0:p.delayMsOverride)!=null?x:0)),h=$g(f.ease),w=typeof f.repeat=="number"?Math.max(0,f.repeat|0):0,y=f.yoyo===!0,m=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),b=[];for(let E of Object.keys(f)){if(m.has(E))continue;let A=f[E];typeof A=="number"&&b.push({key:E,from:Ug(c,E),to:A})}let g=Ec(c,f);return{target:c,startMs:Hi(),delayMs:v,durationMs:u,ease:h,props:b,scaleFrom:g.from,scaleTo:g.to,repeat:w,yoyo:y,onUpdate:typeof f.onUpdate=="function"?f.onUpdate:void 0,onComplete:typeof f.onComplete=="function"?f.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},l={to(c,f){let p=d(c,f);return r(p),{kill:()=>s(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=Hi())},resume:()=>{var h;if(!p.paused)return;let u=(h=p.pauseAtMs)!=null?h:Hi(),v=Hi()-u;p.startMs+=v,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(c,f,p){return l.set(c,f),l.to(c,p)},set(c,f){if(!c||!f)return;for(let u of Object.keys(f)){let v=f[u];u==="scale"||u==="scaleX"||u==="scaleY"||typeof v=="number"&&wc(c,u,v)}let p=Ec(c,f);p.to&&_c(c,p.to)},killTweensOf(c){let f=t.get(c);if(f)for(let p of Array.from(f))s(p)},timeline(c={}){let f=[],p=0,u=!1,v=[],h=m=>{if(typeof m=="number")return Math.max(0,m*1e3);let b=typeof m=="string"?m.trim():"";return b.startsWith("+=")?p+Math.max(0,Number(b.slice(2))*1e3||0):b?Math.max(0,Number(b)*1e3||0):p},w=m=>{f.push(m);let b=Math.max(0,(typeof m.vars.duration=="number"?m.vars.duration:.5)*1e3);p=Math.max(p,m.atMs+b)},y={to(m,b,g){return w({kind:"to",target:m,vars:b,atMs:h(g)}),y},fromTo(m,b,g,x){return w({kind:"fromTo",target:m,vars:g,from:b,atMs:h(x)}),y},play(){var m,b;if(u)return y;u=!0,v=[];for(let g of f)g.kind==="fromTo"&&l.set(g.target,(m=g.from)!=null?m:{}),v.push(l.to(g.target,{...g.vars,delay:g.atMs/1e3+((b=g.vars.delay)!=null?b:0)}));return y},pause(){for(let m of v)m.pause();return y},kill(){for(let m of v)m.kill();v=[],u=!1}};return c.paused||y.play(),y}};return l}function Ac(){if(typeof window=="undefined")return;let e=window;if(!e.gsap)try{e.gsap=Sc()}catch{}}var Cc={name:"handler-playable-sdk",version:"0.3.21",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"}},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","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 --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks",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",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","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",sharp:"^0.34.5"}};var he=0,Wg=he++,Tc=he++,kc=he++,Lc=he++,Rc=he++,Mc=he++,Oc=he++,Ic=he++,Pc=he++,jc=he++,Dc=he++,zc=he++,H=Wg;function Fc(){return H===Tc}function Bc(){return H===kc}function Hc(){return H===Lc}function Nc(){return H===Rc}function Jt(){return H===Mc}function Qt(){return H===Oc}function $c(){return H===Ic}function Uc(){return H===Pc}function qc(){return H===jc}function ba(){return H===Dc}function ya(){return H===zc}function Gc(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),H=Tc;return}catch{}else if(e==="dapi")try{dapi.isReady(),H=kc;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(H=Lc)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(H=Rc)}catch{}else if(t==="mintegral")window.gameReady&&(H=Mc);else if(t==="tapjoy")window.TJ_API&&(H=Oc);else if(t==="tiktok")window.openAppStore&&(H=Ic);else if(t==="smadex")try{window.smxTracking&&(H=Pc)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(H=jc)}catch{}else t==="vungle"?H=Dc:(e==="nucleo"||t==="nucleo")&&(H=zc)}var Wn=Ge(require("lottie-web"),1),Wc=Wn.default;typeof window!="undefined"&&(window.lottie=Wn.default,window.__baseLottie=Wn.default);var Yg=require("pixi.js");var va=require("pixi.js");var Vg=null;function xa(e){Vg=e}Yn();wa();var Ni=require("pixi.js");Yn();var em=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Aa=em;if(typeof window!="undefined")try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);t!=null&&t.buildMode&&(Aa=t.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${Aa}`))}}catch{}var Mt=class{static async create(t,i,n){var d,l,c,f,p,u,v;console.log(`[ObjectFactory] create() called for: ${t}, __BUILD_MODE__: ${Aa}`);let r=(d=i==null?void 0:i.render)==null?void 0:d.asset;if(!r){console.log(`[ObjectFactory] No asset definition for: ${t}, returning empty container`);let h=new Ni.Container;return this.applyTransform(h,i==null?void 0:i.transform),h}let a=(l=i==null?void 0:i.identity)==null?void 0:l.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${t}, configId: ${a}, type: ${r.type}, path: ${r.path}`);let s=await Rt.load(t,r,n,a);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${t}, rawAsset type: ${(c=s==null?void 0:s.constructor)==null?void 0:c.name}`);let o;if(r.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",t),o=new Ni.Sprite(s),console.log("[ObjectFactory] Created object:",o,"type:",(f=o==null?void 0:o.constructor)==null?void 0:f.name),this.applyTransform(o,i==null?void 0:i.transform);else if(r.type==="json")if(console.log("[ObjectFactory] JSON asset for",t,"rawAsset type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name,s),s&&(((u=s.constructor)==null?void 0:u.name)==="Container"||s instanceof Ni.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[r.path,`/assets/${r.path}`,`assets/${r.path}`,`../assets/${r.path}`],w=!1;for(let y of h)try{let m=await fetch(y);if(m.ok){o=await m.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",y,"type:",(v=o==null?void 0:o.constructor)==null?void 0:v.name),w=!0;break}}catch{continue}w||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=s)}else o=s;else o=s,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,i==null?void 0:i.transform);return o}static applyTransform(t,i){var n,r,a,s;!i||!t||(i.position&&("x"in t&&"y"in t?(t.x=(n=i.position.x)!=null?n:0,t.y=(r=i.position.y)!=null?r:0):"position"in t&&t.position&&t.position.set((a=i.position.x)!=null?a:0,(s=i.position.y)!=null?s:0)),i.scale!==void 0&&"scale"in t&&t.scale&&(typeof t.scale=="object"&&"set"in t.scale?t.scale.set(i.scale):t.scale=i.scale),i.rotation!==void 0&&"rotation"in t&&(t.rotation=i.rotation),i.anchor&&"anchor"in t&&t.anchor&&Array.isArray(i.anchor)&&("set"in t.anchor?t.anchor.set(i.anchor[0],i.anchor[1]):(t.anchor.x=i.anchor[0],t.anchor.y=i.anchor[1])))}};var $i=class{constructor(){this.config=null}init(t){this.config=t}get(t){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(t)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(t){return this.config?this.config.objects.has(t):!1}};var nm=Ge(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=nm);Ui();var Xn=require("pixi.js");Ui();var Ta=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new $i}init(t,i){this.registry.init(t),this.app=i}updateConfig(t){this.registry.init(t),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let i=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));if(i.length===0)return;let n=async r=>{r.length&&(console.log("[Assets] Loading objects:",r),await Promise.all(r.map(async a=>{var o;let s=this.registry.get(a);if(!s){console.warn("[Assets] No config found for object:",a);return}try{let d=await Mt.create(a,s,this.app);this.instanceCache.set(a,d),console.log("[Assets] Loaded object:",a,(o=d==null?void 0:d.constructor)==null?void 0:o.name)}catch(d){console.error("[Assets] Failed to load object:",a,d)}})))};return this.readyPromise=(async()=>{await n(i);let r=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));r.length>0&&(console.warn("[Assets] Retrying missing assets:",r),await n(r)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(t){let i=this.registry.get(t);if(i){let n=await Mt.create(t,i,this.app);this.instanceCache.set(t,n)}}get(t){return this.instanceCache.get(t)}},am=new Ta,sm=new Proxy(am,{get(e,t){if(t in e&&typeof e[t]=="function")return e[t].bind(e);if(e.get(t))return e.get(t)}});Ui();var Kc=require("pixi.js"),Xe={width:400,height:600,designWidth:400,scaleFactor:1},Zn={scale:1,position:1},La=[];function cm(e,t,i,n,r,a,s){La.push({element:e,originalScale:a,positionHelper:t,heightPercent:r}),t(e,i,n,r,a,s,!1)}function dm(){La.forEach(({element:e,originalScale:t,positionHelper:i,heightPercent:n})=>{let r=t*Xe.scaleFactor;i(e,Xe.width,Xe.height,n,r,!0,!1)})}function ka(e,t){console.log(`[SCREEN] updateScreenState called: ${e}x${t}`),Xe.width=e,Xe.height=t,Xe.scaleFactor=Math.min(e/Xe.designWidth,1.15),Zn.scale=Xe.scaleFactor,Zn.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Zn.scale.toFixed(3)}`),dm()}var Gi={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 um(e,t,i){let n=Gi[e];n&&n[t]!==void 0&&(n[t]=i,console.log(`Updated ${e}.${t} = ${i}`))}function pm(){return Gi}var fm={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 Kn(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Jn(e,t={x:.5,y:.5}){var i;if(Array.isArray(e))return{x:Kn(e[0],t.x),y:Kn(e[1],t.y)};if(e&&typeof e=="object"){let n=e;return{x:Kn(n.x,t.x),y:Kn(n.y,t.y)}}if(typeof e=="string"){let n=e.trim().toLowerCase();return(i=fm[n])!=null?i:t}return t}function Zc(e,t,i,n={}){var u,v,h,w,y,m;let r=Jn(i),a=(u=n.inset)!=null?u:{},s=(v=n.padding)!=null?v:{x:0,y:0},o=((h=a.left)!=null?h:0)+s.x,d=((w=a.right)!=null?w:0)+s.x,l=((y=a.top)!=null?y:0)+s.y,c=((m=a.bottom)!=null?m:0)+s.y,f=Math.max(0,e-o-d),p=Math.max(0,t-l-c);return{x:o+f*r.x,y:l+p*r.y}}function Jc(e,t,i,n={}){var h,w,y,m,b,g;let r=(h=n.inset)!=null?h:{},a=(w=n.padding)!=null?w:{x:0,y:0},s=((y=r.left)!=null?y:0)+a.x,o=((m=r.right)!=null?m:0)+a.x,d=((b=r.top)!=null?b:0)+a.y,l=((g=r.bottom)!=null?g:0)+a.y,c=Math.max(0,e-s-o),f=Math.max(0,t-d-l),p=Jn(i,{x:.5,y:.5}),u=Math.min(Math.max(p.x,0),1),v=Math.min(Math.max(p.y,0),1);return{x:s+c*u,y:d+f*v}}if(typeof window!="undefined"){let e=window.innerWidth,t=window.innerHeight,i=()=>{let n=window.innerWidth,r=window.innerHeight;(n!==e||r!==t)&&(e=n,t=r,ka(n,r))};window.addEventListener("resize",i),window.addEventListener("orientationchange",()=>{setTimeout(i,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",i),window.mraid.addEventListener("sizeChange",i)),ka(window.innerWidth,window.innerHeight),window.updateDebugConfig=um,window.getDebugConfig=pm,window.copyConfig=Sm,window.applyConfig=qi,window.applyConfigForRatio=Am,window.positionAtBottom=Qc,window.positionAtTop=mm,window.positionAtCenter=bm,window.positionAtLeft=ym,window.positionAtRight=vm,window.positionAtBottomLeft=xm,window.positionAtBottomRight=wm,window.positionAtTopLeft=_m,window.positionAtTopRight=Em,window.applyPositionContract=gm,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 Qn(e,t,i=0){return e*t+i}function er(e,t,i=0){return e*(1-t)+i}function tr(e,t,i=0){return e*t+i}function ir(e,t,i=0){return e*(1-t)+i}function ge(e,t=0){return e/2+t}function hm(e,t){return e*t}function gm(e,t,i,n){var s,o,d,l,c,f,p,u,v,h,w,y,m,b,g,x,E,A,C,T;let r=0,a=0;switch(n.type){case"top":r=ge(t,(o=(s=n.offset)==null?void 0:s.x)!=null?o:0),a=Qn(i,n.percent,(l=(d=n.offset)==null?void 0:d.y)!=null?l:0);break;case"bottom":r=ge(t,(f=(c=n.offset)==null?void 0:c.x)!=null?f:0),a=er(i,n.percent,(u=(p=n.offset)==null?void 0:p.y)!=null?u:0);break;case"left":r=tr(t,n.percent,(h=(v=n.offset)==null?void 0:v.x)!=null?h:0),a=ge(i,(y=(w=n.offset)==null?void 0:w.y)!=null?y:0);break;case"right":r=ir(t,n.percent,(b=(m=n.offset)==null?void 0:m.x)!=null?b:0),a=ge(i,(x=(g=n.offset)==null?void 0:g.y)!=null?x:0);break;case"center":r=ge(t,(A=(E=n.offset)==null?void 0:E.x)!=null?A:0),a=ge(i,(T=(C=n.offset)==null?void 0:C.y)!=null?T:0);break}e.position?e.position.set(r,a):(e.x=r,e.y=a),n.scale!==void 0&&n.scale!==1&&e.scale&&(typeof e.scale.set=="function"?e.scale.set(n.scale,n.scale):(e.scale.x=n.scale,e.scale.y=n.scale))}function Qc(e,t,i,n=.2,r=1,a=!0,s=!1){let o=hm(i,n),d=er(i,n/2);Ke(e,ge(t),d);let l=a?r*Xe.scaleFactor:r;Ze(e,l),s&&!La.find(c=>c.element===e)&&cm(e,Qc,t,i,n,r,a)}function mm(e,t,i,n=.1,r=1){Ke(e,ge(t),Qn(i,n)),Ze(e,r)}function bm(e,t,i,n=0,r=0,a=1){Ke(e,ge(t,n),ge(i,r)),Ze(e,a)}function ym(e,t,i,n=.1,r=1){Ke(e,tr(t,n),ge(i)),Ze(e,r)}function vm(e,t,i,n=.1,r=1){Ke(e,ir(t,n),ge(i)),Ze(e,r)}function xm(e,t,i,n=.05,r=.05,a=1){Ke(e,tr(t,r),er(i,n)),Ze(e,a)}function wm(e,t,i,n=.05,r=.05,a=1){Ke(e,ir(t,r),er(i,n)),Ze(e,a)}function _m(e,t,i,n=.05,r=.05,a=1){Ke(e,tr(t,r),Qn(i,n)),Ze(e,a)}function Em(e,t,i,n=.05,r=.05,a=1){Ke(e,ir(t,r),Qn(i,n)),Ze(e,a)}function Ke(e,t,i){e&&e.position?typeof e.position.set=="function"?e.position.set(t,i):(e.position.x=t,e.position.y=i):e&&(e.x=t,e.y=i)}function Ze(e,t){t!==1&&e&&e.scale&&(typeof e.scale.set=="function"?e.scale.set(t,t):e.scale.x!==void 0&&e.scale.y!==void 0&&(e.scale.x=t,e.scale.y=t))}var Ot={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 Sm(e){return e&&Ot[e]?JSON.parse(JSON.stringify(Ot[e])):JSON.parse(JSON.stringify(Gi))}function qi(e){Object.keys(e).forEach(t=>{let i=t;Gi[i]&&e[i]&&Object.assign(Gi[i],e[i])}),console.log("Config applied:",e)}function Am(e,t){let i=e/t;i>1.6?(qi(Ot.wide),console.log("Applied WIDE config for ratio:",i)):i<.7?(qi(Ot.tall),console.log("Applied TALL config for ratio:",i)):i>.8&&i<1.2?(qi(Ot.square),console.log("Applied SQUARE config for ratio:",i)):(qi(Ot.default),console.log("Applied DEFAULT config for ratio:",i))}if(typeof window!="undefined"){let e=window;e.configPresets=Ot,e.resolveAnchorVec2=e.resolveAnchorVec2||Jn,e.resolveScreenAnchorPoint=e.resolveScreenAnchorPoint||Zc,e.resolveScreenRatioPoint=e.resolveScreenRatioPoint||Jc}Oa();function G(e,t){let i=(r,a)=>a===0?r:i(a,r%a),n=i(e,t);return`${e/n}:${t/n}`}var B_=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:G(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:G(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:G(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:G(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:G(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:G(360,780)}],H_=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:G(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:G(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:G(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:G(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:G(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:G(412,915)}],N_=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:G(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:G(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:G(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:G(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:G(800,1280)}],nd=[{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:G(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:G(768,1024),mraidScale:.7}];var $_=[...nd];var Im=nd[0];pt();var yw=Ge(mh(),1);function gw(e){return new Promise((t,i)=>{let n=new FileReader;n.onerror=()=>i(new Error("FileReader failed")),n.onload=()=>t(String(n.result||"")),n.readAsDataURL(e)})}function mw(e){var r;let[t,i]=e.split(","),n=t==null?void 0:t.match(/data:(.*?);base64/);return{base64:i!=null?i:"",mimeType:(r=n==null?void 0:n[1])!=null?r:"image/png"}}async function bw(e){return await new Promise(t=>{let i=new Image;i.onload=()=>t({width:i.naturalWidth||i.width,height:i.naturalHeight||i.height}),i.onerror=()=>t(null),i.src=e})}async function Eo(e){var t,i;try{console.log("[ImageUtils] Fetching image data from URL:",e);let n=await fetch(e);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,e),null;let r=await n.blob();console.log("[ImageUtils] Blob received, size:",r.size,"type:",r.type);let a=await gw(r),s=await bw(a),o=mw(a);return console.log("[ImageUtils] Success resolution:",s==null?void 0:s.width,"x",s==null?void 0:s.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:a,width:(t=s==null?void 0:s.width)!=null?t:0,height:(i=s==null?void 0:s.height)!=null?i:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function Vr(e,t=30){try{console.log("[ImageUtils] Removing background color...");let i=await new Promise((f,p)=>{let u=new Image;u.onload=()=>f(u),u.onerror=()=>p(new Error("Failed to load image")),u.src=e}),n=document.createElement("canvas");n.width=i.width,n.height=i.height;let r=n.getContext("2d");if(!r)return console.error("[ImageUtils] Failed to get canvas context"),e;r.drawImage(i,0,0);let a=r.getImageData(0,0,n.width,n.height),s=a.data,d=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(f=>({r:s[f.offset],g:s[f.offset+1],b:s[f.offset+2]})),l=0;for(let f=0;f<s.length;f+=4){let p=s[f],u=s[f+1],v=s[f+2],h=!1;for(let w of d)if(Math.sqrt(Math.pow(p-w.r,2)+Math.pow(u-w.g,2)+Math.pow(v-w.b,2))<t){h=!0;break}h&&(s[f+3]=0,l++)}return console.log(`[ImageUtils] Removed background from ${l} pixels (4-corner sampling, tolerance: ${t})`),r.putImageData(a,0,0),n.toDataURL("image/png")}catch(i){return console.error("[ImageUtils] Error removing background:",i),e}}var bh=require("@google/genai");async function So(e,t,i=[],n={}){var r,a,s,o,d,l,c;try{if(!(e!=null&&e.trim()))throw new Error("Gemini API key is required");if(!(t!=null&&t.trim()))throw new Error("Prompt is required");for(let y=0;y<i.length;y++){let m=i[y];if(!m.base64||!m.mimeType)throw new Error(`Image ${y+1} is missing required data`);if(m.base64.length<1e3&&console.warn(`Image ${y+1} data appears very small, may be corrupted`),!m.mimeType.startsWith("image/"))throw new Error(`Image ${y+1} has invalid MIME type: ${m.mimeType}`)}let f=new bh.GoogleGenAI({apiKey:e}),p="gemini-2.5-flash",u=[t];i.length>0&&i.forEach((y,m)=>{u.push({inlineData:{data:y.base64,mimeType:y.mimeType}}),console.log(`[Gemini] Added image ${m+1}: ${y.mimeType}, size: ${Math.round(y.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${i.length} images and prompt length: ${t.length}`);let v=await f.models.generateContent({model:p,contents:u}),h="",w=(s=(a=(r=v.candidates)==null?void 0:r[0])==null?void 0:a.content)==null?void 0:s.parts;if(w)for(let y of w)y.text&&(h+=y.text);if(!h.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${h.length}`),h}catch(f){throw console.error("[Gemini] API error:",f),(o=f.message)!=null&&o.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(d=f.message)!=null&&d.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(l=f.message)!=null&&l.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(c=f.message)!=null&&c.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):f}}var yh=require("@google/genai");async function Xr(e,t,i=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let r=new yh.GoogleGenAI({apiKey:e}),a=[{text:t}];i.length>0&&i.forEach((o,d)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${d}`),a.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let s=await r.models.generateContent({model:"gemini-2.5-flash-image",contents:a});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!s.candidates||!s.candidates[0]||!s.candidates[0].content||!s.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of s.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let d=o.inlineData.data,l=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${l};base64,${d}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(r){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(r,Object.getOwnPropertyNames(r),2)),r}}var vw=require("pixi.js");Ui();pt();var xh=require("pixi.js");var xw=require("pixi.js");pt();function Tw(e){return new Promise((t,i)=>{let n=new FileReader;n.onerror=()=>i(new Error("FileReader failed")),n.onload=()=>t(String(n.result||"")),n.readAsDataURL(e)})}function kw(e){var r;let[t,i]=e.split(","),n=t==null?void 0:t.match(/data:(.*?);base64/);return{base64:i!=null?i:"",mimeType:(r=n==null?void 0:n[1])!=null?r:"image/png"}}function Lw(e){return`
48
48
  Analyze these screenshots of a brand or game and extract its "Brand DNA".
49
49
 
50
50
  Provide a concise summary (2-3 sentences) covering: