handler-playable-sdk 1.0.103 → 1.0.104

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.
Files changed (42) hide show
  1. package/dist/chunk-FL4VTM6W.js +1 -0
  2. package/dist/{chunk-NOMTJOWU.js → chunk-M4ULXPTP.js} +2 -2
  3. package/dist/cli/brand-dna.mjs +1 -1
  4. package/dist/cli/canva-import.mjs +1 -1
  5. package/dist/cli/cleanup-assets.mjs +1 -1
  6. package/dist/cli/fix-scales.mjs +1 -1
  7. package/dist/cli/index.js +1 -1
  8. package/dist/cli/screen-helper.mjs +1 -1
  9. package/dist/cli/setup-library.mjs +1 -1
  10. package/dist/cli/student-helper/add-logic.mjs +1 -1
  11. package/dist/cli/student-helper/add-object.mjs +1 -1
  12. package/dist/cli/student-helper/arg-parsing.mjs +1 -1
  13. package/dist/cli/student-helper/asset-registry.mjs +1 -1
  14. package/dist/cli/student-helper/bullet-system.mjs +1 -1
  15. package/dist/cli/student-helper/collectable-system.mjs +1 -1
  16. package/dist/cli/student-helper/constants.mjs +1 -1
  17. package/dist/cli/student-helper/drag-snap-couples.mjs +1 -1
  18. package/dist/cli/student-helper/endgame-screen.mjs +1 -1
  19. package/dist/cli/student-helper/fs-io.mjs +1 -1
  20. package/dist/cli/student-helper/logic-defaults.mjs +1 -1
  21. package/dist/cli/student-helper/print-help.mjs +1 -1
  22. package/dist/cli/student-helper/prompts.mjs +1 -1
  23. package/dist/cli/student-helper/scratch-card.mjs +1 -1
  24. package/dist/cli/student-helper/screen-utils.mjs +1 -1
  25. package/dist/cli/student-helper/snippets.mjs +1 -1
  26. package/dist/cli/student-helper/start-screen.mjs +1 -1
  27. package/dist/cli/student-helper/swerve-collect.mjs +1 -1
  28. package/dist/cli/student-helper/tap-destroy.mjs +1 -1
  29. package/dist/cli/student-helper/template-packs.mjs +1 -1
  30. package/dist/cli/student-helper.mjs +1 -1
  31. package/dist/cli/sync-screens.mjs +1 -1
  32. package/dist/cli/validate-assets.mjs +1 -1
  33. package/dist/cli/validate.mjs +1 -1
  34. package/dist/{config-HQX4AQNX.js → config-VHVTBJGB.js} +1 -1
  35. package/dist/index.cjs +34 -34
  36. package/dist/index.js +1 -1
  37. package/dist/pixi/index.cjs +1 -1
  38. package/dist/pixi/index.js +1 -1
  39. package/dist/three/index.cjs +1 -1
  40. package/dist/three/index.js +1 -1
  41. package/package.json +1 -1
  42. package/dist/chunk-FOTLNUIS.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as X,d as Q,h as Y}from"./chunk-2MR65LDX.js";var Z=null,u="dev";if(typeof window!="undefined"){let n=window.__BUILD_SETTINGS__;if(n!=null&&n.buildMode)Z=n,u=n.buildMode,console.log("[CONFIG] Loaded inline build settings:",n,"buildMode:",u);else try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);Z=t,u=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",u)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",u)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",u);var q=new Map,J=u==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload");function ie(n,e){try{if(typeof n=="object"&&n!==null)return n;if(typeof n!="string")return null;if(n.startsWith("data:")){let o=n.indexOf(",");if(o===-1)return null;let s=n.slice(0,o);if(!s.includes("application/json")&&!s.includes("text/plain"))return null;let a=n.slice(o+1),i=s.includes("base64")?typeof atob=="function"?atob(a):a:decodeURIComponent(a);return JSON.parse(i)}let t=n.trim();return t.startsWith("{")||t.startsWith("[")?JSON.parse(n):null}catch{return null}}function ae(n){if(typeof window=="undefined"||!window.INLINE_ASSETS)return null;let e=window.INLINE_ASSETS,t=n.replace(/^\.\/+/,""),o=t.split("/").pop()||t,s=[t,o,t.replace(/\.json$/,""),o.replace(/\.json$/,"")];for(let a of s){let i=e[a];if(i){let l=ie(i,a);if(l!==null)return l}}return null}async function D(n){if(q.has(n)&&!J)return console.log(`[CONFIG] Using cached config for: "${n}"`),q.get(n);if(console.log(`[CONFIG] loadConfigFile called with: "${n}", MODE: ${u.toUpperCase()}, CACHE: ${J?"DISABLED":"ENABLED"}`),u==="publish"){let o=ae(n);return o?(console.log(`[CONFIG] \u2713 Loaded ${n} via INLINE_ASSETS`),o):(console.log(`[CONFIG] \u2139\uFE0F Optional config ${n} not in INLINE_ASSETS, skipping fetch in publish mode`),{})}u==="brand"||console.log(`[CONFIG] DEV MODE: Trying nested paths first, then flattened for "${n}"`);let e;u==="brand"?e=[`./${n.split("/").pop()||n}`,`./${n}`,`./${n.replace(/^configs\//,"")}`,`./${n.replace(/^configs\//,"").replace(/\//g,".")}`]:e=[`./${n}`,`./${n.replace(/^configs\//,"")}`,`./${n.replace(/^configs\//,"").replace(/\//g,".")}`],e=Array.from(new Set(e.flatMap(o=>o.startsWith("./")?[o,`/${o.slice(2)}`]:o.startsWith("/")?[o]:[o,`/${o}`]))),console.log("[CONFIG] Will try candidates:",e);let t=(async()=>{let o=J?"no-store":"force-cache";for(let s of e)try{let a=await fetch(s,{cache:o});if(!a.ok)continue;let i=await a.json();return console.log(`[CONFIG] \u2713 Loaded ${n} via ${s}`,i),i}catch(a){console.warn(`[CONFIG] \u2717 Failed to load ${s} (mode: ${u}):`,a)}return console.warn(`[CONFIG] \u2717 All attempts failed for ${n}; using defaults`),{}})();return q.set(n,t),t}async function ne(){console.log("[CONFIG] Loading component schemas...");let n=["components/identity.schema.json","components/transform.schema.json","components/render.schema.json","components/motion.schema.json","components/effects.schema.json","components/interaction.schema.json","components/gameplay.rules.schema.json","components/gameplay.tuning.schema.json","components/visibility.schema.json","components/audio.schema.json","components/physics.schema.json","components/ui.schema.json"],e=new Map;for(let t of n)try{let o=u==="publish"||u==="brand"?t.split("/").pop()||t:`configs/${t}`,s=await D(o);s.component&&(e.set(s.component,s),console.log(`[CONFIG] \u2713 Schema loaded: ${s.component} ${u==="publish"||u==="brand"?"(flattened)":"(nested)"}`))}catch(o){console.warn(`[CONFIG] \u2717 Failed to load schema ${t}:`,o)}return console.log(`[CONFIG] Loaded ${e.size} component schemas`),e}async function M(n){console.log(`[CONFIG] Loading object config: ${n}`);let e=u==="publish"||u==="brand"?`${n}.json`:`configs/objects/${n}.json`;return await D(e)}async function te(n){let e=new Map;if(n.objects&&Array.isArray(n.objects)){for(let t of n.objects)if(t.enabled&&t.object_config)try{let o=t.instance_id;/^(json\.|ui\.|effects\.|engine\.)/.test(o)||(o=`json.${o}`);let s=await M(o);(!s||Object.keys(s).length===0)&&o!==t.instance_id&&(s=await M(t.instance_id)),!s||Object.keys(s).length===0?(console.log(`[CONFIG] No instance snapshot for ${t.instance_id}, using template ${t.object_config}`),s=await M(t.object_config)):console.log(`[CONFIG] \u2713 Loaded instance snapshot for ${t.instance_id}`),e.set(t.instance_id,{...s,instance_id:t.instance_id,object_config:t.object_config})}catch(o){console.warn(`Failed to load object ${t.object_config}:`,o)}}return e}async function oe(){console.log("[CONFIG] Loading engine configs...");let n=["runtime","assets","splash","loading","start","tutorial","endgame"],e=await Promise.all(n.map(o=>{let s=`engine.${o}.json`,a=u==="publish"||u==="brand"?s:`configs/engine/${s}`;return D(a)})),t=Object.fromEntries(n.map((o,s)=>[o,e[s]]));return console.log("[CONFIG] Engine configs loaded:",Object.fromEntries(n.map(o=>{var i;let s=(i=t[o])!=null?i:{},a=Object.keys(s);return[o,a.length>0?a:"empty"]}))),t}async function re(){return await D(u==="publish"||u==="brand"?"game.prompt.json":"configs/engine/game.prompt.json")}async function se(n="scene.main"){console.log(`[CONFIG] Loading scene config: ${n}`);let e=u==="publish"||u==="brand"?`${n}.json`:`configs/scenes/${n}.json`;return await D(e)}function B(n,e){let t=[];if(!n.identity)return t.push("Missing required identity component"),{valid:!1,errors:t};let o=e.get("identity");if(o)for(let s of o.required||[])n.identity[s]||t.push(`Missing required identity field: ${s}`);for(let[s,a]of Object.entries(n)){if(s==="identity")continue;let i=e.get(s);if(i&&a&&typeof a=="object"){let l=a;for(let f of i.required||[])l[f]===void 0&&t.push(`Missing required field in ${s}: ${f}`);if(i.constraints&&typeof i.constraints=="object")for(let[f,h]of Object.entries(i.constraints)){let C=l[f];if(C!==void 0&&h&&typeof h=="object"){let O=h;typeof C=="number"&&(O.min!==void 0&&C<O.min&&t.push(`${s}.${f} value ${C} is below minimum ${O.min}`),O.max!==void 0&&C>O.max&&t.push(`${s}.${f} value ${C} is above maximum ${O.max}`))}}}}return{valid:t.length===0,errors:t}}function z(n,e){let t={...n},o=["identity","transform","render"];for(let[s,a]of e.entries())a.defaults&&Object.keys(a.defaults).length>0&&(o.includes(s)||t[s])&&(t[s]||(t[s]={}),t[s]={...a.defaults,...t[s]});return t}function w(n,e,t,o){return typeof n!="number"||!Number.isFinite(n)?e:Math.min(Math.max(n,t),o)}function ee(n,e){if(Array.isArray(n))return{x:w(n[0],e.x,-2e3,2e3),y:w(n[1],e.y,-2e3,2e3)};if(!n||typeof n!="object")return e;let{x:t,y:o}=n;return{x:w(t,e.x,-2e3,2e3),y:w(o,e.y,-2e3,2e3)}}function ce(n,e){if(Array.isArray(n))return{x:w(n[0],e.x,0,1),y:w(n[1],e.y,0,1)};if(!n||typeof n!="object")return e;let{x:t,y:o}=n;return{x:w(t,e.x,0,1),y:w(o,e.y,0,1)}}function le(n){if(Array.isArray(n))return{x:w(n[0],.5,-10,10),y:w(n[1],.5,-10,10)};if(n&&typeof n=="object"){let{x:e,y:t}=n;return{x:w(e,.5,-10,10),y:w(t,.5,-10,10)}}return typeof n=="string"?n:null}async function U(n="scene.main",e){var h,C,O,E,x,p,d,b,v,N,j,A,k,P,L,H,R,T;console.log("[CONFIG] ===== Starting Object-Centric Config Load =====");let t=await ne(),o=Y(),s=X();console.log(`[CONFIG] Loader: Found ${o.length} persisted overrides, override mode: ${s}`),o.length>0&&console.log("[CONFIG] Override details:",o.map(y=>({objectId:y.objectId,path:y.path,value:typeof y.value=="string"?y.value.substring(0,50):y.value})));let a=await se(n);console.log(`[CONFIG] Scene config loaded: ${((h=a.objects)==null?void 0:h.length)||0} objects`);let i=await oe();console.log("[CONFIG] Loading object configs...");let l=await te(a);console.log(`[CONFIG] Loaded ${l.size} object configs:`,Array.from(l.keys()));for(let[y,I]of l.entries()){let g=z(I,t),$=B(g,t);$.valid||console.warn(`Object ${y} validation errors:`,$.errors),(C=g.transform)!=null&&C.position&&(g.transform.position=ee(g.transform.position,{x:0,y:0})),(O=g.transform)!=null&&O.offset&&(g.transform.offset=ee(g.transform.offset,{x:0,y:0})),((E=g.transform)==null?void 0:E.anchor)!==void 0&&(g.transform.anchor=le(g.transform.anchor)),((x=g.transform)==null?void 0:x.position_ratio)!==void 0&&g.transform.position_ratio!==null&&(g.transform.position_ratio=ce(g.transform.position_ratio,{x:.5,y:.5})),l.set(y,g)}if(e){if(e.objects)for(let[y,I]of e.objects.entries())l.set(y,I);e.engine&&(i.runtime={...i.runtime,...e.engine.runtime},i.assets={...i.assets,...e.engine.assets},i.splash={...(p=i.splash)!=null?p:{},...(d=e.engine.splash)!=null?d:{}})}let f={objects:l,engine:i,scene:a,schemas:t,theme:{background_color:"#ffffff",text_color:"#000000",square_color:"#cccccc",cta_background:"#007bff",cta_text:"#ffffff"},gameplay:{}};if(typeof window!="undefined"&&(window.__editableConfig=f,window.__editableConfigBaseline||(window.__editableConfigBaseline=z(f,t))),o.length>0&&s){console.log(`[CONFIG] \u2705 Applying ${o.length} persisted overrides on startup`);let y=[],I=new Set;for(let r of o){if(!r.objectId){y.push(r);continue}l.has(r.objectId)?y.push(r):I.add(r.objectId)}if(I.size>0){let r=o.length-y.length;if(console.warn(`[CONFIG] \u26A0\uFE0F Found ${r} override(s) for deleted objects: ${Array.from(I).join(", ")}. These will be removed from localStorage.`),typeof window!="undefined"){window.__configOverrides=y;try{let S=`handler_preview_config_overrides::${window.__HANDLER_PROJECT_ID||"handler-default"}`;window.localStorage.setItem(S,JSON.stringify(y))}catch(m){console.warn("[CONFIG] Failed to clean up invalid overrides from localStorage:",m)}}}let g=y,$=new Map;for(let r of g)if(r.path==="render.asset.path"&&r.objectId){let m=r.value;$.has(m)||$.set(m,[]),$.get(m).push(r.objectId)}for(let[r,m]of $.entries())m.length>1&&console.log(`[CONFIG] \u{1F4CB} Multiple objects sharing asset on startup: "${r}" used by: ${m.join(", ")}`);let F=new Map;for(let r of g){let m=r.objectId||"__engine__";F.has(m)||F.set(m,[]),F.get(m).push(r)}console.log("[CONFIG] Override distribution:",{totalOverrides:g.length,objectsWithOverrides:Array.from(F.keys()),overridesPerObject:Array.from(F.entries()).map(([r,m])=>({objectId:r,count:m.length,paths:m.map(S=>S.path)}))}),Q(g,{silent:!1,persist:!1});let G=window.__editableConfig;if(G){for(let r of g.slice(0,5))if(r.objectId){let m=((v=(b=G.objects)==null?void 0:b.get)==null?void 0:v.call(b,r.objectId))||((N=G.objects)==null?void 0:N[r.objectId]);if(m){let S=r.path.split(".").reduce((c,_)=>c==null?void 0:c[_],m);S===r.value?console.log(`[CONFIG] \u2705 Verified override applied: ${r.objectId}.${r.path} = ${typeof r.value=="string"?r.value.substring(0,40):"\u2713"}`):console.error(`[CONFIG] \u274C Override NOT applied correctly: ${r.objectId}.${r.path}. Expected: ${r.value}, Got: ${S}`)}else console.warn(`[CONFIG] \u26A0\uFE0F Object not found after override application: ${r.objectId} (this should have been filtered out)`)}}console.log("[CONFIG] \u2705 Overrides applied. Current config state:",{objectCount:((j=f.objects)==null?void 0:j.size)||0,sampleOverrides:g.slice(0,3).map(r=>`${r.objectId||"engine"}.${r.path} = ${typeof r.value=="string"?r.value.substring(0,30):JSON.stringify(r.value).substring(0,30)}`)})}else o.length>0&&!s?console.warn(`[CONFIG] \u26A0\uFE0F Found ${o.length} persisted overrides but override mode is DISABLED. Overrides will NOT be applied.`):o.length===0&&console.log("[CONFIG] No persisted overrides found in localStorage");return console.log("[CONFIG] ===== Object-Centric Config Load Complete ====="),console.log("[CONFIG] Summary:",{schemas:Array.from(t.keys()),objects:Array.from(l.keys()),engine:{runtime:Object.keys((A=i.runtime)!=null?A:{}),assets:Object.keys((k=i.assets)!=null?k:{}),splash:Object.keys((P=i.splash)!=null?P:{}),loading:Object.keys((L=i.loading)!=null?L:{}),start:Object.keys((H=i.start)!=null?H:{}),tutorial:Object.keys((R=i.tutorial)!=null?R:{}),endgame:Object.keys((T=i.endgame)!=null?T:{})},scene:a.scene_id||"unknown"}),f}function de(n){var t,o,s,a,i,l,f,h,C,O,E,x,p,d,b,v,N,j,A,k,P,L,H,R,T,y,I,g,$,F,G,r,m;let e={gameplay:{},ui:{},theme:{},assets:{}};for(let[S,c]of n.objects.entries()){let _=((t=c.identity)==null?void 0:t.id)||S;_.includes("character")&&(e.gameplay.character_pos=((o=c.transform)==null?void 0:o.position)||{x:0,y:0},e.gameplay.character_scale=((s=c.transform)==null?void 0:s.scale)||1,e.gameplay.character_anim_speed=((i=(a=c.gameplay)==null?void 0:a.tuning)==null?void 0:i.anim_speed)||.003,e.gameplay.character_relief_scale=((f=(l=c.gameplay)==null?void 0:l.tuning)==null?void 0:f.relief_scale)||1.22,e.gameplay.character_relief_speed=((C=(h=c.gameplay)==null?void 0:h.tuning)==null?void 0:C.relief_speed)||.22),(_.includes("gun")||_.includes("flame"))&&(e.gameplay.gun=c.gun||{},e.gameplay.gunmuzzle=((O=c.effects)==null?void 0:O.gunmuzzle)||{},e.gameplay.muzzle_levels=((E=c.effects)==null?void 0:E.muzzle_levels)||{},e.gameplay.flame=((x=c.effects)==null?void 0:x.flame)||{}),_.includes("diamond")&&(e.gameplay.diamond=c),_.includes("ice")&&(e.gameplay.melt=c.melt||{},e.gameplay.melt_anchor=((p=c.transform)==null?void 0:p.melt_anchor)||{x:0,y:0},e.gameplay.melt_pos=((d=c.transform)==null?void 0:d.position)||{x:0,y:0},e.gameplay.hybrid_melting=((b=c.effects)==null?void 0:b.hybrid_melting)||{},e.gameplay.physics_chunks=((v=c.effects)==null?void 0:v.physics_chunks)||{},e.gameplay.melting_particles=((N=c.effects)==null?void 0:N.melting_particles)||{},e.gameplay.hard_ice=c.hard_ice||{}),_.includes("water")&&(e.gameplay.water_drops=c),_.includes("crack")&&(e.gameplay.crack=c),_.includes("hand")&&(e.gameplay.hand=((j=c.gameplay)==null?void 0:j.tuning)||{},e.gameplay.brush_start_pos=((A=c.transform)==null?void 0:A.brush_start_pos)||{x:0,y:-120},e.gameplay.hand_scale=((k=c.transform)==null?void 0:k.scale)||1.5),_.includes("hazard")&&(e.gameplay.hazard=((P=c.gameplay)==null?void 0:P.tuning)||{},e.gameplay.danger_pos=((L=c.transform)==null?void 0:L.danger_pos)||{x:0,y:235},e.gameplay.danger_pulse=((R=(H=c.gameplay)==null?void 0:H.tuning)==null?void 0:R.danger_pulse)||{},e.gameplay.hazard_height=((y=(T=c.gameplay)==null?void 0:T.tuning)==null?void 0:y.hazard_height)||140)}return e.gameplay.timeline=((I=n.engine.runtime)==null?void 0:I.timeline)||{},e.gameplay.drag_surface=((g=n.engine.runtime)==null?void 0:g.drag_surface)||{},e.gameplay.background=(($=n.engine.runtime)==null?void 0:$.background)||{},e.gameplay.ui_styles=((F=n.engine.runtime)==null?void 0:F.ui_styles)||{},e.gameplay.label_pulse=((G=n.engine.runtime)==null?void 0:G.label_pulse)||{},e.ui=((r=n.engine.runtime)==null?void 0:r.ui)||{},e.theme=((m=n.engine.runtime)==null?void 0:m.theme)||{},e.assets=n.engine.assets||{},e}var V=class{shouldFullReload(e){return e.type==="component"||e.type==="scene"}getAffectedObjects(e){return e.type==="object"&&e.objectId?[e.objectId]:[]}},W=class{constructor(e=1e3){this.pollingInterval=null;this.fileHashes=new Map;this.callbacks=new Map;this.intervalMs=e}watch(e,t){this.callbacks.set(e,t),this.pollingInterval===null&&(this.pollingInterval=window.setInterval(()=>{this.checkAllFiles()},this.intervalMs))}async checkAllFiles(){for(let[e,t]of this.callbacks.entries())try{let o=`${e}?t=${Date.now()}&r=${Math.random()}`,s=await fetch(o,{cache:"no-cache",headers:{"Cache-Control":"no-cache"}});if(s.ok){let a=await s.text(),i=this.hashString(a),l=this.fileHashes.get(e);if(l&&l!==i&&console.log(`[HOT-RELOAD] File changed: ${e}`),l&&l!==i){console.log(`[HOT-RELOAD] File changed: ${e}`);let f=this.determineEventType(e);t(f),this.fileHashes.set(e,i)}else l||this.fileHashes.set(e,i)}}catch(o){console.warn(`Failed to check ${e}:`,o)}}determineEventType(e){var t,o;return e.includes("/components/")?{type:"component",path:e,componentName:(t=e.split("/").pop())==null?void 0:t.replace(".schema.json","")}:e.includes("/engine/")?{type:"engine",path:e}:e.includes("/scenes/")?{type:"scene",path:e}:e.includes("/objects/")?{type:"object",path:e,objectId:(o=e.split("/").pop())==null?void 0:o.replace(".json","")}:{type:"object",path:e}}hashString(e){let t=0;for(let o=0;o<e.length;o++){let s=e.charCodeAt(o);t=(t<<5)-t+s,t=t&t}return t.toString()}unwatch(e){this.callbacks.delete(e),this.fileHashes.delete(e)}stop(){this.pollingInterval!==null&&(clearInterval(this.pollingInterval),this.pollingInterval=null),this.callbacks.clear(),this.fileHashes.clear()}};function fe(n,e){let t=[];function o(s,a,i=""){if(s!==a){if(typeof s!=typeof a){t.push(`${i}: type changed`);return}if(typeof s=="object"&&s!==null&&a!==null){let l=new Set([...Object.keys(s),...Object.keys(a)]);for(let f of l){let h=i?`${i}.${f}`:f;f in s?f in a?o(s[f],a[f],h):t.push(`${h}: removed`):t.push(`${h}: added`)}}else t.push(`${i}: changed`)}}return o(n,e),t}function ge(n,e,t,o){let s={...t};for(let[a,i]of o.entries())s[a]&&i.defaults&&(s[a]={...i.defaults,...s[a]});return s}var K={};function ue(n){if(typeof window=="undefined")return;let e=typeof K!="undefined"&&!!K.hot,t=window.location.search.includes("hot-reload");if(!(e||t))return;let s=null,a=!1,i=null;if(t){i=new W;let p=window.__configWatcher;p!=null&&p.stop&&p.stop(),window.__configWatcher=i}let l=new Set,f=p=>{var v,N;if(!i)return;let d=new Set;d.add("configs/engine/engine.runtime.json"),d.add("configs/engine/engine.assets.json"),d.add("configs/engine/engine.splash.json"),d.add("configs/scenes/scene.main.json");let b=(N=(v=p.scene)==null?void 0:v.objects)!=null?N:[];for(let j of b)j!=null&&j.object_config&&d.add(`configs/objects/${j.object_config}.json`);for(let j of l)d.has(j)||i.unwatch(j);for(let j of d)l.has(j)||i.watch(j,A=>x(A));l=d},h=new Set,C=!1,O=async p=>{let d=await M(p),b=z(d,n.activeConfig.schemas),v=B(b,n.activeConfig.schemas);v.valid||console.warn(`[HOT-RELOAD] ${p} validation errors:`,v.errors),await n.liveEditBridge.applyObjectConfig(p,b)};async function E(p){if(!a){a=!0;try{if(C||h.size===0){n.audioSystem.destroy();let d=await U("scene.main");n.setActiveConfig(d),n.gameObjectManager.updateConfig(d),n.CustomAssets.updateConfig(d),await n.CustomAssets.ready();let b=n.createAudioSystem(d);n.setAudioSystem(b),window.__audioSystem=b,await b.start(),n.liveEditBridge.rebuildIndexes(),f(d),console.log(`[GAME] Hot-reload complete (${p})`)}else{let d=Array.from(h);h.clear();for(let b of d)await O(b);console.log(`[GAME] Hot-reload updated objects: ${d.join(", ")}`)}}catch(d){console.warn("[GAME] Hot-reload failed:",d)}finally{a=!1,C=!1,h.clear()}}}function x(p){p.type==="object"&&p.objectId?h.add(p.objectId):C=!0,s&&window.clearTimeout(s),s=window.setTimeout(()=>{E(p.type)},120)}e&&K.hot.on("config-change",()=>{x({type:"hmr"})}),t&&(f(n.activeConfig),console.log(`[GAME] Hot-reload watcher enabled (${l.size} files)`))}export{ne as a,M as b,te as c,oe as d,re as e,se as f,B as g,z as h,U as i,de as j,V as k,W as l,fe as m,ge as n,ue as o};
@@ -1,4 +1,4 @@
1
- import{a as Xt,c as an,d as Te,e as sn}from"./chunk-I5OOVR5U.js";import{i as Qt}from"./chunk-FOTLNUIS.js";import{c as qe,d as Jt,e as Ze,g as Fa,h as rn,j as Ba,k as Ga,n as st,p as Zt,q as rt,r as Ua,s as on,t as qa}from"./chunk-2MR65LDX.js";import{a as Hr}from"./chunk-JXBG6UFL.js";import{Application as al}from"pixi.js";var Ve={};function ei(o,e,t=!1){Ve[o]||(Ve[o]=[]),Ve[o].push({fn:e,once:t})}function ln(o,e){if(Ve[o]){if(!e){delete Ve[o];return}Ve[o]=Ve[o].filter(t=>t.fn!==e)}}function ti(o,...e){let t=Ve[o];if(t)for(let i of[...t])i.fn(...e),i.once&&ln(o,i.fn)}function be(o,e){ei(o,e,!0)}var re=null,xe=[],ot=null;function Wa(o){re=o,xe=[],ot!==null&&(clearTimeout(ot),ot=null)}function Ka(){var o,e,t;return{endpoint:(re==null?void 0:re.endpoint)||"",transport:(re==null?void 0:re.transport)||"beacon",batchSize:(o=re==null?void 0:re.batchSize)!=null?o:10,flushIntervalMs:(e=re==null?void 0:re.flushIntervalMs)!=null?e:300,maxQueue:(t=re==null?void 0:re.maxQueue)!=null?t:200,debug:!!(re!=null&&re.debug)}}async function Va(o,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(o,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(o,{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 cn(o,e){let t=Ka();if(e&&t.endpoint){if(xe.push(o),xe.length>t.maxQueue&&(xe=xe.slice(xe.length-t.maxQueue)),xe.length>=t.batchSize){Ya();return}ot===null&&(ot=window.setTimeout(()=>{ot=null,Ya()},t.flushIntervalMs))}}async function Ya(){let o=Ka();if(!o.endpoint||xe.length===0)return;let e=xe.splice(0,o.batchSize);await Va(o.endpoint,{events:e},o.transport,o.debug),xe.length>0&&await Va(o.endpoint,{events:xe.splice(0,o.batchSize)},o.transport,o.debug)}function Xa(o){return Math.max(0,Math.min(1,o))}function Nr(o){let e=String(o!=null?o:"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 Pt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Fr(o,e){let t=o==null?void 0:o[e];return typeof t=="number"?t:0}function Ja(o,e,t){try{o[e]=t}catch{}}function Br(o){let e=o==null?void 0:o.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 Za(o,e){let t=o==null?void 0:o.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 Qa(o,e){let t=Br(o);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 es(){let o=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,r(),o.size>0&&i()})},n=d=>{var u;o.add(d);let p=(u=e.get(d.target))!=null?u:new Set;p.add(d),e.set(d.target,p),i()},a=d=>{o.delete(d);let p=e.get(d.target);p&&(p.delete(d),p.size===0&&e.delete(d.target))},s=d=>{d.killed||(d.killed=!0,a(d))},r=()=>{var p,u;let d=Pt();for(let g of Array.from(o)){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=Xa(m),b=g.repeat>=0?g.repeat+1:1,y=g.repeat>0?Math.min(Math.floor(m),b-1):0;if(g.repeat>0&&m>=1){let T=m-y;f=Xa(T)}let w=g.ease(f);g.yoyo&&y%2===1&&(w=1-w);for(let T of g.props)Ja(g.target,T.key,T.from+(T.to-T.from)*w);g.scaleFrom&&g.scaleTo&&Za(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>=b){s(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(d,p,u)=>{var T;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+((T=u==null?void 0:u.delayMsOverride)!=null?T:0)),m=Nr(p.ease),f=typeof p.repeat=="number"?Math.max(0,p.repeat|0):0,b=p.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),w=[];for(let P of Object.keys(p)){if(y.has(P))continue;let _=p[P];typeof _=="number"&&w.push({key:P,from:Fr(d,P),to:_})}let v=Qa(d,p);return{target:d,startMs:Pt(),delayMs:h,durationMs:g,ease:m,props:w,scaleFrom:v.from,scaleTo:v.to,repeat:f,yoyo:b,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:()=>s(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=Pt())},resume:()=>{var m;if(!u.paused)return;let g=(m=u.pauseAtMs)!=null?m:Pt(),h=Pt()-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"&&Ja(d,g,h)}let u=Qa(d,p);u.to&&Za(d,u.to)},killTweensOf(d){let p=e.get(d);if(p)for(let u of Array.from(p))s(u)},timeline(d={}){let p=[],u=0,g=!1,h=[],m=y=>{if(typeof y=="number")return Math.max(0,y*1e3);let w=typeof y=="string"?y.trim():"";return w.startsWith("+=")?u+Math.max(0,Number(w.slice(2))*1e3||0):w?Math.max(0,Number(w)*1e3||0):u},f=y=>{p.push(y);let w=Math.max(0,(typeof y.vars.duration=="number"?y.vars.duration:.5)*1e3);u=Math.max(u,y.atMs+w)},b={to(y,w,v){return f({kind:"to",target:y,vars:w,atMs:m(v)}),b},fromTo(y,w,v,T){return f({kind:"fromTo",target:y,vars:v,from:w,atMs:m(T)}),b},play(){var y,w;if(g)return b;g=!0,h=[];for(let v of p)v.kind==="fromTo"&&c.set(v.target,(y=v.from)!=null?y:{}),h.push(c.to(v.target,{...v.vars,delay:v.atMs/1e3+((w=v.vars.delay)!=null?w:0)}));return b},pause(){for(let y of h)y.pause();return b},kill(){for(let y of h)y.kill();h=[],g=!1}};return d.paused||b.play(),b}};return c}function ts(){if(typeof window=="undefined")return;let o=window;if(!o.gsap)try{o.gsap=es()}catch{}}var is={name:"handler-playable-sdk",version:"1.0.103",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 --external jszip && 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/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.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 --external jszip && 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 dist/cli/student-helper/*.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 ye=0,Ur=ye++,ns=ye++,as=ye++,ss=ye++,rs=ye++,os=ye++,ls=ye++,cs=ye++,ds=ye++,ps=ye++,us=ye++,gs=ye++,ne=Ur;function hs(){return ne===ns}function ms(){return ne===as}function fs(){return ne===ss}function bs(){return ne===rs}function lt(){return ne===os}function ct(){return ne===ls}function ys(){return ne===cs}function vs(){return ne===ds}function ws(){return ne===ps}function dn(){return ne===us}function pn(){return ne===gs}function xs(){let o=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(o==="mraid")try{mraid.getState(),ne=ns;return}catch{}else if(o==="dapi")try{dapi.isReady(),ne=as;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(ne=ss)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(ne=rs)}catch{}else if(e==="mintegral")window.gameReady&&(ne=os);else if(e==="tapjoy")window.TJ_API&&(ne=ls);else if(e==="tiktok")window.openAppStore&&(ne=cs);else if(e==="smadex")try{window.smxTracking&&(ne=ds)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(ne=ps)}catch{}else e==="vungle"?ne=us:(o==="nucleo"||e==="nucleo")&&(ne=gs)}import un from"lottie-web";var Ss=un;typeof window!="undefined"&&(window.lottie=un,window.__baseLottie=un);function oe(o,e){let t=(n,a)=>a===0?n:t(a,n%a),i=t(o,e);return`${o/i}:${e/i}`}var jl=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:oe(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:oe(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:oe(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:oe(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:oe(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:oe(360,780)}],_l=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:oe(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:oe(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:oe(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:oe(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:oe(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:oe(412,915)}],Rl=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:oe(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:oe(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:oe(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:oe(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:oe(800,1280)}],gn=[{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:oe(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:oe(768,1024),mraidScale:.7}];var Es=[...gn],As=[{category:"playable",label:"Playable Ad",devices:gn}],hn=gn[0];function dt(o){return Es.find(e=>e.id===o)||hn}function Ol(o){return Es.filter(e=>e.category===o)}var Pe=class{async updateProperty(e,t,i,n={}){var l,c,d,p,u,g,h,m,f,b,y,w;console.log("[PropertyUpdateManager] Updating:",e,t,i);let a=window.getEditableObjectConfig;if(typeof a!="function"){console.error("[PropertyUpdateManager] getEditableObjectConfig not available");return}let s=a(e);if(!s){console.error("[PropertyUpdateManager] Config not found for:",e);return}if(qe({objectId:e,path:t,value:i},{persist:!0}),t==="transform"||t.startsWith("transform.")){console.log("[DEBUG FALLBACK] PropertyUpdateManager SKIP applyEditableObjectConfig (transform path)",t,e);let v=s==null?void 0:s.motion;if(v&&typeof v=="object"&&v.enabled!==!1&&(((p=v==null?void 0:v.intro)==null?void 0:p.enabled)===!0||((u=v==null?void 0:v.pulse)==null?void 0:u.enabled)===!0||((g=v==null?void 0:v.swing)==null?void 0:g.enabled)===!0||((h=v==null?void 0:v.continuousMove)==null?void 0:h.enabled)===!0||((m=v==null?void 0:v.continuousRotate)==null?void 0:m.enabled)===!0||((f=v==null?void 0:v.orbit)==null?void 0:f.enabled)===!0)){let _=window.applyEditableObjectConfig;if(typeof _=="function"){let I=window.__editableConfig,j=(w=(y=(b=I==null?void 0:I.objects)==null?void 0:b.get)==null?void 0:y.call(b,e))!=null?w:s;await _(e,j),console.log("[PropertyUpdateManager] Applied config for motion object")}}n.refreshInspector||requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("config:changed",{detail:{objectId:e}}))})}else{let v=window.applyEditableObjectConfig;if(typeof v=="function"){let T=window.__editableConfig,P=(d=(c=(l=T==null?void 0:T.objects)==null?void 0:l.get)==null?void 0:c.call(l,e))!=null?d:s;await v(e,P),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 mn(o){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()=>{var g,h,m,f;let s=n.result;if(!s||typeof s!="string"){alert("Failed to read file: Invalid data URL"),console.error("[QuickActionsBar] Invalid data URL:",typeof s,s==null?void 0:s.substring(0,50));return}if(!s.startsWith("data:image/")){alert("Invalid file format: Not an image file"),console.error("[QuickActionsBar] Invalid data URL format:",s.substring(0,100));return}let r=s.match(/^data:image\/[^;]+;base64,(.+)$/);if(!r||!r[1]||r[1].length===0){alert("Failed to read file: Invalid base64 data"),console.error("[QuickActionsBar] Invalid base64 data in data URL");return}try{let b=r[1],y=atob(b.substring(0,Math.min(100,b.length)));if(!y||y.length===0)throw new Error("Base64 decode test failed");console.log("[QuickActionsBar] \u2705 Data URL validated, length:",s.length)}catch(b){alert("Failed to read file: Corrupted image data"),console.error("[QuickActionsBar] Base64 validation failed:",b);return}let l=o.category||"misc",c=(o.objectId||"new_asset").replace(/^json\./,"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),d=((g=i.name.toLowerCase().match(/\.(png|jpg|jpeg|gif|webp)$/))==null?void 0:g[1])||"png",p=d==="jpg"?"jpeg":d,u=`${c||"new_asset"}_uploaded_${Date.now()}.${p}`;console.log("[QuickActionsBar] Uploading file:",u,"to category:",l,"data URL length:",s.length);try{let y=await(await fetch("/api/library/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:l,filename:u,data:s,overwrite:!0})})).json();if(!(y!=null&&y.success)){alert(`Upload failed: ${(y==null?void 0:y.error)||"Unknown error"}`);return}await new Promise(S=>setTimeout(S,100));let w=window.addAssetToRegistry;typeof w=="function"&&(w(l,u),console.log("[QuickActionsBar] \u2705 Added to registry:",l,u));let v=window.getEditableAssets;if(typeof v=="function"){let S=v();S&&!S.categories&&(S.categories=[]),S!=null&&S.categories&&!S.categories.includes(l)&&(S.categories.push(l),console.log(`[QuickActionsBar] Added category ${l} to registry`))}let T=!1,P=0,_=10;for(;!T&&P<_;){P++,console.log(`[QuickActionsBar] Refresh attempt ${P}/${_}...`);try{(await fetch("/api/setup-library",{method:"POST",headers:{"Content-Type":"application/json"}})).ok&&console.log("[QuickActionsBar] \u2705 Registry rebuilt from disk")}catch{}await new Promise(A=>setTimeout(A,300));let S=window.refreshAssetLibrary;typeof S=="function"&&(console.log("[QuickActionsBar] Refreshing library panel..."),await S());let x=window.reRenderAssetLibrary;typeof x=="function"&&(console.log("[QuickActionsBar] Re-rendering library panel..."),x());let E=window.getEditableAssets;if(typeof E=="function"){let A=E(),C=((h=A==null?void 0:A.libraryAssets)==null?void 0:h[l])||[];C.some(R=>(R==null?void 0:R.filename)===u)?(console.log("[QuickActionsBar] \u2705 Asset found in registry!"),T=!0):(console.log(`[QuickActionsBar] Asset not found yet, retrying... (found ${C.length} assets in ${l})`),await new Promise(R=>setTimeout(R,500)))}else P>=2&&(T=!0)}T||console.warn("[QuickActionsBar] \u26A0\uFE0F Asset not found in registry after retries, proceeding anyway..."),setTimeout(()=>{try{window.dispatchEvent(new CustomEvent("config:changed",{detail:{action:"batch"}})),console.log("[QuickActionsBar] Dispatched config:changed event")}catch(S){console.warn("[QuickActionsBar] Failed to refresh textures:",S)}},300),console.log("[QuickActionsBar] Applying asset to object:",y.path);let I=!1,j=0,L=5;for(;!I&&j<L;){j++;try{await o.onApply(y.path),await new Promise(x=>setTimeout(x,200));let S=window.getEditableObjectConfig;if(typeof S=="function"){let x=S(o.objectId),E=((f=(m=x==null?void 0:x.render)==null?void 0:m.asset)==null?void 0:f.path)||"";E===y.path||E.includes(u)?(console.log("[QuickActionsBar] \u2705 Asset confirmed applied to object"),I=!0):(console.log(`[QuickActionsBar] Asset not applied yet (attempt ${j}), retrying...`),await new Promise(A=>setTimeout(A,300)))}else I=!0}catch(S){console.error(`[QuickActionsBar] Apply attempt ${j} failed:`,S),j<L&&await new Promise(x=>setTimeout(x,500))}}I?console.log("[QuickActionsBar] \u2705 Asset upload and apply complete!"):console.warn("[QuickActionsBar] \u26A0\uFE0F Asset may not have been applied, but upload succeeded")}catch(b){console.error("[QuickActionsBar] Upload error:",b),alert("Upload failed. Check console.")}},n.readAsDataURL(i)},e.click()}var ii=class{constructor(){this.updateManager=new Pe}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 s=this.updateManager.getNestedProperty(a,i);if(e==="ai-convert"||e==="upload"||e==="library"){let r=i==="ui.text"||i==="render.asset.path",l=i==="render.asset.path";r&&(await this.prepareForImageConversion(t,a),e==="ai-convert"&&i!=="render.asset.path"&&(i="render.asset.path"))}switch(e){case"library":this.openLibrary(t,i,s);break;case"ai-edit":this.openAIEditor(t,i,s);break;case"upload":this.openUpload(t,i);break;case"reset":await this.resetToDefault(t,i);break;case"ai-convert":this.handleAiConvert(t,i,s);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 s=((n=(i=t.transform)==null?void 0:i.scale)!=null?n:1)*.3;await this.updateManager.updateProperty(e,"transform.scale",s),console.log("[QuickActionsBar] Text to PNG conversion: set tint white, scale",s)}this.ensureSlotInRegistry(e,t)}ensureSlotInRegistry(e,t){var r,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=((r=t.identity)==null?void 0:r.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 s=window.__updateWorkbenchTabs;typeof s=="function"&&s()}if(n.libraryPanel){let s=window.getEditableObjectConfig,r=s==null?void 0:s(e),l=(a=r==null?void 0:r.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 s;let i=window.getEditableObjectConfig,n=i==null?void 0:i(e),a=((s=n==null?void 0:n.identity)==null?void 0:s.category)||(t.split(".")[0]==="render"?"environment":"ui");mn({objectId:e,category:a,onApply:async r=>{var g,h;console.log("[QuickActionsBar] Upload complete, applying asset:",r);let l=window.applyAssetToSlot,c=this.getFilenameFromPath(r),d=/render\.asset\.path/i.test(t)||/\.(png|jpg|jpeg|gif|webp)$/i.test(r);if(typeof l=="function"&&c&&d){console.log("[QuickActionsBar] Applying asset to slot:",e,c,a);try{await l(e,c,a),console.log("[QuickActionsBar] \u2705 Asset applied to slot")}catch(m){console.error("[QuickActionsBar] Failed to apply asset to slot:",m)}}console.log("[QuickActionsBar] Updating property:",e,t,r);try{await this.updateManager.updateProperty(e,t,r),console.log("[QuickActionsBar] \u2705 Property updated")}catch(m){console.error("[QuickActionsBar] Failed to update property:",m)}let p=window.__debugContext;(h=(g=p==null?void 0:p.options)==null?void 0:g.onPropertyChange)==null||h.call(g,e,t,r);let u=window.__highlightLibrarySlot;typeof u=="function"&&setTimeout(()=>{u(e,a)},1e3),window.dispatchEvent(new CustomEvent("inspector:refresh")),window.dispatchEvent(new CustomEvent("config:changed",{detail:{objectId:e,action:"update",path:t}})),console.log("[QuickActionsBar] \u2705 Upload and apply complete")}})}getFilenameFromPath(e){if(!e)return"";let t=e.split("?")[0].replace(/\\/g,"/");return t.split("/").pop()||t}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),s=window.__editableConfig;if(!(s!=null&&s.schemas))return;let r=null;if(s.schemas instanceof Map?r=s.schemas.get(n):typeof s.schemas=="object"&&(r=s.schemas[n]),!(r!=null&&r.defaults))return;let l=r.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 s=`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.`,r="render.asset.path";console.log("[QuickActionsBar] AI Convert for:",e,"from:",t,"to:",r),n(e,s,"",{objectId:e,path:r});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 qr=[{value:"loading",label:"Loading"},{value:"start",label:"Start"},{value:"gameplay",label:"Gameplay"},{value:"tutorial",label:"Tutorial"},{value:"endgame",label:"Endgame"}],Vr=["environment","ui","character","system","backgrounds"],Yr=["bg","world","ui"],Cs={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}}},ni=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{a as Xt,c as an,d as Te,e as sn}from"./chunk-I5OOVR5U.js";import{i as Qt}from"./chunk-FL4VTM6W.js";import{c as qe,d as Jt,e as Ze,g as Fa,h as rn,j as Ba,k as Ga,n as st,p as Zt,q as rt,r as Ua,s as on,t as qa}from"./chunk-2MR65LDX.js";import{a as Hr}from"./chunk-JXBG6UFL.js";import{Application as al}from"pixi.js";var Ve={};function ei(o,e,t=!1){Ve[o]||(Ve[o]=[]),Ve[o].push({fn:e,once:t})}function ln(o,e){if(Ve[o]){if(!e){delete Ve[o];return}Ve[o]=Ve[o].filter(t=>t.fn!==e)}}function ti(o,...e){let t=Ve[o];if(t)for(let i of[...t])i.fn(...e),i.once&&ln(o,i.fn)}function be(o,e){ei(o,e,!0)}var re=null,xe=[],ot=null;function Wa(o){re=o,xe=[],ot!==null&&(clearTimeout(ot),ot=null)}function Ka(){var o,e,t;return{endpoint:(re==null?void 0:re.endpoint)||"",transport:(re==null?void 0:re.transport)||"beacon",batchSize:(o=re==null?void 0:re.batchSize)!=null?o:10,flushIntervalMs:(e=re==null?void 0:re.flushIntervalMs)!=null?e:300,maxQueue:(t=re==null?void 0:re.maxQueue)!=null?t:200,debug:!!(re!=null&&re.debug)}}async function Va(o,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(o,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(o,{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 cn(o,e){let t=Ka();if(e&&t.endpoint){if(xe.push(o),xe.length>t.maxQueue&&(xe=xe.slice(xe.length-t.maxQueue)),xe.length>=t.batchSize){Ya();return}ot===null&&(ot=window.setTimeout(()=>{ot=null,Ya()},t.flushIntervalMs))}}async function Ya(){let o=Ka();if(!o.endpoint||xe.length===0)return;let e=xe.splice(0,o.batchSize);await Va(o.endpoint,{events:e},o.transport,o.debug),xe.length>0&&await Va(o.endpoint,{events:xe.splice(0,o.batchSize)},o.transport,o.debug)}function Xa(o){return Math.max(0,Math.min(1,o))}function Nr(o){let e=String(o!=null?o:"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 Pt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Fr(o,e){let t=o==null?void 0:o[e];return typeof t=="number"?t:0}function Ja(o,e,t){try{o[e]=t}catch{}}function Br(o){let e=o==null?void 0:o.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 Za(o,e){let t=o==null?void 0:o.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 Qa(o,e){let t=Br(o);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 es(){let o=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,r(),o.size>0&&i()})},n=d=>{var u;o.add(d);let p=(u=e.get(d.target))!=null?u:new Set;p.add(d),e.set(d.target,p),i()},a=d=>{o.delete(d);let p=e.get(d.target);p&&(p.delete(d),p.size===0&&e.delete(d.target))},s=d=>{d.killed||(d.killed=!0,a(d))},r=()=>{var p,u;let d=Pt();for(let g of Array.from(o)){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=Xa(m),b=g.repeat>=0?g.repeat+1:1,y=g.repeat>0?Math.min(Math.floor(m),b-1):0;if(g.repeat>0&&m>=1){let T=m-y;f=Xa(T)}let w=g.ease(f);g.yoyo&&y%2===1&&(w=1-w);for(let T of g.props)Ja(g.target,T.key,T.from+(T.to-T.from)*w);g.scaleFrom&&g.scaleTo&&Za(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>=b){s(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(d,p,u)=>{var T;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+((T=u==null?void 0:u.delayMsOverride)!=null?T:0)),m=Nr(p.ease),f=typeof p.repeat=="number"?Math.max(0,p.repeat|0):0,b=p.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),w=[];for(let P of Object.keys(p)){if(y.has(P))continue;let _=p[P];typeof _=="number"&&w.push({key:P,from:Fr(d,P),to:_})}let v=Qa(d,p);return{target:d,startMs:Pt(),delayMs:h,durationMs:g,ease:m,props:w,scaleFrom:v.from,scaleTo:v.to,repeat:f,yoyo:b,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:()=>s(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=Pt())},resume:()=>{var m;if(!u.paused)return;let g=(m=u.pauseAtMs)!=null?m:Pt(),h=Pt()-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"&&Ja(d,g,h)}let u=Qa(d,p);u.to&&Za(d,u.to)},killTweensOf(d){let p=e.get(d);if(p)for(let u of Array.from(p))s(u)},timeline(d={}){let p=[],u=0,g=!1,h=[],m=y=>{if(typeof y=="number")return Math.max(0,y*1e3);let w=typeof y=="string"?y.trim():"";return w.startsWith("+=")?u+Math.max(0,Number(w.slice(2))*1e3||0):w?Math.max(0,Number(w)*1e3||0):u},f=y=>{p.push(y);let w=Math.max(0,(typeof y.vars.duration=="number"?y.vars.duration:.5)*1e3);u=Math.max(u,y.atMs+w)},b={to(y,w,v){return f({kind:"to",target:y,vars:w,atMs:m(v)}),b},fromTo(y,w,v,T){return f({kind:"fromTo",target:y,vars:v,from:w,atMs:m(T)}),b},play(){var y,w;if(g)return b;g=!0,h=[];for(let v of p)v.kind==="fromTo"&&c.set(v.target,(y=v.from)!=null?y:{}),h.push(c.to(v.target,{...v.vars,delay:v.atMs/1e3+((w=v.vars.delay)!=null?w:0)}));return b},pause(){for(let y of h)y.pause();return b},kill(){for(let y of h)y.kill();h=[],g=!1}};return d.paused||b.play(),b}};return c}function ts(){if(typeof window=="undefined")return;let o=window;if(!o.gsap)try{o.gsap=es()}catch{}}var is={name:"handler-playable-sdk",version:"1.0.104",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 --external jszip && 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/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.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 --external jszip && 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 dist/cli/student-helper/*.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 ye=0,Ur=ye++,ns=ye++,as=ye++,ss=ye++,rs=ye++,os=ye++,ls=ye++,cs=ye++,ds=ye++,ps=ye++,us=ye++,gs=ye++,ne=Ur;function hs(){return ne===ns}function ms(){return ne===as}function fs(){return ne===ss}function bs(){return ne===rs}function lt(){return ne===os}function ct(){return ne===ls}function ys(){return ne===cs}function vs(){return ne===ds}function ws(){return ne===ps}function dn(){return ne===us}function pn(){return ne===gs}function xs(){let o=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(o==="mraid")try{mraid.getState(),ne=ns;return}catch{}else if(o==="dapi")try{dapi.isReady(),ne=as;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(ne=ss)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(ne=rs)}catch{}else if(e==="mintegral")window.gameReady&&(ne=os);else if(e==="tapjoy")window.TJ_API&&(ne=ls);else if(e==="tiktok")window.openAppStore&&(ne=cs);else if(e==="smadex")try{window.smxTracking&&(ne=ds)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(ne=ps)}catch{}else e==="vungle"?ne=us:(o==="nucleo"||e==="nucleo")&&(ne=gs)}import un from"lottie-web";var Ss=un;typeof window!="undefined"&&(window.lottie=un,window.__baseLottie=un);function oe(o,e){let t=(n,a)=>a===0?n:t(a,n%a),i=t(o,e);return`${o/i}:${e/i}`}var jl=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:oe(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:oe(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:oe(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:oe(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:oe(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:oe(360,780)}],_l=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:oe(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:oe(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:oe(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:oe(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:oe(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:oe(412,915)}],Rl=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:oe(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:oe(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:oe(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:oe(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:oe(800,1280)}],gn=[{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:oe(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:oe(768,1024),mraidScale:.7}];var Es=[...gn],As=[{category:"playable",label:"Playable Ad",devices:gn}],hn=gn[0];function dt(o){return Es.find(e=>e.id===o)||hn}function Ol(o){return Es.filter(e=>e.category===o)}var Pe=class{async updateProperty(e,t,i,n={}){var l,c,d,p,u,g,h,m,f,b,y,w;console.log("[PropertyUpdateManager] Updating:",e,t,i);let a=window.getEditableObjectConfig;if(typeof a!="function"){console.error("[PropertyUpdateManager] getEditableObjectConfig not available");return}let s=a(e);if(!s){console.error("[PropertyUpdateManager] Config not found for:",e);return}if(qe({objectId:e,path:t,value:i},{persist:!0}),t==="transform"||t.startsWith("transform.")){console.log("[DEBUG FALLBACK] PropertyUpdateManager SKIP applyEditableObjectConfig (transform path)",t,e);let v=s==null?void 0:s.motion;if(v&&typeof v=="object"&&v.enabled!==!1&&(((p=v==null?void 0:v.intro)==null?void 0:p.enabled)===!0||((u=v==null?void 0:v.pulse)==null?void 0:u.enabled)===!0||((g=v==null?void 0:v.swing)==null?void 0:g.enabled)===!0||((h=v==null?void 0:v.continuousMove)==null?void 0:h.enabled)===!0||((m=v==null?void 0:v.continuousRotate)==null?void 0:m.enabled)===!0||((f=v==null?void 0:v.orbit)==null?void 0:f.enabled)===!0)){let _=window.applyEditableObjectConfig;if(typeof _=="function"){let I=window.__editableConfig,j=(w=(y=(b=I==null?void 0:I.objects)==null?void 0:b.get)==null?void 0:y.call(b,e))!=null?w:s;await _(e,j),console.log("[PropertyUpdateManager] Applied config for motion object")}}n.refreshInspector||requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("config:changed",{detail:{objectId:e}}))})}else{let v=window.applyEditableObjectConfig;if(typeof v=="function"){let T=window.__editableConfig,P=(d=(c=(l=T==null?void 0:T.objects)==null?void 0:l.get)==null?void 0:c.call(l,e))!=null?d:s;await v(e,P),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 mn(o){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()=>{var g,h,m,f;let s=n.result;if(!s||typeof s!="string"){alert("Failed to read file: Invalid data URL"),console.error("[QuickActionsBar] Invalid data URL:",typeof s,s==null?void 0:s.substring(0,50));return}if(!s.startsWith("data:image/")){alert("Invalid file format: Not an image file"),console.error("[QuickActionsBar] Invalid data URL format:",s.substring(0,100));return}let r=s.match(/^data:image\/[^;]+;base64,(.+)$/);if(!r||!r[1]||r[1].length===0){alert("Failed to read file: Invalid base64 data"),console.error("[QuickActionsBar] Invalid base64 data in data URL");return}try{let b=r[1],y=atob(b.substring(0,Math.min(100,b.length)));if(!y||y.length===0)throw new Error("Base64 decode test failed");console.log("[QuickActionsBar] \u2705 Data URL validated, length:",s.length)}catch(b){alert("Failed to read file: Corrupted image data"),console.error("[QuickActionsBar] Base64 validation failed:",b);return}let l=o.category||"misc",c=(o.objectId||"new_asset").replace(/^json\./,"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),d=((g=i.name.toLowerCase().match(/\.(png|jpg|jpeg|gif|webp)$/))==null?void 0:g[1])||"png",p=d==="jpg"?"jpeg":d,u=`${c||"new_asset"}_uploaded_${Date.now()}.${p}`;console.log("[QuickActionsBar] Uploading file:",u,"to category:",l,"data URL length:",s.length);try{let y=await(await fetch("/api/library/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:l,filename:u,data:s,overwrite:!0})})).json();if(!(y!=null&&y.success)){alert(`Upload failed: ${(y==null?void 0:y.error)||"Unknown error"}`);return}await new Promise(S=>setTimeout(S,100));let w=window.addAssetToRegistry;typeof w=="function"&&(w(l,u),console.log("[QuickActionsBar] \u2705 Added to registry:",l,u));let v=window.getEditableAssets;if(typeof v=="function"){let S=v();S&&!S.categories&&(S.categories=[]),S!=null&&S.categories&&!S.categories.includes(l)&&(S.categories.push(l),console.log(`[QuickActionsBar] Added category ${l} to registry`))}let T=!1,P=0,_=10;for(;!T&&P<_;){P++,console.log(`[QuickActionsBar] Refresh attempt ${P}/${_}...`);try{(await fetch("/api/setup-library",{method:"POST",headers:{"Content-Type":"application/json"}})).ok&&console.log("[QuickActionsBar] \u2705 Registry rebuilt from disk")}catch{}await new Promise(A=>setTimeout(A,300));let S=window.refreshAssetLibrary;typeof S=="function"&&(console.log("[QuickActionsBar] Refreshing library panel..."),await S());let x=window.reRenderAssetLibrary;typeof x=="function"&&(console.log("[QuickActionsBar] Re-rendering library panel..."),x());let E=window.getEditableAssets;if(typeof E=="function"){let A=E(),C=((h=A==null?void 0:A.libraryAssets)==null?void 0:h[l])||[];C.some(R=>(R==null?void 0:R.filename)===u)?(console.log("[QuickActionsBar] \u2705 Asset found in registry!"),T=!0):(console.log(`[QuickActionsBar] Asset not found yet, retrying... (found ${C.length} assets in ${l})`),await new Promise(R=>setTimeout(R,500)))}else P>=2&&(T=!0)}T||console.warn("[QuickActionsBar] \u26A0\uFE0F Asset not found in registry after retries, proceeding anyway..."),setTimeout(()=>{try{window.dispatchEvent(new CustomEvent("config:changed",{detail:{action:"batch"}})),console.log("[QuickActionsBar] Dispatched config:changed event")}catch(S){console.warn("[QuickActionsBar] Failed to refresh textures:",S)}},300),console.log("[QuickActionsBar] Applying asset to object:",y.path);let I=!1,j=0,L=5;for(;!I&&j<L;){j++;try{await o.onApply(y.path),await new Promise(x=>setTimeout(x,200));let S=window.getEditableObjectConfig;if(typeof S=="function"){let x=S(o.objectId),E=((f=(m=x==null?void 0:x.render)==null?void 0:m.asset)==null?void 0:f.path)||"";E===y.path||E.includes(u)?(console.log("[QuickActionsBar] \u2705 Asset confirmed applied to object"),I=!0):(console.log(`[QuickActionsBar] Asset not applied yet (attempt ${j}), retrying...`),await new Promise(A=>setTimeout(A,300)))}else I=!0}catch(S){console.error(`[QuickActionsBar] Apply attempt ${j} failed:`,S),j<L&&await new Promise(x=>setTimeout(x,500))}}I?console.log("[QuickActionsBar] \u2705 Asset upload and apply complete!"):console.warn("[QuickActionsBar] \u26A0\uFE0F Asset may not have been applied, but upload succeeded")}catch(b){console.error("[QuickActionsBar] Upload error:",b),alert("Upload failed. Check console.")}},n.readAsDataURL(i)},e.click()}var ii=class{constructor(){this.updateManager=new Pe}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 s=this.updateManager.getNestedProperty(a,i);if(e==="ai-convert"||e==="upload"||e==="library"){let r=i==="ui.text"||i==="render.asset.path",l=i==="render.asset.path";r&&(await this.prepareForImageConversion(t,a),e==="ai-convert"&&i!=="render.asset.path"&&(i="render.asset.path"))}switch(e){case"library":this.openLibrary(t,i,s);break;case"ai-edit":this.openAIEditor(t,i,s);break;case"upload":this.openUpload(t,i);break;case"reset":await this.resetToDefault(t,i);break;case"ai-convert":this.handleAiConvert(t,i,s);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 s=((n=(i=t.transform)==null?void 0:i.scale)!=null?n:1)*.3;await this.updateManager.updateProperty(e,"transform.scale",s),console.log("[QuickActionsBar] Text to PNG conversion: set tint white, scale",s)}this.ensureSlotInRegistry(e,t)}ensureSlotInRegistry(e,t){var r,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=((r=t.identity)==null?void 0:r.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 s=window.__updateWorkbenchTabs;typeof s=="function"&&s()}if(n.libraryPanel){let s=window.getEditableObjectConfig,r=s==null?void 0:s(e),l=(a=r==null?void 0:r.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 s;let i=window.getEditableObjectConfig,n=i==null?void 0:i(e),a=((s=n==null?void 0:n.identity)==null?void 0:s.category)||(t.split(".")[0]==="render"?"environment":"ui");mn({objectId:e,category:a,onApply:async r=>{var g,h;console.log("[QuickActionsBar] Upload complete, applying asset:",r);let l=window.applyAssetToSlot,c=this.getFilenameFromPath(r),d=/render\.asset\.path/i.test(t)||/\.(png|jpg|jpeg|gif|webp)$/i.test(r);if(typeof l=="function"&&c&&d){console.log("[QuickActionsBar] Applying asset to slot:",e,c,a);try{await l(e,c,a),console.log("[QuickActionsBar] \u2705 Asset applied to slot")}catch(m){console.error("[QuickActionsBar] Failed to apply asset to slot:",m)}}console.log("[QuickActionsBar] Updating property:",e,t,r);try{await this.updateManager.updateProperty(e,t,r),console.log("[QuickActionsBar] \u2705 Property updated")}catch(m){console.error("[QuickActionsBar] Failed to update property:",m)}let p=window.__debugContext;(h=(g=p==null?void 0:p.options)==null?void 0:g.onPropertyChange)==null||h.call(g,e,t,r);let u=window.__highlightLibrarySlot;typeof u=="function"&&setTimeout(()=>{u(e,a)},1e3),window.dispatchEvent(new CustomEvent("inspector:refresh")),window.dispatchEvent(new CustomEvent("config:changed",{detail:{objectId:e,action:"update",path:t}})),console.log("[QuickActionsBar] \u2705 Upload and apply complete")}})}getFilenameFromPath(e){if(!e)return"";let t=e.split("?")[0].replace(/\\/g,"/");return t.split("/").pop()||t}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),s=window.__editableConfig;if(!(s!=null&&s.schemas))return;let r=null;if(s.schemas instanceof Map?r=s.schemas.get(n):typeof s.schemas=="object"&&(r=s.schemas[n]),!(r!=null&&r.defaults))return;let l=r.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 s=`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.`,r="render.asset.path";console.log("[QuickActionsBar] AI Convert for:",e,"from:",t,"to:",r),n(e,s,"",{objectId:e,path:r});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 qr=[{value:"loading",label:"Loading"},{value:"start",label:"Start"},{value:"gameplay",label:"Gameplay"},{value:"tutorial",label:"Tutorial"},{value:"endgame",label:"Endgame"}],Vr=["environment","ui","character","system","backgrounds"],Yr=["bg","world","ui"],Cs={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}}},ni=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">
@@ -1865,7 +1865,7 @@ Generate the requested asset matching the brand style.${o.needsTransparency?" Ba
1865
1865
  </div>
1866
1866
  </div>
1867
1867
  </div>
1868
- `}initialize(e,t){var y,w,v,T,P,_,I,j,L,S,x,E,A,C,k,R;this.options=t,this.root=e.querySelector('[data-panel="loading-screen"]');let n=(()=>{var O;let M=window.getEditableEngineConfig;if(typeof M=="function"){let D=M();return(O=D==null?void 0:D.loading)!=null?O:{}}return{}})(),a=(y=this.root)==null?void 0:y.querySelector("#loading-screen-type");a&&(a.value=n.type==="image"?"image":"color",a.addEventListener("change",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{type:a.value}),this.updateFieldVisibility(a.value)}));let s=(w=this.root)==null?void 0:w.querySelector("#loading-background-color");s&&(s.value=n.background_color||"#160a17",s.addEventListener("input",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{background_color:s.value})}));let r=(v=this.root)==null?void 0:v.querySelector("#loading-overlay-alpha"),l=(T=this.root)==null?void 0:T.querySelector("#loading-overlay-alpha-value");r&&(r.value=String((P=n.overlay_alpha)!=null?P:1),l&&(l.textContent=Number(r.value).toFixed(2)),r.addEventListener("input",()=>{var O,D;let M=Number(r.value);l&&(l.textContent=M.toFixed(2)),(D=(O=this.options)==null?void 0:O.onUpdateLoading)==null||D.call(O,{overlay_alpha:M})}));let c=(_=this.root)==null?void 0:_.querySelector("#loading-text");c&&(c.value=n.text||"",c.addEventListener("input",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{text:c.value})}));let d=(I=this.root)==null?void 0:I.querySelector("#loading-text-scale"),p=(j=this.root)==null?void 0:j.querySelector("#loading-text-scale-value");d&&(d.value=String((L=n.text_scale)!=null?L:.6),p&&(p.textContent=Number(d.value).toFixed(2)),d.addEventListener("input",()=>{var O,D;let M=Number(d.value);p&&(p.textContent=M.toFixed(2)),(D=(O=this.options)==null?void 0:O.onUpdateLoading)==null||D.call(O,{text_scale:M})}));let u=(S=this.root)==null?void 0:S.querySelector("#loading-enabled");u&&(u.checked=n.enabled!==!1,u.addEventListener("change",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{enabled:u.checked})}));let g=(x=this.root)==null?void 0:x.querySelector("#loading-blur-enabled");g&&(g.checked=n.blur_enabled!==!1,g.addEventListener("change",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{blur_enabled:g.checked})}));let h=(E=this.root)==null?void 0:E.querySelector("#loading-blur-strength"),m=(A=this.root)==null?void 0:A.querySelector("#loading-blur-strength-value");h&&(h.value=String((C=n.blur_strength)!=null?C:8),m&&(m.textContent=h.value),h.addEventListener("input",()=>{var M,O;m&&(m.textContent=h.value),(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{blur_strength:Number(h.value)})}));let f=(k=this.root)==null?void 0:k.querySelector("#loading-show-btn"),b=(R=this.root)==null?void 0:R.querySelector("#loading-hide-btn");f==null||f.addEventListener("click",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onShowLoadingScreen)==null||O.call(M)}),b==null||b.addEventListener("click",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onHideLoadingScreen)==null||O.call(M)}),this.updateFieldVisibility(n.type==="image"?"image":"color")}updateFieldVisibility(e){var n,a;let t=(n=this.root)==null?void 0:n.querySelector("#loading-color-field"),i=(a=this.root)==null?void 0:a.querySelector("#loading-alpha-field");e==="image"?(t&&(t.style.display="none"),i&&(i.style.display="none")):(t&&(t.style.display=""),i&&(i.style.display=""))}refresh(){}};import{Graphics as er,Point as Po}from"pixi.js";import{Point as Xs}from"pixi.js";var We=()=>window.debugConfig||{},Js=()=>window.resolveAnchorVec2||(o=>({x:.5,y:.5})),Zs=()=>window.resolveScreenAnchorPoint||(()=>new Xs),Qs=()=>window.resolveScreenRatioPoint||(()=>new Xs);function tr(o){$i(o)&&(o.objectDebugRaf||(o.objectDebugRaf=window.requestAnimationFrame(()=>Di(o))))}function ir(o){o.objectDebugRaf&&(window.cancelAnimationFrame(o.objectDebugRaf),o.objectDebugRaf=null),Ot(o)}function $i(o){return o.isDebugOpen}function Di(o){var a,s,r;if(!$i(o)){o.objectDebugRaf=null;return}o.objectDebugRaf=window.requestAnimationFrame(()=>Di(o));let e=An(o);if(!e){Rt(o,null),Ot(o);return}let t=Cn(o,e);if(!t){Rt(o,null),Ot(o);return}let i=new Po;(a=t.getGlobalPosition)==null||a.call(t,i);let n=Ln(o,t);Rt(o,{instanceId:e,worldX:i.x,worldY:i.y,configX:(s=n==null?void 0:n.x)!=null?s:null,configY:(r=n==null?void 0:n.y)!=null?r:null}),o.highlightObject?In(o,t):jn(o),o.highlightAnchor&&n?Mn(o,n):_n(o)}function An(o){var n;let e=o.selectedObjectId;if(!e)return null;let t=window.__editableObjectInstances,i=(n=t==null?void 0:t.get)==null?void 0:n.call(t,e);return Array.isArray(i)&&i.length>0?i[0]:e}function Cn(o,e){var n,a;let t=window.gameObjectManager,i=(n=t==null?void 0:t.get)==null?void 0:n.call(t,e);return i?((a=i.getDisplayObject)==null?void 0:a.call(i))||i.pixiObject||i:null}function zt(o){let e=o.selectedObjectId;if(!e)return null;let t=window.getEditableObjectConfig;return typeof t!="function"?null:t(e)}function Ln(o,e){var s,r;let t=zt(o);if(!t)return null;let i=(s=t.transform)!=null?s:{},n=kn(o);if(!n)return null;if(i.position_ratio!=null)return Qs()(n.width,n.height,i.position_ratio);let a=(r=i.anchor)!=null?r:"bottom-center";return a==="bottom-center"&&i.anchor==null&&console.log("[DEBUG FALLBACK] objectVisuals transform.anchor \u2192 bottom-center"),Zs()(n.width,n.height,a)}function kn(o){var a;let e=(a=o.container)==null?void 0:a.querySelector(".game-container"),t=Number(e==null?void 0:e.dataset.screenWidth),i=Number(e==null?void 0:e.dataset.screenHeight);if(Number.isFinite(t)&&t>0&&Number.isFinite(i)&&i>0)return{width:t,height:i};let n=window.gameApp;return n!=null&&n.renderer?{width:n.renderer.width,height:n.renderer.height}:null}function Tn(o){let e=window.gameApp;return e!=null&&e.stage?(o.objectBoundsGfx&&o.objectBoundsGfx.parent!==e.stage&&(o.objectBoundsGfx.destroy(),o.objectBoundsGfx=null),o.objectBoundsGfx||(o.objectBoundsGfx=new er,o.objectBoundsGfx.zIndex=999999,e.stage.addChild(o.objectBoundsGfx)),o.objectBoundsGfx):null}function Pn(o){let e=window.gameApp;return e!=null&&e.stage?(o.objectAnchorGfx&&o.objectAnchorGfx.parent!==e.stage&&(o.objectAnchorGfx.destroy(),o.objectAnchorGfx=null),o.objectAnchorGfx||(o.objectAnchorGfx=new er,o.objectAnchorGfx.zIndex=1e6,e.stage.addChild(o.objectAnchorGfx)),o.objectAnchorGfx):null}function In(o,e){var n;let t=Tn(o);if(!t)return;let i=(n=e.getBounds)==null?void 0:n.call(e);i&&(t.clear(),t.rect(i.x,i.y,i.width,i.height).stroke({width:2,color:16726832,alpha:.9}))}function Mn(o,e){let t=Pn(o);if(!t)return;let i=6;t.clear(),t.moveTo(e.x-i,e.y),t.lineTo(e.x+i,e.y),t.moveTo(e.x,e.y-i),t.lineTo(e.x,e.y+i),t.stroke({width:2,color:3066993,alpha:.9})}function jn(o){o.objectBoundsGfx&&o.objectBoundsGfx.clear()}function _n(o){o.objectAnchorGfx&&o.objectAnchorGfx.clear()}function Ot(o){o.objectBoundsGfx&&(o.objectBoundsGfx.destroy(),o.objectBoundsGfx=null),o.objectAnchorGfx&&(o.objectAnchorGfx.destroy(),o.objectAnchorGfx=null)}function Rt(o,e){o.sceneToolsPanel.updateInfo(e?{instanceId:e.instanceId,worldX:e.worldX,worldY:e.worldY,anchorX:e.configX,anchorY:e.configY}:null)}function nr(o,e){return e.split(".").reduce((t,i)=>t?t[i]:void 0,o)}function ar(o,e,t){var s;let i=e.split("."),n=i.pop(),a=o;for(let r of i)a[r]=(s=a[r])!=null?s:{},a=a[r];a[n]=t}function Rn(o){var i,n,a,s,r;if(!o)return!1;if((i=o.transform)!=null&&i.offset)return!0;let e=((a=(n=o.identity)==null?void 0:n.category)!=null?a:"").toString().toLowerCase(),t=((r=(s=o.identity)==null?void 0:s.id)!=null?r:"").toString().toLowerCase();return e.includes("ui")||t.startsWith("ui")||t.includes("label")}function Ni(o){let e=We();e.layout&&(e.layout.scale_multiplier=1,e.layout.position_offset={x:0,y:0},e.layout.debug_rect_visible=!0,e.layout.debug_rect_color=16711680,e.layout.debug_rect_thickness=4),e.engine&&(e.engine.scale=1,e.engine.background_scale=1.05,e.engine.label_pulse_speed=3,e.engine.label_pulse_intensity=.03),e.physics&&(e.physics.rope_length=420),window.location.reload()}function sr(o){window.location.reload()}function Fi(o){let e=JSON.stringify(We(),null,2);navigator.clipboard.writeText(e).then(()=>{alert("Debug config copied to clipboard!")}).catch(()=>{console.log(e),alert("Config logged to console (clipboard not available)")})}async function rr(o,e){var t,i,n;if(!(!o.configViewer||!o.container))try{let a=window.getEditableObjectConfig,s=typeof a=="function"?a(e):null;if(!s){let{loadObjectCentricConfig:r,loadObjectConfig:l}=await import("./config-HQX4AQNX.js"),p=(((t=(await r("scene.main")).scene)==null?void 0:t.objects)||[]).find(g=>g.object_config===e||g.instance_id===e);if(!p)return;let u=await l(p.object_config);console.log("[PREVIEW] Loaded object config (fallback)",e,u),Hi(o,u),(i=o.configViewer)==null||i.style.setProperty("display","block");return}console.log("[PREVIEW] Loaded object config",e,s),Hi(o,s),(n=o.configViewer)==null||n.style.setProperty("display","block");return}catch(a){console.error("[DEBUG] Failed to load object config:",a)}}function Hi(o,e){var u,g,h,m,f,b,y,w,v,T;if(!o.container)return;let t=o.container.querySelector("#config-pos-x"),i=o.container.querySelector("#config-pos-y"),n=o.container.querySelector("#config-scale"),a=o.container.querySelector("#config-anchor-preset"),s=o.container.querySelector("#config-anchor-x"),r=o.container.querySelector("#config-anchor-y"),c=Rn(e)?(u=e.transform)==null?void 0:u.offset:(g=e.transform)==null?void 0:g.position;t&&(t.value=String((h=c==null?void 0:c.x)!=null?h:0)),i&&(i.value=String((m=c==null?void 0:c.y)!=null?m:0)),n&&(n.value=String((b=(f=e.transform)==null?void 0:f.scale)!=null?b:1));let d=(T=(v=(y=e.transform)==null?void 0:y.anchor)!=null?v:(w=e.render)==null?void 0:w.anchor)!=null?T:"center";if(a){typeof d=="string"?a.value=d:a.value="custom";let P=o.container.querySelectorAll(".anchor-custom-field"),_=a.value==="custom";P.forEach(I=>I.style.display=_?"block":"none")}let p=Js()(d);s&&(s.value=String(p.x)),r&&(r.value=String(p.y))}function or(o){var l,c,d,p,u,g,h,m,f,b;let e=o.selectedObjectId;if(!e||!o.container)return;let t=(c=(l=o.container.querySelector("#config-pos-x"))==null?void 0:l.value)!=null?c:"0",i=(p=(d=o.container.querySelector("#config-pos-y"))==null?void 0:d.value)!=null?p:"0",n=(g=(u=o.container.querySelector("#config-scale"))==null?void 0:u.value)!=null?g:"1",a=(m=(h=o.container.querySelector("#config-anchor-x"))==null?void 0:h.value)!=null?m:"0.5",s=(b=(f=o.container.querySelector("#config-anchor-y"))==null?void 0:f.value)!=null?b:"0.5",r=`${e}:
1868
+ `}initialize(e,t){var y,w,v,T,P,_,I,j,L,S,x,E,A,C,k,R;this.options=t,this.root=e.querySelector('[data-panel="loading-screen"]');let n=(()=>{var O;let M=window.getEditableEngineConfig;if(typeof M=="function"){let D=M();return(O=D==null?void 0:D.loading)!=null?O:{}}return{}})(),a=(y=this.root)==null?void 0:y.querySelector("#loading-screen-type");a&&(a.value=n.type==="image"?"image":"color",a.addEventListener("change",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{type:a.value}),this.updateFieldVisibility(a.value)}));let s=(w=this.root)==null?void 0:w.querySelector("#loading-background-color");s&&(s.value=n.background_color||"#160a17",s.addEventListener("input",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{background_color:s.value})}));let r=(v=this.root)==null?void 0:v.querySelector("#loading-overlay-alpha"),l=(T=this.root)==null?void 0:T.querySelector("#loading-overlay-alpha-value");r&&(r.value=String((P=n.overlay_alpha)!=null?P:1),l&&(l.textContent=Number(r.value).toFixed(2)),r.addEventListener("input",()=>{var O,D;let M=Number(r.value);l&&(l.textContent=M.toFixed(2)),(D=(O=this.options)==null?void 0:O.onUpdateLoading)==null||D.call(O,{overlay_alpha:M})}));let c=(_=this.root)==null?void 0:_.querySelector("#loading-text");c&&(c.value=n.text||"",c.addEventListener("input",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{text:c.value})}));let d=(I=this.root)==null?void 0:I.querySelector("#loading-text-scale"),p=(j=this.root)==null?void 0:j.querySelector("#loading-text-scale-value");d&&(d.value=String((L=n.text_scale)!=null?L:.6),p&&(p.textContent=Number(d.value).toFixed(2)),d.addEventListener("input",()=>{var O,D;let M=Number(d.value);p&&(p.textContent=M.toFixed(2)),(D=(O=this.options)==null?void 0:O.onUpdateLoading)==null||D.call(O,{text_scale:M})}));let u=(S=this.root)==null?void 0:S.querySelector("#loading-enabled");u&&(u.checked=n.enabled!==!1,u.addEventListener("change",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{enabled:u.checked})}));let g=(x=this.root)==null?void 0:x.querySelector("#loading-blur-enabled");g&&(g.checked=n.blur_enabled!==!1,g.addEventListener("change",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{blur_enabled:g.checked})}));let h=(E=this.root)==null?void 0:E.querySelector("#loading-blur-strength"),m=(A=this.root)==null?void 0:A.querySelector("#loading-blur-strength-value");h&&(h.value=String((C=n.blur_strength)!=null?C:8),m&&(m.textContent=h.value),h.addEventListener("input",()=>{var M,O;m&&(m.textContent=h.value),(O=(M=this.options)==null?void 0:M.onUpdateLoading)==null||O.call(M,{blur_strength:Number(h.value)})}));let f=(k=this.root)==null?void 0:k.querySelector("#loading-show-btn"),b=(R=this.root)==null?void 0:R.querySelector("#loading-hide-btn");f==null||f.addEventListener("click",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onShowLoadingScreen)==null||O.call(M)}),b==null||b.addEventListener("click",()=>{var M,O;(O=(M=this.options)==null?void 0:M.onHideLoadingScreen)==null||O.call(M)}),this.updateFieldVisibility(n.type==="image"?"image":"color")}updateFieldVisibility(e){var n,a;let t=(n=this.root)==null?void 0:n.querySelector("#loading-color-field"),i=(a=this.root)==null?void 0:a.querySelector("#loading-alpha-field");e==="image"?(t&&(t.style.display="none"),i&&(i.style.display="none")):(t&&(t.style.display=""),i&&(i.style.display=""))}refresh(){}};import{Graphics as er,Point as Po}from"pixi.js";import{Point as Xs}from"pixi.js";var We=()=>window.debugConfig||{},Js=()=>window.resolveAnchorVec2||(o=>({x:.5,y:.5})),Zs=()=>window.resolveScreenAnchorPoint||(()=>new Xs),Qs=()=>window.resolveScreenRatioPoint||(()=>new Xs);function tr(o){$i(o)&&(o.objectDebugRaf||(o.objectDebugRaf=window.requestAnimationFrame(()=>Di(o))))}function ir(o){o.objectDebugRaf&&(window.cancelAnimationFrame(o.objectDebugRaf),o.objectDebugRaf=null),Ot(o)}function $i(o){return o.isDebugOpen}function Di(o){var a,s,r;if(!$i(o)){o.objectDebugRaf=null;return}o.objectDebugRaf=window.requestAnimationFrame(()=>Di(o));let e=An(o);if(!e){Rt(o,null),Ot(o);return}let t=Cn(o,e);if(!t){Rt(o,null),Ot(o);return}let i=new Po;(a=t.getGlobalPosition)==null||a.call(t,i);let n=Ln(o,t);Rt(o,{instanceId:e,worldX:i.x,worldY:i.y,configX:(s=n==null?void 0:n.x)!=null?s:null,configY:(r=n==null?void 0:n.y)!=null?r:null}),o.highlightObject?In(o,t):jn(o),o.highlightAnchor&&n?Mn(o,n):_n(o)}function An(o){var n;let e=o.selectedObjectId;if(!e)return null;let t=window.__editableObjectInstances,i=(n=t==null?void 0:t.get)==null?void 0:n.call(t,e);return Array.isArray(i)&&i.length>0?i[0]:e}function Cn(o,e){var n,a;let t=window.gameObjectManager,i=(n=t==null?void 0:t.get)==null?void 0:n.call(t,e);return i?((a=i.getDisplayObject)==null?void 0:a.call(i))||i.pixiObject||i:null}function zt(o){let e=o.selectedObjectId;if(!e)return null;let t=window.getEditableObjectConfig;return typeof t!="function"?null:t(e)}function Ln(o,e){var s,r;let t=zt(o);if(!t)return null;let i=(s=t.transform)!=null?s:{},n=kn(o);if(!n)return null;if(i.position_ratio!=null)return Qs()(n.width,n.height,i.position_ratio);let a=(r=i.anchor)!=null?r:"bottom-center";return a==="bottom-center"&&i.anchor==null&&console.log("[DEBUG FALLBACK] objectVisuals transform.anchor \u2192 bottom-center"),Zs()(n.width,n.height,a)}function kn(o){var a;let e=(a=o.container)==null?void 0:a.querySelector(".game-container"),t=Number(e==null?void 0:e.dataset.screenWidth),i=Number(e==null?void 0:e.dataset.screenHeight);if(Number.isFinite(t)&&t>0&&Number.isFinite(i)&&i>0)return{width:t,height:i};let n=window.gameApp;return n!=null&&n.renderer?{width:n.renderer.width,height:n.renderer.height}:null}function Tn(o){let e=window.gameApp;return e!=null&&e.stage?(o.objectBoundsGfx&&o.objectBoundsGfx.parent!==e.stage&&(o.objectBoundsGfx.destroy(),o.objectBoundsGfx=null),o.objectBoundsGfx||(o.objectBoundsGfx=new er,o.objectBoundsGfx.zIndex=999999,e.stage.addChild(o.objectBoundsGfx)),o.objectBoundsGfx):null}function Pn(o){let e=window.gameApp;return e!=null&&e.stage?(o.objectAnchorGfx&&o.objectAnchorGfx.parent!==e.stage&&(o.objectAnchorGfx.destroy(),o.objectAnchorGfx=null),o.objectAnchorGfx||(o.objectAnchorGfx=new er,o.objectAnchorGfx.zIndex=1e6,e.stage.addChild(o.objectAnchorGfx)),o.objectAnchorGfx):null}function In(o,e){var n;let t=Tn(o);if(!t)return;let i=(n=e.getBounds)==null?void 0:n.call(e);i&&(t.clear(),t.rect(i.x,i.y,i.width,i.height).stroke({width:2,color:16726832,alpha:.9}))}function Mn(o,e){let t=Pn(o);if(!t)return;let i=6;t.clear(),t.moveTo(e.x-i,e.y),t.lineTo(e.x+i,e.y),t.moveTo(e.x,e.y-i),t.lineTo(e.x,e.y+i),t.stroke({width:2,color:3066993,alpha:.9})}function jn(o){o.objectBoundsGfx&&o.objectBoundsGfx.clear()}function _n(o){o.objectAnchorGfx&&o.objectAnchorGfx.clear()}function Ot(o){o.objectBoundsGfx&&(o.objectBoundsGfx.destroy(),o.objectBoundsGfx=null),o.objectAnchorGfx&&(o.objectAnchorGfx.destroy(),o.objectAnchorGfx=null)}function Rt(o,e){o.sceneToolsPanel.updateInfo(e?{instanceId:e.instanceId,worldX:e.worldX,worldY:e.worldY,anchorX:e.configX,anchorY:e.configY}:null)}function nr(o,e){return e.split(".").reduce((t,i)=>t?t[i]:void 0,o)}function ar(o,e,t){var s;let i=e.split("."),n=i.pop(),a=o;for(let r of i)a[r]=(s=a[r])!=null?s:{},a=a[r];a[n]=t}function Rn(o){var i,n,a,s,r;if(!o)return!1;if((i=o.transform)!=null&&i.offset)return!0;let e=((a=(n=o.identity)==null?void 0:n.category)!=null?a:"").toString().toLowerCase(),t=((r=(s=o.identity)==null?void 0:s.id)!=null?r:"").toString().toLowerCase();return e.includes("ui")||t.startsWith("ui")||t.includes("label")}function Ni(o){let e=We();e.layout&&(e.layout.scale_multiplier=1,e.layout.position_offset={x:0,y:0},e.layout.debug_rect_visible=!0,e.layout.debug_rect_color=16711680,e.layout.debug_rect_thickness=4),e.engine&&(e.engine.scale=1,e.engine.background_scale=1.05,e.engine.label_pulse_speed=3,e.engine.label_pulse_intensity=.03),e.physics&&(e.physics.rope_length=420),window.location.reload()}function sr(o){window.location.reload()}function Fi(o){let e=JSON.stringify(We(),null,2);navigator.clipboard.writeText(e).then(()=>{alert("Debug config copied to clipboard!")}).catch(()=>{console.log(e),alert("Config logged to console (clipboard not available)")})}async function rr(o,e){var t,i,n;if(!(!o.configViewer||!o.container))try{let a=window.getEditableObjectConfig,s=typeof a=="function"?a(e):null;if(!s){let{loadObjectCentricConfig:r,loadObjectConfig:l}=await import("./config-VHVTBJGB.js"),p=(((t=(await r("scene.main")).scene)==null?void 0:t.objects)||[]).find(g=>g.object_config===e||g.instance_id===e);if(!p)return;let u=await l(p.object_config);console.log("[PREVIEW] Loaded object config (fallback)",e,u),Hi(o,u),(i=o.configViewer)==null||i.style.setProperty("display","block");return}console.log("[PREVIEW] Loaded object config",e,s),Hi(o,s),(n=o.configViewer)==null||n.style.setProperty("display","block");return}catch(a){console.error("[DEBUG] Failed to load object config:",a)}}function Hi(o,e){var u,g,h,m,f,b,y,w,v,T;if(!o.container)return;let t=o.container.querySelector("#config-pos-x"),i=o.container.querySelector("#config-pos-y"),n=o.container.querySelector("#config-scale"),a=o.container.querySelector("#config-anchor-preset"),s=o.container.querySelector("#config-anchor-x"),r=o.container.querySelector("#config-anchor-y"),c=Rn(e)?(u=e.transform)==null?void 0:u.offset:(g=e.transform)==null?void 0:g.position;t&&(t.value=String((h=c==null?void 0:c.x)!=null?h:0)),i&&(i.value=String((m=c==null?void 0:c.y)!=null?m:0)),n&&(n.value=String((b=(f=e.transform)==null?void 0:f.scale)!=null?b:1));let d=(T=(v=(y=e.transform)==null?void 0:y.anchor)!=null?v:(w=e.render)==null?void 0:w.anchor)!=null?T:"center";if(a){typeof d=="string"?a.value=d:a.value="custom";let P=o.container.querySelectorAll(".anchor-custom-field"),_=a.value==="custom";P.forEach(I=>I.style.display=_?"block":"none")}let p=Js()(d);s&&(s.value=String(p.x)),r&&(r.value=String(p.y))}function or(o){var l,c,d,p,u,g,h,m,f,b;let e=o.selectedObjectId;if(!e||!o.container)return;let t=(c=(l=o.container.querySelector("#config-pos-x"))==null?void 0:l.value)!=null?c:"0",i=(p=(d=o.container.querySelector("#config-pos-y"))==null?void 0:d.value)!=null?p:"0",n=(g=(u=o.container.querySelector("#config-scale"))==null?void 0:u.value)!=null?g:"1",a=(m=(h=o.container.querySelector("#config-anchor-x"))==null?void 0:h.value)!=null?m:"0.5",s=(b=(f=o.container.querySelector("#config-anchor-y"))==null?void 0:f.value)!=null?b:"0.5",r=`${e}:
1869
1869
  position: (${t}, ${i})
1870
1870
  scale: ${n}
1871
1871
  anchor: (${a}, ${s})`;navigator.clipboard.writeText(r).then(()=>console.log("[DEBUG] Config values copied to clipboard")).catch(y=>console.error("[DEBUG] Failed to copy config values:",y))}async function On(o,e){var u,g,h,m,f,b,y,w,v,T,P,_;if(console.log("[INSPECTOR] \u{1F527} applyObjectConfig called"),!o.container)return;let t=o.selectedObjectId;if(!t){console.warn("[PREVIEW] Apply object config clicked with no selection");return}let i=Number((g=(u=o.container.querySelector("#config-pos-x"))==null?void 0:u.value)!=null?g:0),n=Number((m=(h=o.container.querySelector("#config-pos-y"))==null?void 0:h.value)!=null?m:0),a=Number((b=(f=o.container.querySelector("#config-scale"))==null?void 0:f.value)!=null?b:1),s=(w=(y=o.container.querySelector("#config-anchor-preset"))==null?void 0:y.value)!=null?w:"center",r=Number((T=(v=o.container.querySelector("#config-anchor-x"))==null?void 0:v.value)!=null?T:.5),l=Number((_=(P=o.container.querySelector("#config-anchor-y"))==null?void 0:P.value)!=null?_:.5),c=s==="custom"?{x:r,y:l}:s;console.log("[INSPECTOR] Applying config for:",t,{posX:i,posY:n,scale:a,anchor:c});let{applyConfigOverride:d}=await import("./ConfigOverride-SLXAGR2M.js");d({objectId:t,path:"transform.position",value:{x:i,y:n}},{silent:e==null?void 0:e.silent}),d({objectId:t,path:"transform.scale",value:a},{silent:e==null?void 0:e.silent}),d({objectId:t,path:"transform.anchor",value:c},{silent:e==null?void 0:e.silent});let p=zt(o);Rn(p)&&d({objectId:t,path:"transform.offset",value:{x:i,y:n}},{silent:!0})}async function lr(o,e,t){let{applyConfigOverride:i}=await import("./ConfigOverride-SLXAGR2M.js");Object.entries(e.assets).forEach(([l,c])=>{i({path:`assets.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.theme).forEach(([l,c])=>{i({path:`runtime.theme.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.ui).forEach(([l,c])=>{i({path:`runtime.ui.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.fonts).forEach(([l,c])=>{i({path:`runtime.fonts.${l}`,value:c},{silent:!0})}),Object.entries(e.runtime.audio).forEach(([l,c])=>{i({path:`runtime.audio.${l}`,value:c},{silent:!0})});let n=window.applyEditableEngineConfig;if(typeof n=="function"){let l={theme:e.runtime.theme,fonts:e.runtime.fonts,audio:e.runtime.audio},c={};Object.entries(e.runtime.ui).forEach(([d,p])=>{var u;if(d)if(d.includes(".")){let g=d.split("."),h=c;for(let m=0;m<g.length-1;m++){let f=g[m];h[f]=(u=h[f])!=null?u:{},h=h[f]}h[g[g.length-1]]=p}else c[d]=p}),l.ui=c,n({runtime:l,assets:e.assets})}let a=Object.values(e.assets).some(l=>/^(blob:|data:)/.test(l)),s=(t==null?void 0:t.source)!=="auto"&&!a,r=window.__previewShell;s&&(r!=null&&r.refresh)&&r.refresh()}function cr(o){o.selectedObjectId&&(o.objectAutoApplyTimer&&window.clearTimeout(o.objectAutoApplyTimer),o.objectAutoApplyTimer=window.setTimeout(()=>{o.objectAutoApplyTimer=null,On(o,{silent:!0})},150))}var Io=3e3;function et(o,e,t){let i=t!=null?t:o.offsetParent;if(!i)return;e.style.cursor="move";let n=!1,a=0,s=0,r=0,l=0,c=0,d=0,p=g=>{if(!n)return;let h=i.getBoundingClientRect();o.style.left=`${g.clientX-h.left-c}px`,o.style.top=`${g.clientY-h.top-d}px`},u=()=>{n&&(n=!1,o.classList.remove("dragging"),window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",u))};e.addEventListener("pointerdown",g=>{if(g.button!==0)return;let h=g.target;if(h!=null&&h.closest("button, input, select, textarea"))return;g.preventDefault();let m=o.getBoundingClientRect(),f=i.getBoundingClientRect();console.log("[DRAG] Panel:",o.className),console.log("[DRAG] Container:",i.className),console.log("[DRAG] panelRect:",{left:m.left,top:m.top,width:m.width,height:m.height}),console.log("[DRAG] containerRect:",{left:f.left,top:f.top,width:f.width,height:f.height}),console.log("[DRAG] mouse:",{x:g.clientX,y:g.clientY}),c=g.clientX-m.left,d=g.clientY-m.top,console.log("[DRAG] offset:",{x:c,y:d});let b=m.left-f.left,y=m.top-f.top;console.log("[DRAG] targetPosition:",{left:b,top:y}),o.style.left=`${b}px`,o.style.top=`${y}px`,o.style.right="auto",o.style.bottom="auto",o.style.zIndex=String(++Io),n=!0,o.classList.add("dragging"),window.addEventListener("pointermove",p),window.addEventListener("pointerup",u)})}function Bi(o,e,t,i=280,n=200){e.style.cursor="nwse-resize";let a=0,s=0,r=0,l=0,c=!1,d=u=>{var y;if(!c)return;let g=u.clientX-r,h=u.clientY-l,m=Math.max(i,a+g),f=Math.max(n,s+h);o.style.width=`${m}px`,(y=o.closest(".preview-shell"))!=null&&y.classList.contains("layout-fixed")||(o.style.height=`${f}px`),t==null||t(m,f)},p=()=>{c&&(c=!1,window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p))};e.addEventListener("pointerdown",u=>{if(u.button!==0)return;u.preventDefault(),u.stopPropagation();let g=o.getBoundingClientRect();a=g.width,s=g.height,r=u.clientX,l=u.clientY,c=!0,window.addEventListener("pointermove",d),window.addEventListener("pointerup",p)})}function zn(o,e){var m,f,b,y;let t=(b=(f=(m=o.container)==null?void 0:m.querySelector("#debug-overlay"))!=null?f:o.debugOverlay)!=null?b:e.offsetParent;if(!t||(y=o.container)!=null&&y.classList.contains("layout-fixed"))return;let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),a=12,s=Math.max(250,Math.floor(i.width-a*2)),r=Math.max(200,Math.floor(i.height-a*2));n.width>s&&(e.style.width=`${s}px`),n.height>r&&(e.style.height=`${r}px`);let l=e.getBoundingClientRect(),c=l.left-i.left,d=l.top-i.top,p=Math.max(a,i.width-l.width-a),u=Math.max(a,i.height-l.height-a),g=Math.min(Math.max(c,a),p),h=Math.min(Math.max(d,a),u);e.style.left=`${Math.round(g)}px`,e.style.top=`${Math.round(h)}px`,e.style.right="auto",e.style.bottom="auto"}function ht(o){var i,n;if(!o.container)return;let e=o.container.querySelector("#debug-workbench");if(!e)return;if(zn(o,e),(i=o.container)!=null&&i.classList.contains("layout-fixed")){let a=localStorage.getItem("preview_workbench_state"),s={activeTab:o.activeTab};if(a)try{s={...JSON.parse(a),activeTab:o.activeTab}}catch{}localStorage.setItem("preview_workbench_state",JSON.stringify(s));return}let t={activeTab:o.activeTab,width:e.style.width,height:(n=o.container)!=null&&n.classList.contains("layout-fixed")?"":e.style.height,left:e.style.left,top:e.style.top};localStorage.setItem("preview_workbench_state",JSON.stringify(t))}function Gi(o){try{let e=localStorage.getItem("preview_workbench_state");if(!e)return;let t=JSON.parse(e);t.activeTab&&(o.activeTab=t.activeTab),window.requestAnimationFrame(()=>{var n,a;let i=(n=o.container)==null?void 0:n.querySelector("#debug-workbench");if(i){let s=(a=o.container)==null?void 0:a.classList.contains("layout-fixed");t.width&&(i.style.width=t.width),t.height&&!s?i.style.height=t.height:s&&(i.style.height=""),t.left&&(i.style.left=t.left,i.style.right="auto"),t.top&&(i.style.top=t.top,i.style.bottom="auto"),zn(o,i)}})}catch(e){console.warn("[PREVIEW] Failed to load workbench state",e)}}function $n(o,e){let t=e.getBoundingClientRect();(t.left<0||t.top<0||t.right>window.innerWidth||t.bottom>window.innerHeight)&&(console.warn("[Workbench] Workbench positioned outside viewport, repositioning..."),e.style.left="16px",e.style.top="72px",e.style.right="auto",e.style.bottom="auto",zn(o,e),ht(o))}function dr(o){var n,a,s;if(!o.container)return;let e=o.container,t=e.querySelector("#debug-toggle");t||console.warn("[PREVIEW] Debug toggle not found in DOM"),t==null||t.addEventListener("click",()=>{var r;console.log("[PREVIEW] Debug toggle clicked"),(r=o.toggleDebug)==null||r.call(o)}),(n=e.querySelector("#debug-close"))==null||n.addEventListener("click",()=>{var r;return(r=o.toggleDebug)==null?void 0:r.call(o,!1)}),(a=e.querySelector("#debug-reset"))==null||a.addEventListener("click",()=>Ni(o)),(s=e.querySelector("#debug-export"))==null||s.addEventListener("click",()=>Fi(o)),e.querySelectorAll(".workbench-tab").forEach(r=>{r.addEventListener("click",()=>{let l=r.dataset.tab;o.activeTab=l,Dn(o),ht(o)})}),Nn(o,e),Hn(o,e)}function Dn(o){var n,a;if(!o.container)return;let e=o.container;e.querySelectorAll(".workbench-tab").forEach(s=>{let r=s.dataset.tab;s.classList.toggle("active",r===o.activeTab)}),e.querySelectorAll(".workbench-tab-panel").forEach(s=>{let r=s.dataset.tabPanel;s.classList.toggle("active",r===o.activeTab)}),o.activeTab==="library"&&o.libraryPanel&&((a=(n=o.libraryPanel).resetSearch)==null||a.call(n))}function Hn(o,e){Ae(o,e,"debug-layout-scale","layout.scale_multiplier","#debug-layout-scale-value"),Ae(o,e,"debug-layout-offset-x","layout.position_offset.x","#debug-layout-offset-x-value"),Ae(o,e,"debug-layout-offset-y","layout.position_offset.y","#debug-layout-offset-y-value"),Ae(o,e,"debug-rect-thickness","layout.debug_rect_thickness","#debug-rect-thickness-value"),Ae(o,e,"debug-engine-scale","engine.scale","#debug-engine-scale-value"),Ae(o,e,"debug-background-scale","engine.background_scale","#debug-background-scale-value"),Ae(o,e,"debug-label-pulse-speed","engine.label_pulse_speed","#debug-label-pulse-speed-value"),Ae(o,e,"debug-label-pulse-intensity","engine.label_pulse_intensity","#debug-label-pulse-intensity-value"),Ae(o,e,"debug-rope-length","physics.rope_length","#debug-rope-length-value");let t=e.querySelector("#debug-rect-visible");t==null||t.addEventListener("change",()=>{let n=We();n.layout&&(n.layout.debug_rect_visible=!!t.checked)});let i=e.querySelector("#debug-rect-color");i==null||i.addEventListener("input",()=>{let n=i.value.replace("#",""),a=parseInt(n,16),s=We();s.layout&&(s.layout.debug_rect_color=Number.isFinite(a)?a:16711680)})}function pr(o){if(!o.container||!o.debugOverlay)return;let e=o.container.querySelector("#debug-workbench"),t=o.container.querySelector("#workbench-handle");e&&t&&(!e.style.left&&!e.style.right&&!e.style.top&&!e.style.bottom&&(e.style.right="16px",e.style.top="72px"),et(e,t,o.debugOverlay),t.addEventListener("pointerup",()=>{setTimeout(()=>{ht(o),$n(o,e)},10)}));let i=o.container.querySelector('[data-panel="scene-objects"]'),n=i==null?void 0:i.querySelector("[data-panel-handle]"),a=i==null?void 0:i.querySelector("[data-panel-resize-v]");i&&n&&(!i.style.left&&!i.style.right&&!i.style.top&&!i.style.bottom&&(i.style.left="16px",i.style.top="72px"),et(i,n,o.debugOverlay),n.addEventListener("pointerup",()=>{setTimeout(()=>{$n(o,i)},10)})),i&&a&&Bi(i,a);let s=o.container.querySelector('[data-panel="scene-tools-corner"]'),r=s==null?void 0:s.querySelector("[data-panel-handle]");s&&r&&et(s,r,o.debugOverlay);let l=o.container.querySelector('[data-panel="nudge-panel"]'),c=l==null?void 0:l.querySelector("[data-panel-handle]");l&&c&&et(l,c,o.debugOverlay),Gi(o)}function Nn(o,e){Array.from(e.querySelectorAll("[data-panel-toggle]")).forEach(i=>{i.addEventListener("click",()=>{let n=i.closest(".scene-panel");n&&n.classList.toggle("collapsed")})})}function Ae(o,e,t,i,n){let a=e.querySelector(`#${t}`),s=e.querySelector(n);if(!a||!s)return;let r=nr(We(),i);typeof r=="number"&&(a.value=String(r),s.textContent=String(r)),a.addEventListener("input",()=>{let l=Number(a.value);s.textContent=String(l),ar(We(),i,l)})}var Ui=class{constructor(){this.container=null;this.currentVersion=null;this.availableVersions=[];this.isDevelopmentMode=!1}async forceResyncAfterApply(){var e;try{let t=window.__HANDLER_ACTIVE_SCREEN;await fetch("/api/sync-screens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:!0,screenId:t})})}catch(t){console.warn("[ConfigPersistence] sync-screens failed:",t)}try{let t=window.__HANDLER_REFRESH_SCREEN_INDEX;typeof t=="function"?await t():window.dispatchEvent(new CustomEvent("handler:screen-index-loaded"))}catch{}try{(e=window.refreshEditableConfigIndex)==null||e.call(window)}catch{}try{window.dispatchEvent(new CustomEvent("handler:scene-objects-refresh")),window.dispatchEvent(new CustomEvent("inspector:refresh")),window.dispatchEvent(new CustomEvent("config:changed",{detail:{action:"batch"}}))}catch{}}async initialize(e){this.container=e,this.isDevelopmentMode=typeof window!="undefined"&&document.querySelector('script[type="module"][src*="/@vite/"]')!==null,await this.loadVersionsList(),window.addEventListener("config:changed",()=>{this.refreshPanel()}),this.refreshPanel()}render(){let e=rt(),{hasChanges:t,overrideCount:i,overrides:n}=e,a={};for(let d of n){let p=d.objectId||"Engine";a[p]||(a[p]=[]),a[p].push(d)}let s=localStorage.getItem("handler_last_applied"),r=s?new Date(parseInt(s)).toLocaleString():"Never",l=this.currentVersion?`Version: ${this.currentVersion} (Active)`:"Original",c=this.currentVersion?`Versioned (${this.currentVersion})`:"Global";return`