handler-playable-sdk 0.4.32 → 0.4.35

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.35",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?`
@@ -1460,7 +1460,9 @@ 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