handler-playable-sdk 0.5.548 → 0.5.550
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-2M4VIBDT.js → chunk-CKDDVHY7.js} +3 -3
- package/dist/cli/brand-dna.mjs +1 -1
- package/dist/cli/canva-import.mjs +1 -1
- package/dist/cli/cleanup-assets.mjs +1 -1
- package/dist/cli/fix-scales.mjs +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/screen-helper.mjs +1 -1
- package/dist/cli/setup-library.mjs +1 -1
- package/dist/cli/student-helper.mjs +1 -1
- package/dist/cli/sync-screens.mjs +1 -1
- package/dist/cli/validate-assets.mjs +1 -1
- package/dist/cli/validate.mjs +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +1 -1
- package/dist/pixi/index.cjs +1 -1
- package/dist/pixi/index.js +1 -1
- package/dist/three/index.cjs +1 -1
- package/dist/three/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ki,d as ye,e as Xi}from"./chunk-I5OOVR5U.js";import{i as Ut}from"./chunk-PW2FGMCO.js";import{c as Ve,d as Ft,e as We,g as va,h as Ji,j as ya,k as wa,n as Zi,o as Bt,p as Ze,q as xa,r as Qi,s as Sa}from"./chunk-HVKF2KYL.js";import{a as us}from"./chunk-JXBG6UFL.js";import{Application as _o}from"pixi.js";var Re={};function Gt(s,e,t=!1){Re[s]||(Re[s]=[]),Re[s].push({fn:e,once:t})}function en(s,e){if(Re[s]){if(!e){delete Re[s];return}Re[s]=Re[s].filter(t=>t.fn!==e)}}function qt(s,...e){let t=Re[s];if(t)for(let i of[...t])i.fn(...e),i.once&&en(s,i.fn)}function de(s,e){Gt(s,e,!0)}var X=null,he=[],Qe=null;function Ca(s){X=s,he=[],Qe!==null&&(clearTimeout(Qe),Qe=null)}function Ta(){var s,e,t;return{endpoint:(X==null?void 0:X.endpoint)||"",transport:(X==null?void 0:X.transport)||"beacon",batchSize:(s=X==null?void 0:X.batchSize)!=null?s:10,flushIntervalMs:(e=X==null?void 0:X.flushIntervalMs)!=null?e:300,maxQueue:(t=X==null?void 0:X.maxQueue)!=null?t:200,debug:!!(X!=null&&X.debug)}}async function Ea(s,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(s,new Blob([n],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",a,e);return}catch(a){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(a){i&&console.warn("[handler.telemetry] fetch failed",a)}}function tn(s,e){let t=Ta();if(e&&t.endpoint){if(he.push(s),he.length>t.maxQueue&&(he=he.slice(he.length-t.maxQueue)),he.length>=t.batchSize){Aa();return}Qe===null&&(Qe=window.setTimeout(()=>{Qe=null,Aa()},t.flushIntervalMs))}}async function Aa(){let s=Ta();if(!s.endpoint||he.length===0)return;let e=he.splice(0,s.batchSize);await Ea(s.endpoint,{events:e},s.transport,s.debug),he.length>0&&await Ea(s.endpoint,{events:he.splice(0,s.batchSize)},s.transport,s.debug)}function La(s){return Math.max(0,Math.min(1,s))}function gs(s){let e=String(s!=null?s:"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 yt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function hs(s,e){let t=s==null?void 0:s[e];return typeof t=="number"?t:0}function ka(s,e,t){try{s[e]=t}catch{}}function ms(s){let e=s==null?void 0:s.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 Pa(s,e){let t=s==null?void 0:s.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 Ma(s,e){let t=ms(s);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 Ia(){let s=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),s.size>0&&i()})},n=d=>{var u;s.add(d);let p=(u=e.get(d.target))!=null?u:new Set;p.add(d),e.set(d.target,p),i()},a=d=>{s.delete(d);let p=e.get(d.target);p&&(p.delete(d),p.size===0&&e.delete(d.target))},r=d=>{d.killed||(d.killed=!0,a(d))},o=()=>{var p,u;let d=yt();for(let g of Array.from(s)){if(g.killed||g.paused)continue;let h=d-g.startMs-g.delayMs;if(h<0)continue;let m=g.durationMs>0?h/g.durationMs:1,f=La(m),v=g.repeat>=0?g.repeat+1:1,b=g.repeat>0?Math.min(Math.floor(m),v-1):0;if(g.repeat>0&&m>=1){let x=m-b;f=La(x)}let w=g.ease(f);g.yoyo&&b%2===1&&(w=1-w);for(let x of g.props)ka(g.target,x.key,x.from+(x.to-x.from)*w);g.scaleFrom&&g.scaleTo&&Pa(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*w,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*w});try{(p=g.onUpdate)==null||p.call(g)}catch{}if(m>=v){r(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(d,p,u)=>{var x;let g=Math.max(0,(typeof p.duration=="number"?p.duration:.5)*1e3),h=Math.max(0,(typeof p.delay=="number"?p.delay:0)*1e3+((x=u==null?void 0:u.delayMsOverride)!=null?x:0)),m=gs(p.ease),f=typeof p.repeat=="number"?Math.max(0,p.repeat|0):0,v=p.yoyo===!0,b=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),w=[];for(let I of Object.keys(p)){if(b.has(I))continue;let j=p[I];typeof j=="number"&&w.push({key:I,from:hs(d,I),to:j})}let y=Ma(d,p);return{target:d,startMs:yt(),delayMs:h,durationMs:g,ease:m,props:w,scaleFrom:y.from,scaleTo:y.to,repeat:f,yoyo:v,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:()=>r(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=yt())},resume:()=>{var m;if(!u.paused)return;let g=(m=u.pauseAtMs)!=null?m:yt(),h=yt()-g;u.startMs+=h,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 h=p[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof h=="number"&&ka(d,g,h)}let u=Ma(d,p);u.to&&Pa(d,u.to)},killTweensOf(d){let p=e.get(d);if(p)for(let u of Array.from(p))r(u)},timeline(d={}){let p=[],u=0,g=!1,h=[],m=b=>{if(typeof b=="number")return Math.max(0,b*1e3);let w=typeof b=="string"?b.trim():"";return w.startsWith("+=")?u+Math.max(0,Number(w.slice(2))*1e3||0):w?Math.max(0,Number(w)*1e3||0):u},f=b=>{p.push(b);let w=Math.max(0,(typeof b.vars.duration=="number"?b.vars.duration:.5)*1e3);u=Math.max(u,b.atMs+w)},v={to(b,w,y){return f({kind:"to",target:b,vars:w,atMs:m(y)}),v},fromTo(b,w,y,x){return f({kind:"fromTo",target:b,vars:y,from:w,atMs:m(x)}),v},play(){var b,w;if(g)return v;g=!0,h=[];for(let y of p)y.kind==="fromTo"&&c.set(y.target,(b=y.from)!=null?b:{}),h.push(c.to(y.target,{...y.vars,delay:y.atMs/1e3+((w=y.vars.delay)!=null?w:0)}));return v},pause(){for(let b of h)b.pause();return v},kill(){for(let b of h)b.kill();h=[],g=!1}};return d.paused||v.play(),v}};return c}function ja(){if(typeof window=="undefined")return;let s=window;if(!s.gsap)try{s.gsap=Ia()}catch{}}var _a={name:"handler-playable-sdk",version:"0.5.548",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 pe=0,bs=pe++,Oa=pe++,Ra=pe++,za=pe++,Da=pe++,$a=pe++,Ha=pe++,Na=pe++,Fa=pe++,Ba=pe++,Ua=pe++,Ga=pe++,W=bs;function qa(){return W===Oa}function Va(){return W===Ra}function Wa(){return W===za}function Ya(){return W===Da}function et(){return W===$a}function tt(){return W===Ha}function Ka(){return W===Na}function Xa(){return W===Fa}function Ja(){return W===Ba}function nn(){return W===Ua}function an(){return W===Ga}function Za(){let s=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(s==="mraid")try{mraid.getState(),W=Oa;return}catch{}else if(s==="dapi")try{dapi.isReady(),W=Ra;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(W=za)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(W=Da)}catch{}else if(e==="mintegral")window.gameReady&&(W=$a);else if(e==="tapjoy")window.TJ_API&&(W=Ha);else if(e==="tiktok")window.openAppStore&&(W=Na);else if(e==="smadex")try{window.smxTracking&&(W=Fa)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(W=Ba)}catch{}else e==="vungle"?W=Ua:(s==="nucleo"||e==="nucleo")&&(W=Ga)}import rn from"lottie-web";var Qa=rn;typeof window!="undefined"&&(window.lottie=rn,window.__baseLottie=rn);function J(s,e){let t=(n,a)=>a===0?n:t(a,n%a),i=t(s,e);return`${s/i}:${e/i}`}var ol=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:J(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:J(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:J(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:J(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:J(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:J(360,780)}],ll=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:J(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:J(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:J(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:J(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:J(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:J(412,915)}],cl=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:J(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:J(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:J(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:J(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:J(800,1280)}],sn=[{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:J(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:J(768,1024),mraidScale:.7}];var er=[...sn],tr=[{category:"playable",label:"Playable Ad",devices:sn}],on=sn[0];function it(s){return er.find(e=>e.id===s)||on}function dl(s){return er.filter(e=>e.category===s)}var ze=class{async updateProperty(e,t,i,n={}){var l,c,d;console.log("[PropertyUpdateManager] Updating:",e,t,i);let a=window.getEditableObjectConfig;if(typeof a!="function"){console.error("[PropertyUpdateManager] getEditableObjectConfig not available");return}let r=a(e);if(!r){console.error("[PropertyUpdateManager] Config not found for:",e);return}Ve({objectId:e,path:t,value:i},{persist:!0});let o=window.applyEditableObjectConfig;if(typeof o=="function"){let p=window.__editableConfig,u=(d=(c=(l=p==null?void 0:p.objects)==null?void 0:l.get)==null?void 0:c.call(l,e))!=null?d:r;await o(e,u),console.log("[PropertyUpdateManager] Applied config successfully")}else console.warn("[PropertyUpdateManager] applyEditableObjectConfig not available");this.triggerRefresh(e),n.refreshInspector&&window.dispatchEvent(new CustomEvent("inspector:refresh"))}getNestedProperty(e,t){let i=t.split("."),n=e;for(let a of i)if(n&&typeof n=="object"&&a in n)n=n[a];else return;return n}triggerRefresh(e){let t=window.__refreshHierarchy;typeof t=="function"&&t(),window.dispatchEvent(new CustomEvent("inspector:property-updated",{detail:{objectId:e}}))}};function ln(s){let e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async t=>{var a;let i=(a=t.target.files)==null?void 0:a[0];if(!i)return;let n=new FileReader;n.onload=async()=>{let r=n.result,o=s.category||"misc",c=`${(s.objectId||"new_asset").replace(/^json\./,"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"")||"new_asset"}_uploaded`;try{let p=await(await fetch("/api/library/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:o,filename:`${c}.png`,data:r,overwrite:!0})})).json();if(!(p!=null&&p.success)){alert(`Upload failed: ${(p==null?void 0:p.error)||"Unknown error"}`);return}let u=window.addAssetToRegistry;typeof u=="function"&&u(o,`${c}.png`);try{await fetch("/api/setup-library",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}let g=window.refreshAssetLibrary;typeof g=="function"&&await g(),await s.onApply(p.path)}catch(d){console.error("[QuickActionsBar] Upload error:",d),alert("Upload failed. Check console.")}},n.readAsDataURL(i)},e.click()}var Vt=class{constructor(){this.updateManager=new ze}async handleAction(e,t,i){console.log("[QuickActionsBar] Action:",e,t,i);let n=window.getEditableObjectConfig;if(typeof n!="function")return;let a=n(t);if(!a)return;let r=this.updateManager.getNestedProperty(a,i);if(e==="ai-convert"||e==="upload"||e==="library"){let o=i==="ui.text"||i==="render.asset.path",l=i==="render.asset.path";o&&(await this.prepareForImageConversion(t,a),e==="ai-convert"&&i!=="render.asset.path"&&(i="render.asset.path"))}switch(e){case"library":this.openLibrary(t,i,r);break;case"ai-edit":this.openAIEditor(t,i,r);break;case"upload":this.openUpload(t,i);break;case"reset":await this.resetToDefault(t,i);break;case"ai-convert":this.handleAiConvert(t,i,r);break;default:console.warn("[QuickActionsBar] Unknown action:",e)}}async prepareForImageConversion(e,t){var i,n;if(console.log("[QuickActionsBar] Preparing for image conversion:",e),t.render||(t.render={alpha:1,visible:!0}),(t.render.alpha===0||t.render.alpha===void 0)&&(t.render.alpha=1,await this.updateManager.updateProperty(e,"render.alpha",1)),(t.render.visible===!1||t.render.visible===void 0)&&(t.render.visible=!0,await this.updateManager.updateProperty(e,"render.visible",!0)),t.render.asset||(t.render.asset={type:"image",path:""}),t.render.asset.type!=="image"&&(t.render.asset.type="image",await this.updateManager.updateProperty(e,"render.asset",{type:"image",path:t.render.asset.path||""})),t.ui&&t.ui.renderMode!=="png"){await this.updateManager.updateProperty(e,"ui.renderMode","png",{refreshInspector:!0}),await this.updateManager.updateProperty(e,"render.tint","#ffffff");let r=((n=(i=t.transform)==null?void 0:i.scale)!=null?n:1)*.3;await this.updateManager.updateProperty(e,"transform.scale",r),console.log("[QuickActionsBar] Text to PNG conversion: set tint white, scale",r)}this.ensureSlotInRegistry(e,t)}ensureSlotInRegistry(e,t){var o,l,c;let i=window.getEditableAssets;if(typeof i!="function")return;let n=i();if(!n||!n.slots)return;let a=e.startsWith("json.")?e.replace("json.",""):e;if(!n.slots.some(d=>d.objectId===a||d.slotId===a)){let d=((o=t.identity)==null?void 0:o.category)||"ui";console.log("[QuickActionsBar] Adding new slot to registry for converted object:",a),n.slots.push({slotId:a,displayName:a.replace(/_/g," "),objectId:a,category:d,currentAsset:((c=(l=t.render)==null?void 0:l.asset)==null?void 0:c.path)||"",defaultAsset:"",libraryFolder:d,assetType:"image"}),n.categories&&!n.categories.includes(d)&&n.categories.push(d),n.libraryAssets&&!n.libraryAssets[d]&&(n.libraryAssets[d]=[]);let p=window.reRenderAssetLibrary;typeof p=="function"&&p()}}openLibrary(e,t,i){var a;let n=window.__debugContext;if(n){if(n.activeTab!=="library"){n.activeTab="library";let r=window.__updateWorkbenchTabs;typeof r=="function"&&r()}if(n.libraryPanel){let r=window.getEditableObjectConfig,o=r==null?void 0:r(e),l=(a=o==null?void 0:o.identity)==null?void 0:a.category;l||(l=t.split(".")[0]==="render"?"environment":"ui"),console.log("[QuickActionsBar] Highlighting library slot:",e,"category:",l),n.libraryPanel.highlightSlot(e,l)}}}openAIEditor(e,t,i){let n=window.__openAiEditor;if(typeof n=="function"){let a=t.split(".").pop()||t;n(a,`Edit ${a} for ${e}`,i,{objectId:e,path:t})}else console.warn("[QuickActionsBar] AI Editor not available")}openUpload(e,t){var r;let i=window.getEditableObjectConfig,n=i==null?void 0:i(e),a=((r=n==null?void 0:n.identity)==null?void 0:r.category)||(t.split(".")[0]==="render"?"environment":"ui");ln({objectId:e,category:a,onApply:async o=>{var d,p;await this.updateManager.updateProperty(e,t,o);let l=window.__debugContext;(p=(d=l==null?void 0:l.options)==null?void 0:d.onPropertyChange)==null||p.call(d,e,t,o);let c=window.__highlightLibrarySlot;typeof c=="function"&&setTimeout(()=>{c(e,a)},500),window.dispatchEvent(new CustomEvent("inspector:refresh"))}})}async resetToDefault(e,t){console.log("[QuickActionsBar] Reset to default:",e,t);try{let i=await this.getDefaultValue(e,t);i!==void 0?(await this.updateManager.updateProperty(e,t,i),console.log("[QuickActionsBar] Reset to default value:",i)):alert("No default value found for this property.")}catch(i){console.error("[QuickActionsBar] Failed to reset to default:",i),alert("Failed to reset property. Check console for details.")}}async getDefaultValue(e,t){let i=t.split(".");if(i.length<2)return;let n=i[0],a=i.slice(1),r=window.__editableConfig;if(!(r!=null&&r.schemas))return;let o=null;if(r.schemas instanceof Map?o=r.schemas.get(n):typeof r.schemas=="object"&&(o=r.schemas[n]),!(o!=null&&o.defaults))return;let l=o.defaults;for(let c of a)if(l&&typeof l=="object")l=l[c];else return;return l}handleAiConvert(e,t,i){let n=window.__openAiEditor;if(typeof n=="function"){let r=`A single, high-quality, high-detail game UI icon/asset representing "${String(i||e.replace(/_/g," ").replace("json.",""))}". Modern stylized 3D rendered style, vibrant colors, soft lighting, isolated on solid magenta background, highly polished professional game art.`,o="render.asset.path";console.log("[QuickActionsBar] AI Convert for:",e,"from:",t,"to:",o),n(e,r,"",{objectId:e,path:o});let l=window.__debugContext;if(l){l.activeTab="ai";let c=window.__updateWorkbenchTabs;typeof c=="function"&&c()}}else console.warn("[QuickActionsBar] AI Editor not available")}};var vs=[{value:"loading",label:"Loading"},{value:"start",label:"Start"},{value:"gameplay",label:"Gameplay"},{value:"tutorial",label:"Tutorial"},{value:"endgame",label:"Endgame"}],ys=["environment","ui","character","system","backgrounds"],ws=["bg","world","ui"],ir={SwerveMove:{speed:5,sensitivity:1,directionMode:"dominantAxis",axis:"both",bounds:{left:-400,right:400,top:-300,bottom:300}},DragToWin:{targetId:"",successDistance:80},DragSnap:{snapTargetId:"",snapDistance:40},JoystickMove:{speed:6,bounds:{left:-400,right:400,top:-300,bottom:300}}},Wt=class{constructor(){this.modal=null;this.state=null}open(e){this.state=this.createInitialState(e),this.createModal(),document.body.appendChild(this.modal),this.attachEventListeners(),this.updateStepUI()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),window.__wizardAssetPicker=null,this.modal=null,this.state=null}createInitialState(e){return{step:1,objectType:"sprite",instanceId:"",displayName:"",category:"environment",screenId:e.screenId,layer:"world",positionMode:"static",anchorPreset:"center",anchorX:.5,anchorY:.5,positionX:0,positionY:0,offsetX:0,offsetY:0,scale:.2,rotation:0,zIndex:0,assetPath:"",tint:"",alpha:1,text:"",font:"brand.primary",fontSize:18,letterSpacing:0,align:"center",graphicsWidth:200,graphicsHeight:200,graphicsFill:"#FFFFFF",graphicsAlpha:1,interactionEnabled:!1,dragEnabled:!1,hoverEnabled:!1,clickEnabled:!1,logicId:"",logicPropsRaw:""}}createModal(){let e=document.createElement("div");e.className="wizard-modal",e.innerHTML=`
|
|
1
|
+
import{c as Ki,d as ye,e as Xi}from"./chunk-I5OOVR5U.js";import{i as Ut}from"./chunk-PW2FGMCO.js";import{c as Ve,d as Ft,e as We,g as va,h as Ji,j as ya,k as wa,n as Zi,o as Bt,p as Ze,q as xa,r as Qi,s as Sa}from"./chunk-HVKF2KYL.js";import{a as us}from"./chunk-JXBG6UFL.js";import{Application as _o}from"pixi.js";var Re={};function Gt(s,e,t=!1){Re[s]||(Re[s]=[]),Re[s].push({fn:e,once:t})}function en(s,e){if(Re[s]){if(!e){delete Re[s];return}Re[s]=Re[s].filter(t=>t.fn!==e)}}function qt(s,...e){let t=Re[s];if(t)for(let i of[...t])i.fn(...e),i.once&&en(s,i.fn)}function de(s,e){Gt(s,e,!0)}var X=null,he=[],Qe=null;function Ca(s){X=s,he=[],Qe!==null&&(clearTimeout(Qe),Qe=null)}function Ta(){var s,e,t;return{endpoint:(X==null?void 0:X.endpoint)||"",transport:(X==null?void 0:X.transport)||"beacon",batchSize:(s=X==null?void 0:X.batchSize)!=null?s:10,flushIntervalMs:(e=X==null?void 0:X.flushIntervalMs)!=null?e:300,maxQueue:(t=X==null?void 0:X.maxQueue)!=null?t:200,debug:!!(X!=null&&X.debug)}}async function Ea(s,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(s,new Blob([n],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",a,e);return}catch(a){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(a){i&&console.warn("[handler.telemetry] fetch failed",a)}}function tn(s,e){let t=Ta();if(e&&t.endpoint){if(he.push(s),he.length>t.maxQueue&&(he=he.slice(he.length-t.maxQueue)),he.length>=t.batchSize){Aa();return}Qe===null&&(Qe=window.setTimeout(()=>{Qe=null,Aa()},t.flushIntervalMs))}}async function Aa(){let s=Ta();if(!s.endpoint||he.length===0)return;let e=he.splice(0,s.batchSize);await Ea(s.endpoint,{events:e},s.transport,s.debug),he.length>0&&await Ea(s.endpoint,{events:he.splice(0,s.batchSize)},s.transport,s.debug)}function La(s){return Math.max(0,Math.min(1,s))}function gs(s){let e=String(s!=null?s:"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 yt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function hs(s,e){let t=s==null?void 0:s[e];return typeof t=="number"?t:0}function ka(s,e,t){try{s[e]=t}catch{}}function ms(s){let e=s==null?void 0:s.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 Pa(s,e){let t=s==null?void 0:s.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 Ma(s,e){let t=ms(s);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 Ia(){let s=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),s.size>0&&i()})},n=d=>{var u;s.add(d);let p=(u=e.get(d.target))!=null?u:new Set;p.add(d),e.set(d.target,p),i()},a=d=>{s.delete(d);let p=e.get(d.target);p&&(p.delete(d),p.size===0&&e.delete(d.target))},r=d=>{d.killed||(d.killed=!0,a(d))},o=()=>{var p,u;let d=yt();for(let g of Array.from(s)){if(g.killed||g.paused)continue;let h=d-g.startMs-g.delayMs;if(h<0)continue;let m=g.durationMs>0?h/g.durationMs:1,f=La(m),v=g.repeat>=0?g.repeat+1:1,b=g.repeat>0?Math.min(Math.floor(m),v-1):0;if(g.repeat>0&&m>=1){let x=m-b;f=La(x)}let w=g.ease(f);g.yoyo&&b%2===1&&(w=1-w);for(let x of g.props)ka(g.target,x.key,x.from+(x.to-x.from)*w);g.scaleFrom&&g.scaleTo&&Pa(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*w,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*w});try{(p=g.onUpdate)==null||p.call(g)}catch{}if(m>=v){r(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(d,p,u)=>{var x;let g=Math.max(0,(typeof p.duration=="number"?p.duration:.5)*1e3),h=Math.max(0,(typeof p.delay=="number"?p.delay:0)*1e3+((x=u==null?void 0:u.delayMsOverride)!=null?x:0)),m=gs(p.ease),f=typeof p.repeat=="number"?Math.max(0,p.repeat|0):0,v=p.yoyo===!0,b=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),w=[];for(let I of Object.keys(p)){if(b.has(I))continue;let j=p[I];typeof j=="number"&&w.push({key:I,from:hs(d,I),to:j})}let y=Ma(d,p);return{target:d,startMs:yt(),delayMs:h,durationMs:g,ease:m,props:w,scaleFrom:y.from,scaleTo:y.to,repeat:f,yoyo:v,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:()=>r(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=yt())},resume:()=>{var m;if(!u.paused)return;let g=(m=u.pauseAtMs)!=null?m:yt(),h=yt()-g;u.startMs+=h,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 h=p[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof h=="number"&&ka(d,g,h)}let u=Ma(d,p);u.to&&Pa(d,u.to)},killTweensOf(d){let p=e.get(d);if(p)for(let u of Array.from(p))r(u)},timeline(d={}){let p=[],u=0,g=!1,h=[],m=b=>{if(typeof b=="number")return Math.max(0,b*1e3);let w=typeof b=="string"?b.trim():"";return w.startsWith("+=")?u+Math.max(0,Number(w.slice(2))*1e3||0):w?Math.max(0,Number(w)*1e3||0):u},f=b=>{p.push(b);let w=Math.max(0,(typeof b.vars.duration=="number"?b.vars.duration:.5)*1e3);u=Math.max(u,b.atMs+w)},v={to(b,w,y){return f({kind:"to",target:b,vars:w,atMs:m(y)}),v},fromTo(b,w,y,x){return f({kind:"fromTo",target:b,vars:y,from:w,atMs:m(x)}),v},play(){var b,w;if(g)return v;g=!0,h=[];for(let y of p)y.kind==="fromTo"&&c.set(y.target,(b=y.from)!=null?b:{}),h.push(c.to(y.target,{...y.vars,delay:y.atMs/1e3+((w=y.vars.delay)!=null?w:0)}));return v},pause(){for(let b of h)b.pause();return v},kill(){for(let b of h)b.kill();h=[],g=!1}};return d.paused||v.play(),v}};return c}function ja(){if(typeof window=="undefined")return;let s=window;if(!s.gsap)try{s.gsap=Ia()}catch{}}var _a={name:"handler-playable-sdk",version:"0.5.550",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 pe=0,bs=pe++,Oa=pe++,Ra=pe++,za=pe++,Da=pe++,$a=pe++,Ha=pe++,Na=pe++,Fa=pe++,Ba=pe++,Ua=pe++,Ga=pe++,W=bs;function qa(){return W===Oa}function Va(){return W===Ra}function Wa(){return W===za}function Ya(){return W===Da}function et(){return W===$a}function tt(){return W===Ha}function Ka(){return W===Na}function Xa(){return W===Fa}function Ja(){return W===Ba}function nn(){return W===Ua}function an(){return W===Ga}function Za(){let s=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(s==="mraid")try{mraid.getState(),W=Oa;return}catch{}else if(s==="dapi")try{dapi.isReady(),W=Ra;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(W=za)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(W=Da)}catch{}else if(e==="mintegral")window.gameReady&&(W=$a);else if(e==="tapjoy")window.TJ_API&&(W=Ha);else if(e==="tiktok")window.openAppStore&&(W=Na);else if(e==="smadex")try{window.smxTracking&&(W=Fa)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(W=Ba)}catch{}else e==="vungle"?W=Ua:(s==="nucleo"||e==="nucleo")&&(W=Ga)}import rn from"lottie-web";var Qa=rn;typeof window!="undefined"&&(window.lottie=rn,window.__baseLottie=rn);function J(s,e){let t=(n,a)=>a===0?n:t(a,n%a),i=t(s,e);return`${s/i}:${e/i}`}var ol=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:J(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:J(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:J(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:J(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:J(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:J(360,780)}],ll=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:J(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:J(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:J(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:J(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:J(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:J(412,915)}],cl=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:J(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:J(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:J(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:J(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:J(800,1280)}],sn=[{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:J(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:J(768,1024),mraidScale:.7}];var er=[...sn],tr=[{category:"playable",label:"Playable Ad",devices:sn}],on=sn[0];function it(s){return er.find(e=>e.id===s)||on}function dl(s){return er.filter(e=>e.category===s)}var ze=class{async updateProperty(e,t,i,n={}){var l,c,d;console.log("[PropertyUpdateManager] Updating:",e,t,i);let a=window.getEditableObjectConfig;if(typeof a!="function"){console.error("[PropertyUpdateManager] getEditableObjectConfig not available");return}let r=a(e);if(!r){console.error("[PropertyUpdateManager] Config not found for:",e);return}Ve({objectId:e,path:t,value:i},{persist:!0});let o=window.applyEditableObjectConfig;if(typeof o=="function"){let p=window.__editableConfig,u=(d=(c=(l=p==null?void 0:p.objects)==null?void 0:l.get)==null?void 0:c.call(l,e))!=null?d:r;await o(e,u),console.log("[PropertyUpdateManager] Applied config successfully")}else console.warn("[PropertyUpdateManager] applyEditableObjectConfig not available");this.triggerRefresh(e),n.refreshInspector&&window.dispatchEvent(new CustomEvent("inspector:refresh"))}getNestedProperty(e,t){let i=t.split("."),n=e;for(let a of i)if(n&&typeof n=="object"&&a in n)n=n[a];else return;return n}triggerRefresh(e){let t=window.__refreshHierarchy;typeof t=="function"&&t(),window.dispatchEvent(new CustomEvent("inspector:property-updated",{detail:{objectId:e}}))}};function ln(s){let e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async t=>{var a;let i=(a=t.target.files)==null?void 0:a[0];if(!i)return;let n=new FileReader;n.onload=async()=>{let r=n.result,o=s.category||"misc",c=`${(s.objectId||"new_asset").replace(/^json\./,"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"")||"new_asset"}_uploaded`;try{let p=await(await fetch("/api/library/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:o,filename:`${c}.png`,data:r,overwrite:!0})})).json();if(!(p!=null&&p.success)){alert(`Upload failed: ${(p==null?void 0:p.error)||"Unknown error"}`);return}let u=window.addAssetToRegistry;typeof u=="function"&&u(o,`${c}.png`);try{await fetch("/api/setup-library",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}let g=window.refreshAssetLibrary;typeof g=="function"&&await g(),await s.onApply(p.path)}catch(d){console.error("[QuickActionsBar] Upload error:",d),alert("Upload failed. Check console.")}},n.readAsDataURL(i)},e.click()}var Vt=class{constructor(){this.updateManager=new ze}async handleAction(e,t,i){console.log("[QuickActionsBar] Action:",e,t,i);let n=window.getEditableObjectConfig;if(typeof n!="function")return;let a=n(t);if(!a)return;let r=this.updateManager.getNestedProperty(a,i);if(e==="ai-convert"||e==="upload"||e==="library"){let o=i==="ui.text"||i==="render.asset.path",l=i==="render.asset.path";o&&(await this.prepareForImageConversion(t,a),e==="ai-convert"&&i!=="render.asset.path"&&(i="render.asset.path"))}switch(e){case"library":this.openLibrary(t,i,r);break;case"ai-edit":this.openAIEditor(t,i,r);break;case"upload":this.openUpload(t,i);break;case"reset":await this.resetToDefault(t,i);break;case"ai-convert":this.handleAiConvert(t,i,r);break;default:console.warn("[QuickActionsBar] Unknown action:",e)}}async prepareForImageConversion(e,t){var i,n;if(console.log("[QuickActionsBar] Preparing for image conversion:",e),t.render||(t.render={alpha:1,visible:!0}),(t.render.alpha===0||t.render.alpha===void 0)&&(t.render.alpha=1,await this.updateManager.updateProperty(e,"render.alpha",1)),(t.render.visible===!1||t.render.visible===void 0)&&(t.render.visible=!0,await this.updateManager.updateProperty(e,"render.visible",!0)),t.render.asset||(t.render.asset={type:"image",path:""}),t.render.asset.type!=="image"&&(t.render.asset.type="image",await this.updateManager.updateProperty(e,"render.asset",{type:"image",path:t.render.asset.path||""})),t.ui&&t.ui.renderMode!=="png"){await this.updateManager.updateProperty(e,"ui.renderMode","png",{refreshInspector:!0}),await this.updateManager.updateProperty(e,"render.tint","#ffffff");let r=((n=(i=t.transform)==null?void 0:i.scale)!=null?n:1)*.3;await this.updateManager.updateProperty(e,"transform.scale",r),console.log("[QuickActionsBar] Text to PNG conversion: set tint white, scale",r)}this.ensureSlotInRegistry(e,t)}ensureSlotInRegistry(e,t){var o,l,c;let i=window.getEditableAssets;if(typeof i!="function")return;let n=i();if(!n||!n.slots)return;let a=e.startsWith("json.")?e.replace("json.",""):e;if(!n.slots.some(d=>d.objectId===a||d.slotId===a)){let d=((o=t.identity)==null?void 0:o.category)||"ui";console.log("[QuickActionsBar] Adding new slot to registry for converted object:",a),n.slots.push({slotId:a,displayName:a.replace(/_/g," "),objectId:a,category:d,currentAsset:((c=(l=t.render)==null?void 0:l.asset)==null?void 0:c.path)||"",defaultAsset:"",libraryFolder:d,assetType:"image"}),n.categories&&!n.categories.includes(d)&&n.categories.push(d),n.libraryAssets&&!n.libraryAssets[d]&&(n.libraryAssets[d]=[]);let p=window.reRenderAssetLibrary;typeof p=="function"&&p()}}openLibrary(e,t,i){var a;let n=window.__debugContext;if(n){if(n.activeTab!=="library"){n.activeTab="library";let r=window.__updateWorkbenchTabs;typeof r=="function"&&r()}if(n.libraryPanel){let r=window.getEditableObjectConfig,o=r==null?void 0:r(e),l=(a=o==null?void 0:o.identity)==null?void 0:a.category;l||(l=t.split(".")[0]==="render"?"environment":"ui"),console.log("[QuickActionsBar] Highlighting library slot:",e,"category:",l),n.libraryPanel.highlightSlot(e,l)}}}openAIEditor(e,t,i){let n=window.__openAiEditor;if(typeof n=="function"){let a=t.split(".").pop()||t;n(a,`Edit ${a} for ${e}`,i,{objectId:e,path:t})}else console.warn("[QuickActionsBar] AI Editor not available")}openUpload(e,t){var r;let i=window.getEditableObjectConfig,n=i==null?void 0:i(e),a=((r=n==null?void 0:n.identity)==null?void 0:r.category)||(t.split(".")[0]==="render"?"environment":"ui");ln({objectId:e,category:a,onApply:async o=>{var d,p;await this.updateManager.updateProperty(e,t,o);let l=window.__debugContext;(p=(d=l==null?void 0:l.options)==null?void 0:d.onPropertyChange)==null||p.call(d,e,t,o);let c=window.__highlightLibrarySlot;typeof c=="function"&&setTimeout(()=>{c(e,a)},500),window.dispatchEvent(new CustomEvent("inspector:refresh"))}})}async resetToDefault(e,t){console.log("[QuickActionsBar] Reset to default:",e,t);try{let i=await this.getDefaultValue(e,t);i!==void 0?(await this.updateManager.updateProperty(e,t,i),console.log("[QuickActionsBar] Reset to default value:",i)):alert("No default value found for this property.")}catch(i){console.error("[QuickActionsBar] Failed to reset to default:",i),alert("Failed to reset property. Check console for details.")}}async getDefaultValue(e,t){let i=t.split(".");if(i.length<2)return;let n=i[0],a=i.slice(1),r=window.__editableConfig;if(!(r!=null&&r.schemas))return;let o=null;if(r.schemas instanceof Map?o=r.schemas.get(n):typeof r.schemas=="object"&&(o=r.schemas[n]),!(o!=null&&o.defaults))return;let l=o.defaults;for(let c of a)if(l&&typeof l=="object")l=l[c];else return;return l}handleAiConvert(e,t,i){let n=window.__openAiEditor;if(typeof n=="function"){let r=`A single, high-quality, high-detail game UI icon/asset representing "${String(i||e.replace(/_/g," ").replace("json.",""))}". Modern stylized 3D rendered style, vibrant colors, soft lighting, isolated on solid magenta background, highly polished professional game art.`,o="render.asset.path";console.log("[QuickActionsBar] AI Convert for:",e,"from:",t,"to:",o),n(e,r,"",{objectId:e,path:o});let l=window.__debugContext;if(l){l.activeTab="ai";let c=window.__updateWorkbenchTabs;typeof c=="function"&&c()}}else console.warn("[QuickActionsBar] AI Editor not available")}};var vs=[{value:"loading",label:"Loading"},{value:"start",label:"Start"},{value:"gameplay",label:"Gameplay"},{value:"tutorial",label:"Tutorial"},{value:"endgame",label:"Endgame"}],ys=["environment","ui","character","system","backgrounds"],ws=["bg","world","ui"],ir={SwerveMove:{speed:5,sensitivity:1,directionMode:"dominantAxis",axis:"both",bounds:{left:-400,right:400,top:-300,bottom:300}},DragToWin:{targetId:"",successDistance:80},DragSnap:{snapTargetId:"",snapDistance:40},JoystickMove:{speed:6,bounds:{left:-400,right:400,top:-300,bottom:300}}},Wt=class{constructor(){this.modal=null;this.state=null}open(e){this.state=this.createInitialState(e),this.createModal(),document.body.appendChild(this.modal),this.attachEventListeners(),this.updateStepUI()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),window.__wizardAssetPicker=null,this.modal=null,this.state=null}createInitialState(e){return{step:1,objectType:"sprite",instanceId:"",displayName:"",category:"environment",screenId:e.screenId,layer:"world",positionMode:"static",anchorPreset:"center",anchorX:.5,anchorY:.5,positionX:0,positionY:0,offsetX:0,offsetY:0,scale:.2,rotation:0,zIndex:0,assetPath:"",tint:"",alpha:1,text:"",font:"brand.primary",fontSize:18,letterSpacing:0,align:"center",graphicsWidth:200,graphicsHeight:200,graphicsFill:"#FFFFFF",graphicsAlpha:1,interactionEnabled:!1,dragEnabled:!1,hoverEnabled:!1,clickEnabled:!1,logicId:"",logicPropsRaw:""}}createModal(){let e=document.createElement("div");e.className="wizard-modal",e.innerHTML=`
|
|
2
2
|
<div class="wizard-card">
|
|
3
3
|
<div class="wizard-header">
|
|
4
4
|
<div class="wizard-title">
|
|
@@ -1560,7 +1560,7 @@ Generate the requested asset matching the brand style.${s.needsTransparency?" Ba
|
|
|
1560
1560
|
</div>
|
|
1561
1561
|
<div class="panel-resize-handle" data-panel-resize></div>
|
|
1562
1562
|
</div>
|
|
1563
|
-
`}initialize(e,t){var n,a,r,o,l,c;this.options=t,this.root=e.querySelector('[data-panel="customize-settings"]'),this.assetsContainer=(n=this.root)==null?void 0:n.querySelector("[data-customize-assets]"),this.colorsContainer=(a=this.root)==null?void 0:a.querySelector("[data-customize-colors]"),this.fontsContainer=(r=this.root)==null?void 0:r.querySelector("[data-customize-fonts]"),this.textsContainer=(o=this.root)==null?void 0:o.querySelector("[data-customize-texts]"),this.audioContainer=(l=this.root)==null?void 0:l.querySelector("[data-customize-audio]");let i=(c=this.root)==null?void 0:c.querySelector("[data-customize-apply]");i==null||i.addEventListener("click",()=>this.handleApply()),this.setupRenderModeHandlers(),this.setupResizeHandle(),this.refresh()}setupRenderModeHandlers(){var i,n;let e=(i=this.root)==null?void 0:i.querySelector('[data-render-mode="endgame-png"]'),t=(n=this.root)==null?void 0:n.querySelector('[data-render-mode="splash-png"]');e==null||e.addEventListener("change",()=>{this.applyEndgamePngMode(e.checked)}),t==null||t.addEventListener("change",()=>{this.applySplashPngMode(t.checked)})}applyEndgamePngMode(e){let t=window.getEditableObjectConfig,i=window.applyEditableObjectConfig;if(typeof t!="function"||typeof i!="function")return;let n=["ui_endgame_title_1","ui_endgame_subtitle_1","ui_endgame_logo_1","ui_endgame_cta_1"];for(let a of n){let r=t(a);r&&(r.ui||(r.ui={}),r.ui.renderMode=e?"png":"text",e&&(r.render||(r.render={}),r.render.asset||(r.render.asset={type:"image",path:""}),r.render.asset.type="image"),i(a,r))}console.log("[CustomizePanel] EndGame PNG mode:",e?"enabled":"disabled")}applySplashPngMode(e){let t=window.applyEditableEngineConfig;typeof t=="function"&&(t({splash:{type:e?"image":"text",image_path:e?"library/splash/splash.png":""}}),console.log("[CustomizePanel] Splash PNG mode:",e?"enabled":"disabled"))}openAiEditor(e,t,i,n){this.openAiModal(e,i,n),t&&this.aiPromptInput&&(this.aiPromptInput.value=t,this.setAiStatus("Prompt loaded."))}refresh(){var t,i,n,a,r,o,l,c;let e=this.getEngineSnapshot();if(
|
|
1563
|
+
`}initialize(e,t){var n,a,r,o,l,c;this.options=t,this.root=e.querySelector('[data-panel="customize-settings"]'),this.assetsContainer=(n=this.root)==null?void 0:n.querySelector("[data-customize-assets]"),this.colorsContainer=(a=this.root)==null?void 0:a.querySelector("[data-customize-colors]"),this.fontsContainer=(r=this.root)==null?void 0:r.querySelector("[data-customize-fonts]"),this.textsContainer=(o=this.root)==null?void 0:o.querySelector("[data-customize-texts]"),this.audioContainer=(l=this.root)==null?void 0:l.querySelector("[data-customize-audio]");let i=(c=this.root)==null?void 0:c.querySelector("[data-customize-apply]");i==null||i.addEventListener("click",()=>this.handleApply()),this.setupRenderModeHandlers(),this.setupResizeHandle(),this.refresh()}setupRenderModeHandlers(){var i,n;let e=(i=this.root)==null?void 0:i.querySelector('[data-render-mode="endgame-png"]'),t=(n=this.root)==null?void 0:n.querySelector('[data-render-mode="splash-png"]');e==null||e.addEventListener("change",()=>{this.applyEndgamePngMode(e.checked)}),t==null||t.addEventListener("change",()=>{this.applySplashPngMode(t.checked)})}applyEndgamePngMode(e){let t=window.getEditableObjectConfig,i=window.applyEditableObjectConfig;if(typeof t!="function"||typeof i!="function")return;let n=["ui_endgame_title_1","ui_endgame_subtitle_1","ui_endgame_logo_1","ui_endgame_cta_1"];for(let a of n){let r=t(a);r&&(r.ui||(r.ui={}),r.ui.renderMode=e?"png":"text",e&&(r.render||(r.render={}),r.render.asset||(r.render.asset={type:"image",path:""}),r.render.asset.type="image"),i(a,r))}console.log("[CustomizePanel] EndGame PNG mode:",e?"enabled":"disabled")}applySplashPngMode(e){let t=window.applyEditableEngineConfig;typeof t=="function"&&(t({splash:{type:e?"image":"text",image_path:e?"library/splash/splash.png":""}}),console.log("[CustomizePanel] Splash PNG mode:",e?"enabled":"disabled"))}openAiEditor(e,t,i,n){this.openAiModal(e,i,n),t&&this.aiPromptInput&&(this.aiPromptInput.value=t,this.setAiStatus("Prompt loaded."))}refresh(){var t,i,n,a,r,o,l,c;let e=this.getEngineSnapshot();if(!e){this.scheduleRetry();return}console.log("[CustomizePanel] Snapshot assets count:",Object.keys(e.assets||{}).length),this.renderAssets(e.assets),this.renderColors((i=(t=e.runtime)==null?void 0:t.theme)!=null?i:{}),this.renderFonts((a=(n=e.runtime)==null?void 0:n.fonts)!=null?a:{}),this.renderTexts((o=(r=e.runtime)==null?void 0:r.ui)!=null?o:{}),this.renderAudio((c=(l=e.runtime)==null?void 0:l.audio)!=null?c:{})}getEngineSnapshot(){let e=window.getEditableEngineConfig;return typeof e!="function"?null:e()}renderAssets(e){if(!this.assetsContainer)return;this.assetsContainer.innerHTML="";let t=Object.entries(e!=null?e:{});if(!t.length){this.assetsContainer.innerHTML='<div class="customize-empty">No assets found.</div>',this.scheduleRetry();return}this.clearRetry(),t.forEach(([i,n])=>{var u;let a=document.createElement("div");a.className="customize-row";let r=document.createElement("span");r.className="customize-key",r.textContent=i;let o=document.createElement("input");o.type="text",o.value=n!=null?n:"",o.className="customize-input",o.dataset.assetKey=i,o.addEventListener("input",()=>{this.handleAssetValueChange(i,o)});let l=document.createElement("div");l.className="customize-actions";let c=document.createElement("button");c.type="button",c.className="customize-icon-btn",c.title="Preview asset",c.innerHTML=`
|
|
1564
1564
|
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
1565
1565
|
<path d="M12 5c5.2 0 9.2 3.7 10 6.8-.8 3.1-4.8 6.8-10 6.8S2.8 14.9 2 11.8C2.8 8.7 6.8 5 12 5z" />
|
|
1566
1566
|
<circle cx="12" cy="12" r="3.2" />
|
|
@@ -2188,7 +2188,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=n,this.currentPrompt=n}}c
|
|
|
2188
2188
|
<button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
|
|
2189
2189
|
</div>
|
|
2190
2190
|
</div>
|
|
2191
|
-
`,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 a=8;[[e,t],[e+i-a,t],[e,t+n-a],[e+i-a,t+n-a]].forEach(([o,l])=>{var c;(c=this.ctx)==null||c.fillRect(o,l,a,a)})}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,a=i/this.cropHeight,r=Math.min(n,a),o=this.cropWidth*r,l=this.cropHeight*r,c=(i-o)/2,d=(i-l)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,c,d,o,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(s){new Dn().open(s)};import{Application as uo,Container as Tt,Graphics as ot,Point as Se,Rectangle as go,Text as ho,TextStyle as mo}from"pixi.js";import{Sprite as Fs,Container as Nr}from"pixi.js";var Bs=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",$n=Bs;if(typeof window!="undefined")try{let s=new XMLHttpRequest;if(s.open("GET","./build-settings.json",!1),s.send(),s.status===200&&s.responseText){let e=JSON.parse(s.responseText);e!=null&&e.buildMode&&($n=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${$n}`))}}catch{}function Us(s){var t,i,n,a,r;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(s);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(s))return{x:(t=s[0])!=null?t:.5,y:(i=s[1])!=null?i:.5};if(s&&typeof s=="object"&&"x"in s&&"y"in s)return{x:(n=s.x)!=null?n:.5,y:(a=s.y)!=null?a:.5};if(typeof s=="string"){let o=s.trim().toLowerCase();return(r=e[o])!=null?r:{x:.5,y:.5}}return null}var we=class{static async create(e,t,i){var l,c,d,p,u,g,h;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${$n}`);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 m=new Nr;return this.applyTransform(m,t==null?void 0:t.transform,t),m}let a=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${a}, type: ${n.type}, path: ${n.path}`);let r=await Ki.load(e,n,i,a);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(d=r==null?void 0:r.constructor)==null?void 0:d.name}`);let o;if(n.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",r,"for object:",e),o=new Fs(r),console.log("[ObjectFactory] Created object:",o,"type:",(p=o==null?void 0:o.constructor)==null?void 0:p.name),this.applyTransform(o,t==null?void 0:t.transform,t);else if(n.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(u=r==null?void 0:r.constructor)==null?void 0:u.name,r),r&&(((g=r.constructor)==null?void 0:g.name)==="Container"||r instanceof Nr)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let m=[n.path,`/assets/${n.path}`,`assets/${n.path}`,`../assets/${n.path}`],f=!1;for(let v of m)try{let b=await fetch(v);if(b.ok){o=await b.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",v,"type:",(h=o==null?void 0:o.constructor)==null?void 0:h.name),f=!0;break}}catch{continue}f||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=r)}else o=r;else o=r,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,t==null?void 0:t.transform,t);return o}static applyTransform(e,t,i){var n,a,r,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(n=t.position.x)!=null?n:0,e.y=(a=t.position.y)!=null?a:0):"position"in e&&e.position&&e.position.set((r=t.position.x)!=null?r:0,(o=t.position.y)!=null?o: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=Us(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};import{Graphics as Gs,Point as qs}from"pixi.js";var ke={width:400,height:600,designWidth:400,scaleFactor:1},Ii={scale:1,position:1},ji=[];function Vs(s,e,t,i,n,a,r){ji.push({element:s,originalScale:a,positionHelper:e,heightPercent:n}),e(s,t,i,n,a,r,!1)}function Ws(){ji.forEach(({element:s,originalScale:e,positionHelper:t,heightPercent:i})=>{let n=e*ke.scaleFactor;t(s,ke.width,ke.height,i,n,!0,!1)})}function Ys(){ji.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Hn(s,e){console.log(`[SCREEN] updateScreenState called: ${s}x${e}`),ke.width=s,ke.height=e,ke.scaleFactor=Math.min(s/ke.designWidth,1.15),Ii.scale=ke.scaleFactor,Ii.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Ii.scale.toFixed(3)}`),Ws()}var B={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Ks(s,e,t){let i=B[s];i&&i[e]!==void 0&&(i[e]=t,console.log(`Updated ${s}.${e} = ${t}`))}function Xs(){return B}var Js={center:{x:.5,y:.5},"center-center":{x:.5,y:.5},middle:{x:.5,y:.5},"middle-center":{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},"left-center":{x:0,y:.5},"right-center":{x:1,y:.5},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};function Mi(s,e){return typeof s=="number"&&Number.isFinite(s)?s:e}function He(s,e={x:.5,y:.5}){var t;if(Array.isArray(s))return{x:Mi(s[0],e.x),y:Mi(s[1],e.y)};if(s&&typeof s=="object"){let i=s;return{x:Mi(i.x,e.x),y:Mi(i.y,e.y)}}if(typeof s=="string"){let i=s.trim().toLowerCase();return(t=Js[i])!=null?t:e}return e}function Ne(s,e,t,i={}){var g,h,m,f,v,b;let n=He(t),a=(g=i.inset)!=null?g:{},r=(h=i.padding)!=null?h:{x:0,y:0},o=((m=a.left)!=null?m:0)+r.x,l=((f=a.right)!=null?f:0)+r.x,c=((v=a.top)!=null?v:0)+r.y,d=((b=a.bottom)!=null?b:0)+r.y,p=Math.max(0,s-o-l),u=Math.max(0,e-c-d);return{x:o+p*n.x,y:c+u*n.y}}function Fe(s,e,t,i={}){var m,f,v,b,w,y;let n=(m=i.inset)!=null?m:{},a=(f=i.padding)!=null?f:{x:0,y:0},r=((v=n.left)!=null?v:0)+a.x,o=((b=n.right)!=null?b:0)+a.x,l=((w=n.top)!=null?w:0)+a.y,c=((y=n.bottom)!=null?y:0)+a.y,d=Math.max(0,s-r-o),p=Math.max(0,e-l-c),u=He(t,{x:.5,y:.5}),g=Math.min(Math.max(u.x,0),1),h=Math.min(Math.max(u.y,0),1);return{x:r+d*g,y:l+p*h}}function Nn(s,e,t,i={}){var d,p,u;if(!s)return;let n=i.positionRatio?Fe(e,t,i.positionRatio,{inset:i.inset,padding:i.screenPadding}):Ne(e,t,i.anchor,{inset:i.inset,padding:i.screenPadding}),a=(d=i.offset)!=null?d:{x:0,y:0},r=n.x+a.x,o=n.y+a.y;s.anchor&&i.renderAnchor&&s.anchor.set(i.renderAnchor.x,i.renderAnchor.y),fe(s,r,o);let l=(p=i.scale)!=null?p:1,c=(u=i.scaleMultiplier)!=null?u:1;(i.scale!==void 0||i.scaleMultiplier!==void 0)&&xe(s,l*c)}if(typeof window!="undefined"){let s=window.innerWidth,e=window.innerHeight,t=()=>{let i=window.innerWidth,n=window.innerHeight;(i!==s||n!==e)&&(s=i,e=n,Hn(i,n))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Hn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Ks,window.getDebugConfig=Xs,window.copyConfig=lo,window.applyConfig=Ct,window.applyConfigForRatio=co,window.positionAtBottom=Fr,window.positionAtTop=eo,window.positionAtCenter=to,window.positionAtLeft=io,window.positionAtRight=no,window.positionAtBottomLeft=ao,window.positionAtBottomRight=ro,window.positionAtTopLeft=so,window.positionAtTopRight=oo,window.applyPositionContract=Qs,console.log("\u{1F3AE} Debug Config Functions Available:"),console.log("\u2022 updateDebugConfig(category, key, value)"),console.log("\u2022 getDebugConfig()"),console.log("\u2022 copyConfig(presetName)"),console.log("\u2022 applyConfig(config)"),console.log("\u2022 applyConfigForRatio(width, height)"),console.log("\u{1F4CD} Positioning Helpers Available (with scale):"),console.log("\u2022 positionAtBottom(element, w, h, percent, scale)"),console.log("\u2022 positionAtTop(element, w, h, percent, scale)"),console.log("\u2022 positionAtCenter(element, w, h, offsetX, offsetY, scale)"),console.log("\u2022 positionAtLeft/Right(element, w, h, percent, scale)"),console.log("\u2022 Corner positions: BottomLeft/Right, TopLeft/Right (all with scale)"),console.log("\u2022 applyPositionContract(element, w, h, contract)"),console.log("Example: positionAtCenter(mySprite, 400, 600, 0, -50, 1.2)")}function _i(s,e,t=0){return s*e+t}function Oi(s,e,t=0){return s*(1-e)+t}function Ri(s,e,t=0){return s*e+t}function zi(s,e,t=0){return s*(1-e)+t}function ue(s,e=0){return s/2+e}function Zs(s,e){return s*e}function Qs(s,e,t,i){var r,o,l,c,d,p,u,g,h,m,f,v,b,w,y,x,I,j,T,_;let n=0,a=0;switch(i.type){case"top":n=ue(e,(o=(r=i.offset)==null?void 0:r.x)!=null?o:0),a=_i(t,i.percent,(c=(l=i.offset)==null?void 0:l.y)!=null?c:0);break;case"bottom":n=ue(e,(p=(d=i.offset)==null?void 0:d.x)!=null?p:0),a=Oi(t,i.percent,(g=(u=i.offset)==null?void 0:u.y)!=null?g:0);break;case"left":n=Ri(e,i.percent,(m=(h=i.offset)==null?void 0:h.x)!=null?m:0),a=ue(t,(v=(f=i.offset)==null?void 0:f.y)!=null?v:0);break;case"right":n=zi(e,i.percent,(w=(b=i.offset)==null?void 0:b.x)!=null?w:0),a=ue(t,(x=(y=i.offset)==null?void 0:y.y)!=null?x:0);break;case"center":n=ue(e,(j=(I=i.offset)==null?void 0:I.x)!=null?j:0),a=ue(t,(_=(T=i.offset)==null?void 0:T.y)!=null?_:0);break}s.position?s.position.set(n,a):(s.x=n,s.y=a),i.scale!==void 0&&i.scale!==1&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(i.scale,i.scale):(s.scale.x=i.scale,s.scale.y=i.scale))}function Fr(s,e,t,i=.2,n=1,a=!0,r=!1){let o=Zs(t,i),l=Oi(t,i/2);fe(s,ue(e),l);let c=a?n*ke.scaleFactor:n;xe(s,c),r&&!ji.find(d=>d.element===s)&&Vs(s,Fr,e,t,i,n,a)}function eo(s,e,t,i=.1,n=1){fe(s,ue(e),_i(t,i)),xe(s,n)}function to(s,e,t,i=0,n=0,a=1){fe(s,ue(e,i),ue(t,n)),xe(s,a)}function io(s,e,t,i=.1,n=1){fe(s,Ri(e,i),ue(t)),xe(s,n)}function no(s,e,t,i=.1,n=1){fe(s,zi(e,i),ue(t)),xe(s,n)}function ao(s,e,t,i=.05,n=.05,a=1){fe(s,Ri(e,n),Oi(t,i)),xe(s,a)}function ro(s,e,t,i=.05,n=.05,a=1){fe(s,zi(e,n),Oi(t,i)),xe(s,a)}function so(s,e,t,i=.05,n=.05,a=1){fe(s,Ri(e,n),_i(t,i)),xe(s,a)}function oo(s,e,t,i=.05,n=.05,a=1){fe(s,zi(e,n),_i(t,i)),xe(s,a)}function fe(s,e,t){s&&s.position?typeof s.position.set=="function"?s.position.set(e,t):(s.position.x=e,s.position.y=t):s&&(s.x=e,s.y=t)}function xe(s,e){e!==1&&s&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(e,e):s.scale.x!==void 0&&s.scale.y!==void 0&&(s.scale.x=e,s.scale.y=e))}var Xe={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function lo(s){return s&&Xe[s]?JSON.parse(JSON.stringify(Xe[s])):JSON.parse(JSON.stringify(B))}function Ct(s){Object.keys(s).forEach(e=>{let t=e;B[t]&&s[t]&&Object.assign(B[t],s[t])}),console.log("Config applied:",s)}function co(s,e){let t=s/e;t>1.6?(Ct(Xe.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(Ct(Xe.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(Ct(Xe.square),console.log("Applied SQUARE config for ratio:",t)):(Ct(Xe.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let s=window;s.configPresets=Xe,s.resolveAnchorVec2=s.resolveAnchorVec2||He,s.resolveScreenAnchorPoint=s.resolveScreenAnchorPoint||Ne,s.resolveScreenRatioPoint=s.resolveScreenRatioPoint||Fe}var se=null;function po(s,e,t,i,n,a={}){var M,P,R,D,N,H,F,G,Y,Q,ie,oe,$,Z,le,ge,ce,be,Ce,Te,q,ee,K,ae,_e,Ge,da,pa,ua,ga,ha,ma,fa,ba;let r=(M=a.enableDebugLogs)!=null?M:!1;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:i.width,height:i.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",a));let{mainContainer:o,label:l,background:c,backgroundTexture:d,app:p}=s;if(!p||!p.renderer){r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:p.renderer.width,height:p.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:p.screen.width,height:p.screen.height}));let u=i.width,g=i.height;r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:u,baseHeight:g});let h=u*B.layout.screen_scale_x,m=g*B.layout.screen_scale_y,f=u/2,v=e.engine.runtime||{},b=v.layout||{};r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:B.layout.screen_scale_x,screen_scale_y:B.layout.screen_scale_y}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Calculated dimensions:",{width:h,height:m,midX:f}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",v),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",b));let w=b.design_width_portrait||400,y=h/w;y=Math.min(y,1.15);let x=y*((P=B.engine.scale)!=null?P:1),I=(R=a.skipMainContainerTransform)!=null?R:!1;!I&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(x):(o.scale.x=x,o.scale.y=x));let j=(D=b.main_container_anchor)!=null?D:"center",T=(N=b.main_container_position_ratio)!=null?N:{x:.5,y:.5},_=(H=b.main_container_offset)!=null?H:{x:0,y:0},O=b.main_container_position_ratio?Fe(u,g,T):Ne(u,g,j),L=O.x+_.x+B.layout.position_offset.x,A=O.y+_.y+B.layout.position_offset.y;if(!I&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(L,A):(o.position.x=L,o.position.y=A)),n&&(o!=null&&o.toLocal))for(let[re,ne]of e.objects.entries()){let V=ne==null?void 0:ne.transform;if(!V||((F=V.position_mode)!=null?F:"static")!=="static")continue;let U=(G=n.get)==null?void 0:G.call(n,re),ve=((Y=U==null?void 0:U.getDisplayObject)==null?void 0:Y.call(U))||(U==null?void 0:U.pixiObject)||U;if(!ve||ve.parent!==o)continue;let $t=V.position_ratio!=null?Fe(u,g,V.position_ratio):Ne(u,g,(Q=V.anchor)!=null?Q:"center"),Ht=o.toLocal(new qs($t.x,$t.y)),Nt=(ie=V.position)!=null?ie:{x:0,y:0},qe=Ht.x+Nt.x,Yi=Ht.y+Nt.y;typeof(U==null?void 0:U.setPosition)=="function"?U.setPosition(qe,Yi):(fe(ve,qe,Yi),(oe=U==null?void 0:U.transform)!=null&&oe.position&&(U.transform.position.x=qe,U.transform.position.y=Yi))}let k=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,E=((k==null?void 0:k.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(B.layout.debug_rect_visible&&E){(!se||se.parent!==p.stage)&&(se==null||se.destroy(),se=new Gs,se.zIndex=9999,p.stage.addChild(se)),se.clear();let re=B.layout.debug_rect_scale_x,ne=B.layout.debug_rect_scale_y,V=(u-4)*re,Oe=(g-4)*ne,U=(u-V)/2,ve=(g-Oe)/2;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:u,baseHeight:g,rectW:V,rectH:Oe,offsetX:U,offsetY:ve}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+U,y:2+ve,width:V,height:Oe})),se.rect(2+U,2+ve,V,Oe).stroke({width:B.layout.debug_rect_thickness,color:B.layout.debug_rect_color})}else se&&(se.destroy(),se=null);let S=(($=s.label)==null?void 0:$.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(l&&l.position&&S){let re=(le=(Z=S==null?void 0:S.transform)==null?void 0:Z.anchor)!=null?le:"center",ne=(ge=S==null?void 0:S.transform)==null?void 0:ge.position_ratio,V=((ce=S==null?void 0:S.transform)==null?void 0:ce.offset)||{x:0,y:0};Nn(l,u,g,{anchor:re,positionRatio:ne,offset:{x:V.x*x,y:V.y*x},renderAnchor:He(re)})}if(l&&l.alpha>0){let re=1+Math.sin(t*B.engine.label_pulse_speed)*B.engine.label_pulse_intensity,ne=(Ce=(be=S==null?void 0:S.transform)==null?void 0:be.scale)!=null?Ce:1,V=re*x*ne;l.scale&&(typeof l.scale.set=="function"?l.scale.set(V):(l.scale.x=V,l.scale.y=V))}if(r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),c){r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!c),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(Te=c.constructor)==null?void 0:Te.name)),c.alpha=((ee=(q=v.background)==null?void 0:q.alpha)!=null?ee:.98)*B.engine.background_alpha,r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",c.alpha);let re=e.objects.get("background_1");r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",re);let ne=(re==null?void 0:re.transform)||{};r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",ne);let V=ne.offset||{x:0,y:0},Oe=((ae=(K=v.background)==null?void 0:K.offset_y)!=null?ae:0)+B.engine.background_offset_y,U=(_e=ne.anchor)!=null?_e:"center",ve=ne.position_ratio;if(r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:V,bgRuntimeOffsetY:Oe,bgScreenAnchor:U,bgPositionRatio:ve,baseWidth:u,baseHeight:g,finalScale:x}),Nn(c,u,g,{anchor:U,positionRatio:ve,offset:{x:V.x*x,y:V.y*x+Oe},renderAnchor:He(U)}),r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:c.x,y:c.y,scaleX:(Ge=c.scale)==null?void 0:Ge.x,scaleY:(da=c.scale)==null?void 0:da.y,anchorX:(pa=c.anchor)==null?void 0:pa.x,anchorY:(ua=c.anchor)==null?void 0:ua.y,pivotX:(ga=c.pivot)==null?void 0:ga.x,pivotY:(ha=c.pivot)==null?void 0:ha.y,width:c.width,height:c.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background texture dimensions:",{textureWidth:d==null?void 0:d.width,textureHeight:d==null?void 0:d.height})),d){let $t=Math.max(h/d.width,m/d.height),Ht=(fa=(ma=v.background)==null?void 0:ma.scale_multiplier)!=null?fa:1.05,Nt=(ba=ne.scale)!=null?ba:1,qe=$t*Ht*B.engine.background_scale*Nt;c.scale&&(typeof c.scale.set=="function"?c.scale.set(qe):(c.scale.x=qe,c.scale.y=qe))}else c&&typeof c.clear=="function"&&(c.clear(),c.rect(-h/2,-m/2,h,m).fill({color:1444375}))}}var Di=class{constructor(e){this.app=null;this.camera=new Tt;this.mainContainer=new Tt;this.gizmoLayer=new Tt;this.screenFrame=new ot;this.objectMap=new Map;this.selectedId=null;this.dragMode=null;this.dragStartPointer=null;this.dragStartPos=null;this.dragStartScale=1;this.dragStartRotationDeg=0;this.dragStartAngle=0;this.dragStartDistance=1;this.dragAnchorLocal=null;this.dragStartValue=null;this.cameraScale=1;this.isPanning=!1;this.panStart=null;this.panStartCamera=null;this.hasUserCamera=!1;this.resizeObserver=null;this.gizmoOutline=new ot;this.moveHandle=new ot;this.scaleHandle=new ot;this.rotateHandle=new ot;this.isVisible=!0;this.applyQueued=!1;this.applyQueuedId=null;this.handleScreenChange=e=>{if(!(e!=null&&e.detail))return;let{width:t,height:i}=e.detail;!t||!i||(this.updateLayout({width:t,height:i}),this.updateGizmos(),this.syncFromConfig())};this.handleConfigChanged=e=>{if(!this.isVisible)return;this.updateLayout();let t=e==null?void 0:e.detail;if(!t){this.syncFromConfig();return}let i=t.objectId,n=t.objectIds;if(i){this.syncFromConfig([i]);return}if(Array.isArray(n)&&n.length>0){this.syncFromConfig(n);return}this.syncFromConfig()};this.handleSceneRefresh=()=>{this.isVisible&&this.syncFromConfig()};this.handlePreviewSelect=e=>{var i,n;let t=(n=(i=e==null?void 0:e.detail)==null?void 0:i.objectId)!=null?n:null;this.setSelected(t,{silent:!0})};this.onDragMove=e=>{if(!this.dragMode||!this.selectedId||!this.app)return;let t=this.objectMap.get(this.selectedId);if(!t)return;let i=this.getPointerInCamera(e.clientX,e.clientY);if(!(!i||!this.dragStartPointer||!this.dragStartPos)){if(this.dragMode==="move"){let n=i.x-this.dragStartPointer.x,a=i.y-this.dragStartPointer.y,r=this.dragStartPos.x+n,o=this.dragStartPos.y+a;t.displayObject.position.set(r,o),this.updateLiveConfigPosition(r,o)}else if(this.dragMode==="scale"){let n=new Se(this.dragStartPos.x,this.dragStartPos.y),a=Math.max(1,this.distance(i,n)),r=Math.max(.05,this.dragStartScale*(a/this.dragStartDistance));t.displayObject.scale.set(r),this.updateLiveConfigScale(r)}else if(this.dragMode==="rotate"){let n=new Se(this.dragStartPos.x,this.dragStartPos.y),r=Math.atan2(i.y-n.y,i.x-n.x)-this.dragStartAngle,o=this.dragStartRotationDeg+r*180/Math.PI;t.displayObject.rotation=o*Math.PI/180,this.updateLiveConfigRotation(o)}this.updateGizmos(),this.queueLiveApply(this.selectedId)}};this.onDragEnd=()=>{var i,n,a,r,o,l,c;if(!this.dragMode||!this.selectedId)return;let e=this.selectedId,t=this.getEditableObjectConfig(e);if(t){let d=(i=t.transform)!=null?i:{};if(t.transform||(t.transform=d),this.dragMode==="move"&&this.dragStartValue){let p=d.position,u=Array.isArray(p)?[Number((n=p[0])!=null?n:0),Number((a=p[1])!=null?a:0)]:{x:Number((r=p==null?void 0:p.x)!=null?r:0),y:Number((o=p==null?void 0:p.y)!=null?o:0)};this.applyFinalOverride(e,"transform.position",u,this.dragStartValue)}else this.dragMode==="scale"?this.applyFinalOverride(e,"transform.scale",(l=d.scale)!=null?l:1,this.dragStartValue):this.dragMode==="rotate"&&this.applyFinalOverride(e,"transform.rotation",(c=d.rotation)!=null?c:0,this.dragStartValue);this.queueLiveApply(e)}window.dispatchEvent(new CustomEvent("inspector:refresh")),this.dragMode=null,this.dragStartPointer=null,this.dragStartPos=null,this.dragAnchorLocal=null,this.dragStartValue=null,window.removeEventListener("pointermove",this.onDragMove),window.removeEventListener("pointerup",this.onDragEnd)};this.onWheel=e=>{if(!this.app||!this.isVisible)return;e.preventDefault();let i=Math.sign(e.deltaY)<0?1.1:.9,n=Math.min(6,Math.max(.1,this.cameraScale*i));this.cameraScale=n,this.camera.scale.set(n),this.hasUserCamera=!0,this.updateGizmos()};this.onPanStart=e=>{e.button===2&&(this.isPanning=!0,this.panStart={x:e.clientX,y:e.clientY},this.panStartCamera={x:this.camera.position.x,y:this.camera.position.y},this.hasUserCamera=!0)};this.onPanMove=e=>{if(!this.isPanning||!this.panStart||!this.panStartCamera)return;let t=e.clientX-this.panStart.x,i=e.clientY-this.panStart.y;this.camera.position.set(this.panStartCamera.x+t,this.panStartCamera.y+i)};this.onPanEnd=()=>{this.isPanning=!1,this.panStart=null,this.panStartCamera=null};this.root=e.root,this.getScreen=e.getScreen}async mount(){this.app||(this.app=new uo,await this.app.init({resizeTo:this.root,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0}),this.root.innerHTML="",this.root.appendChild(this.app.canvas),this.root.style.position="relative",this.root.style.overflow="hidden",this.app.stage.sortableChildren=!0,this.app.stage.eventMode="static",this.camera.sortableChildren=!0,this.mainContainer.sortableChildren=!0,this.gizmoLayer.sortableChildren=!0,this.app.stage.addChild(this.camera),this.camera.addChild(this.screenFrame),this.camera.addChild(this.mainContainer),this.camera.addChild(this.gizmoLayer),this.screenFrame.zIndex=-1,this.gizmoLayer.zIndex=1e5,this.gizmoLayer.addChild(this.gizmoOutline),this.gizmoLayer.addChild(this.moveHandle),this.gizmoLayer.addChild(this.scaleHandle),this.gizmoLayer.addChild(this.rotateHandle),this.setupInteractions(),this.setupObservers(),this.updateLayout(),this.refresh(),this.isVisible||this.app.ticker.stop())}destroy(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),window.removeEventListener("handler-preview:screen",this.handleScreenChange),window.removeEventListener("config:changed",this.handleConfigChanged),window.removeEventListener("handler:scene-objects-refresh",this.handleSceneRefresh),window.removeEventListener("preview:select",this.handlePreviewSelect),this.app&&(this.app.destroy(!0),this.app=null)}setVisible(e){this.isVisible=e,this.app&&(e?(this.app.ticker.start(),this.refresh()):this.app.ticker.stop())}refresh(){this.syncFromConfig()}setupObservers(){window.addEventListener("handler-preview:screen",this.handleScreenChange),window.addEventListener("config:changed",this.handleConfigChanged),window.addEventListener("handler:scene-objects-refresh",this.handleSceneRefresh),window.addEventListener("preview:select",this.handlePreviewSelect),this.resizeObserver=new ResizeObserver(()=>{this.handleResize()}),this.resizeObserver.observe(this.root)}setupInteractions(){if(!this.app)return;let e=this.app.canvas;e.addEventListener("contextmenu",t=>t.preventDefault()),e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("pointerdown",this.onPanStart),window.addEventListener("pointermove",this.onPanMove),window.addEventListener("pointerup",this.onPanEnd),this.moveHandle.eventMode="static",this.moveHandle.cursor="move",this.scaleHandle.eventMode="static",this.scaleHandle.cursor="nwse-resize",this.rotateHandle.eventMode="static",this.rotateHandle.cursor="crosshair",this.moveHandle.on("pointerdown",t=>this.startDrag("move",t)),this.scaleHandle.on("pointerdown",t=>this.startDrag("scale",t)),this.rotateHandle.on("pointerdown",t=>this.startDrag("rotate",t))}handleResize(){this.app&&(this.updateLayout(),this.hasUserCamera||this.centerCamera(),this.updateGizmos())}getEditableConfig(){return window.__editableConfig||null}getEditableObjectConfig(e){var n,a;let t=window.getEditableObjectConfig;if(typeof t=="function")return t(e);let i=this.getEditableConfig();return i!=null&&i.objects?typeof i.objects.get=="function"?(n=i.objects.get(e))!=null?n:null:(a=i.objects[e])!=null?a:null:null}getEditableObjectIds(){let e=window.getEditableObjectList;if(typeof e=="function"){let i=e();if(Array.isArray(i))return i}let t=this.getEditableConfig();return t!=null&&t.objects?typeof t.objects.keys=="function"?Array.from(t.objects.keys()):Object.keys(t.objects):[]}async syncFromConfig(e){if(!this.app)return;let t=this.getEditableConfig();if(!(t!=null&&t.objects))return;let i=e!=null&&e.length?e:this.getEditableObjectIds(),n=new Set(i);if(!e)for(let a of Array.from(this.objectMap.keys()))n.has(a)||this.removeObject(a);for(let a of i){let r=this.getEditableObjectConfig(a);if(!r){this.removeObject(a);continue}await this.upsertObject(a,r)}this.updateGizmos()}removeObject(e){var i,n;let t=this.objectMap.get(e);if(t){try{(n=(i=t.displayObject)==null?void 0:i.destroy)==null||n.call(i)}catch{}this.objectMap.delete(e),this.selectedId===e&&this.setSelected(null,{silent:!0})}}async upsertObject(e,t){let i=this.getAssetKey(t),n=this.objectMap.get(e);if(!n||n.assetKey!==i){n&&this.removeObject(e);let r=await this.createDisplayObject(e,t);if(!r)return;this.mainContainer.addChild(r),this.objectMap.set(e,{id:e,displayObject:r,assetKey:i}),this.attachObjectInteraction(r,e)}let a=this.objectMap.get(e);a&&(this.applyVisualConfig(a.displayObject,t),this.updateObjectTransform(a.displayObject,t))}async createDisplayObject(e,t){var i,n,a,r,o,l,c,d,p,u,g,h,m,f,v,b,w,y,x,I;if((i=t==null?void 0:t.render)!=null&&i.asset)try{if(((a=(n=t==null?void 0:t.render)==null?void 0:n.asset)==null?void 0:a.type)!=="json"){let T=await we.create(e,t,this.app);if(T instanceof Tt)return T}}catch(j){console.warn("[SceneEditor] ObjectFactory failed for",e,j)}if((r=t==null?void 0:t.ui)!=null&&r.text||((o=t==null?void 0:t.ui)==null?void 0:o.kind)==="text"){let j=(p=(d=(l=t==null?void 0:t.ui)==null?void 0:l.color)!=null?d:(c=t==null?void 0:t.render)==null?void 0:c.tint)!=null?p:"#ffffff",T=new mo({fontFamily:"Arial, sans-serif",fontSize:(g=(u=t==null?void 0:t.ui)==null?void 0:u.fontSize)!=null?g:16,fill:j,align:(m=(h=t==null?void 0:t.ui)==null?void 0:h.align)!=null?m:"center",letterSpacing:(v=(f=t==null?void 0:t.ui)==null?void 0:f.letterSpacing)!=null?v:0});return new ho({text:(w=(b=t==null?void 0:t.ui)==null?void 0:b.text)!=null?w:"",style:T})}if((y=t==null?void 0:t.effects)!=null&&y.width||(x=t==null?void 0:t.effects)!=null&&x.height){let j=new ot,T=typeof t.effects.width=="number"?t.effects.width:100,_=typeof t.effects.height=="number"?t.effects.height:100,O=(I=t.effects.fill_color)!=null?I:"#ffffff",L=typeof t.effects.fill_alpha=="number"?t.effects.fill_alpha:1,A=Number.parseInt(String(O).replace("#",""),16);return j.rect(0,0,T,_).fill({color:Number.isFinite(A)?A:16777215,alpha:L}),j}return new Tt}attachObjectInteraction(e,t){if(e){if(e.eventMode="static",e.cursor="pointer",!e.hitArea&&typeof e.getLocalBounds=="function"){let i=e.getLocalBounds();i&&i.width>0&&i.height>0&&(e.hitArea=i)}e.on("pointerdown",i=>{var a,r,o;((o=(r=(a=i==null?void 0:i.data)==null?void 0:a.originalEvent)==null?void 0:r.button)!=null?o:0)===0&&(this.setSelected(t),this.startDrag("move",i))})}}getAssetKey(e){var i;let t=(i=e==null?void 0:e.render)==null?void 0:i.asset;return t?`${t.type||"asset"}::${t.path||""}`:null}applyVisualConfig(e,t){var r,o,l,c,d,p,u;if(!e)return;let i=(r=t==null?void 0:t.render)!=null?r:{};typeof i.alpha=="number"&&(e.alpha=i.alpha),e.visible=i.visible!==!1,e.zIndex=typeof i.z_index=="number"?i.z_index:0;let n=(d=(c=(o=t==null?void 0:t.render)==null?void 0:o.anchor)!=null?c:(l=t==null?void 0:t.transform)==null?void 0:l.anchor)!=null?d:"center",a=He(n,{x:.5,y:.5});if((p=e.anchor)!=null&&p.set)e.anchor.set(a.x,a.y);else if(e.pivot){let g=(u=e.getLocalBounds)==null?void 0:u.call(e);g&&e.pivot.set(g.width*a.x,g.height*a.y)}}updateObjectTransform(e,t){var l;if(!e)return;let i=(l=t==null?void 0:t.transform)!=null?l:{},n=this.getAnchorLocalPoint(i),a=this.getPositionOffset(i);n&&e.position.set(n.x+a.x,n.y+a.y);let r=typeof i.scale=="number"?i.scale:void 0;typeof r=="number"&&e.scale&&e.scale.set(r);let o=typeof i.rotation=="number"?i.rotation:0;typeof e.rotation=="number"&&(e.rotation=o*Math.PI/180)}getAnchorLocalPoint(e){var a;let t=this.getScreen();if(!(t!=null&&t.width)||!(t!=null&&t.height))return null;let i=(e==null?void 0:e.position_ratio)!=null?Fe(t.width,t.height,e.position_ratio):Ne(t.width,t.height,(a=e==null?void 0:e.anchor)!=null?a:"center"),n=new Se;return this.mainContainer.toLocal(new Se(i.x,i.y),void 0,n),n}getPositionOffset(e){var l,c,d,p,u,g,h,m;let t=e==null?void 0:e.position,i=e==null?void 0:e.offset,n=Array.isArray(t)?Number((l=t[0])!=null?l:0):Number((c=t==null?void 0:t.x)!=null?c:0),a=Array.isArray(t)?Number((d=t[1])!=null?d:0):Number((p=t==null?void 0:t.y)!=null?p:0),r=Array.isArray(i)?Number((u=i[0])!=null?u:0):Number((g=i==null?void 0:i.x)!=null?g:0),o=Array.isArray(i)?Number((h=i[1])!=null?h:0):Number((m=i==null?void 0:i.y)!=null?m:0);return{x:n+r,y:a+o}}updateLayout(e){var m,f,v,b,w,y,x,I;let t=e!=null?e:this.getScreen();if(!(t!=null&&t.width)||!(t!=null&&t.height))return;let n=(((f=(m=this.getEditableConfig())==null?void 0:m.engine)==null?void 0:f.runtime)||{}).layout||{},a=t.width*((v=B.layout.screen_scale_x)!=null?v:1),r=n.design_width_portrait||400,o=a/r;o=Math.min(o,1.15);let l=o*((b=B.engine.scale)!=null?b:1);this.mainContainer.scale.set(l);let c=(w=n.main_container_anchor)!=null?w:"center",d=(y=n.main_container_position_ratio)!=null?y:{x:.5,y:.5},p=(x=n.main_container_offset)!=null?x:{x:0,y:0},u=n.main_container_position_ratio?Fe(t.width,t.height,d):Ne(t.width,t.height,c),g=u.x+p.x+B.layout.position_offset.x,h=u.y+p.y+B.layout.position_offset.y;this.mainContainer.position.set(g,h),this.screenFrame.clear(),this.screenFrame.rect(0,0,t.width,t.height),this.screenFrame.stroke({width:2,color:2894892,alpha:.5}),(I=this.app)!=null&&I.stage&&(this.app.stage.hitArea=new go(0,0,t.width,t.height)),this.hasUserCamera||this.centerCamera()}centerCamera(){if(!this.app)return;let e=this.getScreen(),t=this.app.renderer.width,i=this.app.renderer.height;this.cameraScale=1,this.camera.scale.set(this.cameraScale),this.camera.position.set((t-e.width)/2,(i-e.height)/2)}updateGizmos(){var d,p;if(!this.selectedId||!this.isVisible){this.clearGizmos();return}let e=this.objectMap.get(this.selectedId);if(!(e!=null&&e.displayObject)){this.clearGizmos();return}let t=(p=(d=e.displayObject).getBounds)==null?void 0:p.call(d);if(!t||t.width<=0||t.height<=0){this.clearGizmos();return}let i=this.camera.toLocal(new Se(t.x,t.y)),n=this.camera.toLocal(new Se(t.x+t.width,t.y+t.height)),a=n.x-i.x,r=n.y-i.y,o=i.x+a/2,l=i.y+r/2;this.gizmoOutline.clear(),this.gizmoOutline.rect(i.x,i.y,a,r),this.gizmoOutline.stroke({width:2,color:16752394,alpha:.9});let c=10;this.moveHandle.clear(),this.moveHandle.circle(0,0,c/2),this.moveHandle.fill({color:16752394,alpha:.9}),this.moveHandle.position.set(o,l),this.scaleHandle.clear(),this.scaleHandle.rect(-c/2,-c/2,c,c),this.scaleHandle.fill({color:3900150,alpha:.9}),this.scaleHandle.position.set(n.x,n.y),this.rotateHandle.clear(),this.rotateHandle.circle(0,0,c/2),this.rotateHandle.fill({color:1096065,alpha:.9}),this.rotateHandle.position.set(o,i.y-20)}clearGizmos(){this.gizmoOutline.clear(),this.moveHandle.clear(),this.scaleHandle.clear(),this.rotateHandle.clear()}setSelected(e,t={}){if(this.selectedId!==e&&(this.selectedId=e,this.updateGizmos(),!t.silent&&e)){let i=window.__previewSelectObject;typeof i=="function"&&i(e)}}startDrag(e,t){var d,p,u,g,h;if(!this.selectedId||!e||!this.app||((u=(p=(d=t==null?void 0:t.data)==null?void 0:d.originalEvent)==null?void 0:p.button)!=null?u:0)!==0)return;let n=this.objectMap.get(this.selectedId);if(!n)return;let a=this.camera.toLocal(t.data.global),r=n.displayObject;this.dragMode=e,this.dragStartPointer=a.clone(),this.dragStartPos=new Se(r.position.x,r.position.y),this.dragStartScale=typeof((g=r.scale)==null?void 0:g.x)=="number"?r.scale.x:1;let o=this.getEditableObjectConfig(this.selectedId),l=(h=o==null?void 0:o.transform)!=null?h:{};this.dragStartRotationDeg=typeof l.rotation=="number"?l.rotation:0,this.dragAnchorLocal=this.getAnchorLocalPoint(l),this.dragStartValue=this.getDragStartValue(e,l);let c=new Se(r.position.x,r.position.y);this.dragStartAngle=Math.atan2(a.y-c.y,a.x-c.x),this.dragStartDistance=Math.max(1,this.distance(a,c)),window.addEventListener("pointermove",this.onDragMove),window.addEventListener("pointerup",this.onDragEnd)}getDragStartValue(e,t){var i,n,a;return e==="move"?(i=t==null?void 0:t.position)!=null?i:{x:0,y:0}:e==="scale"?(n=t==null?void 0:t.scale)!=null?n:1:e==="rotate"?(a=t==null?void 0:t.rotation)!=null?a:0:null}updateLiveConfigPosition(e,t){var p,u,g,h,m,f;if(!this.selectedId||!this.dragAnchorLocal)return;let i=e-this.dragAnchorLocal.x,n=t-this.dragAnchorLocal.y,a=this.getEditableObjectConfig(this.selectedId);if(!a)return;let r=(p=a.transform)!=null?p:{};a.transform||(a.transform=r);let o=(u=r.offset)!=null?u:{x:0,y:0},l=Array.isArray(o)?Number((g=o[0])!=null?g:0):Number((h=o==null?void 0:o.x)!=null?h:0),c=Array.isArray(o)?Number((m=o[1])!=null?m:0):Number((f=o==null?void 0:o.y)!=null?f:0),d=this.buildPositionValue(r,{x:i-l,y:n-c});this.setNestedValue(r,"position",d)}updateLiveConfigScale(e){var n;if(!this.selectedId)return;let t=this.getEditableObjectConfig(this.selectedId);if(!t)return;let i=(n=t.transform)!=null?n:{};t.transform||(t.transform=i),i.scale=e}updateLiveConfigRotation(e){var n;if(!this.selectedId)return;let t=this.getEditableObjectConfig(this.selectedId);if(!t)return;let i=(n=t.transform)!=null?n:{};t.transform||(t.transform=i),i.rotation=e}applyFinalOverride(e,t,i,n){let a=this.getEditableObjectConfig(e);a!=null&&a.transform&&this.setNestedValue(a.transform,t.replace("transform.",""),n),Ve({objectId:e,path:t,value:i},{persist:!0,emitEvent:!0,trackHistory:!0})}queueLiveApply(e){this.applyQueuedId=e,!this.applyQueued&&(this.applyQueued=!0,requestAnimationFrame(()=>{this.applyQueued=!1;let t=this.applyQueuedId;if(!t)return;let i=this.getEditableObjectConfig(t),n=window.applyEditableObjectConfig;typeof n=="function"&&i&&n(t,i)}))}setNestedValue(e,t,i){let n=t.split("."),a=e;for(let r=0;r<n.length-1;r+=1){let o=n[r];(!a[o]||typeof a[o]!="object")&&(a[o]={}),a=a[o]}a[n[n.length-1]]=i}buildPositionValue(e,t){let i=e==null?void 0:e.position;return Array.isArray(i)?[t.x,t.y]:{x:t.x,y:t.y}}distance(e,t){let i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)}getPointerInCamera(e,t){if(!this.app)return null;let i=this.app.canvas.getBoundingClientRect(),n=(e-i.left)*(this.app.renderer.width/i.width),a=(t-i.top)*(this.app.renderer.height/i.height),r=new Se;return this.camera.toLocal(new Se(n,a),void 0,r),r}};var Fn=class{constructor(e={}){this.isLandscape=!1;this.autoScale=1;this.userScaleMultiplier=1;this.viewMode="single";this.layoutMode="fixed";this.comparePresets=[it("playable-portrait"),it("iphone-14"),it("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.sceneEditor=null;this.sceneVisiblePreference=!0;this.sceneVisible=!0;this.hasInitialFit=!1;this.isMounted=!1;this.isInitialized=!1;this.gameReady=!1;this.resizeListenersDisabled=!1;this.compareSnapshotTimer=null;this.hasUnsavedChanges=!1;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=it(e.defaultDevice||on.id),this.debugPanel=new Pi,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.scenePane=this.mustQuery("[data-scene-pane]"),this.sceneRoot=this.mustQuery("#scene-editor-root"),this.sceneSplitter=this.mustQuery("[data-scene-splitter]"),this.gameViewPane=this.mustQuery("[data-game-pane]"),this.lastSinglePresetId=this.currentPreset.id,this.consolePanel=this.container.querySelector(".console-panel"),this.debugPanel.initialize(this.container),this.debugPanel.setupDebugEventListeners();try{let t=window.localStorage.getItem(this.getSceneVisibilityStorageKey());this.sceneVisiblePreference=t===null?!0:t==="true"}catch{}this.sceneEditor=new Di({root:this.sceneRoot,getScreen:()=>this.getScreen()}),this.sceneEditor.mount(),this.applyDeviceFrameStyles(),this.setupCompareViewports(),this.setupConsoleInterceptor(),this.setupObserversAndListeners(),this.setupFrameDragging(),this.setupSpaceKeyListener(),this.setupShortcutListeners(),this.setupUnsavedChangesIndicator(),this.setupScenePaneInteractions(),this.updateSceneVisibility(),this.setDevice(this.currentPreset.id,{suppressCallback:!0}),this.updateDockState(),this.isInitialized=!0}getShortcutKey(){return typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0?"CMD":"CTRL"}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,this.sceneEditor&&(this.sceneEditor.destroy(),this.sceneEditor=null)}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(){var e;this.gameReady=!0,this.enableResizeListeners(),this.scheduleFit(),this.debugPanel.refresh(),(e=this.sceneEditor)==null||e.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,a;let i=this.autoScale*this.userScaleMultiplier;this.isLandscape=!1,this.currentPreset=it(e),this.viewMode==="single"&&(this.lastSinglePresetId=this.currentPreset.id),this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale:i}),t.suppressCallback||(a=(n=this.options).onDeviceChange)==null||a.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(),this.updateSceneVisibility(),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,a=o=>{let l=o.clientY-i,c=Math.max(100,Math.min(800,n-l));e.style.height=`${c}px`;let d=this.autoScale*this.userScaleMultiplier;this.fitToScreen({keepVisibleScale:d})},r=()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",r),e.classList.remove("resizing")};t.addEventListener("pointerdown",o=>{o.preventDefault(),i=o.clientY,n=e.offsetHeight,document.addEventListener("pointermove",a),document.addEventListener("pointerup",r),e.classList.add("resizing")})}makeSidebarResizable(e,t,i){let n,a,r=l=>{let c=i==="left"?l.clientX-n:n-l.clientX,d=Math.max(200,Math.min(600,a+c));e.style.width=`${d}px`;let p=this.container.querySelector(".preview-main");if(p){let g=i==="left"?`${d}px`:p.style.gridTemplateColumns.split(" ")[0]||"300px",h=i==="right"?`${d}px`:p.style.gridTemplateColumns.split(" ")[2]||"350px";p.style.gridTemplateColumns=`${g} 1fr ${h}`}let u=this.autoScale*this.userScaleMultiplier;this.fitToScreen({keepVisibleScale:u})},o=()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",o),e.classList.remove("resizing")};t.addEventListener("pointerdown",l=>{l.preventDefault(),n=l.clientX,a=e.offsetWidth,document.addEventListener("pointermove",r),document.addEventListener("pointerup",o),e.classList.add("resizing")})}getSceneVisibilityStorageKey(){return`handler_preview_scene_visible::${typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default"}`}getSceneWidthStorageKey(){return`handler_preview_scene_width::${typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default"}`}setupScenePaneInteractions(){let e=this.scenePane.querySelector("[data-scene-drag-handle]"),t=this.scenePane.querySelector("[data-scene-resize]"),i=this.container.querySelector("[data-preview-split]");e&&Ye(this.scenePane,e,i!=null?i:this.previewContainer),t&&Ti(this.scenePane,t,void 0,260,200);let n=this.getStoredSceneWidth();n&&(this.scenePane.style.width=`${n}px`),this.sceneSplitter.addEventListener("pointerdown",a=>{if(this.layoutMode!=="fixed"||!this.sceneVisible)return;a.preventDefault();let r=a.clientX,o=this.scenePane.offsetWidth,l=Math.max(260,Math.min(720,this.previewContainer.clientWidth*.6)),c=p=>{let u=p.clientX-r,g=Math.max(240,Math.min(l,o+u));this.scenePane.style.width=`${g}px`;let h=this.autoScale*this.userScaleMultiplier;this.fitToScreen({keepVisibleScale:h})},d=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",d),this.storeSceneWidth(this.scenePane.offsetWidth)};document.addEventListener("pointermove",c),document.addEventListener("pointerup",d)})}storeSceneWidth(e){try{window.localStorage.setItem(this.getSceneWidthStorageKey(),String(e))}catch{}}getStoredSceneWidth(){try{let e=window.localStorage.getItem(this.getSceneWidthStorageKey()),t=e?Number(e):null;return Number.isFinite(t)&&t?t:null}catch{return null}}updateSceneVisibility(){let e=this.viewMode==="single"&&this.sceneVisiblePreference;this.setSceneVisible(e,{persist:!1});let t=this.container.querySelector("#scene-toggle");t&&(t.classList.toggle("active",this.sceneVisiblePreference),t.setAttribute("aria-pressed",String(this.sceneVisiblePreference)))}setSceneVisible(e,t={}){var i;if(this.sceneVisible=e,this.container.classList.toggle("scene-hidden",!e),(i=this.sceneEditor)==null||i.setVisible(e),t.persist!==!1){this.sceneVisiblePreference=e;try{window.localStorage.setItem(this.getSceneVisibilityStorageKey(),String(e))}catch{}}this.scheduleFit()}createShell(){var t;let e=document.createElement("div");return e.className="preview-shell layout-fixed",e.innerHTML=`
|
|
2191
|
+
`,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 a=8;[[e,t],[e+i-a,t],[e,t+n-a],[e+i-a,t+n-a]].forEach(([o,l])=>{var c;(c=this.ctx)==null||c.fillRect(o,l,a,a)})}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,a=i/this.cropHeight,r=Math.min(n,a),o=this.cropWidth*r,l=this.cropHeight*r,c=(i-o)/2,d=(i-l)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,c,d,o,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(s){new Dn().open(s)};import{Application as uo,Container as Tt,Graphics as ot,Point as Se,Rectangle as go,Text as ho,TextStyle as mo}from"pixi.js";import{Sprite as Fs,Container as Nr}from"pixi.js";var Bs=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",$n=Bs;if(typeof window!="undefined")try{let s=new XMLHttpRequest;if(s.open("GET","./build-settings.json",!1),s.send(),s.status===200&&s.responseText){let e=JSON.parse(s.responseText);e!=null&&e.buildMode&&($n=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${$n}`))}}catch{}function Us(s){var t,i,n,a,r;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(s);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(s))return{x:(t=s[0])!=null?t:.5,y:(i=s[1])!=null?i:.5};if(s&&typeof s=="object"&&"x"in s&&"y"in s)return{x:(n=s.x)!=null?n:.5,y:(a=s.y)!=null?a:.5};if(typeof s=="string"){let o=s.trim().toLowerCase();return(r=e[o])!=null?r:{x:.5,y:.5}}return null}var we=class{static async create(e,t,i){var l,c,d,p,u,g,h;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${$n}`);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 m=new Nr;return this.applyTransform(m,t==null?void 0:t.transform,t),m}let a=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${a}, type: ${n.type}, path: ${n.path}`);let r=await Ki.load(e,n,i,a);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(d=r==null?void 0:r.constructor)==null?void 0:d.name}`);let o;if(n.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",r,"for object:",e),o=new Fs(r),console.log("[ObjectFactory] Created object:",o,"type:",(p=o==null?void 0:o.constructor)==null?void 0:p.name),this.applyTransform(o,t==null?void 0:t.transform,t);else if(n.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(u=r==null?void 0:r.constructor)==null?void 0:u.name,r),r&&(((g=r.constructor)==null?void 0:g.name)==="Container"||r instanceof Nr)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let m=[n.path,`/assets/${n.path}`,`assets/${n.path}`,`../assets/${n.path}`],f=!1;for(let v of m)try{let b=await fetch(v);if(b.ok){o=await b.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",v,"type:",(h=o==null?void 0:o.constructor)==null?void 0:h.name),f=!0;break}}catch{continue}f||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=r)}else o=r;else o=r,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,t==null?void 0:t.transform,t);return o}static applyTransform(e,t,i){var n,a,r,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(n=t.position.x)!=null?n:0,e.y=(a=t.position.y)!=null?a:0):"position"in e&&e.position&&e.position.set((r=t.position.x)!=null?r:0,(o=t.position.y)!=null?o: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=Us(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};import{Graphics as Gs,Point as qs}from"pixi.js";var ke={width:400,height:600,designWidth:400,scaleFactor:1},Ii={scale:1,position:1},ji=[];function Vs(s,e,t,i,n,a,r){ji.push({element:s,originalScale:a,positionHelper:e,heightPercent:n}),e(s,t,i,n,a,r,!1)}function Ws(){ji.forEach(({element:s,originalScale:e,positionHelper:t,heightPercent:i})=>{let n=e*ke.scaleFactor;t(s,ke.width,ke.height,i,n,!0,!1)})}function Ys(){ji.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Hn(s,e){console.log(`[SCREEN] updateScreenState called: ${s}x${e}`),ke.width=s,ke.height=e,ke.scaleFactor=Math.min(s/ke.designWidth,1.15),Ii.scale=ke.scaleFactor,Ii.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Ii.scale.toFixed(3)}`),Ws()}var B={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Ks(s,e,t){let i=B[s];i&&i[e]!==void 0&&(i[e]=t,console.log(`Updated ${s}.${e} = ${t}`))}function Xs(){return B}var Js={center:{x:.5,y:.5},"center-center":{x:.5,y:.5},middle:{x:.5,y:.5},"middle-center":{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},"left-center":{x:0,y:.5},"right-center":{x:1,y:.5},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};function Mi(s,e){return typeof s=="number"&&Number.isFinite(s)?s:e}function He(s,e={x:.5,y:.5}){var t;if(Array.isArray(s))return{x:Mi(s[0],e.x),y:Mi(s[1],e.y)};if(s&&typeof s=="object"){let i=s;return{x:Mi(i.x,e.x),y:Mi(i.y,e.y)}}if(typeof s=="string"){let i=s.trim().toLowerCase();return(t=Js[i])!=null?t:e}return e}function Ne(s,e,t,i={}){var g,h,m,f,v,b;let n=He(t),a=(g=i.inset)!=null?g:{},r=(h=i.padding)!=null?h:{x:0,y:0},o=((m=a.left)!=null?m:0)+r.x,l=((f=a.right)!=null?f:0)+r.x,c=((v=a.top)!=null?v:0)+r.y,d=((b=a.bottom)!=null?b:0)+r.y,p=Math.max(0,s-o-l),u=Math.max(0,e-c-d);return{x:o+p*n.x,y:c+u*n.y}}function Fe(s,e,t,i={}){var m,f,v,b,w,y;let n=(m=i.inset)!=null?m:{},a=(f=i.padding)!=null?f:{x:0,y:0},r=((v=n.left)!=null?v:0)+a.x,o=((b=n.right)!=null?b:0)+a.x,l=((w=n.top)!=null?w:0)+a.y,c=((y=n.bottom)!=null?y:0)+a.y,d=Math.max(0,s-r-o),p=Math.max(0,e-l-c),u=He(t,{x:.5,y:.5}),g=Math.min(Math.max(u.x,0),1),h=Math.min(Math.max(u.y,0),1);return{x:r+d*g,y:l+p*h}}function Nn(s,e,t,i={}){var d,p,u;if(!s)return;let n=i.positionRatio?Fe(e,t,i.positionRatio,{inset:i.inset,padding:i.screenPadding}):Ne(e,t,i.anchor,{inset:i.inset,padding:i.screenPadding}),a=(d=i.offset)!=null?d:{x:0,y:0},r=n.x+a.x,o=n.y+a.y;s.anchor&&i.renderAnchor&&s.anchor.set(i.renderAnchor.x,i.renderAnchor.y),fe(s,r,o);let l=(p=i.scale)!=null?p:1,c=(u=i.scaleMultiplier)!=null?u:1;(i.scale!==void 0||i.scaleMultiplier!==void 0)&&xe(s,l*c)}if(typeof window!="undefined"){let s=window.innerWidth,e=window.innerHeight,t=()=>{let i=window.innerWidth,n=window.innerHeight;(i!==s||n!==e)&&(s=i,e=n,Hn(i,n))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Hn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Ks,window.getDebugConfig=Xs,window.copyConfig=lo,window.applyConfig=Ct,window.applyConfigForRatio=co,window.positionAtBottom=Fr,window.positionAtTop=eo,window.positionAtCenter=to,window.positionAtLeft=io,window.positionAtRight=no,window.positionAtBottomLeft=ao,window.positionAtBottomRight=ro,window.positionAtTopLeft=so,window.positionAtTopRight=oo,window.applyPositionContract=Qs,console.log("\u{1F3AE} Debug Config Functions Available:"),console.log("\u2022 updateDebugConfig(category, key, value)"),console.log("\u2022 getDebugConfig()"),console.log("\u2022 copyConfig(presetName)"),console.log("\u2022 applyConfig(config)"),console.log("\u2022 applyConfigForRatio(width, height)"),console.log("\u{1F4CD} Positioning Helpers Available (with scale):"),console.log("\u2022 positionAtBottom(element, w, h, percent, scale)"),console.log("\u2022 positionAtTop(element, w, h, percent, scale)"),console.log("\u2022 positionAtCenter(element, w, h, offsetX, offsetY, scale)"),console.log("\u2022 positionAtLeft/Right(element, w, h, percent, scale)"),console.log("\u2022 Corner positions: BottomLeft/Right, TopLeft/Right (all with scale)"),console.log("\u2022 applyPositionContract(element, w, h, contract)"),console.log("Example: positionAtCenter(mySprite, 400, 600, 0, -50, 1.2)")}function _i(s,e,t=0){return s*e+t}function Oi(s,e,t=0){return s*(1-e)+t}function Ri(s,e,t=0){return s*e+t}function zi(s,e,t=0){return s*(1-e)+t}function ue(s,e=0){return s/2+e}function Zs(s,e){return s*e}function Qs(s,e,t,i){var r,o,l,c,d,p,u,g,h,m,f,v,b,w,y,x,I,j,T,_;let n=0,a=0;switch(i.type){case"top":n=ue(e,(o=(r=i.offset)==null?void 0:r.x)!=null?o:0),a=_i(t,i.percent,(c=(l=i.offset)==null?void 0:l.y)!=null?c:0);break;case"bottom":n=ue(e,(p=(d=i.offset)==null?void 0:d.x)!=null?p:0),a=Oi(t,i.percent,(g=(u=i.offset)==null?void 0:u.y)!=null?g:0);break;case"left":n=Ri(e,i.percent,(m=(h=i.offset)==null?void 0:h.x)!=null?m:0),a=ue(t,(v=(f=i.offset)==null?void 0:f.y)!=null?v:0);break;case"right":n=zi(e,i.percent,(w=(b=i.offset)==null?void 0:b.x)!=null?w:0),a=ue(t,(x=(y=i.offset)==null?void 0:y.y)!=null?x:0);break;case"center":n=ue(e,(j=(I=i.offset)==null?void 0:I.x)!=null?j:0),a=ue(t,(_=(T=i.offset)==null?void 0:T.y)!=null?_:0);break}s.position?s.position.set(n,a):(s.x=n,s.y=a),i.scale!==void 0&&i.scale!==1&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(i.scale,i.scale):(s.scale.x=i.scale,s.scale.y=i.scale))}function Fr(s,e,t,i=.2,n=1,a=!0,r=!1){let o=Zs(t,i),l=Oi(t,i/2);fe(s,ue(e),l);let c=a?n*ke.scaleFactor:n;xe(s,c),r&&!ji.find(d=>d.element===s)&&Vs(s,Fr,e,t,i,n,a)}function eo(s,e,t,i=.1,n=1){fe(s,ue(e),_i(t,i)),xe(s,n)}function to(s,e,t,i=0,n=0,a=1){fe(s,ue(e,i),ue(t,n)),xe(s,a)}function io(s,e,t,i=.1,n=1){fe(s,Ri(e,i),ue(t)),xe(s,n)}function no(s,e,t,i=.1,n=1){fe(s,zi(e,i),ue(t)),xe(s,n)}function ao(s,e,t,i=.05,n=.05,a=1){fe(s,Ri(e,n),Oi(t,i)),xe(s,a)}function ro(s,e,t,i=.05,n=.05,a=1){fe(s,zi(e,n),Oi(t,i)),xe(s,a)}function so(s,e,t,i=.05,n=.05,a=1){fe(s,Ri(e,n),_i(t,i)),xe(s,a)}function oo(s,e,t,i=.05,n=.05,a=1){fe(s,zi(e,n),_i(t,i)),xe(s,a)}function fe(s,e,t){s&&s.position?typeof s.position.set=="function"?s.position.set(e,t):(s.position.x=e,s.position.y=t):s&&(s.x=e,s.y=t)}function xe(s,e){e!==1&&s&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(e,e):s.scale.x!==void 0&&s.scale.y!==void 0&&(s.scale.x=e,s.scale.y=e))}var Xe={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function lo(s){return s&&Xe[s]?JSON.parse(JSON.stringify(Xe[s])):JSON.parse(JSON.stringify(B))}function Ct(s){Object.keys(s).forEach(e=>{let t=e;B[t]&&s[t]&&Object.assign(B[t],s[t])}),console.log("Config applied:",s)}function co(s,e){let t=s/e;t>1.6?(Ct(Xe.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(Ct(Xe.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(Ct(Xe.square),console.log("Applied SQUARE config for ratio:",t)):(Ct(Xe.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let s=window;s.configPresets=Xe,s.resolveAnchorVec2=s.resolveAnchorVec2||He,s.resolveScreenAnchorPoint=s.resolveScreenAnchorPoint||Ne,s.resolveScreenRatioPoint=s.resolveScreenRatioPoint||Fe}var se=null;function po(s,e,t,i,n,a={}){var M,P,R,D,N,H,F,G,Y,Q,ie,oe,$,Z,le,ge,ce,be,Ce,Te,q,ee,K,ae,_e,Ge,da,pa,ua,ga,ha,ma,fa,ba;let r=(M=a.enableDebugLogs)!=null?M:!1;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:i.width,height:i.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",a));let{mainContainer:o,label:l,background:c,backgroundTexture:d,app:p}=s;if(!p||!p.renderer){r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:p.renderer.width,height:p.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:p.screen.width,height:p.screen.height}));let u=i.width,g=i.height;r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:u,baseHeight:g});let h=u*B.layout.screen_scale_x,m=g*B.layout.screen_scale_y,f=u/2,v=e.engine.runtime||{},b=v.layout||{};r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:B.layout.screen_scale_x,screen_scale_y:B.layout.screen_scale_y}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Calculated dimensions:",{width:h,height:m,midX:f}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",v),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",b));let w=b.design_width_portrait||400,y=h/w;y=Math.min(y,1.15);let x=y*((P=B.engine.scale)!=null?P:1),I=(R=a.skipMainContainerTransform)!=null?R:!1;!I&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(x):(o.scale.x=x,o.scale.y=x));let j=(D=b.main_container_anchor)!=null?D:"center",T=(N=b.main_container_position_ratio)!=null?N:{x:.5,y:.5},_=(H=b.main_container_offset)!=null?H:{x:0,y:0},O=b.main_container_position_ratio?Fe(u,g,T):Ne(u,g,j),L=O.x+_.x+B.layout.position_offset.x,A=O.y+_.y+B.layout.position_offset.y;if(!I&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(L,A):(o.position.x=L,o.position.y=A)),n&&(o!=null&&o.toLocal))for(let[re,ne]of e.objects.entries()){let V=ne==null?void 0:ne.transform;if(!V||((F=V.position_mode)!=null?F:"static")!=="static")continue;let U=(G=n.get)==null?void 0:G.call(n,re),ve=((Y=U==null?void 0:U.getDisplayObject)==null?void 0:Y.call(U))||(U==null?void 0:U.pixiObject)||U;if(!ve||ve.parent!==o)continue;let $t=V.position_ratio!=null?Fe(u,g,V.position_ratio):Ne(u,g,(Q=V.anchor)!=null?Q:"center"),Ht=o.toLocal(new qs($t.x,$t.y)),Nt=(ie=V.position)!=null?ie:{x:0,y:0},qe=Ht.x+Nt.x,Yi=Ht.y+Nt.y;typeof(U==null?void 0:U.setPosition)=="function"?U.setPosition(qe,Yi):(fe(ve,qe,Yi),(oe=U==null?void 0:U.transform)!=null&&oe.position&&(U.transform.position.x=qe,U.transform.position.y=Yi))}let k=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,E=((k==null?void 0:k.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(B.layout.debug_rect_visible&&E){(!se||se.parent!==p.stage)&&(se==null||se.destroy(),se=new Gs,se.zIndex=9999,p.stage.addChild(se)),se.clear();let re=B.layout.debug_rect_scale_x,ne=B.layout.debug_rect_scale_y,V=(u-4)*re,Oe=(g-4)*ne,U=(u-V)/2,ve=(g-Oe)/2;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:u,baseHeight:g,rectW:V,rectH:Oe,offsetX:U,offsetY:ve}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+U,y:2+ve,width:V,height:Oe})),se.rect(2+U,2+ve,V,Oe).stroke({width:B.layout.debug_rect_thickness,color:B.layout.debug_rect_color})}else se&&(se.destroy(),se=null);let S=(($=s.label)==null?void 0:$.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(l&&l.position&&S){let re=(le=(Z=S==null?void 0:S.transform)==null?void 0:Z.anchor)!=null?le:"center",ne=(ge=S==null?void 0:S.transform)==null?void 0:ge.position_ratio,V=((ce=S==null?void 0:S.transform)==null?void 0:ce.offset)||{x:0,y:0};Nn(l,u,g,{anchor:re,positionRatio:ne,offset:{x:V.x*x,y:V.y*x},renderAnchor:He(re)})}if(l&&l.alpha>0){let re=1+Math.sin(t*B.engine.label_pulse_speed)*B.engine.label_pulse_intensity,ne=(Ce=(be=S==null?void 0:S.transform)==null?void 0:be.scale)!=null?Ce:1,V=re*x*ne;l.scale&&(typeof l.scale.set=="function"?l.scale.set(V):(l.scale.x=V,l.scale.y=V))}if(r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),c){r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!c),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(Te=c.constructor)==null?void 0:Te.name)),c.alpha=((ee=(q=v.background)==null?void 0:q.alpha)!=null?ee:.98)*B.engine.background_alpha,r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",c.alpha);let re=e.objects.get("background_1");r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",re);let ne=(re==null?void 0:re.transform)||{};r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",ne);let V=ne.offset||{x:0,y:0},Oe=((ae=(K=v.background)==null?void 0:K.offset_y)!=null?ae:0)+B.engine.background_offset_y,U=(_e=ne.anchor)!=null?_e:"center",ve=ne.position_ratio;if(r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:V,bgRuntimeOffsetY:Oe,bgScreenAnchor:U,bgPositionRatio:ve,baseWidth:u,baseHeight:g,finalScale:x}),Nn(c,u,g,{anchor:U,positionRatio:ve,offset:{x:V.x*x,y:V.y*x+Oe},renderAnchor:He(U)}),r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:c.x,y:c.y,scaleX:(Ge=c.scale)==null?void 0:Ge.x,scaleY:(da=c.scale)==null?void 0:da.y,anchorX:(pa=c.anchor)==null?void 0:pa.x,anchorY:(ua=c.anchor)==null?void 0:ua.y,pivotX:(ga=c.pivot)==null?void 0:ga.x,pivotY:(ha=c.pivot)==null?void 0:ha.y,width:c.width,height:c.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background texture dimensions:",{textureWidth:d==null?void 0:d.width,textureHeight:d==null?void 0:d.height})),d){let $t=Math.max(h/d.width,m/d.height),Ht=(fa=(ma=v.background)==null?void 0:ma.scale_multiplier)!=null?fa:1.05,Nt=(ba=ne.scale)!=null?ba:1,qe=$t*Ht*B.engine.background_scale*Nt;c.scale&&(typeof c.scale.set=="function"?c.scale.set(qe):(c.scale.x=qe,c.scale.y=qe))}else c&&typeof c.clear=="function"&&(c.clear(),c.rect(-h/2,-m/2,h,m).fill({color:1444375}))}}var Di=class{constructor(e){this.app=null;this.camera=new Tt;this.mainContainer=new Tt;this.gizmoLayer=new Tt;this.screenFrame=new ot;this.objectMap=new Map;this.selectedId=null;this.dragMode=null;this.dragStartPointer=null;this.dragStartPos=null;this.dragStartScale=1;this.dragStartRotationDeg=0;this.dragStartAngle=0;this.dragStartDistance=1;this.dragAnchorLocal=null;this.dragStartValue=null;this.cameraScale=1;this.isPanning=!1;this.panStart=null;this.panStartCamera=null;this.hasUserCamera=!1;this.resizeObserver=null;this.gizmoOutline=new ot;this.moveHandle=new ot;this.scaleHandle=new ot;this.rotateHandle=new ot;this.isVisible=!0;this.applyQueued=!1;this.applyQueuedId=null;this.handleScreenChange=e=>{if(!(e!=null&&e.detail))return;let{width:t,height:i}=e.detail;!t||!i||(this.updateLayout({width:t,height:i}),this.updateGizmos(),this.syncFromConfig())};this.handleConfigChanged=e=>{if(!this.isVisible)return;this.updateLayout();let t=e==null?void 0:e.detail;if(!t){this.syncFromConfig();return}let i=t.objectId,n=t.objectIds;if(i){this.syncFromConfig([i]);return}if(Array.isArray(n)&&n.length>0){this.syncFromConfig(n);return}this.syncFromConfig()};this.handleSceneRefresh=()=>{this.isVisible&&this.syncFromConfig()};this.handlePreviewSelect=e=>{var i,n;let t=(n=(i=e==null?void 0:e.detail)==null?void 0:i.objectId)!=null?n:null;this.setSelected(t,{silent:!0})};this.onDragMove=e=>{if(!this.dragMode||!this.selectedId||!this.app)return;let t=this.objectMap.get(this.selectedId);if(!t)return;let i=this.getPointerInCamera(e.clientX,e.clientY);if(!(!i||!this.dragStartPointer||!this.dragStartPos)){if(this.dragMode==="move"){let n=i.x-this.dragStartPointer.x,a=i.y-this.dragStartPointer.y,r=this.dragStartPos.x+n,o=this.dragStartPos.y+a;t.displayObject.position.set(r,o),this.updateLiveConfigPosition(r,o)}else if(this.dragMode==="scale"){let n=new Se(this.dragStartPos.x,this.dragStartPos.y),a=Math.max(1,this.distance(i,n)),r=Math.max(.05,this.dragStartScale*(a/this.dragStartDistance));t.displayObject.scale.set(r),this.updateLiveConfigScale(r)}else if(this.dragMode==="rotate"){let n=new Se(this.dragStartPos.x,this.dragStartPos.y),r=Math.atan2(i.y-n.y,i.x-n.x)-this.dragStartAngle,o=this.dragStartRotationDeg+r*180/Math.PI;t.displayObject.rotation=o*Math.PI/180,this.updateLiveConfigRotation(o)}this.updateGizmos(),this.queueLiveApply(this.selectedId)}};this.onDragEnd=()=>{var i,n,a,r,o,l,c;if(!this.dragMode||!this.selectedId)return;let e=this.selectedId,t=this.getEditableObjectConfig(e);if(t){let d=(i=t.transform)!=null?i:{};if(t.transform||(t.transform=d),this.dragMode==="move"&&this.dragStartValue){let p=d.position,u=Array.isArray(p)?[Number((n=p[0])!=null?n:0),Number((a=p[1])!=null?a:0)]:{x:Number((r=p==null?void 0:p.x)!=null?r:0),y:Number((o=p==null?void 0:p.y)!=null?o:0)};this.applyFinalOverride(e,"transform.position",u,this.dragStartValue)}else this.dragMode==="scale"?this.applyFinalOverride(e,"transform.scale",(l=d.scale)!=null?l:1,this.dragStartValue):this.dragMode==="rotate"&&this.applyFinalOverride(e,"transform.rotation",(c=d.rotation)!=null?c:0,this.dragStartValue);this.queueLiveApply(e)}window.dispatchEvent(new CustomEvent("inspector:refresh")),this.dragMode=null,this.dragStartPointer=null,this.dragStartPos=null,this.dragAnchorLocal=null,this.dragStartValue=null,window.removeEventListener("pointermove",this.onDragMove),window.removeEventListener("pointerup",this.onDragEnd)};this.onWheel=e=>{if(!this.app||!this.isVisible)return;e.preventDefault();let i=Math.sign(e.deltaY)<0?1.1:.9,n=Math.min(6,Math.max(.1,this.cameraScale*i));this.cameraScale=n,this.camera.scale.set(n),this.hasUserCamera=!0,this.updateGizmos()};this.onPanStart=e=>{e.button===2&&(this.isPanning=!0,this.panStart={x:e.clientX,y:e.clientY},this.panStartCamera={x:this.camera.position.x,y:this.camera.position.y},this.hasUserCamera=!0)};this.onPanMove=e=>{if(!this.isPanning||!this.panStart||!this.panStartCamera)return;let t=e.clientX-this.panStart.x,i=e.clientY-this.panStart.y;this.camera.position.set(this.panStartCamera.x+t,this.panStartCamera.y+i)};this.onPanEnd=()=>{this.isPanning=!1,this.panStart=null,this.panStartCamera=null};this.root=e.root,this.getScreen=e.getScreen}async mount(){this.app||(this.app=new uo,await this.app.init({resizeTo:this.root,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0}),this.root.innerHTML="",this.root.appendChild(this.app.canvas),this.root.style.position="relative",this.root.style.overflow="hidden",this.app.stage.sortableChildren=!0,this.app.stage.eventMode="static",this.camera.sortableChildren=!0,this.mainContainer.sortableChildren=!0,this.gizmoLayer.sortableChildren=!0,this.app.stage.addChild(this.camera),this.camera.addChild(this.screenFrame),this.camera.addChild(this.mainContainer),this.camera.addChild(this.gizmoLayer),this.screenFrame.zIndex=-1,this.gizmoLayer.zIndex=1e5,this.gizmoLayer.addChild(this.gizmoOutline),this.gizmoLayer.addChild(this.moveHandle),this.gizmoLayer.addChild(this.scaleHandle),this.gizmoLayer.addChild(this.rotateHandle),this.setupInteractions(),this.setupObservers(),this.updateLayout(),this.refresh(),!this.isVisible&&this.app.ticker&&this.app.ticker.stop())}destroy(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),window.removeEventListener("handler-preview:screen",this.handleScreenChange),window.removeEventListener("config:changed",this.handleConfigChanged),window.removeEventListener("handler:scene-objects-refresh",this.handleSceneRefresh),window.removeEventListener("preview:select",this.handlePreviewSelect),this.app&&(this.app.destroy(!0),this.app=null)}setVisible(e){this.isVisible=e,!(!this.app||!this.app.ticker)&&(e?(this.app.ticker.start(),this.refresh()):this.app.ticker.stop())}refresh(){this.syncFromConfig()}setupObservers(){window.addEventListener("handler-preview:screen",this.handleScreenChange),window.addEventListener("config:changed",this.handleConfigChanged),window.addEventListener("handler:scene-objects-refresh",this.handleSceneRefresh),window.addEventListener("preview:select",this.handlePreviewSelect),this.resizeObserver=new ResizeObserver(()=>{this.handleResize()}),this.resizeObserver.observe(this.root)}setupInteractions(){if(!this.app)return;let e=this.app.canvas;e.addEventListener("contextmenu",t=>t.preventDefault()),e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("pointerdown",this.onPanStart),window.addEventListener("pointermove",this.onPanMove),window.addEventListener("pointerup",this.onPanEnd),this.moveHandle.eventMode="static",this.moveHandle.cursor="move",this.scaleHandle.eventMode="static",this.scaleHandle.cursor="nwse-resize",this.rotateHandle.eventMode="static",this.rotateHandle.cursor="crosshair",this.moveHandle.on("pointerdown",t=>this.startDrag("move",t)),this.scaleHandle.on("pointerdown",t=>this.startDrag("scale",t)),this.rotateHandle.on("pointerdown",t=>this.startDrag("rotate",t))}handleResize(){this.app&&(this.updateLayout(),this.hasUserCamera||this.centerCamera(),this.updateGizmos())}getEditableConfig(){return window.__editableConfig||null}getEditableObjectConfig(e){var n,a;let t=window.getEditableObjectConfig;if(typeof t=="function")return t(e);let i=this.getEditableConfig();return i!=null&&i.objects?typeof i.objects.get=="function"?(n=i.objects.get(e))!=null?n:null:(a=i.objects[e])!=null?a:null:null}getEditableObjectIds(){let e=window.getEditableObjectList;if(typeof e=="function"){let i=e();if(Array.isArray(i))return i}let t=this.getEditableConfig();return t!=null&&t.objects?typeof t.objects.keys=="function"?Array.from(t.objects.keys()):Object.keys(t.objects):[]}async syncFromConfig(e){if(!this.app)return;let t=this.getEditableConfig();if(!(t!=null&&t.objects))return;let i=e!=null&&e.length?e:this.getEditableObjectIds(),n=new Set(i);if(!e)for(let a of Array.from(this.objectMap.keys()))n.has(a)||this.removeObject(a);for(let a of i){let r=this.getEditableObjectConfig(a);if(!r){this.removeObject(a);continue}await this.upsertObject(a,r)}this.updateGizmos()}removeObject(e){var i,n;let t=this.objectMap.get(e);if(t){try{(n=(i=t.displayObject)==null?void 0:i.destroy)==null||n.call(i)}catch{}this.objectMap.delete(e),this.selectedId===e&&this.setSelected(null,{silent:!0})}}async upsertObject(e,t){let i=this.getAssetKey(t),n=this.objectMap.get(e);if(!n||n.assetKey!==i){n&&this.removeObject(e);let r=await this.createDisplayObject(e,t);if(!r)return;this.mainContainer.addChild(r),this.objectMap.set(e,{id:e,displayObject:r,assetKey:i}),this.attachObjectInteraction(r,e)}let a=this.objectMap.get(e);a&&(this.applyVisualConfig(a.displayObject,t),this.updateObjectTransform(a.displayObject,t))}async createDisplayObject(e,t){var i,n,a,r,o,l,c,d,p,u,g,h,m,f,v,b,w,y,x,I;if((i=t==null?void 0:t.render)!=null&&i.asset)try{if(((a=(n=t==null?void 0:t.render)==null?void 0:n.asset)==null?void 0:a.type)!=="json"){let T=await we.create(e,t,this.app);if(T instanceof Tt)return T}}catch(j){console.warn("[SceneEditor] ObjectFactory failed for",e,j)}if((r=t==null?void 0:t.ui)!=null&&r.text||((o=t==null?void 0:t.ui)==null?void 0:o.kind)==="text"){let j=(p=(d=(l=t==null?void 0:t.ui)==null?void 0:l.color)!=null?d:(c=t==null?void 0:t.render)==null?void 0:c.tint)!=null?p:"#ffffff",T=new mo({fontFamily:"Arial, sans-serif",fontSize:(g=(u=t==null?void 0:t.ui)==null?void 0:u.fontSize)!=null?g:16,fill:j,align:(m=(h=t==null?void 0:t.ui)==null?void 0:h.align)!=null?m:"center",letterSpacing:(v=(f=t==null?void 0:t.ui)==null?void 0:f.letterSpacing)!=null?v:0});return new ho({text:(w=(b=t==null?void 0:t.ui)==null?void 0:b.text)!=null?w:"",style:T})}if((y=t==null?void 0:t.effects)!=null&&y.width||(x=t==null?void 0:t.effects)!=null&&x.height){let j=new ot,T=typeof t.effects.width=="number"?t.effects.width:100,_=typeof t.effects.height=="number"?t.effects.height:100,O=(I=t.effects.fill_color)!=null?I:"#ffffff",L=typeof t.effects.fill_alpha=="number"?t.effects.fill_alpha:1,A=Number.parseInt(String(O).replace("#",""),16);return j.rect(0,0,T,_).fill({color:Number.isFinite(A)?A:16777215,alpha:L}),j}return new Tt}attachObjectInteraction(e,t){if(e){if(e.eventMode="static",e.cursor="pointer",!e.hitArea&&typeof e.getLocalBounds=="function"){let i=e.getLocalBounds();i&&i.width>0&&i.height>0&&(e.hitArea=i)}e.on("pointerdown",i=>{var a,r,o;((o=(r=(a=i==null?void 0:i.data)==null?void 0:a.originalEvent)==null?void 0:r.button)!=null?o:0)===0&&(this.setSelected(t),this.startDrag("move",i))})}}getAssetKey(e){var i;let t=(i=e==null?void 0:e.render)==null?void 0:i.asset;return t?`${t.type||"asset"}::${t.path||""}`:null}applyVisualConfig(e,t){var r,o,l,c,d,p,u;if(!e)return;let i=(r=t==null?void 0:t.render)!=null?r:{};typeof i.alpha=="number"&&(e.alpha=i.alpha),e.visible=i.visible!==!1,e.zIndex=typeof i.z_index=="number"?i.z_index:0;let n=(d=(c=(o=t==null?void 0:t.render)==null?void 0:o.anchor)!=null?c:(l=t==null?void 0:t.transform)==null?void 0:l.anchor)!=null?d:"center",a=He(n,{x:.5,y:.5});if((p=e.anchor)!=null&&p.set)e.anchor.set(a.x,a.y);else if(e.pivot){let g=(u=e.getLocalBounds)==null?void 0:u.call(e);g&&e.pivot.set(g.width*a.x,g.height*a.y)}}updateObjectTransform(e,t){var l;if(!e)return;let i=(l=t==null?void 0:t.transform)!=null?l:{},n=this.getAnchorLocalPoint(i),a=this.getPositionOffset(i);n&&e.position.set(n.x+a.x,n.y+a.y);let r=typeof i.scale=="number"?i.scale:void 0;typeof r=="number"&&e.scale&&e.scale.set(r);let o=typeof i.rotation=="number"?i.rotation:0;typeof e.rotation=="number"&&(e.rotation=o*Math.PI/180)}getAnchorLocalPoint(e){var a;let t=this.getScreen();if(!(t!=null&&t.width)||!(t!=null&&t.height))return null;let i=(e==null?void 0:e.position_ratio)!=null?Fe(t.width,t.height,e.position_ratio):Ne(t.width,t.height,(a=e==null?void 0:e.anchor)!=null?a:"center"),n=new Se;return this.mainContainer.toLocal(new Se(i.x,i.y),void 0,n),n}getPositionOffset(e){var l,c,d,p,u,g,h,m;let t=e==null?void 0:e.position,i=e==null?void 0:e.offset,n=Array.isArray(t)?Number((l=t[0])!=null?l:0):Number((c=t==null?void 0:t.x)!=null?c:0),a=Array.isArray(t)?Number((d=t[1])!=null?d:0):Number((p=t==null?void 0:t.y)!=null?p:0),r=Array.isArray(i)?Number((u=i[0])!=null?u:0):Number((g=i==null?void 0:i.x)!=null?g:0),o=Array.isArray(i)?Number((h=i[1])!=null?h:0):Number((m=i==null?void 0:i.y)!=null?m:0);return{x:n+r,y:a+o}}updateLayout(e){var m,f,v,b,w,y,x,I;let t=e!=null?e:this.getScreen();if(!(t!=null&&t.width)||!(t!=null&&t.height))return;let n=(((f=(m=this.getEditableConfig())==null?void 0:m.engine)==null?void 0:f.runtime)||{}).layout||{},a=t.width*((v=B.layout.screen_scale_x)!=null?v:1),r=n.design_width_portrait||400,o=a/r;o=Math.min(o,1.15);let l=o*((b=B.engine.scale)!=null?b:1);this.mainContainer.scale.set(l);let c=(w=n.main_container_anchor)!=null?w:"center",d=(y=n.main_container_position_ratio)!=null?y:{x:.5,y:.5},p=(x=n.main_container_offset)!=null?x:{x:0,y:0},u=n.main_container_position_ratio?Fe(t.width,t.height,d):Ne(t.width,t.height,c),g=u.x+p.x+B.layout.position_offset.x,h=u.y+p.y+B.layout.position_offset.y;this.mainContainer.position.set(g,h),this.screenFrame.clear(),this.screenFrame.rect(0,0,t.width,t.height),this.screenFrame.stroke({width:2,color:2894892,alpha:.5}),(I=this.app)!=null&&I.stage&&(this.app.stage.hitArea=new go(0,0,t.width,t.height)),this.hasUserCamera||this.centerCamera()}centerCamera(){if(!this.app)return;let e=this.getScreen(),t=this.app.renderer.width,i=this.app.renderer.height;this.cameraScale=1,this.camera.scale.set(this.cameraScale),this.camera.position.set((t-e.width)/2,(i-e.height)/2)}updateGizmos(){var d,p;if(!this.selectedId||!this.isVisible){this.clearGizmos();return}let e=this.objectMap.get(this.selectedId);if(!(e!=null&&e.displayObject)){this.clearGizmos();return}let t=(p=(d=e.displayObject).getBounds)==null?void 0:p.call(d);if(!t||t.width<=0||t.height<=0){this.clearGizmos();return}let i=this.camera.toLocal(new Se(t.x,t.y)),n=this.camera.toLocal(new Se(t.x+t.width,t.y+t.height)),a=n.x-i.x,r=n.y-i.y,o=i.x+a/2,l=i.y+r/2;this.gizmoOutline.clear(),this.gizmoOutline.rect(i.x,i.y,a,r),this.gizmoOutline.stroke({width:2,color:16752394,alpha:.9});let c=10;this.moveHandle.clear(),this.moveHandle.circle(0,0,c/2),this.moveHandle.fill({color:16752394,alpha:.9}),this.moveHandle.position.set(o,l),this.scaleHandle.clear(),this.scaleHandle.rect(-c/2,-c/2,c,c),this.scaleHandle.fill({color:3900150,alpha:.9}),this.scaleHandle.position.set(n.x,n.y),this.rotateHandle.clear(),this.rotateHandle.circle(0,0,c/2),this.rotateHandle.fill({color:1096065,alpha:.9}),this.rotateHandle.position.set(o,i.y-20)}clearGizmos(){this.gizmoOutline.clear(),this.moveHandle.clear(),this.scaleHandle.clear(),this.rotateHandle.clear()}setSelected(e,t={}){if(this.selectedId!==e&&(this.selectedId=e,this.updateGizmos(),!t.silent&&e)){let i=window.__previewSelectObject;typeof i=="function"&&i(e)}}startDrag(e,t){var d,p,u,g,h;if(!this.selectedId||!e||!this.app||((u=(p=(d=t==null?void 0:t.data)==null?void 0:d.originalEvent)==null?void 0:p.button)!=null?u:0)!==0)return;let n=this.objectMap.get(this.selectedId);if(!n)return;let a=this.camera.toLocal(t.data.global),r=n.displayObject;this.dragMode=e,this.dragStartPointer=a.clone(),this.dragStartPos=new Se(r.position.x,r.position.y),this.dragStartScale=typeof((g=r.scale)==null?void 0:g.x)=="number"?r.scale.x:1;let o=this.getEditableObjectConfig(this.selectedId),l=(h=o==null?void 0:o.transform)!=null?h:{};this.dragStartRotationDeg=typeof l.rotation=="number"?l.rotation:0,this.dragAnchorLocal=this.getAnchorLocalPoint(l),this.dragStartValue=this.getDragStartValue(e,l);let c=new Se(r.position.x,r.position.y);this.dragStartAngle=Math.atan2(a.y-c.y,a.x-c.x),this.dragStartDistance=Math.max(1,this.distance(a,c)),window.addEventListener("pointermove",this.onDragMove),window.addEventListener("pointerup",this.onDragEnd)}getDragStartValue(e,t){var i,n,a;return e==="move"?(i=t==null?void 0:t.position)!=null?i:{x:0,y:0}:e==="scale"?(n=t==null?void 0:t.scale)!=null?n:1:e==="rotate"?(a=t==null?void 0:t.rotation)!=null?a:0:null}updateLiveConfigPosition(e,t){var p,u,g,h,m,f;if(!this.selectedId||!this.dragAnchorLocal)return;let i=e-this.dragAnchorLocal.x,n=t-this.dragAnchorLocal.y,a=this.getEditableObjectConfig(this.selectedId);if(!a)return;let r=(p=a.transform)!=null?p:{};a.transform||(a.transform=r);let o=(u=r.offset)!=null?u:{x:0,y:0},l=Array.isArray(o)?Number((g=o[0])!=null?g:0):Number((h=o==null?void 0:o.x)!=null?h:0),c=Array.isArray(o)?Number((m=o[1])!=null?m:0):Number((f=o==null?void 0:o.y)!=null?f:0),d=this.buildPositionValue(r,{x:i-l,y:n-c});this.setNestedValue(r,"position",d)}updateLiveConfigScale(e){var n;if(!this.selectedId)return;let t=this.getEditableObjectConfig(this.selectedId);if(!t)return;let i=(n=t.transform)!=null?n:{};t.transform||(t.transform=i),i.scale=e}updateLiveConfigRotation(e){var n;if(!this.selectedId)return;let t=this.getEditableObjectConfig(this.selectedId);if(!t)return;let i=(n=t.transform)!=null?n:{};t.transform||(t.transform=i),i.rotation=e}applyFinalOverride(e,t,i,n){let a=this.getEditableObjectConfig(e);a!=null&&a.transform&&this.setNestedValue(a.transform,t.replace("transform.",""),n),Ve({objectId:e,path:t,value:i},{persist:!0,emitEvent:!0,trackHistory:!0})}queueLiveApply(e){this.applyQueuedId=e,!this.applyQueued&&(this.applyQueued=!0,requestAnimationFrame(()=>{this.applyQueued=!1;let t=this.applyQueuedId;if(!t)return;let i=this.getEditableObjectConfig(t),n=window.applyEditableObjectConfig;typeof n=="function"&&i&&n(t,i)}))}setNestedValue(e,t,i){let n=t.split("."),a=e;for(let r=0;r<n.length-1;r+=1){let o=n[r];(!a[o]||typeof a[o]!="object")&&(a[o]={}),a=a[o]}a[n[n.length-1]]=i}buildPositionValue(e,t){let i=e==null?void 0:e.position;return Array.isArray(i)?[t.x,t.y]:{x:t.x,y:t.y}}distance(e,t){let i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)}getPointerInCamera(e,t){if(!this.app)return null;let i=this.app.canvas.getBoundingClientRect(),n=(e-i.left)*(this.app.renderer.width/i.width),a=(t-i.top)*(this.app.renderer.height/i.height),r=new Se;return this.camera.toLocal(new Se(n,a),void 0,r),r}};var Fn=class{constructor(e={}){this.isLandscape=!1;this.autoScale=1;this.userScaleMultiplier=1;this.viewMode="single";this.layoutMode="fixed";this.comparePresets=[it("playable-portrait"),it("iphone-14"),it("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.sceneEditor=null;this.sceneVisiblePreference=!0;this.sceneVisible=!0;this.hasInitialFit=!1;this.isMounted=!1;this.isInitialized=!1;this.gameReady=!1;this.resizeListenersDisabled=!1;this.compareSnapshotTimer=null;this.hasUnsavedChanges=!1;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=it(e.defaultDevice||on.id),this.debugPanel=new Pi,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.scenePane=this.mustQuery("[data-scene-pane]"),this.sceneRoot=this.mustQuery("#scene-editor-root"),this.sceneSplitter=this.mustQuery("[data-scene-splitter]"),this.gameViewPane=this.mustQuery("[data-game-pane]"),this.lastSinglePresetId=this.currentPreset.id,this.consolePanel=this.container.querySelector(".console-panel"),this.debugPanel.initialize(this.container),this.debugPanel.setupDebugEventListeners();try{let t=window.localStorage.getItem(this.getSceneVisibilityStorageKey());this.sceneVisiblePreference=t===null?!0:t==="true"}catch{}this.sceneEditor=new Di({root:this.sceneRoot,getScreen:()=>this.getScreen()}),this.sceneEditor.mount(),this.applyDeviceFrameStyles(),this.setupCompareViewports(),this.setupConsoleInterceptor(),this.setupObserversAndListeners(),this.setupFrameDragging(),this.setupSpaceKeyListener(),this.setupShortcutListeners(),this.setupUnsavedChangesIndicator(),this.setupScenePaneInteractions(),this.updateSceneVisibility(),this.setDevice(this.currentPreset.id,{suppressCallback:!0}),this.updateDockState(),this.isInitialized=!0}getShortcutKey(){return typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0?"CMD":"CTRL"}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,this.sceneEditor&&(this.sceneEditor.destroy(),this.sceneEditor=null)}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(){var e;this.gameReady=!0,this.enableResizeListeners(),this.scheduleFit(),this.debugPanel.refresh(),(e=this.sceneEditor)==null||e.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,a;let i=this.autoScale*this.userScaleMultiplier;this.isLandscape=!1,this.currentPreset=it(e),this.viewMode==="single"&&(this.lastSinglePresetId=this.currentPreset.id),this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale:i}),t.suppressCallback||(a=(n=this.options).onDeviceChange)==null||a.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(),this.updateSceneVisibility(),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,a=o=>{let l=o.clientY-i,c=Math.max(100,Math.min(800,n-l));e.style.height=`${c}px`;let d=this.autoScale*this.userScaleMultiplier;this.fitToScreen({keepVisibleScale:d})},r=()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",r),e.classList.remove("resizing")};t.addEventListener("pointerdown",o=>{o.preventDefault(),i=o.clientY,n=e.offsetHeight,document.addEventListener("pointermove",a),document.addEventListener("pointerup",r),e.classList.add("resizing")})}makeSidebarResizable(e,t,i){let n,a,r=l=>{let c=i==="left"?l.clientX-n:n-l.clientX,d=Math.max(200,Math.min(600,a+c));e.style.width=`${d}px`;let p=this.container.querySelector(".preview-main");if(p){let g=i==="left"?`${d}px`:p.style.gridTemplateColumns.split(" ")[0]||"300px",h=i==="right"?`${d}px`:p.style.gridTemplateColumns.split(" ")[2]||"350px";p.style.gridTemplateColumns=`${g} 1fr ${h}`}let u=this.autoScale*this.userScaleMultiplier;this.fitToScreen({keepVisibleScale:u})},o=()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",o),e.classList.remove("resizing")};t.addEventListener("pointerdown",l=>{l.preventDefault(),n=l.clientX,a=e.offsetWidth,document.addEventListener("pointermove",r),document.addEventListener("pointerup",o),e.classList.add("resizing")})}getSceneVisibilityStorageKey(){return`handler_preview_scene_visible::${typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default"}`}getSceneWidthStorageKey(){return`handler_preview_scene_width::${typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default"}`}setupScenePaneInteractions(){let e=this.scenePane.querySelector("[data-scene-drag-handle]"),t=this.scenePane.querySelector("[data-scene-resize]"),i=this.container.querySelector("[data-preview-split]");e&&Ye(this.scenePane,e,i!=null?i:this.previewContainer),t&&Ti(this.scenePane,t,void 0,260,200);let n=this.getStoredSceneWidth();n&&(this.scenePane.style.width=`${n}px`),this.sceneSplitter.addEventListener("pointerdown",a=>{if(this.layoutMode!=="fixed"||!this.sceneVisible)return;a.preventDefault();let r=a.clientX,o=this.scenePane.offsetWidth,l=Math.max(260,Math.min(720,this.previewContainer.clientWidth*.6)),c=p=>{let u=p.clientX-r,g=Math.max(240,Math.min(l,o+u));this.scenePane.style.width=`${g}px`;let h=this.autoScale*this.userScaleMultiplier;this.fitToScreen({keepVisibleScale:h})},d=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",d),this.storeSceneWidth(this.scenePane.offsetWidth)};document.addEventListener("pointermove",c),document.addEventListener("pointerup",d)})}storeSceneWidth(e){try{window.localStorage.setItem(this.getSceneWidthStorageKey(),String(e))}catch{}}getStoredSceneWidth(){try{let e=window.localStorage.getItem(this.getSceneWidthStorageKey()),t=e?Number(e):null;return Number.isFinite(t)&&t?t:null}catch{return null}}updateSceneVisibility(){let e=this.viewMode==="single"&&this.sceneVisiblePreference;this.setSceneVisible(e,{persist:!1});let t=this.container.querySelector("#scene-toggle");t&&(t.classList.toggle("active",this.sceneVisiblePreference),t.setAttribute("aria-pressed",String(this.sceneVisiblePreference)))}setSceneVisible(e,t={}){var i;if(this.sceneVisible=e,this.container.classList.toggle("scene-hidden",!e),(i=this.sceneEditor)==null||i.setVisible(e),t.persist!==!1){this.sceneVisiblePreference=e;try{window.localStorage.setItem(this.getSceneVisibilityStorageKey(),String(e))}catch{}}this.scheduleFit()}createShell(){var t;let e=document.createElement("div");return e.className="preview-shell layout-fixed",e.innerHTML=`
|
|
2192
2192
|
<div class="preview-toolbar">
|
|
2193
2193
|
<div class="preview-toolbar-left">
|
|
2194
2194
|
<span class="preview-logo">PREVIEWER</span>
|