handler-playable-sdk 0.4.32 → 0.4.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{c as Oi,d as le,e as Ii}from"./chunk-I5OOVR5U.js";import{i as zt}from"./chunk-LV4HGC5G.js";import{c as st,d as jt,e as lt,g as na,h as ji,j as Di,k as Dt,l as aa,m as ra,n as zi,o as oa}from"./chunk-ZLL42OOV.js";import{a as Yr}from"./chunk-JXBG6UFL.js";import{Application as $o}from"pixi.js";var Ce={};function Ht(a,e,t=!1){Ce[a]||(Ce[a]=[]),Ce[a].push({fn:e,once:t})}function Hi(a,e){if(Ce[a]){if(!e){delete Ce[a];return}Ce[a]=Ce[a].filter(t=>t.fn!==e)}}function $t(a,...e){let t=Ce[a];if(t)for(let i of[...t])i.fn(...e),i.once&&Hi(a,i.fn)}function ee(a,e){Ht(a,e,!0)}var G=null,ne=[],Ne=null;function ca(a){G=a,ne=[],Ne!==null&&(clearTimeout(Ne),Ne=null)}function da(){var a,e,t;return{endpoint:(G==null?void 0:G.endpoint)||"",transport:(G==null?void 0:G.transport)||"beacon",batchSize:(a=G==null?void 0:G.batchSize)!=null?a:10,flushIntervalMs:(e=G==null?void 0:G.flushIntervalMs)!=null?e:300,maxQueue:(t=G==null?void 0:G.maxQueue)!=null?t:200,debug:!!(G!=null&&G.debug)}}async function sa(a,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(a,new Blob([n],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function $i(a,e){let t=da();if(e&&t.endpoint){if(ne.push(a),ne.length>t.maxQueue&&(ne=ne.slice(ne.length-t.maxQueue)),ne.length>=t.batchSize){la();return}Ne===null&&(Ne=window.setTimeout(()=>{Ne=null,la()},t.flushIntervalMs))}}async function la(){let a=da();if(!a.endpoint||ne.length===0)return;let e=ne.splice(0,a.batchSize);await sa(a.endpoint,{events:e},a.transport,a.debug),ne.length>0&&await sa(a.endpoint,{events:ne.splice(0,a.batchSize)},a.transport,a.debug)}function pa(a){return Math.max(0,Math.min(1,a))}function Wr(a){let e=String(a!=null?a:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),i=t?Number(t[1]):1.8;return n=>1+(i+1)*Math.pow(n-1,3)+i*Math.pow(n-1,2)}return t=>1-(1-t)*(1-t)}function ct(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Kr(a,e){let t=a==null?void 0:a[e];return typeof t=="number"?t:0}function ua(a,e,t){try{a[e]=t}catch{}}function Xr(a){let e=a==null?void 0:a.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:t,y:i}}function ga(a,e){let t=a==null?void 0:a.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function ha(a,e){let t=Xr(a);if(!t)return{from:null,to:null};let i=null,n=null;return typeof e.scale=="number"?(i=e.scale,n=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(n=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(n=e.scaleY),i===null&&n===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:i!=null?i:t.x,y:n!=null?n:t.y}}}function fa(){let a=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,s(),a.size>0&&i()})},n=d=>{var u;a.add(d);let p=(u=e.get(d.target))!=null?u:new Set;p.add(d),e.set(d.target,p),i()},r=d=>{a.delete(d);let p=e.get(d.target);p&&(p.delete(d),p.size===0&&e.delete(d.target))},o=d=>{d.killed||(d.killed=!0,r(d))},s=()=>{var p,u;let d=ct();for(let g of Array.from(a)){if(g.killed||g.paused)continue;let m=d-g.startMs-g.delayMs;if(m<0)continue;let h=g.durationMs>0?m/g.durationMs:1,f=pa(h),y=g.repeat>=0?g.repeat+1:1,b=g.repeat>0?Math.min(Math.floor(h),y-1):0;if(g.repeat>0&&h>=1){let w=h-b;f=pa(w)}let v=g.ease(f);g.yoyo&&b%2===1&&(v=1-v);for(let w of g.props)ua(g.target,w.key,w.from+(w.to-w.from)*v);g.scaleFrom&&g.scaleTo&&ga(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*v,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*v});try{(p=g.onUpdate)==null||p.call(g)}catch{}if(h>=y){o(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(d,p,u)=>{var w;let g=Math.max(0,(typeof p.duration=="number"?p.duration:.5)*1e3),m=Math.max(0,(typeof p.delay=="number"?p.delay:0)*1e3+((w=u==null?void 0:u.delayMsOverride)!=null?w:0)),h=Wr(p.ease),f=typeof p.repeat=="number"?Math.max(0,p.repeat|0):0,y=p.yoyo===!0,b=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let E of Object.keys(p)){if(b.has(E))continue;let L=p[E];typeof L=="number"&&v.push({key:E,from:Kr(d,E),to:L})}let x=ha(d,p);return{target:d,startMs:ct(),delayMs:m,durationMs:g,ease:h,props:v,scaleFrom:x.from,scaleTo:x.to,repeat:f,yoyo:y,onUpdate:typeof p.onUpdate=="function"?p.onUpdate:void 0,onComplete:typeof p.onComplete=="function"?p.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(d,p){let u=l(d,p);return n(u),{kill:()=>o(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=ct())},resume:()=>{var h;if(!u.paused)return;let g=(h=u.pauseAtMs)!=null?h:ct(),m=ct()-g;u.startMs+=m,u.paused=!1,u.pauseAtMs=null},isActive:()=>!u.killed&&!u.paused}},fromTo(d,p,u){return c.set(d,p),c.to(d,u)},set(d,p){if(!d||!p)return;for(let g of Object.keys(p)){let m=p[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof m=="number"&&ua(d,g,m)}let u=ha(d,p);u.to&&ga(d,u.to)},killTweensOf(d){let p=e.get(d);if(p)for(let u of Array.from(p))o(u)},timeline(d={}){let p=[],u=0,g=!1,m=[],h=b=>{if(typeof b=="number")return Math.max(0,b*1e3);let v=typeof b=="string"?b.trim():"";return v.startsWith("+=")?u+Math.max(0,Number(v.slice(2))*1e3||0):v?Math.max(0,Number(v)*1e3||0):u},f=b=>{p.push(b);let v=Math.max(0,(typeof b.vars.duration=="number"?b.vars.duration:.5)*1e3);u=Math.max(u,b.atMs+v)},y={to(b,v,x){return f({kind:"to",target:b,vars:v,atMs:h(x)}),y},fromTo(b,v,x,w){return f({kind:"fromTo",target:b,vars:x,from:v,atMs:h(w)}),y},play(){var b,v;if(g)return y;g=!0,m=[];for(let x of p)x.kind==="fromTo"&&c.set(x.target,(b=x.from)!=null?b:{}),m.push(c.to(x.target,{...x.vars,delay:x.atMs/1e3+((v=x.vars.delay)!=null?v:0)}));return y},pause(){for(let b of m)b.pause();return y},kill(){for(let b of m)b.kill();m=[],g=!1}};return d.paused||y.play(),y}};return c}function ma(){if(typeof window=="undefined")return;let a=window;if(!a.gsap)try{a.gsap=fa()}catch{}}var ba={name:"handler-playable-sdk",version:"0.4.32",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && chmod +x dist/cli/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var te=0,Zr=te++,ya=te++,va=te++,xa=te++,wa=te++,Ea=te++,Sa=te++,Aa=te++,Ca=te++,Ta=te++,La=te++,ka=te++,F=Zr;function Pa(){return F===ya}function Ma(){return F===va}function _a(){return F===xa}function Ra(){return F===wa}function Fe(){return F===Ea}function Ue(){return F===Sa}function Oa(){return F===Aa}function Ia(){return F===Ca}function ja(){return F===Ta}function Bi(){return F===La}function Ni(){return F===ka}function Da(){let a=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(a==="mraid")try{mraid.getState(),F=ya;return}catch{}else if(a==="dapi")try{dapi.isReady(),F=va;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(F=xa)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(F=wa)}catch{}else if(e==="mintegral")window.gameReady&&(F=Ea);else if(e==="tapjoy")window.TJ_API&&(F=Sa);else if(e==="tiktok")window.openAppStore&&(F=Aa);else if(e==="smadex")try{window.smxTracking&&(F=Ca)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(F=Ta)}catch{}else e==="vungle"?F=La:(a==="nucleo"||e==="nucleo")&&(F=ka)}import Fi from"lottie-web";var za=Fi;typeof window!="undefined"&&(window.lottie=Fi,window.__baseLottie=Fi);function q(a,e){let t=(n,r)=>r===0?n:t(r,n%r),i=t(a,e);return`${a/i}:${e/i}`}var Is=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:q(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:q(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:q(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:q(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:q(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:q(360,780)}],js=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:q(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:q(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:q(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:q(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:q(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:q(412,915)}],Ds=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:q(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:q(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:q(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:q(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:q(800,1280)}],Ui=[{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:q(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:q(768,1024),mraidScale:.7}];var Ha=[...Ui],$a=[{category:"playable",label:"Playable Ad",devices:Ui}],Gi=Ui[0];function Ge(a){return Ha.find(e=>e.id===a)||Gi}function zs(a){return Ha.filter(e=>e.category===a)}var Bt=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`
1
+ import{c as Oi,d as le,e as Ii}from"./chunk-I5OOVR5U.js";import{i as zt}from"./chunk-LV4HGC5G.js";import{c as st,d as jt,e as lt,g as na,h as ji,j as Di,k as Dt,l as aa,m as ra,n as zi,o as oa}from"./chunk-ZLL42OOV.js";import{a as Yr}from"./chunk-JXBG6UFL.js";import{Application as $o}from"pixi.js";var Ce={};function Ht(a,e,t=!1){Ce[a]||(Ce[a]=[]),Ce[a].push({fn:e,once:t})}function Hi(a,e){if(Ce[a]){if(!e){delete Ce[a];return}Ce[a]=Ce[a].filter(t=>t.fn!==e)}}function $t(a,...e){let t=Ce[a];if(t)for(let i of[...t])i.fn(...e),i.once&&Hi(a,i.fn)}function ee(a,e){Ht(a,e,!0)}var G=null,ne=[],Ne=null;function ca(a){G=a,ne=[],Ne!==null&&(clearTimeout(Ne),Ne=null)}function da(){var a,e,t;return{endpoint:(G==null?void 0:G.endpoint)||"",transport:(G==null?void 0:G.transport)||"beacon",batchSize:(a=G==null?void 0:G.batchSize)!=null?a:10,flushIntervalMs:(e=G==null?void 0:G.flushIntervalMs)!=null?e:300,maxQueue:(t=G==null?void 0:G.maxQueue)!=null?t:200,debug:!!(G!=null&&G.debug)}}async function sa(a,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(a,new Blob([n],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function $i(a,e){let t=da();if(e&&t.endpoint){if(ne.push(a),ne.length>t.maxQueue&&(ne=ne.slice(ne.length-t.maxQueue)),ne.length>=t.batchSize){la();return}Ne===null&&(Ne=window.setTimeout(()=>{Ne=null,la()},t.flushIntervalMs))}}async function la(){let a=da();if(!a.endpoint||ne.length===0)return;let e=ne.splice(0,a.batchSize);await sa(a.endpoint,{events:e},a.transport,a.debug),ne.length>0&&await sa(a.endpoint,{events:ne.splice(0,a.batchSize)},a.transport,a.debug)}function pa(a){return Math.max(0,Math.min(1,a))}function Wr(a){let e=String(a!=null?a:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),i=t?Number(t[1]):1.8;return n=>1+(i+1)*Math.pow(n-1,3)+i*Math.pow(n-1,2)}return t=>1-(1-t)*(1-t)}function ct(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Kr(a,e){let t=a==null?void 0:a[e];return typeof t=="number"?t:0}function ua(a,e,t){try{a[e]=t}catch{}}function Xr(a){let e=a==null?void 0:a.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:t,y:i}}function ga(a,e){let t=a==null?void 0:a.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function ha(a,e){let t=Xr(a);if(!t)return{from:null,to:null};let i=null,n=null;return typeof e.scale=="number"?(i=e.scale,n=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(n=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(n=e.scaleY),i===null&&n===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:i!=null?i:t.x,y:n!=null?n:t.y}}}function fa(){let a=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,s(),a.size>0&&i()})},n=d=>{var u;a.add(d);let p=(u=e.get(d.target))!=null?u:new Set;p.add(d),e.set(d.target,p),i()},r=d=>{a.delete(d);let p=e.get(d.target);p&&(p.delete(d),p.size===0&&e.delete(d.target))},o=d=>{d.killed||(d.killed=!0,r(d))},s=()=>{var p,u;let d=ct();for(let g of Array.from(a)){if(g.killed||g.paused)continue;let m=d-g.startMs-g.delayMs;if(m<0)continue;let h=g.durationMs>0?m/g.durationMs:1,f=pa(h),y=g.repeat>=0?g.repeat+1:1,b=g.repeat>0?Math.min(Math.floor(h),y-1):0;if(g.repeat>0&&h>=1){let w=h-b;f=pa(w)}let v=g.ease(f);g.yoyo&&b%2===1&&(v=1-v);for(let w of g.props)ua(g.target,w.key,w.from+(w.to-w.from)*v);g.scaleFrom&&g.scaleTo&&ga(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*v,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*v});try{(p=g.onUpdate)==null||p.call(g)}catch{}if(h>=y){o(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(d,p,u)=>{var w;let g=Math.max(0,(typeof p.duration=="number"?p.duration:.5)*1e3),m=Math.max(0,(typeof p.delay=="number"?p.delay:0)*1e3+((w=u==null?void 0:u.delayMsOverride)!=null?w:0)),h=Wr(p.ease),f=typeof p.repeat=="number"?Math.max(0,p.repeat|0):0,y=p.yoyo===!0,b=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let E of Object.keys(p)){if(b.has(E))continue;let L=p[E];typeof L=="number"&&v.push({key:E,from:Kr(d,E),to:L})}let x=ha(d,p);return{target:d,startMs:ct(),delayMs:m,durationMs:g,ease:h,props:v,scaleFrom:x.from,scaleTo:x.to,repeat:f,yoyo:y,onUpdate:typeof p.onUpdate=="function"?p.onUpdate:void 0,onComplete:typeof p.onComplete=="function"?p.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(d,p){let u=l(d,p);return n(u),{kill:()=>o(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=ct())},resume:()=>{var h;if(!u.paused)return;let g=(h=u.pauseAtMs)!=null?h:ct(),m=ct()-g;u.startMs+=m,u.paused=!1,u.pauseAtMs=null},isActive:()=>!u.killed&&!u.paused}},fromTo(d,p,u){return c.set(d,p),c.to(d,u)},set(d,p){if(!d||!p)return;for(let g of Object.keys(p)){let m=p[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof m=="number"&&ua(d,g,m)}let u=ha(d,p);u.to&&ga(d,u.to)},killTweensOf(d){let p=e.get(d);if(p)for(let u of Array.from(p))o(u)},timeline(d={}){let p=[],u=0,g=!1,m=[],h=b=>{if(typeof b=="number")return Math.max(0,b*1e3);let v=typeof b=="string"?b.trim():"";return v.startsWith("+=")?u+Math.max(0,Number(v.slice(2))*1e3||0):v?Math.max(0,Number(v)*1e3||0):u},f=b=>{p.push(b);let v=Math.max(0,(typeof b.vars.duration=="number"?b.vars.duration:.5)*1e3);u=Math.max(u,b.atMs+v)},y={to(b,v,x){return f({kind:"to",target:b,vars:v,atMs:h(x)}),y},fromTo(b,v,x,w){return f({kind:"fromTo",target:b,vars:x,from:v,atMs:h(w)}),y},play(){var b,v;if(g)return y;g=!0,m=[];for(let x of p)x.kind==="fromTo"&&c.set(x.target,(b=x.from)!=null?b:{}),m.push(c.to(x.target,{...x.vars,delay:x.atMs/1e3+((v=x.vars.delay)!=null?v:0)}));return y},pause(){for(let b of m)b.pause();return y},kill(){for(let b of m)b.kill();m=[],g=!1}};return d.paused||y.play(),y}};return c}function ma(){if(typeof window=="undefined")return;let a=window;if(!a.gsap)try{a.gsap=fa()}catch{}}var ba={name:"handler-playable-sdk",version:"0.4.37",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && chmod +x dist/cli/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var te=0,Zr=te++,ya=te++,va=te++,xa=te++,wa=te++,Ea=te++,Sa=te++,Aa=te++,Ca=te++,Ta=te++,La=te++,ka=te++,F=Zr;function Pa(){return F===ya}function Ma(){return F===va}function _a(){return F===xa}function Ra(){return F===wa}function Fe(){return F===Ea}function Ue(){return F===Sa}function Oa(){return F===Aa}function Ia(){return F===Ca}function ja(){return F===Ta}function Bi(){return F===La}function Ni(){return F===ka}function Da(){let a=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(a==="mraid")try{mraid.getState(),F=ya;return}catch{}else if(a==="dapi")try{dapi.isReady(),F=va;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(F=xa)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(F=wa)}catch{}else if(e==="mintegral")window.gameReady&&(F=Ea);else if(e==="tapjoy")window.TJ_API&&(F=Sa);else if(e==="tiktok")window.openAppStore&&(F=Aa);else if(e==="smadex")try{window.smxTracking&&(F=Ca)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(F=Ta)}catch{}else e==="vungle"?F=La:(a==="nucleo"||e==="nucleo")&&(F=ka)}import Fi from"lottie-web";var za=Fi;typeof window!="undefined"&&(window.lottie=Fi,window.__baseLottie=Fi);function q(a,e){let t=(n,r)=>r===0?n:t(r,n%r),i=t(a,e);return`${a/i}:${e/i}`}var Is=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:q(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:q(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:q(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:q(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:q(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:q(360,780)}],js=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:q(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:q(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:q(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:q(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:q(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:q(412,915)}],Ds=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:q(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:q(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:q(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:q(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:q(800,1280)}],Ui=[{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:q(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:q(768,1024),mraidScale:.7}];var Ha=[...Ui],$a=[{category:"playable",label:"Playable Ad",devices:Ui}],Gi=Ui[0];function Ge(a){return Ha.find(e=>e.id===a)||Gi}function zs(a){return Ha.filter(e=>e.category===a)}var Bt=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`
2
2
  <div class="scene-panel scene-objects panel-accent-teal" data-panel="scene-objects">
3
3
  <div class="scene-panel-header" data-panel-handle>
4
4
  <div class="panel-title">
@@ -922,7 +922,7 @@ Generate the requested asset matching the brand style.${a.needsTransparency?" Ba
922
922
  `}initialize(e,t){var b,v,x,w,E,L,k,I,j,P,S,C,A,M,O,D;this.options=t,this.root=e.querySelector('[data-panel="loading-screen"]');let n=(()=>{var _;let T=window.getEditableEngineConfig;if(typeof T=="function"){let $=T();return(_=$==null?void 0:$.loading)!=null?_:{}}return{}})(),r=(b=this.root)==null?void 0:b.querySelector("#loading-screen-type");r&&(r.value=n.type==="image"?"image":"color",r.addEventListener("change",()=>{var T,_;(_=(T=this.options)==null?void 0:T.onUpdateLoading)==null||_.call(T,{type:r.value}),this.updateFieldVisibility(r.value)}));let o=(v=this.root)==null?void 0:v.querySelector("#loading-background-color");o&&(o.value=n.background_color||"#160a17",o.addEventListener("input",()=>{var T,_;(_=(T=this.options)==null?void 0:T.onUpdateLoading)==null||_.call(T,{background_color:o.value})}));let s=(x=this.root)==null?void 0:x.querySelector("#loading-overlay-alpha"),l=(w=this.root)==null?void 0:w.querySelector("#loading-overlay-alpha-value");s&&(s.value=String((E=n.overlay_alpha)!=null?E:1),l&&(l.textContent=Number(s.value).toFixed(2)),s.addEventListener("input",()=>{var _,$;let T=Number(s.value);l&&(l.textContent=T.toFixed(2)),($=(_=this.options)==null?void 0:_.onUpdateLoading)==null||$.call(_,{overlay_alpha:T})}));let c=(L=this.root)==null?void 0:L.querySelector("#loading-text");c&&(c.value=n.text||"",c.addEventListener("input",()=>{var T,_;(_=(T=this.options)==null?void 0:T.onUpdateLoading)==null||_.call(T,{text:c.value})}));let d=(k=this.root)==null?void 0:k.querySelector("#loading-text-scale"),p=(I=this.root)==null?void 0:I.querySelector("#loading-text-scale-value");d&&(d.value=String((j=n.text_scale)!=null?j:.6),p&&(p.textContent=Number(d.value).toFixed(2)),d.addEventListener("input",()=>{var _,$;let T=Number(d.value);p&&(p.textContent=T.toFixed(2)),($=(_=this.options)==null?void 0:_.onUpdateLoading)==null||$.call(_,{text_scale:T})}));let u=(P=this.root)==null?void 0:P.querySelector("#loading-enabled");u&&(u.checked=n.enabled!==!1,u.addEventListener("change",()=>{var T,_;(_=(T=this.options)==null?void 0:T.onUpdateLoading)==null||_.call(T,{enabled:u.checked})}));let g=(S=this.root)==null?void 0:S.querySelector("#loading-blur-enabled");g&&(g.checked=n.blur_enabled!==!1,g.addEventListener("change",()=>{var T,_;(_=(T=this.options)==null?void 0:T.onUpdateLoading)==null||_.call(T,{blur_enabled:g.checked})}));let m=(C=this.root)==null?void 0:C.querySelector("#loading-blur-strength"),h=(A=this.root)==null?void 0:A.querySelector("#loading-blur-strength-value");m&&(m.value=String((M=n.blur_strength)!=null?M:8),h&&(h.textContent=m.value),m.addEventListener("input",()=>{var T,_;h&&(h.textContent=m.value),(_=(T=this.options)==null?void 0:T.onUpdateLoading)==null||_.call(T,{blur_strength:Number(m.value)})}));let f=(O=this.root)==null?void 0:O.querySelector("#loading-show-btn"),y=(D=this.root)==null?void 0:D.querySelector("#loading-hide-btn");f==null||f.addEventListener("click",()=>{var T,_;(_=(T=this.options)==null?void 0:T.onShowLoadingScreen)==null||_.call(T)}),y==null||y.addEventListener("click",()=>{var T,_;(_=(T=this.options)==null?void 0:T.onHideLoadingScreen)==null||_.call(T)}),this.updateFieldVisibility(n.type==="image"?"image":"color")}updateFieldVisibility(e){var n,r;let t=(n=this.root)==null?void 0:n.querySelector("#loading-color-field"),i=(r=this.root)==null?void 0:r.querySelector("#loading-alpha-field");e==="image"?(t&&(t.style.display="none"),i&&(i.style.display="none")):(t&&(t.style.display=""),i&&(i.style.display=""))}refresh(){}};import{Assets as oi}from"pixi.js";async function er(a,e,t){var i,n;console.log("[LIBRARY] applyAssetChange called with:",e,t);try{let r=Date.now(),s=`/${`raw/library/${e}/${t}`}?t=${r}`;console.log("[LIBRARY] Loading texture from:",s);let l=await oi.load(s);if(!l){console.error("[LIBRARY] Failed to load texture:",s);return}let c=window.CustomAssets,d=Object.keys(c||{}).filter(u=>{let g=e.replace(/s$/,"");return u.startsWith(g)||u.includes(g)});for(let u of d)le[u]=l,console.log("[LIBRARY] \u2705 Updated AssetTextures."+u),(i=c[u])!=null&&i.texture&&(c[u].texture=l,console.log("[LIBRARY] \u2705 Updated CustomAssets."+u+".texture"));let p=window.gameObjectManager;if(p)for(let u of d){let g=p.get(u);if(g){let m=((n=g.getDisplayObject)==null?void 0:n.call(g))||g.pixiObject||g;m!=null&&m.texture&&(m.texture=l,console.log("[LIBRARY] \u2705 Applied to display object:",u))}}}catch(r){console.error("[LIBRARY] Error applying asset change:",r)}}async function tr(a,e){var t,i,n;console.log("[LIBRARY] resetAsset called for:",e);try{let r=window.getEditableAssets,o=typeof r=="function"?r():null,s=(t=o==null?void 0:o.slots)==null?void 0:t.find(f=>f.category===e),l=s==null?void 0:s.defaultAsset;if(!l){console.warn("[LIBRARY] Could not find default asset for:",e);return}let c=Date.now(),d=`/raw/${l}?t=${c}`;console.log("[LIBRARY] Loading default texture from:",d);let p=await oi.load(d);if(!p){console.error("[LIBRARY] Failed to load default texture:",d);return}let u=window.CustomAssets,g=e.replace(/s$/,""),m=Object.keys(u||{}).filter(f=>f.startsWith(g)||f.includes(g));for(let f of m)le[f]=p,console.log("[LIBRARY] \u2705 Reset AssetTextures."+f),(i=u[f])!=null&&i.texture&&(u[f].texture=p,console.log("[LIBRARY] \u2705 Reset CustomAssets."+f+" to default"));let h=window.gameObjectManager;if(h)for(let f of m){let y=h.get(f);if(y){let b=((n=y.getDisplayObject)==null?void 0:n.call(y))||y.pixiObject||y;b!=null&&b.texture&&(b.texture=p,console.log("[LIBRARY] \u2705 Reset display object:",f))}}}catch(r){console.error("[LIBRARY] Error resetting asset:",r)}}async function ir(a,e,t,i){var n,r,o,s,l,c,d,p,u,g,m,h,f,y,b;console.log("[LIBRARY] applySlotAsset:",{objectId:e,assetFilename:t,category:i});try{let v=e.startsWith("json.")?e.replace("json.",""):e;console.log("[LIBRARY] Asset key:",v);let x=Date.now(),w=`/raw/library/${i}/${t}?t=${x}`;console.log("[LIBRARY] Loading texture from:",w);let E=await oi.load(w);if(!E){console.error("[LIBRARY] Failed to load texture:",w);return}console.log("[LIBRARY] \u2705 Texture loaded"),le[v]=E,console.log("[LIBRARY] \u2705 Updated AssetTextures."+v);let L=window.CustomAssets;L!=null&&L[v]&&(L[v].texture=E,console.log("[LIBRARY] \u2705 Updated legacy CustomAssets."+v));let k=window.gameObjectManager;if(console.log("[LIBRARY] gameObjectManager exists?",!!k),k){let j=Array.from(((n=k.keys)==null?void 0:n.call(k))||[]).slice(0,10);console.log("[LIBRARY] Available gameObject keys (first 10):",j);let P=k.get(v);if(console.log("[LIBRARY] gameObject for "+v+"?",!!P),P){let S=((r=P.getDisplayObject)==null?void 0:r.call(P))||P.pixiObject||P.pixi||P,C=(o=S==null?void 0:S.constructor)==null?void 0:o.name;if(console.log("[LIBRARY] displayObject:",S),console.log("[LIBRARY] displayObject type:",C),console.log("[LIBRARY] has texture?",!!(S!=null&&S.texture)),S!=null&&S.texture)S.texture=E,console.log("[LIBRARY] \u2705 Applied to display object:",v);else if(C==="Text"){console.log("[LIBRARY] \u{1F504} Converting Text to Sprite...");let{Sprite:A}=await import("pixi.js"),M=S.parent,O=(l=(s=M==null?void 0:M.getChildIndex)==null?void 0:s.call(M,S))!=null?l:0,D={x:S.x,y:S.y},T={x:(d=(c=S.anchor)==null?void 0:c.x)!=null?d:.5,y:(u=(p=S.anchor)==null?void 0:p.y)!=null?u:.5},_={x:(m=(g=S.scale)==null?void 0:g.x)!=null?m:1,y:(f=(h=S.scale)==null?void 0:h.y)!=null?f:1},$=(y=S.alpha)!=null?y:1,Q=(b=S.visible)!=null?b:!0,B=new A(E);B.anchor.set(T.x,T.y),B.position.set(D.x,D.y),B.scale.set(_.x,_.y),B.alpha=$,B.visible=Q,M&&(M.removeChild(S),M.addChildAt(B,O),console.log("[LIBRARY] \u2705 Replaced Text with Sprite in parent")),P.pixiObject&&(P.pixiObject=B),P.pixi&&(P.pixi=B),console.log("[LIBRARY] \u2705 Text \u2192 Sprite conversion complete")}else if(S!=null&&S.children){let A=S.children.find(M=>M.texture);A?(A.texture=E,console.log("[LIBRARY] \u2705 Applied to child sprite")):console.warn("[LIBRARY] \u26A0\uFE0F No texture found in displayObject or children")}}}let I=`raw/library/${i}/${t}`;st({objectId:v,path:"render.asset.path",value:I}),console.log("[LIBRARY] \u2705 Staged config override for:",v,"path:",I)}catch(v){console.error("[LIBRARY] Error applying slot asset:",v)}}async function nr(a,e,t,i){var n;console.log("[LIBRARY] resetSlotAsset:",{objectId:e,defaultAsset:t,category:i});try{let r=e.startsWith("json.")?e.replace("json.",""):e,o=Date.now(),s=`/raw/${t}?t=${o}`;console.log("[LIBRARY] Loading default texture from:",s);let l=await oi.load(s);if(!l){console.error("[LIBRARY] Failed to load default texture:",s);return}le[r]=l,console.log("[LIBRARY] \u2705 Reset AssetTextures."+r);let c=window.CustomAssets;c!=null&&c[r]&&(c[r].texture=l,console.log("[LIBRARY] \u2705 Reset CustomAssets."+r+" to default"));let d=window.gameObjectManager;if(d){let p=d.get(r);if(p){let u=((n=p.getDisplayObject)==null?void 0:n.call(p))||p.pixiObject||p;u!=null&&u.texture&&(u.texture=l,console.log("[LIBRARY] \u2705 Reset display object:",r))}}st({objectId:r,path:"render.asset.path",value:t}),console.log("[LIBRARY] \u2705 Reset config override for:",r)}catch(r){console.error("[LIBRARY] Error resetting slot asset:",r)}}import{Graphics as lr,Point as go}from"pixi.js";import{Point as ar}from"pixi.js";var Le=()=>window.debugConfig||{},rr=()=>window.resolveAnchorVec2||(a=>({x:.5,y:.5})),or=()=>window.resolveScreenAnchorPoint||(()=>new ar),sr=()=>window.resolveScreenRatioPoint||(()=>new ar);function cr(a){si(a)&&(a.objectDebugRaf||(a.objectDebugRaf=window.requestAnimationFrame(()=>li(a))))}function dr(a){a.objectDebugRaf&&(window.cancelAnimationFrame(a.objectDebugRaf),a.objectDebugRaf=null),ut(a)}function si(a){return a.isDebugOpen}function li(a){var r,o,s;if(!si(a)){a.objectDebugRaf=null;return}a.objectDebugRaf=window.requestAnimationFrame(()=>li(a));let e=Ji(a);if(!e){pt(a,null),ut(a);return}let t=Zi(a,e);if(!t){pt(a,null),ut(a);return}let i=new go;(r=t.getGlobalPosition)==null||r.call(t,i);let n=Qi(a,t);pt(a,{instanceId:e,worldX:i.x,worldY:i.y,configX:(o=n==null?void 0:n.x)!=null?o:null,configY:(s=n==null?void 0:n.y)!=null?s:null}),a.highlightObject?an(a,t):on(a),a.highlightAnchor&&n?rn(a,n):sn(a)}function Ji(a){var n;let e=a.selectedObjectId;if(!e)return null;let t=window.__editableObjectInstances,i=(n=t==null?void 0:t.get)==null?void 0:n.call(t,e);return Array.isArray(i)&&i.length>0?i[0]:e}function Zi(a,e){var n,r;let t=window.gameObjectManager,i=(n=t==null?void 0:t.get)==null?void 0:n.call(t,e);return i?((r=i.getDisplayObject)==null?void 0:r.call(i))||i.pixiObject||i:null}function gt(a){let e=a.selectedObjectId;if(!e)return null;let t=window.getEditableObjectConfig;return typeof t!="function"?null:t(e)}function Qi(a,e){var o,s;let t=gt(a);if(!t)return null;let i=(o=t.transform)!=null?o:{},n=en(a);if(!n)return null;if(i.position_ratio!=null)return sr()(n.width,n.height,i.position_ratio);let r=(s=i.anchor)!=null?s:"center";return or()(n.width,n.height,r)}function en(a){var r;let e=(r=a.container)==null?void 0:r.querySelector(".game-container"),t=Number(e==null?void 0:e.dataset.screenWidth),i=Number(e==null?void 0:e.dataset.screenHeight);if(Number.isFinite(t)&&t>0&&Number.isFinite(i)&&i>0)return{width:t,height:i};let n=window.gameApp;return n!=null&&n.renderer?{width:n.renderer.width,height:n.renderer.height}:null}function tn(a){let e=window.gameApp;return e!=null&&e.stage?(a.objectBoundsGfx&&a.objectBoundsGfx.parent!==e.stage&&(a.objectBoundsGfx.destroy(),a.objectBoundsGfx=null),a.objectBoundsGfx||(a.objectBoundsGfx=new lr,a.objectBoundsGfx.zIndex=999999,e.stage.addChild(a.objectBoundsGfx)),a.objectBoundsGfx):null}function nn(a){let e=window.gameApp;return e!=null&&e.stage?(a.objectAnchorGfx&&a.objectAnchorGfx.parent!==e.stage&&(a.objectAnchorGfx.destroy(),a.objectAnchorGfx=null),a.objectAnchorGfx||(a.objectAnchorGfx=new lr,a.objectAnchorGfx.zIndex=1e6,e.stage.addChild(a.objectAnchorGfx)),a.objectAnchorGfx):null}function an(a,e){var n;let t=tn(a);if(!t)return;let i=(n=e.getBounds)==null?void 0:n.call(e);i&&(t.clear(),t.rect(i.x,i.y,i.width,i.height).stroke({width:2,color:16726832,alpha:.9}))}function rn(a,e){let t=nn(a);if(!t)return;let i=6;t.clear(),t.moveTo(e.x-i,e.y),t.lineTo(e.x+i,e.y),t.moveTo(e.x,e.y-i),t.lineTo(e.x,e.y+i),t.stroke({width:2,color:3066993,alpha:.9})}function on(a){a.objectBoundsGfx&&a.objectBoundsGfx.clear()}function sn(a){a.objectAnchorGfx&&a.objectAnchorGfx.clear()}function ut(a){a.objectBoundsGfx&&(a.objectBoundsGfx.destroy(),a.objectBoundsGfx=null),a.objectAnchorGfx&&(a.objectAnchorGfx.destroy(),a.objectAnchorGfx=null)}function pt(a,e){a.sceneToolsPanel.updateInfo(e?{instanceId:e.instanceId,worldX:e.worldX,worldY:e.worldY,anchorX:e.configX,anchorY:e.configY}:null)}function pr(a,e){return e.split(".").reduce((t,i)=>t?t[i]:void 0,a)}function ur(a,e,t){var o;let i=e.split("."),n=i.pop(),r=a;for(let s of i)r[s]=(o=r[s])!=null?o:{},r=r[s];r[n]=t}function ln(a){var i,n,r,o,s;if(!a)return!1;if((i=a.transform)!=null&&i.offset)return!0;let e=((r=(n=a.identity)==null?void 0:n.category)!=null?r:"").toString().toLowerCase(),t=((s=(o=a.identity)==null?void 0:o.id)!=null?s:"").toString().toLowerCase();return e.includes("ui")||t.startsWith("ui")||t.includes("label")}function di(a){let e=Le();e.layout&&(e.layout.scale_multiplier=1,e.layout.position_offset={x:0,y:0},e.layout.debug_rect_visible=!0,e.layout.debug_rect_color=16711680,e.layout.debug_rect_thickness=4),e.engine&&(e.engine.scale=1,e.engine.background_scale=1.05,e.engine.label_pulse_speed=3,e.engine.label_pulse_intensity=.03),e.physics&&(e.physics.rope_length=420),window.location.reload()}function gr(a){window.location.reload()}function pi(a){let e=JSON.stringify(Le(),null,2);navigator.clipboard.writeText(e).then(()=>{alert("Debug config copied to clipboard!")}).catch(()=>{console.log(e),alert("Config logged to console (clipboard not available)")})}async function hr(a,e){var t,i,n;if(!(!a.configViewer||!a.container))try{let r=window.getEditableObjectConfig,o=typeof r=="function"?r(e):null;if(!o){let{loadObjectCentricConfig:s,loadObjectConfig:l}=await import("./config-VESWPZAY.js"),p=(((t=(await s("scene.main")).scene)==null?void 0:t.objects)||[]).find(g=>g.object_config===e||g.instance_id===e);if(!p)return;let u=await l(p.object_config);console.log("[PREVIEW] Loaded object config (fallback)",e,u),ci(a,u),(i=a.configViewer)==null||i.style.setProperty("display","block");return}console.log("[PREVIEW] Loaded object config",e,o),ci(a,o),(n=a.configViewer)==null||n.style.setProperty("display","block");return}catch(r){console.error("[DEBUG] Failed to load object config:",r)}}function ci(a,e){var p,u,g,m,h,f,y,b,v,x;if(!a.container)return;let t=a.container.querySelector("#config-pos-x"),i=a.container.querySelector("#config-pos-y"),n=a.container.querySelector("#config-scale"),r=a.container.querySelector("#config-anchor-x"),o=a.container.querySelector("#config-anchor-y"),l=ln(e)?(p=e.transform)==null?void 0:p.offset:(u=e.transform)==null?void 0:u.position;t&&(t.value=String((g=l==null?void 0:l.x)!=null?g:0)),i&&(i.value=String((m=l==null?void 0:l.y)!=null?m:0)),n&&(n.value=String((f=(h=e.transform)==null?void 0:h.scale)!=null?f:1));let c=(x=(v=(y=e.transform)==null?void 0:y.anchor)!=null?v:(b=e.render)==null?void 0:b.anchor)!=null?x:{x:.5,y:.5},d=rr()(c);r&&(r.value=String(d.x)),o&&(o.value=String(d.y))}function fr(a){var l,c,d,p,u,g,m,h,f,y;let e=a.selectedObjectId;if(!e||!a.container)return;let t=(c=(l=a.container.querySelector("#config-pos-x"))==null?void 0:l.value)!=null?c:"0",i=(p=(d=a.container.querySelector("#config-pos-y"))==null?void 0:d.value)!=null?p:"0",n=(g=(u=a.container.querySelector("#config-scale"))==null?void 0:u.value)!=null?g:"1",r=(h=(m=a.container.querySelector("#config-anchor-x"))==null?void 0:m.value)!=null?h:"0.5",o=(y=(f=a.container.querySelector("#config-anchor-y"))==null?void 0:f.value)!=null?y:"0.5",s=`${e}:
923
923
  position: (${t}, ${i})
924
924
  scale: ${n}
925
- anchor: (${r}, ${o})`;navigator.clipboard.writeText(s).then(()=>console.log("[DEBUG] Config values copied to clipboard")).catch(b=>console.error("[DEBUG] Failed to copy config values:",b))}async function cn(a,e){var p,u,g,m,h,f,y,b,v,x,w;if(console.log("[INSPECTOR] \u{1F527} applyObjectConfig called"),!a.container)return;let t=a.selectedObjectId;if(!t){console.warn("[PREVIEW] Apply object config clicked with no selection");return}let i=Number((u=(p=a.container.querySelector("#config-pos-x"))==null?void 0:p.value)!=null?u:0),n=Number((m=(g=a.container.querySelector("#config-pos-y"))==null?void 0:g.value)!=null?m:0),r=Number((f=(h=a.container.querySelector("#config-scale"))==null?void 0:h.value)!=null?f:1),o=Number((b=(y=a.container.querySelector("#config-anchor-x"))==null?void 0:y.value)!=null?b:.5),s=Number((x=(v=a.container.querySelector("#config-anchor-y"))==null?void 0:v.value)!=null?x:.5);console.log("[INSPECTOR] Applying config for:",t,{posX:i,posY:n,scale:r,anchorX:o,anchorY:s});let{applyConfigOverride:l}=await import("./ConfigOverride-JLWPHR4L.js");l({objectId:t,path:"transform.position",value:{x:i,y:n}},{silent:e==null?void 0:e.silent}),l({objectId:t,path:"transform.scale",value:r},{silent:e==null?void 0:e.silent}),l({objectId:t,path:"transform.anchor",value:{x:o,y:s}},{silent:e==null?void 0:e.silent});let c=gt(a);ln(c)&&l({objectId:t,path:"transform.offset",value:{x:i,y:n}},{silent:!0}),console.log("[INSPECTOR] Calling applyEditableObjectConfig...");let d=window.applyEditableObjectConfig;if(typeof d=="function"){let E=(w=window.getEditableObjectConfig)==null?void 0:w.call(window,t);E?(console.log("[INSPECTOR] \u2705 Calling applyEditableObjectConfig for:",t),d(t,E)):console.warn("[INSPECTOR] \u26A0\uFE0F No config found for:",t)}else console.warn("[INSPECTOR] \u26A0\uFE0F applyEditableObjectConfig not available")}async function mr(a,e,t){let{applyConfigOverride:i}=await import("./ConfigOverride-JLWPHR4L.js");Object.entries(e.assets).forEach(([l,c])=>{i({path:`assets.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.theme).forEach(([l,c])=>{i({path:`runtime.theme.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.ui).forEach(([l,c])=>{i({path:`runtime.ui.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.fonts).forEach(([l,c])=>{i({path:`runtime.fonts.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.audio).forEach(([l,c])=>{i({path:`runtime.audio.${l}`,value:c},{silent:!0})});let n=window.applyEditableEngineConfig;if(typeof n=="function"){let l={theme:e.runtime.theme,fonts:e.runtime.fonts,audio:e.runtime.audio},c={};Object.entries(e.runtime.ui).forEach(([d,p])=>{var u;if(d)if(d.includes(".")){let g=d.split("."),m=c;for(let h=0;h<g.length-1;h++){let f=g[h];m[f]=(u=m[f])!=null?u:{},m=m[f]}m[g[g.length-1]]=p}else c[d]=p}),l.ui=c,n({runtime:l,assets:e.assets})}let r=Object.values(e.assets).some(l=>/^(blob:|data:)/.test(l)),o=(t==null?void 0:t.source)!=="auto"&&!r,s=window.__previewShell;o&&(s!=null&&s.refresh)&&s.refresh()}function br(a){a.selectedObjectId&&(a.objectAutoApplyTimer&&window.clearTimeout(a.objectAutoApplyTimer),a.objectAutoApplyTimer=window.setTimeout(()=>{a.objectAutoApplyTimer=null,cn(a,{silent:!0})},150))}var ho=3e3;function ht(a,e,t){let i=t!=null?t:a.offsetParent;if(!i)return;e.style.cursor="move";let n=!1,r=0,o=0,s=c=>{if(!n)return;let d=i.getBoundingClientRect(),p=c.clientX-d.left-r,u=c.clientY-d.top-o;a.style.left=`${p}px`,a.style.top=`${u}px`},l=()=>{n&&(n=!1,a.classList.remove("dragging"),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",l))};e.addEventListener("pointerdown",c=>{if(c.button!==0)return;let d=c.target;if(d!=null&&d.closest("button, input, select, textarea"))return;c.preventDefault();let p=a.getBoundingClientRect(),u=i.getBoundingClientRect();r=c.clientX-p.left,o=c.clientY-p.top,a.style.left=`${p.left-u.left}px`,a.style.top=`${p.top-u.top}px`,a.style.right="auto",a.style.bottom="auto",a.style.zIndex=String(++ho),n=!0,a.classList.add("dragging"),window.addEventListener("pointermove",s),window.addEventListener("pointerup",l)})}function dn(a,e,t,i=280,n=200){e.style.cursor="nwse-resize";let r=0,o=0,s=0,l=0,c=!1,d=u=>{if(!c)return;let g=u.clientX-s,m=u.clientY-l,h=Math.max(i,r+g),f=Math.max(n,o+m);a.style.width=`${h}px`,a.style.height=`${f}px`,t==null||t(h,f)},p=()=>{c&&(c=!1,window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p))};e.addEventListener("pointerdown",u=>{if(u.button!==0)return;u.preventDefault(),u.stopPropagation();let g=a.getBoundingClientRect();r=g.width,o=g.height,s=u.clientX,l=u.clientY,c=!0,window.addEventListener("pointermove",d),window.addEventListener("pointerup",p)})}function pn(a,e){var h,f,y,b;let t=(y=(f=(h=a.container)==null?void 0:h.querySelector("#debug-overlay"))!=null?f:a.debugOverlay)!=null?y:e.offsetParent;if(!t||(b=a.container)!=null&&b.classList.contains("layout-fixed"))return;let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),r=12,o=Math.max(250,Math.floor(i.width-r*2)),s=Math.max(200,Math.floor(i.height-r*2));n.width>o&&(e.style.width=`${o}px`),n.height>s&&(e.style.height=`${s}px`);let l=e.getBoundingClientRect(),c=l.left-i.left,d=l.top-i.top,p=Math.max(r,i.width-l.width-r),u=Math.max(r,i.height-l.height-r),g=Math.min(Math.max(c,r),p),m=Math.min(Math.max(d,r),u);e.style.left=`${Math.round(g)}px`,e.style.top=`${Math.round(m)}px`,e.style.right="auto",e.style.bottom="auto"}function Oe(a){var i;if(!a.container)return;let e=a.container.querySelector("#debug-workbench");if(!e)return;if(pn(a,e),(i=a.container)!=null&&i.classList.contains("layout-fixed")){let n=localStorage.getItem("preview_workbench_state"),r={activeTab:a.activeTab};if(n)try{r={...JSON.parse(n),activeTab:a.activeTab}}catch{}localStorage.setItem("preview_workbench_state",JSON.stringify(r));return}let t={activeTab:a.activeTab,width:e.style.width,height:e.style.height,left:e.style.left,top:e.style.top};localStorage.setItem("preview_workbench_state",JSON.stringify(t))}function ui(a){try{let e=localStorage.getItem("preview_workbench_state");if(!e)return;let t=JSON.parse(e);t.activeTab&&(a.activeTab=t.activeTab),window.requestAnimationFrame(()=>{var n;let i=(n=a.container)==null?void 0:n.querySelector("#debug-workbench");i&&(t.width&&(i.style.width=t.width),t.height&&(i.style.height=t.height),t.left&&(i.style.left=t.left,i.style.right="auto"),t.top&&(i.style.top=t.top,i.style.bottom="auto"),pn(a,i))})}catch(e){console.warn("[PREVIEW] Failed to load workbench state",e)}}function un(a,e){let t=e.getBoundingClientRect();(t.left<0||t.top<0||t.right>window.innerWidth||t.bottom>window.innerHeight)&&(console.warn("[Workbench] Workbench positioned outside viewport, repositioning..."),e.style.left="16px",e.style.top="72px",e.style.right="auto",e.style.bottom="auto",pn(a,e),Oe(a))}function yr(a){var n,r,o;if(!a.container)return;let e=a.container,t=e.querySelector("#debug-toggle");t||console.warn("[PREVIEW] Debug toggle not found in DOM"),t==null||t.addEventListener("click",()=>{var s;console.log("[PREVIEW] Debug toggle clicked"),(s=a.toggleDebug)==null||s.call(a)}),(n=e.querySelector("#debug-close"))==null||n.addEventListener("click",()=>{var s;return(s=a.toggleDebug)==null?void 0:s.call(a,!1)}),(r=e.querySelector("#debug-reset"))==null||r.addEventListener("click",()=>di(a)),(o=e.querySelector("#debug-export"))==null||o.addEventListener("click",()=>pi(a)),e.querySelectorAll(".workbench-tab").forEach(s=>{s.addEventListener("click",()=>{let l=s.dataset.tab;a.activeTab=l,gn(a),Oe(a)})}),fn(a,e),hn(a,e)}function gn(a){if(!a.container)return;let e=a.container;e.querySelectorAll(".workbench-tab").forEach(n=>{let r=n.dataset.tab;n.classList.toggle("active",r===a.activeTab)}),e.querySelectorAll(".workbench-tab-panel").forEach(n=>{let r=n.dataset.tabPanel;n.classList.toggle("active",r===a.activeTab)})}function hn(a,e){ae(a,e,"debug-layout-scale","layout.scale_multiplier","#debug-layout-scale-value"),ae(a,e,"debug-layout-offset-x","layout.position_offset.x","#debug-layout-offset-x-value"),ae(a,e,"debug-layout-offset-y","layout.position_offset.y","#debug-layout-offset-y-value"),ae(a,e,"debug-rect-thickness","layout.debug_rect_thickness","#debug-rect-thickness-value"),ae(a,e,"debug-engine-scale","engine.scale","#debug-engine-scale-value"),ae(a,e,"debug-background-scale","engine.background_scale","#debug-background-scale-value"),ae(a,e,"debug-label-pulse-speed","engine.label_pulse_speed","#debug-label-pulse-speed-value"),ae(a,e,"debug-label-pulse-intensity","engine.label_pulse_intensity","#debug-label-pulse-intensity-value"),ae(a,e,"debug-rope-length","physics.rope_length","#debug-rope-length-value");let t=e.querySelector("#debug-rect-visible");t==null||t.addEventListener("change",()=>{let n=Le();n.layout&&(n.layout.debug_rect_visible=!!t.checked)});let i=e.querySelector("#debug-rect-color");i==null||i.addEventListener("input",()=>{let n=i.value.replace("#",""),r=parseInt(n,16),o=Le();o.layout&&(o.layout.debug_rect_color=Number.isFinite(r)?r:16711680)})}function vr(a){if(!a.container||!a.debugOverlay)return;let e=a.container.querySelector("#debug-workbench"),t=a.container.querySelector("#workbench-handle"),i=a.container.querySelector("#workbench-resize");e&&t&&(!e.style.left&&!e.style.right&&!e.style.top&&!e.style.bottom&&(e.style.right="16px",e.style.top="72px"),ht(e,t,a.debugOverlay),t.addEventListener("pointerup",()=>{setTimeout(()=>{Oe(a),un(a,e)},10)}));let n=a.container.querySelector('[data-panel="scene-objects"]'),r=n==null?void 0:n.querySelector("[data-panel-handle]"),o=n==null?void 0:n.querySelector("[data-panel-resize-v]");n&&r&&(!n.style.left&&!n.style.right&&!n.style.top&&!n.style.bottom&&(n.style.left="16px",n.style.top="72px"),ht(n,r,a.debugOverlay),r.addEventListener("pointerup",()=>{setTimeout(()=>{un(a,n)},10)})),n&&o&&dn(n,o);let s=a.container.querySelector('[data-panel="scene-tools-corner"]'),l=s==null?void 0:s.querySelector("[data-panel-handle]"),c=a.container.querySelector(".preview-main");s&&l&&c&&ht(s,l,c);let d=a.container.querySelector('[data-panel="nudge-panel"]'),p=d==null?void 0:d.querySelector("[data-panel-handle]");d&&p&&c&&ht(d,p,c),e&&i&&dn(e,i,()=>Oe(a)),ui(a)}function fn(a,e){Array.from(e.querySelectorAll("[data-panel-toggle]")).forEach(i=>{i.addEventListener("click",()=>{let n=i.closest(".scene-panel");n&&n.classList.toggle("collapsed")})})}function ae(a,e,t,i,n){let r=e.querySelector(`#${t}`),o=e.querySelector(n);if(!r||!o)return;let s=pr(Le(),i);typeof s=="number"&&(r.value=String(s),o.textContent=String(s)),r.addEventListener("input",()=>{let l=Number(r.value);o.textContent=String(l),ur(Le(),i,l)})}var gi=class{constructor(){this.container=null;this.currentVersion=null;this.availableVersions=[];this.isDevelopmentMode=!1}async initialize(e){this.container=e,this.isDevelopmentMode=typeof window!="undefined"&&document.querySelector('script[type="module"][src*="/@vite/"]')!==null,await this.loadVersionsList(),window.addEventListener("config:changed",()=>{this.refreshPanel()}),this.refreshPanel()}render(){let e=aa(),{hasChanges:t,overrideCount:i,overrides:n}=e,r={};for(let l of n){let c=l.objectId||"Engine";r[c]||(r[c]=[]),r[c].push(l)}let o=localStorage.getItem("handler_last_applied"),s=o?new Date(parseInt(o)).toLocaleString():"Never";return`
925
+ anchor: (${r}, ${o})`;navigator.clipboard.writeText(s).then(()=>console.log("[DEBUG] Config values copied to clipboard")).catch(b=>console.error("[DEBUG] Failed to copy config values:",b))}async function cn(a,e){var p,u,g,m,h,f,y,b,v,x,w;if(console.log("[INSPECTOR] \u{1F527} applyObjectConfig called"),!a.container)return;let t=a.selectedObjectId;if(!t){console.warn("[PREVIEW] Apply object config clicked with no selection");return}let i=Number((u=(p=a.container.querySelector("#config-pos-x"))==null?void 0:p.value)!=null?u:0),n=Number((m=(g=a.container.querySelector("#config-pos-y"))==null?void 0:g.value)!=null?m:0),r=Number((f=(h=a.container.querySelector("#config-scale"))==null?void 0:h.value)!=null?f:1),o=Number((b=(y=a.container.querySelector("#config-anchor-x"))==null?void 0:y.value)!=null?b:.5),s=Number((x=(v=a.container.querySelector("#config-anchor-y"))==null?void 0:v.value)!=null?x:.5);console.log("[INSPECTOR] Applying config for:",t,{posX:i,posY:n,scale:r,anchorX:o,anchorY:s});let{applyConfigOverride:l}=await import("./ConfigOverride-JLWPHR4L.js");l({objectId:t,path:"transform.position",value:{x:i,y:n}},{silent:e==null?void 0:e.silent}),l({objectId:t,path:"transform.scale",value:r},{silent:e==null?void 0:e.silent}),l({objectId:t,path:"transform.anchor",value:{x:o,y:s}},{silent:e==null?void 0:e.silent});let c=gt(a);ln(c)&&l({objectId:t,path:"transform.offset",value:{x:i,y:n}},{silent:!0}),console.log("[INSPECTOR] Calling applyEditableObjectConfig...");let d=window.applyEditableObjectConfig;if(typeof d=="function"){let E=(w=window.getEditableObjectConfig)==null?void 0:w.call(window,t);E?(console.log("[INSPECTOR] \u2705 Calling applyEditableObjectConfig for:",t),d(t,E)):console.warn("[INSPECTOR] \u26A0\uFE0F No config found for:",t)}else console.warn("[INSPECTOR] \u26A0\uFE0F applyEditableObjectConfig not available")}async function mr(a,e,t){let{applyConfigOverride:i}=await import("./ConfigOverride-JLWPHR4L.js");Object.entries(e.assets).forEach(([l,c])=>{i({path:`assets.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.theme).forEach(([l,c])=>{i({path:`runtime.theme.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.ui).forEach(([l,c])=>{i({path:`runtime.ui.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.fonts).forEach(([l,c])=>{i({path:`runtime.fonts.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.audio).forEach(([l,c])=>{i({path:`runtime.audio.${l}`,value:c},{silent:!0})});let n=window.applyEditableEngineConfig;if(typeof n=="function"){let l={theme:e.runtime.theme,fonts:e.runtime.fonts,audio:e.runtime.audio},c={};Object.entries(e.runtime.ui).forEach(([d,p])=>{var u;if(d)if(d.includes(".")){let g=d.split("."),m=c;for(let h=0;h<g.length-1;h++){let f=g[h];m[f]=(u=m[f])!=null?u:{},m=m[f]}m[g[g.length-1]]=p}else c[d]=p}),l.ui=c,n({runtime:l,assets:e.assets})}let r=Object.values(e.assets).some(l=>/^(blob:|data:)/.test(l)),o=(t==null?void 0:t.source)!=="auto"&&!r,s=window.__previewShell;o&&(s!=null&&s.refresh)&&s.refresh()}function br(a){a.selectedObjectId&&(a.objectAutoApplyTimer&&window.clearTimeout(a.objectAutoApplyTimer),a.objectAutoApplyTimer=window.setTimeout(()=>{a.objectAutoApplyTimer=null,cn(a,{silent:!0})},150))}var ho=3e3;function ht(a,e,t){let i=t!=null?t:a.offsetParent;if(!i)return;e.style.cursor="move";let n=!1,r=0,o=0,s=0,l=0,c=p=>{if(!n)return;let u=p.clientX-r,g=p.clientY-o;a.style.left=`${s+u}px`,a.style.top=`${l+g}px`},d=()=>{n&&(n=!1,a.classList.remove("dragging"),window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",d))};e.addEventListener("pointerdown",p=>{if(p.button!==0)return;let u=p.target;if(u!=null&&u.closest("button, input, select, textarea"))return;p.preventDefault();let g=a.getBoundingClientRect(),m=i.getBoundingClientRect();s=g.left-m.left,l=g.top-m.top,r=p.clientX,o=p.clientY,a.style.left=`${s}px`,a.style.top=`${l}px`,a.style.right="auto",a.style.bottom="auto",a.style.zIndex=String(++ho),n=!0,a.classList.add("dragging"),window.addEventListener("pointermove",c),window.addEventListener("pointerup",d)})}function dn(a,e,t,i=280,n=200){e.style.cursor="nwse-resize";let r=0,o=0,s=0,l=0,c=!1,d=u=>{if(!c)return;let g=u.clientX-s,m=u.clientY-l,h=Math.max(i,r+g),f=Math.max(n,o+m);a.style.width=`${h}px`,a.style.height=`${f}px`,t==null||t(h,f)},p=()=>{c&&(c=!1,window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p))};e.addEventListener("pointerdown",u=>{if(u.button!==0)return;u.preventDefault(),u.stopPropagation();let g=a.getBoundingClientRect();r=g.width,o=g.height,s=u.clientX,l=u.clientY,c=!0,window.addEventListener("pointermove",d),window.addEventListener("pointerup",p)})}function pn(a,e){var h,f,y,b;let t=(y=(f=(h=a.container)==null?void 0:h.querySelector("#debug-overlay"))!=null?f:a.debugOverlay)!=null?y:e.offsetParent;if(!t||(b=a.container)!=null&&b.classList.contains("layout-fixed"))return;let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),r=12,o=Math.max(250,Math.floor(i.width-r*2)),s=Math.max(200,Math.floor(i.height-r*2));n.width>o&&(e.style.width=`${o}px`),n.height>s&&(e.style.height=`${s}px`);let l=e.getBoundingClientRect(),c=l.left-i.left,d=l.top-i.top,p=Math.max(r,i.width-l.width-r),u=Math.max(r,i.height-l.height-r),g=Math.min(Math.max(c,r),p),m=Math.min(Math.max(d,r),u);e.style.left=`${Math.round(g)}px`,e.style.top=`${Math.round(m)}px`,e.style.right="auto",e.style.bottom="auto"}function Oe(a){var i;if(!a.container)return;let e=a.container.querySelector("#debug-workbench");if(!e)return;if(pn(a,e),(i=a.container)!=null&&i.classList.contains("layout-fixed")){let n=localStorage.getItem("preview_workbench_state"),r={activeTab:a.activeTab};if(n)try{r={...JSON.parse(n),activeTab:a.activeTab}}catch{}localStorage.setItem("preview_workbench_state",JSON.stringify(r));return}let t={activeTab:a.activeTab,width:e.style.width,height:e.style.height,left:e.style.left,top:e.style.top};localStorage.setItem("preview_workbench_state",JSON.stringify(t))}function ui(a){try{let e=localStorage.getItem("preview_workbench_state");if(!e)return;let t=JSON.parse(e);t.activeTab&&(a.activeTab=t.activeTab),window.requestAnimationFrame(()=>{var n;let i=(n=a.container)==null?void 0:n.querySelector("#debug-workbench");i&&(t.width&&(i.style.width=t.width),t.height&&(i.style.height=t.height),t.left&&(i.style.left=t.left,i.style.right="auto"),t.top&&(i.style.top=t.top,i.style.bottom="auto"),pn(a,i))})}catch(e){console.warn("[PREVIEW] Failed to load workbench state",e)}}function un(a,e){let t=e.getBoundingClientRect();(t.left<0||t.top<0||t.right>window.innerWidth||t.bottom>window.innerHeight)&&(console.warn("[Workbench] Workbench positioned outside viewport, repositioning..."),e.style.left="16px",e.style.top="72px",e.style.right="auto",e.style.bottom="auto",pn(a,e),Oe(a))}function yr(a){var n,r,o;if(!a.container)return;let e=a.container,t=e.querySelector("#debug-toggle");t||console.warn("[PREVIEW] Debug toggle not found in DOM"),t==null||t.addEventListener("click",()=>{var s;console.log("[PREVIEW] Debug toggle clicked"),(s=a.toggleDebug)==null||s.call(a)}),(n=e.querySelector("#debug-close"))==null||n.addEventListener("click",()=>{var s;return(s=a.toggleDebug)==null?void 0:s.call(a,!1)}),(r=e.querySelector("#debug-reset"))==null||r.addEventListener("click",()=>di(a)),(o=e.querySelector("#debug-export"))==null||o.addEventListener("click",()=>pi(a)),e.querySelectorAll(".workbench-tab").forEach(s=>{s.addEventListener("click",()=>{let l=s.dataset.tab;a.activeTab=l,gn(a),Oe(a)})}),fn(a,e),hn(a,e)}function gn(a){if(!a.container)return;let e=a.container;e.querySelectorAll(".workbench-tab").forEach(n=>{let r=n.dataset.tab;n.classList.toggle("active",r===a.activeTab)}),e.querySelectorAll(".workbench-tab-panel").forEach(n=>{let r=n.dataset.tabPanel;n.classList.toggle("active",r===a.activeTab)})}function hn(a,e){ae(a,e,"debug-layout-scale","layout.scale_multiplier","#debug-layout-scale-value"),ae(a,e,"debug-layout-offset-x","layout.position_offset.x","#debug-layout-offset-x-value"),ae(a,e,"debug-layout-offset-y","layout.position_offset.y","#debug-layout-offset-y-value"),ae(a,e,"debug-rect-thickness","layout.debug_rect_thickness","#debug-rect-thickness-value"),ae(a,e,"debug-engine-scale","engine.scale","#debug-engine-scale-value"),ae(a,e,"debug-background-scale","engine.background_scale","#debug-background-scale-value"),ae(a,e,"debug-label-pulse-speed","engine.label_pulse_speed","#debug-label-pulse-speed-value"),ae(a,e,"debug-label-pulse-intensity","engine.label_pulse_intensity","#debug-label-pulse-intensity-value"),ae(a,e,"debug-rope-length","physics.rope_length","#debug-rope-length-value");let t=e.querySelector("#debug-rect-visible");t==null||t.addEventListener("change",()=>{let n=Le();n.layout&&(n.layout.debug_rect_visible=!!t.checked)});let i=e.querySelector("#debug-rect-color");i==null||i.addEventListener("input",()=>{let n=i.value.replace("#",""),r=parseInt(n,16),o=Le();o.layout&&(o.layout.debug_rect_color=Number.isFinite(r)?r:16711680)})}function vr(a){if(!a.container||!a.debugOverlay)return;let e=a.container.querySelector("#debug-workbench"),t=a.container.querySelector("#workbench-handle"),i=a.container.querySelector("#workbench-resize");e&&t&&(!e.style.left&&!e.style.right&&!e.style.top&&!e.style.bottom&&(e.style.right="16px",e.style.top="72px"),ht(e,t,a.debugOverlay),t.addEventListener("pointerup",()=>{setTimeout(()=>{Oe(a),un(a,e)},10)}));let n=a.container.querySelector('[data-panel="scene-objects"]'),r=n==null?void 0:n.querySelector("[data-panel-handle]"),o=n==null?void 0:n.querySelector("[data-panel-resize-v]");n&&r&&(!n.style.left&&!n.style.right&&!n.style.top&&!n.style.bottom&&(n.style.left="16px",n.style.top="72px"),ht(n,r,a.debugOverlay),r.addEventListener("pointerup",()=>{setTimeout(()=>{un(a,n)},10)})),n&&o&&dn(n,o);let s=a.container.querySelector('[data-panel="scene-tools-corner"]'),l=s==null?void 0:s.querySelector("[data-panel-handle]"),c=a.container.querySelector(".preview-main");s&&l&&c&&ht(s,l,c);let d=a.container.querySelector('[data-panel="nudge-panel"]'),p=d==null?void 0:d.querySelector("[data-panel-handle]");d&&p&&c&&ht(d,p,c),e&&i&&dn(e,i,()=>Oe(a)),ui(a)}function fn(a,e){Array.from(e.querySelectorAll("[data-panel-toggle]")).forEach(i=>{i.addEventListener("click",()=>{let n=i.closest(".scene-panel");n&&n.classList.toggle("collapsed")})})}function ae(a,e,t,i,n){let r=e.querySelector(`#${t}`),o=e.querySelector(n);if(!r||!o)return;let s=pr(Le(),i);typeof s=="number"&&(r.value=String(s),o.textContent=String(s)),r.addEventListener("input",()=>{let l=Number(r.value);o.textContent=String(l),ur(Le(),i,l)})}var gi=class{constructor(){this.container=null;this.currentVersion=null;this.availableVersions=[];this.isDevelopmentMode=!1}async initialize(e){this.container=e,this.isDevelopmentMode=typeof window!="undefined"&&document.querySelector('script[type="module"][src*="/@vite/"]')!==null,await this.loadVersionsList(),window.addEventListener("config:changed",()=>{this.refreshPanel()}),this.refreshPanel()}render(){let e=aa(),{hasChanges:t,overrideCount:i,overrides:n}=e,r={};for(let l of n){let c=l.objectId||"Engine";r[c]||(r[c]=[]),r[c].push(l)}let o=localStorage.getItem("handler_last_applied"),s=o?new Date(parseInt(o)).toLocaleString():"Never";return`
926
926
  <div class="config-persistence-panel">
927
927
  <div class="persistence-status-bar ${t?"has-changes":"no-changes"}">
928
928
  ${t?`
@@ -1306,7 +1306,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=n,this.currentPrompt=n}}c
1306
1306
  <button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
1307
1307
  </div>
1308
1308
  </div>
1309
- `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,i=this.cropX+this.cropWidth/2,n=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,i-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,n-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,i=this.cropWidth*this.scale,n=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,i,n),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,i,n),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+i-r,t],[e,t+n-r],[e+i-r,t+n-r]].forEach(([s,l])=>{var c;(c=this.ctx)==null||c.fillRect(s,l,r,r)})}updatePreview(){if(!this.modal||!this.image)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let i=150;e.width=i,e.height=i;let n=i/this.cropWidth,r=i/this.cropHeight,o=Math.min(n,r),s=this.cropWidth*o,l=this.cropHeight*o,c=(i-s)/2,d=(i-l)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,c,d,s,l)}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",i=>{let n=parseFloat(i.target.value);this.setZoom(n)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",i=>{let n=i.target.value;this.setAspectRatio(n)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var n;if(!this.image||!((n=this.options)!=null&&n.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let i=e.toDataURL("image/png");this.options.onCrop(i),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(a){new wn().open(a)};var En=class{constructor(e={}){this.isLandscape=!1;this.autoScale=1;this.userScaleMultiplier=1;this.viewMode="single";this.layoutMode="fixed";this.comparePresets=[Ge("playable-portrait"),Ge("iphone-14"),Ge("ipad-mini")];this.activeCompareId="playable-portrait";this.compareViewports=new Map;this.resizeObserver=null;this.rafFitHandle=null;this.ignoreNextWindowResize=!1;this.frameDragOffsetX=0;this.frameDragOffsetY=0;this.frameDragActive=!1;this.frameDragStartX=0;this.frameDragStartY=0;this.frameDragOriginX=0;this.frameDragOriginY=0;this.isSpaceKeyPressed=!1;this.consolePanel=null;this.consoleMessages=[];this.isConsoleOpen=!1;this.hasInitialFit=!1;this.isMounted=!1;this.isInitialized=!1;this.gameReady=!1;this.resizeListenersDisabled=!1;this.compareSnapshotTimer=null;this.onWindowResize=e=>{if(this.ignoreNextWindowResize){this.ignoreNextWindowResize=!1;return}this.resizeListenersDisabled||!this.gameReady||this.scheduleFit()};this.onFrameDragMove=e=>{if(!this.frameDragActive)return;let t=e.clientX-this.frameDragStartX,i=e.clientY-this.frameDragStartY;this.frameDragOffsetX=this.frameDragOriginX+t,this.frameDragOffsetY=this.frameDragOriginY+i,this.applyFrameDrag(),this.updateDragCursor()};this.onFrameDragEnd=()=>{this.frameDragActive&&(this.frameDragActive=!1,window.removeEventListener("pointermove",this.onFrameDragMove),window.removeEventListener("pointerup",this.onFrameDragEnd),this.updateDragCursor())};this.options=e,this.currentPreset=Ge(e.defaultDevice||Gi.id),this.debugPanel=new hi,this.container=this.createShell(),this.previewContainer=this.mustQuery(".preview-container"),this.singleStage=this.mustQuery('[data-preview-stage="single"]'),this.compareStage=this.mustQuery('[data-preview-stage="compare"]'),this.frameDragger=this.mustQuery(".frame-dragger"),this.frameWrapper=this.mustQuery(".frame-wrapper"),this.deviceFrame=this.mustQuery(".device-frame"),this.gameContainer=this.mustQuery(".game-container"),this.lastSinglePresetId=this.currentPreset.id,this.consolePanel=this.container.querySelector(".console-panel"),this.debugPanel.initialize(this.container),this.debugPanel.setupDebugEventListeners(),this.applyDeviceFrameStyles(),this.setupCompareViewports(),this.setupConsoleInterceptor(),this.setupObserversAndListeners(),this.setupFrameDragging(),this.setupSpaceKeyListener(),this.setDevice(this.currentPreset.id,{suppressCallback:!0}),this.updateDockState(),this.isInitialized=!0}mount(e=document.body){e.innerHTML="",e.appendChild(this.container),this.isMounted=!0,this.scheduleFit()}destroy(){if(this.disableResizeListeners(),this.resizeObserver){try{this.resizeObserver.disconnect()}catch{}this.resizeObserver=null}window.removeEventListener("resize",this.onWindowResize),this.rafFitHandle&&(cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=null),this.compareSnapshotTimer&&(window.clearInterval(this.compareSnapshotTimer),this.compareSnapshotTimer=null),this.gameReady=!1}getGameContainer(){return this.gameContainer}getScreen(){let e=this.getEffectivePreset();return{width:e.width,height:e.height}}getEffectivePreset(){var e;return this.isLandscape?{...this.currentPreset,width:this.currentPreset.height,height:this.currentPreset.width,ratio:((e=this.currentPreset.ratio)==null?void 0:e.split(":").reverse().join(":"))||this.currentPreset.ratio}:this.currentPreset}notifyGameLoaded(){this.gameReady=!0,this.enableResizeListeners(),this.scheduleFit(),this.debugPanel.refresh(),requestAnimationFrame(()=>this.updatePanelPositions())}notifyGameDestroyed(){this.gameReady=!1,this.disableResizeListeners()}disableResizeListeners(){this.resizeListenersDisabled=!0,this.rafFitHandle&&(cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=null)}enableResizeListeners(){this.resizeListenersDisabled=!1}refresh(){this.options.onRefresh?this.options.onRefresh():window.location.reload()}setDevice(e,t={}){var n,r;let i=this.autoScale*this.userScaleMultiplier;this.isLandscape=!1,this.currentPreset=Ge(e),this.viewMode==="single"&&(this.lastSinglePresetId=this.currentPreset.id),this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale:i}),t.suppressCallback||(r=(n=this.options).onDeviceChange)==null||r.call(n,this.getEffectivePreset()),this.emitScreenChange()}setTheme(e){e==="dark"?this.container.classList.add("theme-dark"):this.container.classList.remove("theme-dark"),requestAnimationFrame(()=>this.updatePanelPositions())}setLayoutMode(e){if(this.layoutMode===e)return;this.layoutMode=e,this.container.classList.toggle("layout-fixed",e==="fixed"),this.container.classList.toggle("layout-draggable",e==="draggable"),Array.from(this.container.querySelectorAll("[data-layout-toggle]")).forEach(n=>n.classList.toggle("active",n.dataset.layoutToggle===e)),Array.from(this.container.querySelectorAll(".debug-workbench, .scene-panel")).forEach(n=>{n.style.left="",n.style.top="",n.style.width="",n.style.height="",n.style.zIndex=""}),this.scheduleFit(),this.updateDockState(),this.updatePanelPositions(),window.dispatchEvent(new CustomEvent("inspector:refresh"))}updateDockState(){let e=this.container.querySelector("#bottom-dock");e==null||e.classList.remove("hidden");let t=this.container.querySelector("#console-messages"),i=this.container.querySelector("#dock-console-content");t&&i&&t.parentElement!==i&&i.appendChild(t)}makeBottomDockResizable(e,t){let i,n,r=s=>{let l=s.clientY-i,c=Math.max(100,Math.min(800,n-l));e.style.height=`${c}px`,this.scheduleFit()},o=()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",o),e.classList.remove("resizing")};t.addEventListener("pointerdown",s=>{s.preventDefault(),i=s.clientY,n=e.offsetHeight,document.addEventListener("pointermove",r),document.addEventListener("pointerup",o),e.classList.add("resizing")})}makeSidebarResizable(e,t,i){let n,r,o=l=>{let c=i==="left"?l.clientX-n:n-l.clientX,d=Math.max(200,Math.min(600,r+c));e.style.width=`${d}px`;let p=this.container.querySelector(".preview-main");if(p){let u=i==="left"?`${d}px`:p.style.gridTemplateColumns.split(" ")[0]||"300px",g=i==="right"?`${d}px`:p.style.gridTemplateColumns.split(" ")[2]||"350px";p.style.gridTemplateColumns=`${u} 1fr ${g}`}this.scheduleFit()},s=()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",s),e.classList.remove("resizing")};t.addEventListener("pointerdown",l=>{l.preventDefault(),n=l.clientX,r=e.offsetWidth,document.addEventListener("pointermove",o),document.addEventListener("pointerup",s),e.classList.add("resizing")})}createShell(){var t;let e=document.createElement("div");return e.className="preview-shell layout-fixed",e.innerHTML=`
1309
+ `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,i=this.cropX+this.cropWidth/2,n=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,i-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,n-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,i=this.cropWidth*this.scale,n=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,i,n),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,i,n),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+i-r,t],[e,t+n-r],[e+i-r,t+n-r]].forEach(([s,l])=>{var c;(c=this.ctx)==null||c.fillRect(s,l,r,r)})}updatePreview(){if(!this.modal||!this.image)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let i=150;e.width=i,e.height=i;let n=i/this.cropWidth,r=i/this.cropHeight,o=Math.min(n,r),s=this.cropWidth*o,l=this.cropHeight*o,c=(i-s)/2,d=(i-l)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,c,d,s,l)}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",i=>{let n=parseFloat(i.target.value);this.setZoom(n)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",i=>{let n=i.target.value;this.setAspectRatio(n)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var n;if(!this.image||!((n=this.options)!=null&&n.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let i=e.toDataURL("image/png");this.options.onCrop(i),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(a){new wn().open(a)};var En=class{constructor(e={}){this.isLandscape=!1;this.autoScale=1;this.userScaleMultiplier=1;this.viewMode="single";this.layoutMode="fixed";this.comparePresets=[Ge("playable-portrait"),Ge("iphone-14"),Ge("ipad-mini")];this.activeCompareId="playable-portrait";this.compareViewports=new Map;this.resizeObserver=null;this.rafFitHandle=null;this.ignoreNextWindowResize=!1;this.frameDragOffsetX=0;this.frameDragOffsetY=0;this.frameDragActive=!1;this.frameDragStartX=0;this.frameDragStartY=0;this.frameDragOriginX=0;this.frameDragOriginY=0;this.isSpaceKeyPressed=!1;this.consolePanel=null;this.consoleMessages=[];this.isConsoleOpen=!1;this.originalConsole={log:console.log.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),info:console.info.bind(console)};this.hasInitialFit=!1;this.isMounted=!1;this.isInitialized=!1;this.gameReady=!1;this.resizeListenersDisabled=!1;this.compareSnapshotTimer=null;this.onWindowResize=e=>{if(this.ignoreNextWindowResize){this.ignoreNextWindowResize=!1;return}this.resizeListenersDisabled||!this.gameReady||this.scheduleFit()};this.onFrameDragMove=e=>{if(!this.frameDragActive)return;let t=e.clientX-this.frameDragStartX,i=e.clientY-this.frameDragStartY;this.frameDragOffsetX=this.frameDragOriginX+t,this.frameDragOffsetY=this.frameDragOriginY+i,this.applyFrameDrag(),this.updateDragCursor()};this.onFrameDragEnd=()=>{this.frameDragActive&&(this.frameDragActive=!1,window.removeEventListener("pointermove",this.onFrameDragMove),window.removeEventListener("pointerup",this.onFrameDragEnd),this.updateDragCursor())};this.options=e,this.currentPreset=Ge(e.defaultDevice||Gi.id),this.debugPanel=new hi,this.container=this.createShell(),this.previewContainer=this.mustQuery(".preview-container"),this.singleStage=this.mustQuery('[data-preview-stage="single"]'),this.compareStage=this.mustQuery('[data-preview-stage="compare"]'),this.frameDragger=this.mustQuery(".frame-dragger"),this.frameWrapper=this.mustQuery(".frame-wrapper"),this.deviceFrame=this.mustQuery(".device-frame"),this.gameContainer=this.mustQuery(".game-container"),this.lastSinglePresetId=this.currentPreset.id,this.consolePanel=this.container.querySelector(".console-panel"),this.debugPanel.initialize(this.container),this.debugPanel.setupDebugEventListeners(),this.applyDeviceFrameStyles(),this.setupCompareViewports(),this.setupConsoleInterceptor(),this.setupObserversAndListeners(),this.setupFrameDragging(),this.setupSpaceKeyListener(),this.setDevice(this.currentPreset.id,{suppressCallback:!0}),this.updateDockState(),this.isInitialized=!0}mount(e=document.body){e.innerHTML="",e.appendChild(this.container),this.isMounted=!0,this.scheduleFit()}destroy(){if(this.disableResizeListeners(),this.resizeObserver){try{this.resizeObserver.disconnect()}catch{}this.resizeObserver=null}window.removeEventListener("resize",this.onWindowResize),this.rafFitHandle&&(cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=null),this.compareSnapshotTimer&&(window.clearInterval(this.compareSnapshotTimer),this.compareSnapshotTimer=null),this.gameReady=!1}getGameContainer(){return this.gameContainer}getScreen(){let e=this.getEffectivePreset();return{width:e.width,height:e.height}}getEffectivePreset(){var e;return this.isLandscape?{...this.currentPreset,width:this.currentPreset.height,height:this.currentPreset.width,ratio:((e=this.currentPreset.ratio)==null?void 0:e.split(":").reverse().join(":"))||this.currentPreset.ratio}:this.currentPreset}notifyGameLoaded(){this.gameReady=!0,this.enableResizeListeners(),this.scheduleFit(),this.debugPanel.refresh(),requestAnimationFrame(()=>this.updatePanelPositions())}notifyGameDestroyed(){this.gameReady=!1,this.disableResizeListeners()}disableResizeListeners(){this.resizeListenersDisabled=!0,this.rafFitHandle&&(cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=null)}enableResizeListeners(){this.resizeListenersDisabled=!1}refresh(){this.options.onRefresh?this.options.onRefresh():window.location.reload()}setDevice(e,t={}){var n,r;let i=this.autoScale*this.userScaleMultiplier;this.isLandscape=!1,this.currentPreset=Ge(e),this.viewMode==="single"&&(this.lastSinglePresetId=this.currentPreset.id),this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale:i}),t.suppressCallback||(r=(n=this.options).onDeviceChange)==null||r.call(n,this.getEffectivePreset()),this.emitScreenChange()}setTheme(e){e==="dark"?this.container.classList.add("theme-dark"):this.container.classList.remove("theme-dark"),requestAnimationFrame(()=>this.updatePanelPositions())}setLayoutMode(e){if(this.layoutMode===e)return;this.layoutMode=e,this.container.classList.toggle("layout-fixed",e==="fixed"),this.container.classList.toggle("layout-draggable",e==="draggable"),Array.from(this.container.querySelectorAll("[data-layout-toggle]")).forEach(n=>n.classList.toggle("active",n.dataset.layoutToggle===e)),Array.from(this.container.querySelectorAll(".debug-workbench, .scene-panel")).forEach(n=>{n.style.left="",n.style.top="",n.style.width="",n.style.height="",n.style.zIndex=""}),this.scheduleFit(),this.updateDockState(),this.updatePanelPositions(),window.dispatchEvent(new CustomEvent("inspector:refresh"))}updateDockState(){let e=this.container.querySelector("#bottom-dock");e==null||e.classList.remove("hidden");let t=this.container.querySelector("#console-messages"),i=this.container.querySelector("#dock-console-content");t&&i&&t.parentElement!==i&&i.appendChild(t)}makeBottomDockResizable(e,t){let i,n,r=s=>{let l=s.clientY-i,c=Math.max(100,Math.min(800,n-l));e.style.height=`${c}px`,this.scheduleFit()},o=()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",o),e.classList.remove("resizing")};t.addEventListener("pointerdown",s=>{s.preventDefault(),i=s.clientY,n=e.offsetHeight,document.addEventListener("pointermove",r),document.addEventListener("pointerup",o),e.classList.add("resizing")})}makeSidebarResizable(e,t,i){let n,r,o=l=>{let c=i==="left"?l.clientX-n:n-l.clientX,d=Math.max(200,Math.min(600,r+c));e.style.width=`${d}px`;let p=this.container.querySelector(".preview-main");if(p){let u=i==="left"?`${d}px`:p.style.gridTemplateColumns.split(" ")[0]||"300px",g=i==="right"?`${d}px`:p.style.gridTemplateColumns.split(" ")[2]||"350px";p.style.gridTemplateColumns=`${u} 1fr ${g}`}this.scheduleFit()},s=()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",s),e.classList.remove("resizing")};t.addEventListener("pointerdown",l=>{l.preventDefault(),n=l.clientX,r=e.offsetWidth,document.addEventListener("pointermove",o),document.addEventListener("pointerup",s),e.classList.add("resizing")})}createShell(){var t;let e=document.createElement("div");return e.className="preview-shell layout-fixed",e.innerHTML=`
1310
1310
  <div class="preview-toolbar">
1311
1311
  <div class="preview-toolbar-left">
1312
1312
  <span class="preview-logo">PREVIEWER</span>
@@ -1460,12 +1460,14 @@ Style guidelines: ${i.summary}`;this.promptInput.value=n,this.currentPrompt=n}}c
1460
1460
  </div>
1461
1461
  <div class="bottom-dock-content">
1462
1462
  <div class="bottom-dock-panel active" data-dock-panel="library" id="dock-library-content"></div>
1463
- <div class="bottom-dock-panel" data-dock-panel="console" id="dock-console-content"></div>
1463
+ <div class="bottom-dock-panel" data-dock-panel="console" id="dock-console-content">
1464
+ <div class="console-messages" id="console-messages"></div>
1465
+ </div>
1464
1466
  </div>
1465
1467
  </div>
1466
1468
 
1467
1469
  </div>
1468
- `,this.setupEventListeners(e),e}setupEventListeners(e){var g,m,h,f,y,b,v,x;let t=e.querySelector("#device-select");t==null||t.addEventListener("change",w=>{if(this.viewMode==="compare")return;let E=w.target.value;this.setDevice(E)});let i=e.querySelector("#theme-select");i==null||i.addEventListener("change",w=>{let E=w.target.value;this.setTheme(E)}),Array.from(e.querySelectorAll("[data-view-toggle]")).forEach(w=>{w.addEventListener("click",()=>{let E=w.dataset.viewToggle;E&&this.setViewMode(E)})}),Array.from(e.querySelectorAll("[data-layout-toggle]")).forEach(w=>{w.addEventListener("click",()=>{let E=w.dataset.layoutToggle;E&&this.setLayoutMode(E)})}),(g=e.querySelector("#rotate-btn"))==null||g.addEventListener("click",()=>this.toggleRotation()),(m=e.querySelector("#zoom-in-btn"))==null||m.addEventListener("click",()=>this.adjustUserZoom(.1)),(h=e.querySelector("#zoom-out-btn"))==null||h.addEventListener("click",()=>this.adjustUserZoom(-.1)),(f=e.querySelector("#refresh-btn"))==null||f.addEventListener("click",()=>this.refresh());let o=e.querySelector("#bottom-dock"),s=e.querySelector("#bottom-dock-resize");o&&s&&this.makeBottomDockResizable(o,s);let l=Array.from(e.querySelectorAll(".bottom-dock-tab"));l.forEach(w=>{w.addEventListener("click",()=>{let E=w.dataset.dockTab;if(!E)return;l.forEach(k=>k.classList.remove("active")),w.classList.add("active"),Array.from(e.querySelectorAll(".bottom-dock-panel")).forEach(k=>{let I=k.dataset.dockPanel;k.classList.toggle("active",I===E)})})}),(y=e.querySelector("#console-clear"))==null||y.addEventListener("click",()=>this.clearConsole()),(b=e.querySelector("#corner-zoom-in-btn"))==null||b.addEventListener("click",()=>this.adjustUserZoom(.1)),(v=e.querySelector("#corner-zoom-out-btn"))==null||v.addEventListener("click",()=>this.adjustUserZoom(-.1)),(x=e.querySelector("#corner-grab-btn"))==null||x.addEventListener("click",()=>{this.frameDragger.style.cursor="grab",setTimeout(()=>{this.isSpaceKeyPressed||(this.frameDragger.style.cursor="")},1e3)});let c=e.querySelector(".scene-panel.scene-objects"),d=e.querySelector("[data-panel-resize-v]");c&&d&&this.makeSidebarResizable(c,d,"left");let p=e.querySelector(".debug-workbench"),u=e.querySelector("#workbench-resize-v");p&&u&&this.makeSidebarResizable(p,u,"right")}applyDeviceFrameStyles(){Object.assign(this.frameDragger.style,{display:"flex",justifyContent:"center",alignItems:"center",transform:"translate(0px, 0px)",touchAction:"none"}),Object.assign(this.frameWrapper.style,{display:"flex",justifyContent:"center",alignItems:"center",transformOrigin:"center center",transition:"transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)",boxShadow:"var(--ui-shadow-strong)",borderRadius:"0px",willChange:"transform"}),Object.assign(this.deviceFrame.style,{overflow:"hidden",position:"relative",borderRadius:"0px"}),Object.assign(this.gameContainer.style,{position:"relative",overflow:"hidden",minWidth:"0px",minHeight:"0px"})}setupObserversAndListeners(){this.resizeObserver=new ResizeObserver(()=>{this.resizeListenersDisabled||this.scheduleFit()}),this.resizeObserver.observe(this.previewContainer),window.addEventListener("resize",this.onWindowResize,{passive:!0})}scheduleFit(){this.rafFitHandle&&cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=requestAnimationFrame(()=>{this.rafFitHandle=null,this.fitToScreen()})}applyPresetDimensions(){let e=this.getEffectivePreset(),t=`${e.width}px`,i=`${e.height}px`;this.deviceFrame.style.width=t,this.deviceFrame.style.height=i,this.gameContainer.style.width=t,this.gameContainer.style.height=i,this.gameContainer.style.maxWidth=t,this.gameContainer.style.maxHeight=i,this.gameContainer.style.minWidth=t,this.gameContainer.style.minHeight=i,this.gameContainer.dataset.screenWidth=String(e.width),this.gameContainer.dataset.screenHeight=String(e.height),this.container.style.setProperty("--preview-screen-width",String(e.width)),this.container.style.setProperty("--preview-screen-height",String(e.height))}fitToScreen(e){if(!this.previewContainer)return;let t=this.getEffectivePreset(),i=this.getFitBounds(),n=Math.max(0,i.width),r=Math.max(0,i.height);if(n<=0||r<=0)return;this.applyPresetDimensions(),this.viewMode==="compare"&&this.applyCompareDimensions();let o=n/t.width,s=r/t.height;if(this.autoScale=Math.max(.01,Math.min(o,s)),!this.hasInitialFit){this.hasInitialFit=!0;let l=.6;this.userScaleMultiplier=l/this.autoScale}e!=null&&e.keepVisibleScale&&e.keepVisibleScale>0&&(this.userScaleMultiplier=e.keepVisibleScale/this.autoScale),this.applyTransform(),this.viewMode==="compare"&&this.fitCompareGhosts(),requestAnimationFrame(()=>this.updatePanelPositions()),this.emitScreenChange()}applyTransform(){let e=this.autoScale*this.userScaleMultiplier;this.frameWrapper.style.transform=`scale(${e})`;let t=this.container.querySelector("#zoom-label");t&&(t.textContent=`${Math.round(e*100)}%`),requestAnimationFrame(()=>this.updatePanelPositions())}applyFrameDrag(){this.frameDragger.style.transform=`translate(${this.frameDragOffsetX}px, ${this.frameDragOffsetY}px)`,requestAnimationFrame(()=>this.updatePanelPositions())}updatePanelPositions(){if(!this.gameReady||this.viewMode==="compare")return;let e=this.container.querySelector("#scene-tools-container"),t=this.container.querySelector("#nudge-panel-container");if(this.layoutMode==="fixed"){let n=this.container.querySelector(".preview-container");n&&(e&&(n.appendChild(e),e.style.position="absolute",e.style.left="50%",e.style.top="16px",e.style.transform="translateX(-50%)",e.style.zIndex="100"),t&&(n.appendChild(t),t.style.position="absolute",t.style.left="50%",t.style.top="16px",t.style.transform="translateX(calc(-50% + 200px))",t.style.zIndex="100"));return}let i=this.container.querySelector(".preview-main");i&&(e&&e.parentElement!==i&&i.appendChild(e),t&&t.parentElement!==i&&i.appendChild(t)),e&&e.children.length>0&&(e.style.position="absolute",e.style.left="50%",e.style.top="16px",e.style.transform="translateX(-50%)",e.style.zIndex="100"),t&&t.children.length>0&&(t.style.position="absolute",t.style.left="50%",t.style.top="16px",t.style.transform="translateX(calc(-50% + 200px))",t.style.zIndex="100")}setupFrameDragging(){this.frameDragger.addEventListener("pointerdown",e=>{let t=!this.gameContainer.contains(e.target);!this.isSpaceKeyPressed&&!t||e.button===0&&(e.preventDefault(),this.frameDragActive=!0,this.frameDragStartX=e.clientX,this.frameDragStartY=e.clientY,this.frameDragOriginX=this.frameDragOffsetX,this.frameDragOriginY=this.frameDragOffsetY,window.addEventListener("pointermove",this.onFrameDragMove),window.addEventListener("pointerup",this.onFrameDragEnd))})}setupSpaceKeyListener(){window.addEventListener("keydown",e=>{e.code==="Space"&&!this.isInputFocused()&&(this.isSpaceKeyPressed||(this.isSpaceKeyPressed=!0,this.updateDragCursor(),e.preventDefault()))}),window.addEventListener("keyup",e=>{e.code==="Space"&&(this.isSpaceKeyPressed=!1,this.updateDragCursor(),this.frameDragActive&&this.onFrameDragEnd())}),window.addEventListener("blur",()=>{this.isSpaceKeyPressed=!1,this.updateDragCursor(),this.frameDragActive&&this.onFrameDragEnd()})}isInputFocused(){let e=document.activeElement;if(!e)return!1;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"||e.isContentEditable}updateDragCursor(){this.isSpaceKeyPressed?(this.frameDragger.style.cursor="grab",this.frameDragActive&&(this.frameDragger.style.cursor="grabbing")):this.frameDragger.style.cursor=""}adjustUserZoom(e){this.userScaleMultiplier=Math.max(.1,Math.min(6,this.userScaleMultiplier+e)),this.applyTransform(),this.emitScreenChange()}toggleRotation(){var t,i;if(this.viewMode==="compare")return;let e=this.autoScale*this.userScaleMultiplier;this.isLandscape=!this.isLandscape,this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale:e}),(i=(t=this.options).onDeviceChange)==null||i.call(t,this.getEffectivePreset()),this.emitScreenChange()}emitScreenChange(){if(!this.gameReady)return;let e=this.getEffectivePreset(),t={width:e.width,height:e.height,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:e.id,isLandscape:this.isLandscape};if(window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:t})),this.viewMode==="compare"&&this.refreshCompareSnapshots(),this.isInitialized&&this.isMounted&&this.gameReady){let i=window.gameApp;if(!(i!=null&&i.renderer))return;this.ignoreNextWindowResize=!0,window.dispatchEvent(new Event("resize"))}}safeStringify(e){var i;let t=new WeakSet;try{return JSON.stringify(e,(n,r)=>{if(typeof r=="object"&&r!==null){if(t.has(r))return"[Circular]";t.add(r)}return r},2)}catch{try{if(e&&((i=e.constructor)!=null&&i.name))return`[object ${e.constructor.name}]`}catch{}return String(e)}}setupConsoleInterceptor(){let e=console.log.bind(console),t=console.warn.bind(console),i=console.error.bind(console),n=console.info.bind(console),r=(o,...s)=>{let l=s.map(d=>typeof d=="object"?this.safeStringify(d):String(d)).join(" ");this.consoleMessages.push({type:o,message:l,timestamp:new Date}),this.appendConsoleMessage(this.consoleMessages[this.consoleMessages.length-1]);let c=this.container.querySelector("#console-badge");if(c){let d=this.consoleMessages.filter(p=>p.type==="error").length;c.textContent=d>0?`${d}!`:"0",c.classList.toggle("has-errors",d>0)}};console.log=(...o)=>{e(...o),r("log",...o)},console.warn=(...o)=>{t(...o),r("warn",...o)},console.error=(...o)=>{i(...o),r("error",...o)},console.info=(...o)=>{n(...o),r("info",...o)}}appendConsoleMessage(e){let t=this.container.querySelector("#console-messages");if(!t)return;let i=document.createElement("div");i.className=`console-msg type-${e.type}`;let n=e.timestamp.toLocaleTimeString();i.innerHTML=`<span class="time">${this.escapeHtml(n)}</span> <pre>${this.escapeHtml(e.message)}</pre>`,t.appendChild(i),t.scrollTop=t.scrollHeight}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}toggleConsole(e){var t;if(this.layoutMode==="fixed"){let i=this.container.querySelector('[data-dock-tab="console"]');if(i){i.click();let n=this.container.querySelector("#bottom-dock");n==null||n.classList.remove("hidden")}return}this.isConsoleOpen=e!=null?e:!this.isConsoleOpen,(t=this.consolePanel)==null||t.classList.toggle("closed",!this.isConsoleOpen)}clearConsole(){this.consoleMessages=[];let e=this.container.querySelector("#console-messages");e&&(e.innerHTML="");let t=this.container.querySelector("#console-badge");t&&(t.textContent="0")}setupCompareViewports(){Array.from(this.container.querySelectorAll("[data-viewport]")).forEach(t=>{let i=t.dataset.viewport;if(!i)return;let n=this.comparePresets.find(p=>p.id===i);if(!n)return;let r=t.querySelector("[data-compare-slot]"),o=t.querySelector("[data-compare-ghost]"),s=t.querySelector("[data-compare-wrapper]"),l=t.querySelector("[data-compare-frame]"),c=t.querySelector("[data-compare-snapshot]"),d=t.querySelector("[data-compare-focus]");!r||!o||!s||!l||(t.addEventListener("click",p=>{let u=p.target;if(u!=null&&u.closest("[data-compare-focus]")){p.preventDefault(),this.activateCompareViewport(i);return}t.classList.contains("is-active")||this.activateCompareViewport(i)}),this.compareViewports.set(i,{preset:n,root:t,slot:r,ghost:o,wrapper:s,frame:l,canvas:c,focus:d}))})}setViewMode(e){if(this.viewMode===e)return;this.viewMode=e,this.container.classList.toggle("compare-mode",e==="compare"),this.singleStage.classList.toggle("hidden",e!=="single"),this.compareStage.classList.toggle("hidden",e!=="compare");let t=this.container.querySelector("#device-select");t&&(t.disabled=e==="compare");let i=this.container.querySelector("#rotate-btn");if(i&&(i.disabled=e==="compare"),this.updateViewToggleUI(),e==="compare"){this.lastSinglePresetId=this.currentPreset.id,this.activateCompareViewport(this.activeCompareId),this.refreshCompareSnapshots(),this.startCompareSnapshots();return}this.stopCompareSnapshots(),this.singleStage.appendChild(this.frameDragger),this.setDevice(this.lastSinglePresetId,{suppressCallback:!0}),this.fitToScreen()}updateViewToggleUI(){Array.from(this.container.querySelectorAll("[data-view-toggle]")).forEach(t=>{t.classList.toggle("active",t.dataset.viewToggle===this.viewMode)})}activateCompareViewport(e){var r,o;let t=this.compareViewports.get(e);if(!t)return;let i=this.autoScale*this.userScaleMultiplier,n=this.activeCompareId;n&&n!==e&&this.captureCompareSnapshot(n),this.activeCompareId=e,this.currentPreset=t.preset,this.isLandscape=!1,t.slot.appendChild(this.frameDragger),this.frameDragOffsetX=0,this.frameDragOffsetY=0,this.applyFrameDrag(),this.compareViewports.forEach((s,l)=>{s.root.classList.toggle("is-active",l===e),s.ghost.classList.toggle("hidden",l===e),s.focus&&(s.focus.textContent=l===e?"Live":"Focus")}),this.applyPresetDimensions(),this.applyCompareDimensions(),this.fitToScreen({keepVisibleScale:i}),(o=(r=this.options).onDeviceChange)==null||o.call(r,this.getEffectivePreset())}applyCompareDimensions(){this.compareViewports.forEach(e=>{let t=e.preset,i=`${t.width}px`,n=`${t.height}px`;e.frame.style.width=i,e.frame.style.height=n,e.canvas&&(e.canvas.width=t.width,e.canvas.height=t.height)})}fitCompareGhosts(){this.compareViewports.forEach(e=>{let t=e.root.querySelector(".compare-body");if(!t)return;let i=Math.max(0,t.clientWidth-24),n=Math.max(0,t.clientHeight-24);if(i<=0||n<=0)return;let r=i/e.preset.width,o=n/e.preset.height,s=Math.max(.01,Math.min(r,o));e.wrapper.style.transform=`scale(${s})`})}captureCompareSnapshot(e){let t=this.compareViewports.get(e);if(!(t!=null&&t.canvas))return;let i=this.gameContainer.querySelector("canvas");if(!i)return;let n=t.canvas.getContext("2d");if(!n)return;let r=t.canvas.width,o=t.canvas.height,s=Math.min(r/i.width,o/i.height),l=i.width*s,c=i.height*s,d=(r-l)/2,p=(o-c)/2;n.clearRect(0,0,r,o),n.drawImage(i,d,p,l,c)}refreshCompareSnapshots(){this.compareViewports.forEach((e,t)=>{t!==this.activeCompareId&&this.captureCompareSnapshot(t)})}startCompareSnapshots(){this.compareSnapshotTimer||(this.compareSnapshotTimer=window.setInterval(()=>{this.viewMode==="compare"&&this.refreshCompareSnapshots()},500))}stopCompareSnapshots(){this.compareSnapshotTimer&&(window.clearInterval(this.compareSnapshotTimer),this.compareSnapshotTimer=null)}getFitBounds(){if(this.viewMode!=="compare")return{width:this.previewContainer.clientWidth-40,height:this.previewContainer.clientHeight-40};let e=this.compareViewports.get(this.activeCompareId),t=e==null?void 0:e.root.querySelector(".compare-body");return t?{width:t.clientWidth-24,height:t.clientHeight-24}:{width:this.previewContainer.clientWidth-40,height:this.previewContainer.clientHeight-40}}mustQuery(e){let t=this.container.querySelector(e);if(!t)throw new Error(`PreviewShell missing element: ${e}`);return t}};function wr(a={}){let e=new En(a);return typeof window!="undefined"&&(window.__previewShell=e),e.mount(),e}import{Sprite as vo,Container as Er}from"pixi.js";var xo=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Sn=xo;if(typeof window!="undefined")try{let a=new XMLHttpRequest;if(a.open("GET","./build-settings.json",!1),a.send(),a.status===200&&a.responseText){let e=JSON.parse(a.responseText);e!=null&&e.buildMode&&(Sn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${Sn}`))}}catch{}function wo(a){var t,i,n,r,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(a);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(a))return{x:(t=a[0])!=null?t:.5,y:(i=a[1])!=null?i:.5};if(a&&typeof a=="object"&&"x"in a&&"y"in a)return{x:(n=a.x)!=null?n:.5,y:(r=a.y)!=null?r:.5};if(typeof a=="string"){let s=a.trim().toLowerCase();return(o=e[s])!=null?o:{x:.5,y:.5}}return null}var ke=class{static async create(e,t,i){var l,c,d,p,u,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${Sn}`);let n=(l=t==null?void 0:t.render)==null?void 0:l.asset;if(!n){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let h=new Er;return this.applyTransform(h,t==null?void 0:t.transform,t),h}let r=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${n.type}, path: ${n.path}`);let o=await Oi.load(e,n,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(d=o==null?void 0:o.constructor)==null?void 0:d.name}`);let s;if(n.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),s=new vo(o),console.log("[ObjectFactory] Created object:",s,"type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name),this.applyTransform(s,t==null?void 0:t.transform,t);else if(n.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(u=o==null?void 0:o.constructor)==null?void 0:u.name,o),o&&(((g=o.constructor)==null?void 0:g.name)==="Container"||o instanceof Er)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[n.path,`/assets/${n.path}`,`assets/${n.path}`,`../assets/${n.path}`],f=!1;for(let y of h)try{let b=await fetch(y);if(b.ok){s=await b.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",y,"type:",(m=s==null?void 0:s.constructor)==null?void 0:m.name),f=!0;break}}catch{continue}f||(console.error("[ObjectFactory] Failed to reload JSON from any path"),s=o)}else s=o;else s=o,s&&typeof s=="object"&&("x"in s||"position"in s)&&this.applyTransform(s,t==null?void 0:t.transform,t);return s}static applyTransform(e,t,i){var n,r,o,s;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(n=t.position.x)!=null?n:0,e.y=(r=t.position.y)!=null?r:0):"position"in e&&e.position&&e.position.set((o=t.position.x)!=null?o:0,(s=t.position.y)!=null?s:0)),t.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(t.scale):e.scale=t.scale),t.rotation!==void 0&&"rotation"in e&&(e.rotation=t.rotation),t.anchor&&"anchor"in e&&e.anchor)){let l=wo(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};function An(a){try{if(a&&typeof a.keys=="function")return Array.from(a.keys())}catch{}return[]}function Sr(a){var e;return a?((e=a.getDisplayObject)==null?void 0:e.call(a))||a.pixiObject||a:null}function Eo(a,e){if(!a||!(e!=null&&e.interaction))return;let t=e.interaction,i=t.enabled!==!1&&(t.draggable===!0||t.clickable===!0);a.eventMode=i?"static":"none",a.interactive=i,i&&(a.cursor=t.draggable?"move":"pointer")}function Ar(a,e){var l,c,d;if(!a||!e)return;let t=e.transform||{};Eo(a,e);let i=t.position||{},n=t.offset||{},r=(typeof i.x=="number"?i.x:0)+(typeof n.x=="number"?n.x:0),o=(typeof i.y=="number"?i.y:0)+(typeof n.y=="number"?n.y:0);(l=a.position)!=null&&l.set?a.position.set(r,o):(typeof a.x=="number"&&(a.x=r),typeof a.y=="number"&&(a.y=o)),typeof t.scale=="number"&&((c=a.scale)!=null&&c.set?a.scale.set(t.scale):a.scale&&(a.scale.x=t.scale,a.scale.y=t.scale));let s=t.anchor;if(s&&((d=a.anchor)!=null&&d.set)){let p=null;typeof window!="undefined"&&window.resolveAnchorVec2?p=window.resolveAnchorVec2(s):typeof s=="object"&&s.x!==void 0&&s.y!==void 0?p=s:Array.isArray(s)&&s.length===2&&(p={x:s[0],y:s[1]}),p&&typeof p.x=="number"&&typeof p.y=="number"&&a.anchor.set(p.x,p.y)}}function Cr(a){if(typeof window=="undefined")return;let e=a==null?void 0:a.objects,t=An(e),i=r=>{try{let o=window.__HANDLER_ACTIVE_SCREEN;if(!o||o==="all")return r;let s=window.__HANDLER_SCREEN_INDEX,l=s==null?void 0:s.instanceToScreen;return l?r.filter(c=>l[c]===o):r}catch{return r}};window.__editableObjectConfigs=e;let n=new Map;t.forEach(r=>n.set(r,[r])),window.__editableObjectInstances=n,window.refreshEditableConfigIndex=()=>Cr(window.__editableConfig),window.getEditableObjectList=()=>{var r;return i(An((r=window.__editableConfig)==null?void 0:r.objects))},window.getEditableObjectListAll=()=>{var r;return An((r=window.__editableConfig)==null?void 0:r.objects)},window.getEditableObjectConfig=r=>{var d,p,u,g,m;let o=(g=(u=(p=(d=window.__editableConfig)==null?void 0:d.objects)==null?void 0:p.get)==null?void 0:u.call(p,r))!=null?g:null,s=window.__HANDLER_ACTIVE_SCREEN;if(!s||s==="all")return o;let l=window.__HANDLER_SCREEN_INDEX,c=(m=l==null?void 0:l.instanceToScreen)==null?void 0:m[r];return c&&c===s?o:null},window.getEditableEngineConfig=()=>{let r=window.__editableConfig;if(console.log("[BRIDGE] getEditableEngineConfig called, cfg present:",!!r),!r)return null;if(r.engine&&r.objects instanceof Map){console.log("[BRIDGE] Detected ObjectCentricConfig, flattening...");let o={...r.engine,objects:r.objects,scene:r.scene};return console.log("[BRIDGE] Returned assets:",Object.keys(o.assets||{})),o}return r}}function So(){if(typeof window=="undefined")return;let a=t=>{let i=String(t||"").trim();return i?/^(data:|blob:|https?:)/.test(i)||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`:""},e=async(t,i)=>{var r,o,s;let n=a(i);if(n)try{let[{Assets:l},{AssetTextures:c}]=await Promise.all([import("pixi.js"),import("./AssetTextures-67BIZDFD.js")]),d=Date.now(),p=/^(data:|blob:)/.test(n)?n:n+(n.includes("?")?`&t=${d}`:`?t=${d}`),u=await l.load(p);if(!u)return;c[t]=u;let g=window.CustomAssets;(r=g==null?void 0:g[t])!=null&&r.texture&&(g[t].texture=u);let m=window.gameObjectManager,h=(o=m==null?void 0:m.get)==null?void 0:o.call(m,t);if(h){let f=((s=h.getDisplayObject)==null?void 0:s.call(h))||h.pixiObject||h.pixi||h;if(f!=null&&f.texture)f.texture=u;else if(f!=null&&f.children){let y=f.children.find(b=>b==null?void 0:b.texture);y!=null&&y.texture&&(y.texture=u)}}}catch(l){console.warn("[LIVE-EDIT] Failed to reload Pixi texture for",t,l)}};window.applyLiveEditOverrides=t=>{try{let i=ji();Array.isArray(i)&&i.length&&(window.__editableConfig=t,jt(i,{silent:!0,persist:!1}))}catch{}},window.applyEngineOverrides=t=>{try{let i=ji();Array.isArray(i)&&i.length&&(window.__editableConfig=t,jt(i,{silent:!0,persist:!1}))}catch{}},window.applyEditableEngineConfig=t=>{let i=window.__editableConfig;if(!(i!=null&&i.engine))return;let n=[];if(t.runtime)for(let[r,o]of Object.entries(t.runtime))n.push({path:`runtime.${r}`,value:o});if(t.assets)for(let[r,o]of Object.entries(t.assets))n.push({path:`assets.${r}`,value:o}),typeof o=="string"&&e(r,o);if(t.splash)for(let[r,o]of Object.entries(t.splash))n.push({path:`splash.${r}`,value:o});if(t.loading)for(let[r,o]of Object.entries(t.loading))n.push({path:`loading.${r}`,value:o});if(t.start)for(let[r,o]of Object.entries(t.start))n.push({path:`start.${r}`,value:o});n.length&&jt(n,{silent:!0,persist:!0,emitEvent:!0})}}function Cn(a){let{getConfig:e,gameObjectManager:t,onObjectConfigApplied:i}=a;t&&(t.onObjectRebuildRequired=async(r,o)=>{console.log(`[LIVE-EDIT] \u{1F3D7}\uFE0F Rebuilding object ${r} due to type change...`);let s=t.get(r),l=s==null?void 0:s.pixiObject,c=l==null?void 0:l.parent,d=c==null?void 0:c.children.indexOf(l);s?t.remove(r):l&&l.destroy();let p=window.gameApp,u=await ke.create(r,o,p);c&&(d!==void 0&&d!==-1?c.addChildAt(u,d):c.addChild(u));let g=t.create(r,u);return console.log(`[LIVE-EDIT] \u2705 Rebuild complete for ${r}`),g}),typeof window!="undefined"&&(So(),window.applyEditableObjectConfig=(r,o)=>{var s,l,c;console.log("[LIVE-EDIT] \u{1F504} applyEditableObjectConfig called for:",r);try{let d=window.__editableConfig;(s=d==null?void 0:d.objects)!=null&&s.set&&(d.objects.set(r,o),console.log("[LIVE-EDIT] \u2705 Updated config in __editableConfig"));let p=(l=t==null?void 0:t.get)==null?void 0:l.call(t,r);if(console.log("[LIVE-EDIT] gameObject found?",!!p),p&&(console.log("[LIVE-EDIT] gameObject type:",(c=p.constructor)==null?void 0:c.name),console.log("[LIVE-EDIT] has updateConfig?",typeof p.updateConfig=="function"),console.log("[LIVE-EDIT] has onConfigUpdate?",typeof p.onConfigUpdate=="function")),p&&typeof p.updateConfig=="function")console.log("[LIVE-EDIT] \u2705 Calling updateConfig()"),p.updateConfig(o);else if(p&&typeof p.onConfigUpdate=="function")console.log("[LIVE-EDIT] \u2705 Calling onConfigUpdate()"),p.onConfigUpdate();else{console.log("[LIVE-EDIT] \u26A0\uFE0F No updateConfig or onConfigUpdate, applying transform directly");let u=Sr(p);Ar(u,o)}}catch(d){console.error("[LIVE-EDIT] \u274C Error in applyEditableObjectConfig:",d)}});let n={async applyObjectConfig(r,o){var d,p;console.log("[BRIDGE] \u{1F504} applyObjectConfig called for:",r);let s=e();(d=s==null?void 0:s.objects)!=null&&d.set&&(s.objects.set(r,o),console.log("[BRIDGE] \u2705 Updated config"));let l=(p=t==null?void 0:t.get)==null?void 0:p.call(t,r);if(console.log("[BRIDGE] gameObject found?",!!l),l&&(console.log("[BRIDGE] has updateConfig?",typeof l.updateConfig=="function"),console.log("[BRIDGE] has onConfigUpdate?",typeof l.onConfigUpdate=="function")),l&&typeof l.updateConfig=="function")console.log("[BRIDGE] \u2705 Calling updateConfig()"),l.updateConfig(o);else if(l&&typeof l.onConfigUpdate=="function")console.log("[BRIDGE] \u2705 Calling onConfigUpdate()"),l.onConfigUpdate();else{console.log("[BRIDGE] \u26A0\uFE0F Applying transform directly");let u=Sr(l);Ar(u,o)}let c=[r];i==null||i(r,o,c)},rebuildIndexes(){let r=e();typeof window!="undefined"&&(window.__editableConfig=r,Cr(r))}};return n.rebuildIndexes(),n}import Ao from"lottie-web";Pn(za);typeof window!="undefined"&&!window.lottie&&(window.lottie=Ao);var Ke=null,Co=async()=>{if(!Ke){let a=typeof window!="undefined"?window.INLINE_ASSETS:null,e=(a==null?void 0:a["handler.config"])||(a==null?void 0:a["handler.config.json"]);if(e)try{if(e.startsWith("data:")){let i=atob(e.split(",")[1]);Ke=JSON.parse(i)}else Ke=JSON.parse(e);return Ke}catch(i){console.warn("[CONFIG] Failed to parse inline handler.config.json:",i)}Ke=await(await fetch("./handler.config.json")).json()}return Ke},Mn,mt,kr,Xe,Ln,kn;function ld(a){Mn=a.initGame,mt=a.CustomAssets,kr=a.updateScreenState,Xe=a.globalResponsiveMultipliers,Ln=a.layout,kn=a.clearResponsiveElements}var fi="web_embed",ft="https://example.com",Tr={profile_id:fi},Pe=null,ce=null,Tn={width:0,height:0},To=!0,cd=async()=>{var c,d,p,u;document.title="Handler Pixi Game";let a=await Co();Tr={...a.ids||{},profile_id:fi},ft=a.destination_url||((d=(c=a.export_profiles)==null?void 0:c[fi])==null?void 0:d.destination_url)||ft,me.init({ids:Tr,profile:fi,destinationUrl:ft});let e=me.getRoot();if(typeof __PREVIEW_SHELL__!="undefined"&&__PREVIEW_SHELL__){console.log("[BOOTSTRAP] Initializing Preview Shell..."),ce=wr({onDeviceChange:m=>{console.log(`[PREVIEW] Device switched to ${m.width}x${m.height}, restarting game...`),Lr()},onRefresh:Lr});let g=ce.getGameContainer();g&&(e=g),window.addEventListener("handler-preview:screen",m=>{var v,x,w,E,L,k,I,j,P,S,C;let h=window.gameApp,f=window.gameObjectManager,{width:y,height:b}=m.detail;if(Tn.width=y,Tn.height=b,kr(y,b),!(!h||!h.renderer)){f&&s(h,f);try{h.renderer.resize(y,b);let A=h.view;A&&(A.style.width="100%",A.style.height="100%",A.style.display="block")}catch(A){console.warn("[SCREEN] Error resizing renderer:",A);return}if(t&&f&&Ln)try{let A=(v=window.__mainContainer)!=null?v:h.stage,M=(I=(k=(E=window.__tutorialLabel)!=null?E:(w=(x=f.get("label_1"))==null?void 0:x.getDisplayObject)==null?void 0:w.call(x))!=null?k:(L=f.get("label_1"))==null?void 0:L.pixiObject)!=null?I:f.get("label_1"),O=f.get("background_1"),D=(C=(S=(P=window.__background)!=null?P:(j=O==null?void 0:O.getDisplayObject)==null?void 0:j.call(O))!=null?S:O==null?void 0:O.pixiObject)!=null?C:O;if(A){let T=A===h.stage;Ln({mainContainer:A,label:M,background:D,backgroundTexture:(D==null?void 0:D.texture)||null,app:h},t,0,Tn,f,{skipMainContainerTransform:T})}}catch(A){console.warn("[SCREEN] Error in layout:",A)}}})}let t=await zt("scene.main");window.__editableConfig=t,o(),window.__editableConfigBaseline||(window.__editableConfigBaseline=Di(t),console.log("[BOOTSTRAP] Frozen config baseline for persistence")),(u=(p=t.engine.runtime)==null?void 0:p.layout)!=null&&u.design_width_portrait||(console.warn("[BOOTSTRAP] Config layout missing, retrying..."),await new Promise(g=>setTimeout(g,100)),t=await zt("scene.main"));let i=await Mn(e,t,ft,ce);Pe=i.app;let n=i.gameObjectManager;window.gameApp=Pe,window.gameObjectManager=n;try{window.__liveEditBridge=Cn({getConfig:()=>window.__editableConfig,gameObjectManager:n,assets:mt})}catch(g){console.warn("[BOOTSTRAP] Failed to initialize live-edit bridge",g)}ce&&ce.notifyGameLoaded();let r=window.__debugScale;r&&typeof r=="number"&&(Xe.scale=r,console.log(`[DEBUG] Applied persisted debug scale: ${r}`)),s(Pe,n);async function o(){try{let g=async b=>{let v=b.startsWith("/")?b:`/${b}`,x=await fetch(v,{cache:"no-cache"});if(!x.ok)return null;let w=await x.text();try{return JSON.parse(w)}catch{return null}},m=await g("configs/flow/app.flow.json");if(!m||typeof m!="object")return;let h=m.screens;if(!h||typeof h!="object")return;let f={},y={};for(let[b,v]of Object.entries(h)){let x=v==null?void 0:v.source;if(typeof x!="string")continue;let w=await g(x),E=w==null?void 0:w.elements;if(!Array.isArray(E))continue;let L=E.map(k=>k==null?void 0:k.instance_id).filter(k=>typeof k=="string");f[b]=L;for(let k of L)y[k]||(y[k]=b)}window.__HANDLER_APP_FLOW=m,window.__HANDLER_SCREEN_INDEX={screenToInstances:f,instanceToScreen:y},window.dispatchEvent(new CustomEvent("handler:screen-index-loaded"))}catch{}}function s(g,m){if(To){console.log("[RESPONSIVE] Skipping global scaling; using config-driven layout");return}if(console.log("[RESPONSIVE] ===== APPLYING GLOBAL RESPONSIVE SCALING ====="),console.log(`[RESPONSIVE] Scale multiplier: ${Xe.scale.toFixed(3)}`),g.stage){let f=function(y,b=0){if(!y||!y.children)return;let v=" ".repeat(b);y.children.forEach((x,w)=>{if(x&&x.zIndex===9999){console.log(`${v}[RESPONSIVE] Skipping debug border (zIndex 9999)`);return}if(x&&x.scale){let E=x.scale.x||1,L=x.scale.y||1;x.__originalScale||(x.__originalScale={x:E,y:L},console.log(`${v}[RESPONSIVE] Stored original scale for child[${w}]: ${E.toFixed(3)}, ${L.toFixed(3)}`));let k=x.__originalScale.x*Xe.scale,I=x.__originalScale.y*Xe.scale;typeof x.scale.set=="function"?x.scale.set(k,I):(x.scale.x=k,x.scale.y=I),console.log(`${v}[RESPONSIVE] Child[${w}] scale: ${E.toFixed(3)}\u2192${x.scale.x.toFixed(3)} (type: ${x.constructor.name})`),f(x,b+1)}else x&&console.log(`${v}[RESPONSIVE] Child[${w}] has no scale (type: ${x.constructor.name})`)})};var h=f;console.log("[RESPONSIVE] Applying scale to PIXI stage children"),f(g.stage)}else console.warn("[RESPONSIVE] No app.stage found!");console.log("[REDDEBUG] Debug border left unscaled (fixed boundaries)"),console.log("[RESPONSIVE] ===== GLOBAL RESPONSIVE SCALING COMPLETE =====")}function l(g){if(g!==void 0){Xe.scale=g,console.log(`[RESPONSIVE] Updated global scale multiplier to: ${g.toFixed(3)}`);let m=window.gameApp,h=window.gameObjectManager;m&&h?(s(m,h),m.renderer&&(m.renderer.render(m.stage),console.log("[RESPONSIVE] Forced PIXI renderer update"))):console.warn(`[RESPONSIVE] No gameApp (${!!m}) or gameObjectManager (${!!h}) found in window for live update`)}}window.updateGlobalResponsiveMultipliers=l,me.start()},Lr=async()=>{var e,t,i,n;console.log("[PREVIEW] Restarting game in 1 seconds...");let a=(e=window.gameObjectManager)==null?void 0:e.get("character_1");if(a){let r=((t=a.getDisplayObject)==null?void 0:t.call(a))||a;r&&r.scale&&console.log(`[CHARACTER] Before restart - Current scale - x: ${((i=r.scale.x)!=null?i:1).toFixed(3)}, y: ${((n=r.scale.y)!=null?n:1).toFixed(3)}`)}if(ce){ce.notifyGameDestroyed();try{kn&&kn()}catch(r){console.warn("Failed to clear responsive elements",r)}setTimeout(()=>{console.log("[PREVIEW] Executing restart...");let r=ce.getGameContainer(),o=window.gameObjectManager;if(o&&typeof o.clear=="function"&&(console.log("[PREVIEW] Clearing old GameObjectManager tickers..."),o.clear()),Pe){try{Pe.destroy(!0,{children:!0,texture:!1})}catch(s){console.warn("[PREVIEW] Destroy warning:",s)}Pe=null}window.gameApp=null,window.gameObjectManager=null,r&&(r.innerHTML="");try{typeof mt.resetScene=="function"&&mt.resetScene()}catch(s){console.warn("Asset reset failed",s)}setTimeout(()=>{zt("scene.main").then(s=>{window.__editableConfig=s,window.__editableConfigBaseline||(window.__editableConfigBaseline=Di(s)),Mn(r,s,ft).then(l=>{Pe=l.app,window.gameApp=Pe,window.gameObjectManager=l.gameObjectManager;try{window.__liveEditBridge=Cn({getConfig:()=>window.__editableConfig,gameObjectManager:window.gameObjectManager,assets:mt})}catch(c){console.warn("[BOOTSTRAP] Failed to re-initialize live-edit bridge",c)}ce&&ce.notifyGameLoaded(),console.log("[PREVIEW] Game restarted successfully");try{me.start()}catch{}})})},100)},1e3)}};var be={background:"#F6F3EF",ink:"#1E1E1E",secondaryText:"#8E8A84",primaryAccent:"#E38A5A",secondaryAccent:"#C9A28C",statusGreen:"#5F8F6B"},Lo=1.25,ko={fontFamily:"Inter, system-ui, sans-serif"};var _n=class{constructor(e={}){this.currentProgress=0;var t;this.currentProgress=(t=e.progress)!=null?t:0,this.container=this.createContainer()}createContainer(){let e=document.createElement("div");e.className="handler-loading-screen",e.style.cssText=`
1470
+ `,this.setupEventListeners(e),e}setupEventListeners(e){var g,m,h,f,y,b,v,x;let t=e.querySelector("#device-select");t==null||t.addEventListener("change",w=>{if(this.viewMode==="compare")return;let E=w.target.value;this.setDevice(E)});let i=e.querySelector("#theme-select");i==null||i.addEventListener("change",w=>{let E=w.target.value;this.setTheme(E)}),Array.from(e.querySelectorAll("[data-view-toggle]")).forEach(w=>{w.addEventListener("click",()=>{let E=w.dataset.viewToggle;E&&this.setViewMode(E)})}),Array.from(e.querySelectorAll("[data-layout-toggle]")).forEach(w=>{w.addEventListener("click",()=>{let E=w.dataset.layoutToggle;E&&this.setLayoutMode(E)})}),(g=e.querySelector("#rotate-btn"))==null||g.addEventListener("click",()=>this.toggleRotation()),(m=e.querySelector("#zoom-in-btn"))==null||m.addEventListener("click",()=>this.adjustUserZoom(.1)),(h=e.querySelector("#zoom-out-btn"))==null||h.addEventListener("click",()=>this.adjustUserZoom(-.1)),(f=e.querySelector("#refresh-btn"))==null||f.addEventListener("click",()=>this.refresh());let o=e.querySelector("#bottom-dock"),s=e.querySelector("#bottom-dock-resize");o&&s&&this.makeBottomDockResizable(o,s);let l=Array.from(e.querySelectorAll(".bottom-dock-tab"));l.forEach(w=>{w.addEventListener("click",()=>{let E=w.dataset.dockTab;if(!E)return;l.forEach(k=>k.classList.remove("active")),w.classList.add("active"),Array.from(e.querySelectorAll(".bottom-dock-panel")).forEach(k=>{let I=k.dataset.dockPanel;k.classList.toggle("active",I===E)})})}),(y=e.querySelector("#console-clear"))==null||y.addEventListener("click",()=>this.clearConsole()),(b=e.querySelector("#corner-zoom-in-btn"))==null||b.addEventListener("click",()=>this.adjustUserZoom(.1)),(v=e.querySelector("#corner-zoom-out-btn"))==null||v.addEventListener("click",()=>this.adjustUserZoom(-.1)),(x=e.querySelector("#corner-grab-btn"))==null||x.addEventListener("click",()=>{this.frameDragger.style.cursor="grab",setTimeout(()=>{this.isSpaceKeyPressed||(this.frameDragger.style.cursor="")},1e3)});let c=e.querySelector(".scene-panel.scene-objects"),d=e.querySelector("[data-panel-resize-v]");c&&d&&this.makeSidebarResizable(c,d,"left");let p=e.querySelector(".debug-workbench"),u=e.querySelector("#workbench-resize-v");p&&u&&this.makeSidebarResizable(p,u,"right")}applyDeviceFrameStyles(){Object.assign(this.frameDragger.style,{display:"flex",justifyContent:"center",alignItems:"center",transform:"translate(0px, 0px)",touchAction:"none"}),Object.assign(this.frameWrapper.style,{display:"flex",justifyContent:"center",alignItems:"center",transformOrigin:"center center",transition:"transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)",boxShadow:"var(--ui-shadow-strong)",borderRadius:"0px",willChange:"transform"}),Object.assign(this.deviceFrame.style,{overflow:"hidden",position:"relative",borderRadius:"0px"}),Object.assign(this.gameContainer.style,{position:"relative",overflow:"hidden",minWidth:"0px",minHeight:"0px"})}setupObserversAndListeners(){this.resizeObserver=new ResizeObserver(()=>{this.resizeListenersDisabled||this.scheduleFit()}),this.resizeObserver.observe(this.previewContainer),window.addEventListener("resize",this.onWindowResize,{passive:!0})}scheduleFit(){this.rafFitHandle&&cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=requestAnimationFrame(()=>{this.rafFitHandle=null,this.fitToScreen()})}applyPresetDimensions(){let e=this.getEffectivePreset(),t=`${e.width}px`,i=`${e.height}px`;this.deviceFrame.style.width=t,this.deviceFrame.style.height=i,this.gameContainer.style.width=t,this.gameContainer.style.height=i,this.gameContainer.style.maxWidth=t,this.gameContainer.style.maxHeight=i,this.gameContainer.style.minWidth=t,this.gameContainer.style.minHeight=i,this.gameContainer.dataset.screenWidth=String(e.width),this.gameContainer.dataset.screenHeight=String(e.height),this.container.style.setProperty("--preview-screen-width",String(e.width)),this.container.style.setProperty("--preview-screen-height",String(e.height))}fitToScreen(e){if(!this.previewContainer)return;let t=this.getEffectivePreset(),i=this.getFitBounds(),n=Math.max(0,i.width),r=Math.max(0,i.height);if(n<=0||r<=0)return;this.applyPresetDimensions(),this.viewMode==="compare"&&this.applyCompareDimensions();let o=n/t.width,s=r/t.height;if(this.autoScale=Math.max(.01,Math.min(o,s)),!this.hasInitialFit){this.hasInitialFit=!0;let l=.6;this.userScaleMultiplier=l/this.autoScale}e!=null&&e.keepVisibleScale&&e.keepVisibleScale>0&&(this.userScaleMultiplier=e.keepVisibleScale/this.autoScale),this.applyTransform(),this.viewMode==="compare"&&this.fitCompareGhosts(),requestAnimationFrame(()=>this.updatePanelPositions()),this.emitScreenChange()}applyTransform(){let e=this.autoScale*this.userScaleMultiplier;this.frameWrapper.style.transform=`scale(${e})`;let t=this.container.querySelector("#zoom-label");t&&(t.textContent=`${Math.round(e*100)}%`),requestAnimationFrame(()=>this.updatePanelPositions())}applyFrameDrag(){this.frameDragger.style.transform=`translate(${this.frameDragOffsetX}px, ${this.frameDragOffsetY}px)`,requestAnimationFrame(()=>this.updatePanelPositions())}updatePanelPositions(){if(!this.gameReady||this.viewMode==="compare")return;let e=this.container.querySelector("#scene-tools-container"),t=this.container.querySelector("#nudge-panel-container");if(this.layoutMode==="fixed"){let n=this.container.querySelector(".preview-container");n&&(e&&(n.appendChild(e),e.style.position="absolute",e.style.left="50%",e.style.top="16px",e.style.transform="translateX(-50%)",e.style.zIndex="100"),t&&(n.appendChild(t),t.style.position="absolute",t.style.left="50%",t.style.top="16px",t.style.transform="translateX(calc(-50% + 200px))",t.style.zIndex="100"));return}let i=this.container.querySelector(".preview-main");i&&(e&&e.parentElement!==i&&i.appendChild(e),t&&t.parentElement!==i&&i.appendChild(t)),e&&e.children.length>0&&(e.style.position="absolute",e.style.left="50%",e.style.top="16px",e.style.transform="translateX(-50%)",e.style.zIndex="100"),t&&t.children.length>0&&(t.style.position="absolute",t.style.left="50%",t.style.top="16px",t.style.transform="translateX(calc(-50% + 200px))",t.style.zIndex="100")}setupFrameDragging(){this.frameDragger.addEventListener("pointerdown",e=>{let t=!this.gameContainer.contains(e.target);!this.isSpaceKeyPressed&&!t||e.button===0&&(e.preventDefault(),this.frameDragActive=!0,this.frameDragStartX=e.clientX,this.frameDragStartY=e.clientY,this.frameDragOriginX=this.frameDragOffsetX,this.frameDragOriginY=this.frameDragOffsetY,window.addEventListener("pointermove",this.onFrameDragMove),window.addEventListener("pointerup",this.onFrameDragEnd))})}setupSpaceKeyListener(){window.addEventListener("keydown",e=>{e.code==="Space"&&!this.isInputFocused()&&(this.isSpaceKeyPressed||(this.isSpaceKeyPressed=!0,this.updateDragCursor(),e.preventDefault()))}),window.addEventListener("keyup",e=>{e.code==="Space"&&(this.isSpaceKeyPressed=!1,this.updateDragCursor(),this.frameDragActive&&this.onFrameDragEnd())}),window.addEventListener("blur",()=>{this.isSpaceKeyPressed=!1,this.updateDragCursor(),this.frameDragActive&&this.onFrameDragEnd()})}isInputFocused(){let e=document.activeElement;if(!e)return!1;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"||e.isContentEditable}updateDragCursor(){this.isSpaceKeyPressed?(this.frameDragger.style.cursor="grab",this.frameDragActive&&(this.frameDragger.style.cursor="grabbing")):this.frameDragger.style.cursor=""}adjustUserZoom(e){this.userScaleMultiplier=Math.max(.1,Math.min(6,this.userScaleMultiplier+e)),this.applyTransform(),this.emitScreenChange()}toggleRotation(){var t,i;if(this.viewMode==="compare")return;let e=this.autoScale*this.userScaleMultiplier;this.isLandscape=!this.isLandscape,this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale:e}),(i=(t=this.options).onDeviceChange)==null||i.call(t,this.getEffectivePreset()),this.emitScreenChange()}emitScreenChange(){if(!this.gameReady)return;let e=this.getEffectivePreset(),t={width:e.width,height:e.height,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:e.id,isLandscape:this.isLandscape};if(window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:t})),this.viewMode==="compare"&&this.refreshCompareSnapshots(),this.isInitialized&&this.isMounted&&this.gameReady){let i=window.gameApp;if(!(i!=null&&i.renderer))return;this.ignoreNextWindowResize=!0,window.dispatchEvent(new Event("resize"))}}safeStringify(e){var i;let t=new WeakSet;try{return JSON.stringify(e,(n,r)=>{if(typeof r=="object"&&r!==null){if(t.has(r))return"[Circular]";t.add(r)}return r},2)}catch{try{if(e&&((i=e.constructor)!=null&&i.name))return`[object ${e.constructor.name}]`}catch{}return String(e)}}setupConsoleInterceptor(){let e=(t,...i)=>{let n=i.map(o=>typeof o=="object"?this.safeStringify(o):String(o)).join(" ");this.consoleMessages.push({type:t,message:n,timestamp:new Date}),this.appendConsoleMessage(this.consoleMessages[this.consoleMessages.length-1]);let r=this.container.querySelector("#console-badge");if(r){let o=this.consoleMessages.filter(s=>s.type==="error").length;r.textContent=o>0?`${o}!`:"0",r.classList.toggle("has-errors",o>0)}};console.log=(...t)=>{this.originalConsole.log(...t),e("log",...t)},console.warn=(...t)=>{this.originalConsole.warn(...t),e("warn",...t)},console.error=(...t)=>{this.originalConsole.error(...t),e("error",...t)},console.info=(...t)=>{this.originalConsole.info(...t),e("info",...t)}}appendConsoleMessage(e){let t=this.container.querySelector("#console-messages");if(this.originalConsole.log("[DEBUG] appendConsoleMessage - container found:",!!t),this.originalConsole.log("[DEBUG] container element:",t),this.originalConsole.log("[DEBUG] container parent:",t==null?void 0:t.parentElement),this.originalConsole.log("[DEBUG] container children count:",t==null?void 0:t.children.length),!t){this.originalConsole.error("[DEBUG] Console messages container NOT FOUND!");return}let i=document.createElement("div");i.className=`console-msg type-${e.type}`;let n=e.timestamp.toLocaleTimeString();i.innerHTML=`<span class="time">${this.escapeHtml(n)}</span> <pre>${this.escapeHtml(e.message)}</pre>`,this.originalConsole.log("[DEBUG] Appending console message div:",i),t.appendChild(i),this.originalConsole.log("[DEBUG] After append - children count:",t.children.length),t.scrollTop=t.scrollHeight}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}toggleConsole(e){var t;if(this.layoutMode==="fixed"){let i=this.container.querySelector('[data-dock-tab="console"]');if(i){i.click();let n=this.container.querySelector("#bottom-dock");n==null||n.classList.remove("hidden")}return}this.isConsoleOpen=e!=null?e:!this.isConsoleOpen,(t=this.consolePanel)==null||t.classList.toggle("closed",!this.isConsoleOpen)}clearConsole(){this.consoleMessages=[];let e=this.container.querySelector("#console-messages");e&&(e.innerHTML="");let t=this.container.querySelector("#console-badge");t&&(t.textContent="0")}setupCompareViewports(){Array.from(this.container.querySelectorAll("[data-viewport]")).forEach(t=>{let i=t.dataset.viewport;if(!i)return;let n=this.comparePresets.find(p=>p.id===i);if(!n)return;let r=t.querySelector("[data-compare-slot]"),o=t.querySelector("[data-compare-ghost]"),s=t.querySelector("[data-compare-wrapper]"),l=t.querySelector("[data-compare-frame]"),c=t.querySelector("[data-compare-snapshot]"),d=t.querySelector("[data-compare-focus]");!r||!o||!s||!l||(t.addEventListener("click",p=>{let u=p.target;if(u!=null&&u.closest("[data-compare-focus]")){p.preventDefault(),this.activateCompareViewport(i);return}t.classList.contains("is-active")||this.activateCompareViewport(i)}),this.compareViewports.set(i,{preset:n,root:t,slot:r,ghost:o,wrapper:s,frame:l,canvas:c,focus:d}))})}setViewMode(e){if(this.viewMode===e)return;this.viewMode=e,this.container.classList.toggle("compare-mode",e==="compare"),this.singleStage.classList.toggle("hidden",e!=="single"),this.compareStage.classList.toggle("hidden",e!=="compare");let t=this.container.querySelector("#device-select");t&&(t.disabled=e==="compare");let i=this.container.querySelector("#rotate-btn");if(i&&(i.disabled=e==="compare"),this.updateViewToggleUI(),e==="compare"){this.lastSinglePresetId=this.currentPreset.id,this.activateCompareViewport(this.activeCompareId),this.refreshCompareSnapshots(),this.startCompareSnapshots();return}this.stopCompareSnapshots(),this.singleStage.appendChild(this.frameDragger),this.setDevice(this.lastSinglePresetId,{suppressCallback:!0}),this.fitToScreen()}updateViewToggleUI(){Array.from(this.container.querySelectorAll("[data-view-toggle]")).forEach(t=>{t.classList.toggle("active",t.dataset.viewToggle===this.viewMode)})}activateCompareViewport(e){var r,o;let t=this.compareViewports.get(e);if(!t)return;let i=this.autoScale*this.userScaleMultiplier,n=this.activeCompareId;n&&n!==e&&this.captureCompareSnapshot(n),this.activeCompareId=e,this.currentPreset=t.preset,this.isLandscape=!1,t.slot.appendChild(this.frameDragger),this.frameDragOffsetX=0,this.frameDragOffsetY=0,this.applyFrameDrag(),this.compareViewports.forEach((s,l)=>{s.root.classList.toggle("is-active",l===e),s.ghost.classList.toggle("hidden",l===e),s.focus&&(s.focus.textContent=l===e?"Live":"Focus")}),this.applyPresetDimensions(),this.applyCompareDimensions(),this.fitToScreen({keepVisibleScale:i}),(o=(r=this.options).onDeviceChange)==null||o.call(r,this.getEffectivePreset())}applyCompareDimensions(){this.compareViewports.forEach(e=>{let t=e.preset,i=`${t.width}px`,n=`${t.height}px`;e.frame.style.width=i,e.frame.style.height=n,e.canvas&&(e.canvas.width=t.width,e.canvas.height=t.height)})}fitCompareGhosts(){this.compareViewports.forEach(e=>{let t=e.root.querySelector(".compare-body");if(!t)return;let i=Math.max(0,t.clientWidth-24),n=Math.max(0,t.clientHeight-24);if(i<=0||n<=0)return;let r=i/e.preset.width,o=n/e.preset.height,s=Math.max(.01,Math.min(r,o));e.wrapper.style.transform=`scale(${s})`})}captureCompareSnapshot(e){let t=this.compareViewports.get(e);if(!(t!=null&&t.canvas))return;let i=this.gameContainer.querySelector("canvas");if(!i)return;let n=t.canvas.getContext("2d");if(!n)return;let r=t.canvas.width,o=t.canvas.height,s=Math.min(r/i.width,o/i.height),l=i.width*s,c=i.height*s,d=(r-l)/2,p=(o-c)/2;n.clearRect(0,0,r,o),n.drawImage(i,d,p,l,c)}refreshCompareSnapshots(){this.compareViewports.forEach((e,t)=>{t!==this.activeCompareId&&this.captureCompareSnapshot(t)})}startCompareSnapshots(){this.compareSnapshotTimer||(this.compareSnapshotTimer=window.setInterval(()=>{this.viewMode==="compare"&&this.refreshCompareSnapshots()},500))}stopCompareSnapshots(){this.compareSnapshotTimer&&(window.clearInterval(this.compareSnapshotTimer),this.compareSnapshotTimer=null)}getFitBounds(){if(this.viewMode!=="compare")return{width:this.previewContainer.clientWidth-40,height:this.previewContainer.clientHeight-40};let e=this.compareViewports.get(this.activeCompareId),t=e==null?void 0:e.root.querySelector(".compare-body");return t?{width:t.clientWidth-24,height:t.clientHeight-24}:{width:this.previewContainer.clientWidth-40,height:this.previewContainer.clientHeight-40}}mustQuery(e){let t=this.container.querySelector(e);if(!t)throw new Error(`PreviewShell missing element: ${e}`);return t}};function wr(a={}){let e=new En(a);return typeof window!="undefined"&&(window.__previewShell=e),e.mount(),e}import{Sprite as vo,Container as Er}from"pixi.js";var xo=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Sn=xo;if(typeof window!="undefined")try{let a=new XMLHttpRequest;if(a.open("GET","./build-settings.json",!1),a.send(),a.status===200&&a.responseText){let e=JSON.parse(a.responseText);e!=null&&e.buildMode&&(Sn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${Sn}`))}}catch{}function wo(a){var t,i,n,r,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(a);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(a))return{x:(t=a[0])!=null?t:.5,y:(i=a[1])!=null?i:.5};if(a&&typeof a=="object"&&"x"in a&&"y"in a)return{x:(n=a.x)!=null?n:.5,y:(r=a.y)!=null?r:.5};if(typeof a=="string"){let s=a.trim().toLowerCase();return(o=e[s])!=null?o:{x:.5,y:.5}}return null}var ke=class{static async create(e,t,i){var l,c,d,p,u,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${Sn}`);let n=(l=t==null?void 0:t.render)==null?void 0:l.asset;if(!n){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let h=new Er;return this.applyTransform(h,t==null?void 0:t.transform,t),h}let r=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${n.type}, path: ${n.path}`);let o=await Oi.load(e,n,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(d=o==null?void 0:o.constructor)==null?void 0:d.name}`);let s;if(n.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),s=new vo(o),console.log("[ObjectFactory] Created object:",s,"type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name),this.applyTransform(s,t==null?void 0:t.transform,t);else if(n.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(u=o==null?void 0:o.constructor)==null?void 0:u.name,o),o&&(((g=o.constructor)==null?void 0:g.name)==="Container"||o instanceof Er)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[n.path,`/assets/${n.path}`,`assets/${n.path}`,`../assets/${n.path}`],f=!1;for(let y of h)try{let b=await fetch(y);if(b.ok){s=await b.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",y,"type:",(m=s==null?void 0:s.constructor)==null?void 0:m.name),f=!0;break}}catch{continue}f||(console.error("[ObjectFactory] Failed to reload JSON from any path"),s=o)}else s=o;else s=o,s&&typeof s=="object"&&("x"in s||"position"in s)&&this.applyTransform(s,t==null?void 0:t.transform,t);return s}static applyTransform(e,t,i){var n,r,o,s;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(n=t.position.x)!=null?n:0,e.y=(r=t.position.y)!=null?r:0):"position"in e&&e.position&&e.position.set((o=t.position.x)!=null?o:0,(s=t.position.y)!=null?s:0)),t.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(t.scale):e.scale=t.scale),t.rotation!==void 0&&"rotation"in e&&(e.rotation=t.rotation),t.anchor&&"anchor"in e&&e.anchor)){let l=wo(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};function An(a){try{if(a&&typeof a.keys=="function")return Array.from(a.keys())}catch{}return[]}function Sr(a){var e;return a?((e=a.getDisplayObject)==null?void 0:e.call(a))||a.pixiObject||a:null}function Eo(a,e){if(!a||!(e!=null&&e.interaction))return;let t=e.interaction,i=t.enabled!==!1&&(t.draggable===!0||t.clickable===!0);a.eventMode=i?"static":"none",a.interactive=i,i&&(a.cursor=t.draggable?"move":"pointer")}function Ar(a,e){var l,c,d;if(!a||!e)return;let t=e.transform||{};Eo(a,e);let i=t.position||{},n=t.offset||{},r=(typeof i.x=="number"?i.x:0)+(typeof n.x=="number"?n.x:0),o=(typeof i.y=="number"?i.y:0)+(typeof n.y=="number"?n.y:0);(l=a.position)!=null&&l.set?a.position.set(r,o):(typeof a.x=="number"&&(a.x=r),typeof a.y=="number"&&(a.y=o)),typeof t.scale=="number"&&((c=a.scale)!=null&&c.set?a.scale.set(t.scale):a.scale&&(a.scale.x=t.scale,a.scale.y=t.scale));let s=t.anchor;if(s&&((d=a.anchor)!=null&&d.set)){let p=null;typeof window!="undefined"&&window.resolveAnchorVec2?p=window.resolveAnchorVec2(s):typeof s=="object"&&s.x!==void 0&&s.y!==void 0?p=s:Array.isArray(s)&&s.length===2&&(p={x:s[0],y:s[1]}),p&&typeof p.x=="number"&&typeof p.y=="number"&&a.anchor.set(p.x,p.y)}}function Cr(a){if(typeof window=="undefined")return;let e=a==null?void 0:a.objects,t=An(e),i=r=>{try{let o=window.__HANDLER_ACTIVE_SCREEN;if(!o||o==="all")return r;let s=window.__HANDLER_SCREEN_INDEX,l=s==null?void 0:s.instanceToScreen;return l?r.filter(c=>l[c]===o):r}catch{return r}};window.__editableObjectConfigs=e;let n=new Map;t.forEach(r=>n.set(r,[r])),window.__editableObjectInstances=n,window.refreshEditableConfigIndex=()=>Cr(window.__editableConfig),window.getEditableObjectList=()=>{var r;return i(An((r=window.__editableConfig)==null?void 0:r.objects))},window.getEditableObjectListAll=()=>{var r;return An((r=window.__editableConfig)==null?void 0:r.objects)},window.getEditableObjectConfig=r=>{var d,p,u,g,m;let o=(g=(u=(p=(d=window.__editableConfig)==null?void 0:d.objects)==null?void 0:p.get)==null?void 0:u.call(p,r))!=null?g:null,s=window.__HANDLER_ACTIVE_SCREEN;if(!s||s==="all")return o;let l=window.__HANDLER_SCREEN_INDEX,c=(m=l==null?void 0:l.instanceToScreen)==null?void 0:m[r];return c&&c===s?o:null},window.getEditableEngineConfig=()=>{let r=window.__editableConfig;if(console.log("[BRIDGE] getEditableEngineConfig called, cfg present:",!!r),!r)return null;if(r.engine&&r.objects instanceof Map){console.log("[BRIDGE] Detected ObjectCentricConfig, flattening...");let o={...r.engine,objects:r.objects,scene:r.scene};return console.log("[BRIDGE] Returned assets:",Object.keys(o.assets||{})),o}return r}}function So(){if(typeof window=="undefined")return;let a=t=>{let i=String(t||"").trim();return i?/^(data:|blob:|https?:)/.test(i)||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`:""},e=async(t,i)=>{var r,o,s;let n=a(i);if(n)try{let[{Assets:l},{AssetTextures:c}]=await Promise.all([import("pixi.js"),import("./AssetTextures-67BIZDFD.js")]),d=Date.now(),p=/^(data:|blob:)/.test(n)?n:n+(n.includes("?")?`&t=${d}`:`?t=${d}`),u=await l.load(p);if(!u)return;c[t]=u;let g=window.CustomAssets;(r=g==null?void 0:g[t])!=null&&r.texture&&(g[t].texture=u);let m=window.gameObjectManager,h=(o=m==null?void 0:m.get)==null?void 0:o.call(m,t);if(h){let f=((s=h.getDisplayObject)==null?void 0:s.call(h))||h.pixiObject||h.pixi||h;if(f!=null&&f.texture)f.texture=u;else if(f!=null&&f.children){let y=f.children.find(b=>b==null?void 0:b.texture);y!=null&&y.texture&&(y.texture=u)}}}catch(l){console.warn("[LIVE-EDIT] Failed to reload Pixi texture for",t,l)}};window.applyLiveEditOverrides=t=>{try{let i=ji();Array.isArray(i)&&i.length&&(window.__editableConfig=t,jt(i,{silent:!0,persist:!1}))}catch{}},window.applyEngineOverrides=t=>{try{let i=ji();Array.isArray(i)&&i.length&&(window.__editableConfig=t,jt(i,{silent:!0,persist:!1}))}catch{}},window.applyEditableEngineConfig=t=>{let i=window.__editableConfig;if(!(i!=null&&i.engine))return;let n=[];if(t.runtime)for(let[r,o]of Object.entries(t.runtime))n.push({path:`runtime.${r}`,value:o});if(t.assets)for(let[r,o]of Object.entries(t.assets))n.push({path:`assets.${r}`,value:o}),typeof o=="string"&&e(r,o);if(t.splash)for(let[r,o]of Object.entries(t.splash))n.push({path:`splash.${r}`,value:o});if(t.loading)for(let[r,o]of Object.entries(t.loading))n.push({path:`loading.${r}`,value:o});if(t.start)for(let[r,o]of Object.entries(t.start))n.push({path:`start.${r}`,value:o});n.length&&jt(n,{silent:!0,persist:!0,emitEvent:!0})}}function Cn(a){let{getConfig:e,gameObjectManager:t,onObjectConfigApplied:i}=a;t&&(t.onObjectRebuildRequired=async(r,o)=>{console.log(`[LIVE-EDIT] \u{1F3D7}\uFE0F Rebuilding object ${r} due to type change...`);let s=t.get(r),l=s==null?void 0:s.pixiObject,c=l==null?void 0:l.parent,d=c==null?void 0:c.children.indexOf(l);s?t.remove(r):l&&l.destroy();let p=window.gameApp,u=await ke.create(r,o,p);c&&(d!==void 0&&d!==-1?c.addChildAt(u,d):c.addChild(u));let g=t.create(r,u);return console.log(`[LIVE-EDIT] \u2705 Rebuild complete for ${r}`),g}),typeof window!="undefined"&&(So(),window.applyEditableObjectConfig=(r,o)=>{var s,l,c;console.log("[LIVE-EDIT] \u{1F504} applyEditableObjectConfig called for:",r);try{let d=window.__editableConfig;(s=d==null?void 0:d.objects)!=null&&s.set&&(d.objects.set(r,o),console.log("[LIVE-EDIT] \u2705 Updated config in __editableConfig"));let p=(l=t==null?void 0:t.get)==null?void 0:l.call(t,r);if(console.log("[LIVE-EDIT] gameObject found?",!!p),p&&(console.log("[LIVE-EDIT] gameObject type:",(c=p.constructor)==null?void 0:c.name),console.log("[LIVE-EDIT] has updateConfig?",typeof p.updateConfig=="function"),console.log("[LIVE-EDIT] has onConfigUpdate?",typeof p.onConfigUpdate=="function")),p&&typeof p.updateConfig=="function")console.log("[LIVE-EDIT] \u2705 Calling updateConfig()"),p.updateConfig(o);else if(p&&typeof p.onConfigUpdate=="function")console.log("[LIVE-EDIT] \u2705 Calling onConfigUpdate()"),p.onConfigUpdate();else{console.log("[LIVE-EDIT] \u26A0\uFE0F No updateConfig or onConfigUpdate, applying transform directly");let u=Sr(p);Ar(u,o)}}catch(d){console.error("[LIVE-EDIT] \u274C Error in applyEditableObjectConfig:",d)}});let n={async applyObjectConfig(r,o){var d,p;console.log("[BRIDGE] \u{1F504} applyObjectConfig called for:",r);let s=e();(d=s==null?void 0:s.objects)!=null&&d.set&&(s.objects.set(r,o),console.log("[BRIDGE] \u2705 Updated config"));let l=(p=t==null?void 0:t.get)==null?void 0:p.call(t,r);if(console.log("[BRIDGE] gameObject found?",!!l),l&&(console.log("[BRIDGE] has updateConfig?",typeof l.updateConfig=="function"),console.log("[BRIDGE] has onConfigUpdate?",typeof l.onConfigUpdate=="function")),l&&typeof l.updateConfig=="function")console.log("[BRIDGE] \u2705 Calling updateConfig()"),l.updateConfig(o);else if(l&&typeof l.onConfigUpdate=="function")console.log("[BRIDGE] \u2705 Calling onConfigUpdate()"),l.onConfigUpdate();else{console.log("[BRIDGE] \u26A0\uFE0F Applying transform directly");let u=Sr(l);Ar(u,o)}let c=[r];i==null||i(r,o,c)},rebuildIndexes(){let r=e();typeof window!="undefined"&&(window.__editableConfig=r,Cr(r))}};return n.rebuildIndexes(),n}import Ao from"lottie-web";Pn(za);typeof window!="undefined"&&!window.lottie&&(window.lottie=Ao);var Ke=null,Co=async()=>{if(!Ke){let a=typeof window!="undefined"?window.INLINE_ASSETS:null,e=(a==null?void 0:a["handler.config"])||(a==null?void 0:a["handler.config.json"]);if(e)try{if(e.startsWith("data:")){let i=atob(e.split(",")[1]);Ke=JSON.parse(i)}else Ke=JSON.parse(e);return Ke}catch(i){console.warn("[CONFIG] Failed to parse inline handler.config.json:",i)}Ke=await(await fetch("./handler.config.json")).json()}return Ke},Mn,mt,kr,Xe,Ln,kn;function ld(a){Mn=a.initGame,mt=a.CustomAssets,kr=a.updateScreenState,Xe=a.globalResponsiveMultipliers,Ln=a.layout,kn=a.clearResponsiveElements}var fi="web_embed",ft="https://example.com",Tr={profile_id:fi},Pe=null,ce=null,Tn={width:0,height:0},To=!0,cd=async()=>{var c,d,p,u;document.title="Handler Pixi Game";let a=await Co();Tr={...a.ids||{},profile_id:fi},ft=a.destination_url||((d=(c=a.export_profiles)==null?void 0:c[fi])==null?void 0:d.destination_url)||ft,me.init({ids:Tr,profile:fi,destinationUrl:ft});let e=me.getRoot();if(typeof __PREVIEW_SHELL__!="undefined"&&__PREVIEW_SHELL__){console.log("[BOOTSTRAP] Initializing Preview Shell..."),ce=wr({onDeviceChange:m=>{console.log(`[PREVIEW] Device switched to ${m.width}x${m.height}, restarting game...`),Lr()},onRefresh:Lr});let g=ce.getGameContainer();g&&(e=g),window.addEventListener("handler-preview:screen",m=>{var v,x,w,E,L,k,I,j,P,S,C;let h=window.gameApp,f=window.gameObjectManager,{width:y,height:b}=m.detail;if(Tn.width=y,Tn.height=b,kr(y,b),!(!h||!h.renderer)){f&&s(h,f);try{h.renderer.resize(y,b);let A=h.view;A&&(A.style.width="100%",A.style.height="100%",A.style.display="block")}catch(A){console.warn("[SCREEN] Error resizing renderer:",A);return}if(t&&f&&Ln)try{let A=(v=window.__mainContainer)!=null?v:h.stage,M=(I=(k=(E=window.__tutorialLabel)!=null?E:(w=(x=f.get("label_1"))==null?void 0:x.getDisplayObject)==null?void 0:w.call(x))!=null?k:(L=f.get("label_1"))==null?void 0:L.pixiObject)!=null?I:f.get("label_1"),O=f.get("background_1"),D=(C=(S=(P=window.__background)!=null?P:(j=O==null?void 0:O.getDisplayObject)==null?void 0:j.call(O))!=null?S:O==null?void 0:O.pixiObject)!=null?C:O;if(A){let T=A===h.stage;Ln({mainContainer:A,label:M,background:D,backgroundTexture:(D==null?void 0:D.texture)||null,app:h},t,0,Tn,f,{skipMainContainerTransform:T})}}catch(A){console.warn("[SCREEN] Error in layout:",A)}}})}let t=await zt("scene.main");window.__editableConfig=t,o(),window.__editableConfigBaseline||(window.__editableConfigBaseline=Di(t),console.log("[BOOTSTRAP] Frozen config baseline for persistence")),(u=(p=t.engine.runtime)==null?void 0:p.layout)!=null&&u.design_width_portrait||(console.warn("[BOOTSTRAP] Config layout missing, retrying..."),await new Promise(g=>setTimeout(g,100)),t=await zt("scene.main"));let i=await Mn(e,t,ft,ce);Pe=i.app;let n=i.gameObjectManager;window.gameApp=Pe,window.gameObjectManager=n;try{window.__liveEditBridge=Cn({getConfig:()=>window.__editableConfig,gameObjectManager:n,assets:mt})}catch(g){console.warn("[BOOTSTRAP] Failed to initialize live-edit bridge",g)}ce&&ce.notifyGameLoaded();let r=window.__debugScale;r&&typeof r=="number"&&(Xe.scale=r,console.log(`[DEBUG] Applied persisted debug scale: ${r}`)),s(Pe,n);async function o(){try{let g=async b=>{let v=b.startsWith("/")?b:`/${b}`,x=await fetch(v,{cache:"no-cache"});if(!x.ok)return null;let w=await x.text();try{return JSON.parse(w)}catch{return null}},m=await g("configs/flow/app.flow.json");if(!m||typeof m!="object")return;let h=m.screens;if(!h||typeof h!="object")return;let f={},y={};for(let[b,v]of Object.entries(h)){let x=v==null?void 0:v.source;if(typeof x!="string")continue;let w=await g(x),E=w==null?void 0:w.elements;if(!Array.isArray(E))continue;let L=E.map(k=>k==null?void 0:k.instance_id).filter(k=>typeof k=="string");f[b]=L;for(let k of L)y[k]||(y[k]=b)}window.__HANDLER_APP_FLOW=m,window.__HANDLER_SCREEN_INDEX={screenToInstances:f,instanceToScreen:y},window.dispatchEvent(new CustomEvent("handler:screen-index-loaded"))}catch{}}function s(g,m){if(To){console.log("[RESPONSIVE] Skipping global scaling; using config-driven layout");return}if(console.log("[RESPONSIVE] ===== APPLYING GLOBAL RESPONSIVE SCALING ====="),console.log(`[RESPONSIVE] Scale multiplier: ${Xe.scale.toFixed(3)}`),g.stage){let f=function(y,b=0){if(!y||!y.children)return;let v=" ".repeat(b);y.children.forEach((x,w)=>{if(x&&x.zIndex===9999){console.log(`${v}[RESPONSIVE] Skipping debug border (zIndex 9999)`);return}if(x&&x.scale){let E=x.scale.x||1,L=x.scale.y||1;x.__originalScale||(x.__originalScale={x:E,y:L},console.log(`${v}[RESPONSIVE] Stored original scale for child[${w}]: ${E.toFixed(3)}, ${L.toFixed(3)}`));let k=x.__originalScale.x*Xe.scale,I=x.__originalScale.y*Xe.scale;typeof x.scale.set=="function"?x.scale.set(k,I):(x.scale.x=k,x.scale.y=I),console.log(`${v}[RESPONSIVE] Child[${w}] scale: ${E.toFixed(3)}\u2192${x.scale.x.toFixed(3)} (type: ${x.constructor.name})`),f(x,b+1)}else x&&console.log(`${v}[RESPONSIVE] Child[${w}] has no scale (type: ${x.constructor.name})`)})};var h=f;console.log("[RESPONSIVE] Applying scale to PIXI stage children"),f(g.stage)}else console.warn("[RESPONSIVE] No app.stage found!");console.log("[REDDEBUG] Debug border left unscaled (fixed boundaries)"),console.log("[RESPONSIVE] ===== GLOBAL RESPONSIVE SCALING COMPLETE =====")}function l(g){if(g!==void 0){Xe.scale=g,console.log(`[RESPONSIVE] Updated global scale multiplier to: ${g.toFixed(3)}`);let m=window.gameApp,h=window.gameObjectManager;m&&h?(s(m,h),m.renderer&&(m.renderer.render(m.stage),console.log("[RESPONSIVE] Forced PIXI renderer update"))):console.warn(`[RESPONSIVE] No gameApp (${!!m}) or gameObjectManager (${!!h}) found in window for live update`)}}window.updateGlobalResponsiveMultipliers=l,me.start()},Lr=async()=>{var e,t,i,n;console.log("[PREVIEW] Restarting game in 1 seconds...");let a=(e=window.gameObjectManager)==null?void 0:e.get("character_1");if(a){let r=((t=a.getDisplayObject)==null?void 0:t.call(a))||a;r&&r.scale&&console.log(`[CHARACTER] Before restart - Current scale - x: ${((i=r.scale.x)!=null?i:1).toFixed(3)}, y: ${((n=r.scale.y)!=null?n:1).toFixed(3)}`)}if(ce){ce.notifyGameDestroyed();try{kn&&kn()}catch(r){console.warn("Failed to clear responsive elements",r)}setTimeout(()=>{console.log("[PREVIEW] Executing restart...");let r=ce.getGameContainer(),o=window.gameObjectManager;if(o&&typeof o.clear=="function"&&(console.log("[PREVIEW] Clearing old GameObjectManager tickers..."),o.clear()),Pe){try{Pe.destroy(!0,{children:!0,texture:!1})}catch(s){console.warn("[PREVIEW] Destroy warning:",s)}Pe=null}window.gameApp=null,window.gameObjectManager=null,r&&(r.innerHTML="");try{typeof mt.resetScene=="function"&&mt.resetScene()}catch(s){console.warn("Asset reset failed",s)}setTimeout(()=>{zt("scene.main").then(s=>{window.__editableConfig=s,window.__editableConfigBaseline||(window.__editableConfigBaseline=Di(s)),Mn(r,s,ft).then(l=>{Pe=l.app,window.gameApp=Pe,window.gameObjectManager=l.gameObjectManager;try{window.__liveEditBridge=Cn({getConfig:()=>window.__editableConfig,gameObjectManager:window.gameObjectManager,assets:mt})}catch(c){console.warn("[BOOTSTRAP] Failed to re-initialize live-edit bridge",c)}ce&&ce.notifyGameLoaded(),console.log("[PREVIEW] Game restarted successfully");try{me.start()}catch{}})})},100)},1e3)}};var be={background:"#F6F3EF",ink:"#1E1E1E",secondaryText:"#8E8A84",primaryAccent:"#E38A5A",secondaryAccent:"#C9A28C",statusGreen:"#5F8F6B"},Lo=1.25,ko={fontFamily:"Inter, system-ui, sans-serif"};var _n=class{constructor(e={}){this.currentProgress=0;var t;this.currentProgress=(t=e.progress)!=null?t:0,this.container=this.createContainer()}createContainer(){let e=document.createElement("div");e.className="handler-loading-screen",e.style.cssText=`
1469
1471
  position: fixed;
1470
1472
  inset: 0;
1471
1473
  display: flex;