handler-playable-sdk 0.2.7 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigOverride-6YH2ILBJ.mjs +1 -0
- package/dist/chunk-BDZGKN5O.mjs +1 -0
- package/dist/chunk-GYW3GFXA.mjs +830 -0
- package/dist/chunk-HN7I4BLB.mjs +1 -0
- package/dist/config-QLS2MDB6.mjs +1 -0
- package/dist/index.css +1 -0
- package/dist/index.d.mts +388 -2
- package/dist/index.d.ts +388 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/loader-object-centric-C1QteFfG.d.mts +81 -0
- package/dist/loader-object-centric-C1QteFfG.d.ts +81 -0
- package/dist/pixi/index.css +1 -0
- package/dist/pixi/index.d.mts +407 -93
- package/dist/pixi/index.d.ts +407 -93
- package/dist/pixi/index.js +9 -9
- package/dist/pixi/index.mjs +1 -11
- package/dist/three/index.css +1 -0
- package/dist/three/index.js +55 -55
- package/dist/three/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-UVBNGLP3.mjs +0 -17
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
import{i as Yt}from"./chunk-BDZGKN5O.mjs";import{a as Ut,b as On,d as Rn}from"./chunk-HN7I4BLB.mjs";import{Application as So}from"pixi.js";var ze={};function Wt(s,e,t=!1){ze[s]||(ze[s]=[]),ze[s].push({fn:e,once:t})}function Hn(s,e){if(ze[s]){if(!e){delete ze[s];return}ze[s]=ze[s].filter(t=>t.fn!==e)}}function Vt(s,...e){let t=ze[s];if(t)for(let n of[...t])n.fn(...e),n.once&&Hn(s,n.fn)}function re(s,e){Wt(s,e,!0)}var le=0,Xs=le++,ka=le++,Ia=le++,Pa=le++,Oa=le++,Ra=le++,Ha=le++,Ba=le++,Da=le++,za=le++,ja=le++,Fa=le++,U=Xs;function Na(){return U===ka}function $a(){return U===Ia}function Ga(){return U===Pa}function qa(){return U===Oa}function tt(){return U===Ra}function nt(){return U===Ha}function Ua(){return U===Ba}function Ya(){return U===Da}function Wa(){return U===za}function Bn(){return U===ja}function Dn(){return U===Fa}function Va(){let s=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(s==="mraid")try{mraid.getState(),U=ka;return}catch{}else if(s==="dapi")try{dapi.isReady(),U=Ia;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(U=Pa)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(U=Oa)}catch{}else if(e==="mintegral")window.gameReady&&(U=Ra);else if(e==="tapjoy")window.TJ_API&&(U=Ha);else if(e==="tiktok")window.openAppStore&&(U=Ba);else if(e==="smadex")try{window.smxTracking&&(U=Da)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(U=za)}catch{}else e==="vungle"?U=ja:(s==="nucleo"||e==="nucleo")&&(U=Fa)}import zn from"lottie-web";var Xa=zn;typeof window!="undefined"&&(window.lottie=zn,window.__baseLottie=zn);function W(s,e){let t=(i,a)=>a===0?i:t(a,i%a),n=t(s,e);return`${s/n}:${e/n}`}var _r=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:W(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:W(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:W(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:W(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:W(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:W(360,780)}],Ar=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:W(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:W(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:W(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:W(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:W(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:W(412,915)}],Tr=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:W(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:W(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:W(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:W(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:W(800,1280)}],jn=[{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:W(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:W(768,1024),mraidScale:.7}];var Ka=[...jn],Ja=[{category:"playable",label:"Playable Ad",devices:jn}],Fn=jn[0];function it(s){return Ka.find(e=>e.id===s)||Fn}function Cr(s){return Ka.filter(e=>e.category===s)}import{Graphics as rs,Point as Gn,Assets as ln,AnimatedSprite as ls}from"pixi.js";var Xt=class{constructor(){this.root=null;this.listContainer=null;this.searchInput=null;this.selectedId=null;this.options=null;this.retryTimer=null;this.filterMode="all"}render(){return`
|
|
2
|
+
<div class="scene-panel scene-objects panel-accent-teal" data-panel="scene-objects" style="left:16px; top:72px;">
|
|
3
|
+
<div class="scene-panel-header" data-panel-handle>
|
|
4
|
+
<div class="panel-title">
|
|
5
|
+
<span class="panel-pill">Hierarchy</span>
|
|
6
|
+
<span class="panel-title-text">Scene Objects</span>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="scene-panel-actions">
|
|
9
|
+
<button class="scene-panel-toggle" type="button" data-panel-toggle>\u25BE</button>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="scene-panel-body">
|
|
13
|
+
<div class="scene-panel-search">
|
|
14
|
+
<input type="text" id="scene-object-search" placeholder="Search ids, tags, UI">
|
|
15
|
+
</div>
|
|
16
|
+
<div class="scene-panel-filters">
|
|
17
|
+
<button class="filter-chip active" type="button" data-filter="all">All</button>
|
|
18
|
+
<button class="filter-chip" type="button" data-filter="ui">UI</button>
|
|
19
|
+
<button class="filter-chip" type="button" data-filter="scene">Scene</button>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="scene-object-list" data-object-list></div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
`}initialize(e,t){var i,a,o,r,l;this.options=t,this.root=e.querySelector('[data-panel="scene-objects"]'),this.listContainer=(i=this.root)==null?void 0:i.querySelector("[data-object-list]"),this.searchInput=(a=this.root)==null?void 0:a.querySelector("#scene-object-search"),(o=this.searchInput)==null||o.addEventListener("input",()=>this.refreshObjects());let n=Array.from(((r=this.root)==null?void 0:r.querySelectorAll("[data-filter]"))||[]);n.forEach(c=>{c.addEventListener("click",()=>{let u=c.dataset.filter;u&&(this.filterMode=u,n.forEach(d=>d.classList.toggle("active",d.dataset.filter===u)),this.refreshObjects())})}),(l=this.root)==null||l.addEventListener("click",c=>{let u=c.target;if(!u)return;let d=u.closest("[data-object-id]");if(!d)return;let p=d.dataset.objectId;p&&this.select(p)})}setSelected(e){if(this.selectedId=e,!this.listContainer)return;Array.from(this.listContainer.querySelectorAll("[data-object-id]")).forEach(n=>{n.classList.toggle("selected",n.dataset.objectId===e)})}refreshObjects(){var d;if(!this.listContainer)return;let e=window.getEditableObjectList,t=window.getEditableObjectConfig,n=window.refreshEditableConfigIndex;if(typeof n=="function"&&n(),typeof e!="function"){this.scheduleRetry();return}let i=e();if(!Array.isArray(i)||i.length===0){let p=window.__editableObjectConfigs;p&&typeof p.keys=="function"&&(i=Array.from(p.keys()))}if(!Array.isArray(i)||i.length===0){this.scheduleRetry();return}let a=(((d=this.searchInput)==null?void 0:d.value)||"").trim().toLowerCase(),o=[];i.forEach(p=>{var S,A,I;let h=typeof t=="function"?t(p):null;if(!h){let T=window.__editableObjectConfigs;T&&typeof T.get=="function"&&(h=(S=T.get(p))!=null?S:null)}let g=(((A=h==null?void 0:h.identity)==null?void 0:A.category)||"scene").toString(),b=(((I=h==null?void 0:h.identity)==null?void 0:I.id)||p).toString(),f=g.toLowerCase(),m=b.toLowerCase(),y=f.includes("ui")||m.startsWith("ui")||m.includes("label"),w={id:p,label:b||p,category:g,isUi:y};(!a||w.id.toLowerCase().includes(a)||w.label.toLowerCase().includes(a))&&o.push(w)});let r=o.filter(p=>p.isUi),l=o.filter(p=>!p.isUi),c=this.filterMode==="scene"?[]:r,u=this.filterMode==="ui"?[]:l;this.listContainer.innerHTML=`
|
|
25
|
+
${this.renderGroup("UI",c)}
|
|
26
|
+
${this.renderGroup("Scene",u)}
|
|
27
|
+
`,this.setSelected(this.selectedId)}renderGroup(e,t){if(!t.length)return"";let n=t.map(i=>`
|
|
28
|
+
<button class="scene-object-item" data-object-id="${i.id}">
|
|
29
|
+
<span class="scene-object-label">${i.label}</span>
|
|
30
|
+
<span class="scene-object-badge ${i.isUi?"ui":"scene"}">${i.category}</span>
|
|
31
|
+
</button>
|
|
32
|
+
`).join("");return`
|
|
33
|
+
<div class="scene-object-group">
|
|
34
|
+
<div class="scene-object-group-title">${e} <span class="scene-object-count">${t.length}</span></div>
|
|
35
|
+
<div class="scene-object-group-items">
|
|
36
|
+
${n}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
`}scheduleRetry(){this.retryTimer||(this.retryTimer=window.setTimeout(()=>{this.retryTimer=null,this.refreshObjects()},400))}select(e){var t;this.selectedId=e,this.setSelected(e),(t=this.options)==null||t.onSelect(e)}};var Kt=class{constructor(){this.root=null;this.selectedLabel=null;this.configViewer=null;this.options=null}render(){return`
|
|
40
|
+
<div class="scene-panel scene-edit panel-accent-blue" data-panel="scene-edit">
|
|
41
|
+
<div class="scene-panel-header" data-panel-handle>
|
|
42
|
+
<div class="panel-title">
|
|
43
|
+
<span class="panel-pill">Inspector</span>
|
|
44
|
+
<span class="panel-title-text">Scene Edit</span>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="scene-panel-actions">
|
|
47
|
+
<button class="scene-panel-toggle" type="button" data-panel-toggle>\u25BE</button>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="scene-panel-body">
|
|
51
|
+
<div class="scene-edit-selected">
|
|
52
|
+
Selected <span id="scene-selected-id">\u2014</span>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div id="config-viewer" class="config-editor" style="display:none;">
|
|
56
|
+
<div class="panel-section">
|
|
57
|
+
<div class="panel-section-title">Transform</div>
|
|
58
|
+
<div class="field-grid">
|
|
59
|
+
<div class="debug-field">
|
|
60
|
+
<label>Position X</label>
|
|
61
|
+
<input type="number" id="config-pos-x" step="1" value="0">
|
|
62
|
+
</div>
|
|
63
|
+
<div class="debug-field">
|
|
64
|
+
<label>Position Y</label>
|
|
65
|
+
<input type="number" id="config-pos-y" step="1" value="0">
|
|
66
|
+
</div>
|
|
67
|
+
<div class="debug-field">
|
|
68
|
+
<label>Scale</label>
|
|
69
|
+
<input type="number" id="config-scale" step="0.01" value="1.0">
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<div class="panel-section">
|
|
75
|
+
<div class="panel-section-title">Anchor</div>
|
|
76
|
+
<div class="field-grid">
|
|
77
|
+
<div class="debug-field">
|
|
78
|
+
<label>Anchor X</label>
|
|
79
|
+
<input type="number" id="config-anchor-x" min="0" max="1" step="0.01" value="0.5">
|
|
80
|
+
</div>
|
|
81
|
+
<div class="debug-field">
|
|
82
|
+
<label>Anchor Y</label>
|
|
83
|
+
<input type="number" id="config-anchor-y" min="0" max="1" step="0.01" value="0.5">
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div class="debug-btn-group">
|
|
89
|
+
<button id="apply-object-config" class="debug-btn primary">Apply Changes</button>
|
|
90
|
+
<button id="copy-config-values" class="debug-btn">Copy Values</button>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
`}initialize(e,t){var o,r,l,c;this.options=t,this.root=e.querySelector('[data-panel="scene-edit"]'),this.selectedLabel=(o=this.root)==null?void 0:o.querySelector("#scene-selected-id"),this.configViewer=(r=this.root)==null?void 0:r.querySelector("#config-viewer");let n=(l=this.root)==null?void 0:l.querySelector("#apply-object-config"),i=(c=this.root)==null?void 0:c.querySelector("#copy-config-values");n==null||n.addEventListener("click",()=>{var u;return(u=this.options)==null?void 0:u.onApply()}),i==null||i.addEventListener("click",()=>{var u;return(u=this.options)==null?void 0:u.onCopy()}),["#config-pos-x","#config-pos-y","#config-scale","#config-anchor-x","#config-anchor-y"].forEach(u=>{var p;let d=(p=this.root)==null?void 0:p.querySelector(u);d==null||d.addEventListener("input",()=>{var h;return(h=this.options)==null?void 0:h.onChange()}),d==null||d.addEventListener("change",()=>{var h;return(h=this.options)==null?void 0:h.onChange()})})}setSelected(e){this.selectedLabel&&(this.selectedLabel.textContent=e||"\u2014"),this.configViewer&&(this.configViewer.style.display=e?"block":"none")}};var Jt=class{constructor(){this.root=null;this.infoEls={};this.options=null}render(){return`
|
|
96
|
+
<div class="scene-panel scene-tools panel-accent-amber" data-panel="scene-tools">
|
|
97
|
+
<div class="scene-panel-header" data-panel-handle>
|
|
98
|
+
<div class="panel-title">
|
|
99
|
+
<span class="panel-pill">Tools</span>
|
|
100
|
+
<span class="panel-title-text">Scene Tools</span>
|
|
101
|
+
</div>
|
|
102
|
+
<button class="scene-panel-toggle" type="button" data-panel-toggle>\u25BE</button>
|
|
103
|
+
</div>
|
|
104
|
+
<div class="scene-panel-body">
|
|
105
|
+
<div class="debug-section">
|
|
106
|
+
<div class="debug-section-title">Visualize</div>
|
|
107
|
+
<div class="debug-field">
|
|
108
|
+
<label>Scene Scale</label>
|
|
109
|
+
<input type="range" id="debug-scene-scale" min="0.4" max="1.6" step="0.05" value="1.0">
|
|
110
|
+
<span class="debug-value-display" id="debug-scene-scale-value">1.0</span>
|
|
111
|
+
</div>
|
|
112
|
+
<div class="debug-field checkbox-field">
|
|
113
|
+
<input type="checkbox" id="debug-highlight-object">
|
|
114
|
+
<label>Highlight bounds</label>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="debug-field checkbox-field">
|
|
117
|
+
<input type="checkbox" id="debug-highlight-anchor">
|
|
118
|
+
<label>Highlight config anchor</label>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="debug-field checkbox-field">
|
|
121
|
+
<input type="checkbox" id="debug-nudge-enabled">
|
|
122
|
+
<label>Enable arrow nudging</label>
|
|
123
|
+
</div>
|
|
124
|
+
<div id="debug-nudge-controls" class="debug-nudge hidden">
|
|
125
|
+
<div class="debug-field">
|
|
126
|
+
<label>Nudge step (px)</label>
|
|
127
|
+
<input type="number" id="debug-nudge-step" step="1" value="10">
|
|
128
|
+
</div>
|
|
129
|
+
<div class="debug-arrow-pad">
|
|
130
|
+
<button class="debug-arrow-btn" data-nudge="up">\u2191</button>
|
|
131
|
+
<button class="debug-arrow-btn" data-nudge="left">\u2190</button>
|
|
132
|
+
<button class="debug-arrow-btn" data-nudge="down">\u2193</button>
|
|
133
|
+
<button class="debug-arrow-btn" data-nudge="right">\u2192</button>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<div class="debug-section">
|
|
139
|
+
<div class="debug-section-title">Splash Screen</div>
|
|
140
|
+
<div class="debug-field">
|
|
141
|
+
<label>Loading text</label>
|
|
142
|
+
<input type="text" id="debug-loading-text" placeholder="Y\xFCkleniyor...">
|
|
143
|
+
</div>
|
|
144
|
+
<div class="debug-field">
|
|
145
|
+
<label>Loading text scale</label>
|
|
146
|
+
<input type="range" id="debug-loading-text-scale" min="0.2" max="1.2" step="0.05" value="0.6">
|
|
147
|
+
<span class="debug-value-display" id="debug-loading-text-scale-value">0.6</span>
|
|
148
|
+
</div>
|
|
149
|
+
<div class="debug-field checkbox-field">
|
|
150
|
+
<input type="checkbox" id="debug-splash-on-start">
|
|
151
|
+
<label>Show on start</label>
|
|
152
|
+
</div>
|
|
153
|
+
<div class="debug-btn-group">
|
|
154
|
+
<button class="debug-btn" id="debug-show-splash">Show Splash Screen</button>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
<div class="debug-section">
|
|
159
|
+
<div class="debug-section-title">Object Info</div>
|
|
160
|
+
<div class="debug-info-grid">
|
|
161
|
+
<div class="debug-info-row">
|
|
162
|
+
<span class="debug-info-label">Instance</span>
|
|
163
|
+
<span class="debug-info-value" id="debug-instance-id">\u2014</span>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="debug-info-row">
|
|
166
|
+
<span class="debug-info-label">World X</span>
|
|
167
|
+
<span class="debug-info-value" id="debug-world-x">0</span>
|
|
168
|
+
</div>
|
|
169
|
+
<div class="debug-info-row">
|
|
170
|
+
<span class="debug-info-label">World Y</span>
|
|
171
|
+
<span class="debug-info-value" id="debug-world-y">0</span>
|
|
172
|
+
</div>
|
|
173
|
+
<div class="debug-info-row">
|
|
174
|
+
<span class="debug-info-label">Anchor X</span>
|
|
175
|
+
<span class="debug-info-value" id="debug-config-x">\u2014</span>
|
|
176
|
+
</div>
|
|
177
|
+
<div class="debug-info-row">
|
|
178
|
+
<span class="debug-info-label">Anchor Y</span>
|
|
179
|
+
<span class="debug-info-value" id="debug-config-y">\u2014</span>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
<div class="debug-collapsible collapsed" data-advanced-settings>
|
|
185
|
+
<button class="debug-collapsible-header" type="button" data-advanced-toggle>
|
|
186
|
+
<span>Advanced Settings</span>
|
|
187
|
+
<span class="debug-collapsible-icon">\u25BE</span>
|
|
188
|
+
</button>
|
|
189
|
+
<div class="debug-collapsible-body">
|
|
190
|
+
<div class="debug-section">
|
|
191
|
+
<div class="debug-section-title">Global Settings</div>
|
|
192
|
+
<div class="debug-field">
|
|
193
|
+
<label>Scale Multiplier</label>
|
|
194
|
+
<input type="range" id="debug-layout-scale" min="0.1" max="2.0" step="0.05" value="1.0">
|
|
195
|
+
<span class="debug-value-display" id="debug-layout-scale-value">1.0</span>
|
|
196
|
+
</div>
|
|
197
|
+
<div class="debug-field">
|
|
198
|
+
<label>Position Offset X</label>
|
|
199
|
+
<input type="range" id="debug-layout-offset-x" min="-150" max="150" step="1" value="0">
|
|
200
|
+
<span class="debug-value-display" id="debug-layout-offset-x-value">0</span>
|
|
201
|
+
</div>
|
|
202
|
+
<div class="debug-field">
|
|
203
|
+
<label>Position Offset Y</label>
|
|
204
|
+
<input type="range" id="debug-layout-offset-y" min="-150" max="150" step="1" value="0">
|
|
205
|
+
<span class="debug-value-display" id="debug-layout-offset-y-value">0</span>
|
|
206
|
+
</div>
|
|
207
|
+
<div class="debug-field checkbox-field">
|
|
208
|
+
<input type="checkbox" id="debug-rect-visible" checked>
|
|
209
|
+
<label>Debug Rectangle Visible</label>
|
|
210
|
+
</div>
|
|
211
|
+
<div class="debug-field">
|
|
212
|
+
<label>Debug Rect Color</label>
|
|
213
|
+
<input type="color" id="debug-rect-color" value="#ff0000">
|
|
214
|
+
</div>
|
|
215
|
+
<div class="debug-field">
|
|
216
|
+
<label>Debug Rect Thickness</label>
|
|
217
|
+
<input type="range" id="debug-rect-thickness" min="1" max="10" step="1" value="4">
|
|
218
|
+
<span class="debug-value-display" id="debug-rect-thickness-value">4</span>
|
|
219
|
+
</div>
|
|
220
|
+
<div class="debug-field">
|
|
221
|
+
<label>Engine Scale</label>
|
|
222
|
+
<input type="range" id="debug-engine-scale" min="0.1" max="2.0" step="0.05" value="1.0">
|
|
223
|
+
<span class="debug-value-display" id="debug-engine-scale-value">1.0</span>
|
|
224
|
+
</div>
|
|
225
|
+
<div class="debug-field">
|
|
226
|
+
<label>Background Scale</label>
|
|
227
|
+
<input type="range" id="debug-background-scale" min="0.5" max="2.0" step="0.05" value="1.05">
|
|
228
|
+
<span class="debug-value-display" id="debug-background-scale-value">1.05</span>
|
|
229
|
+
</div>
|
|
230
|
+
<div class="debug-field">
|
|
231
|
+
<label>Label Pulse Speed</label>
|
|
232
|
+
<input type="range" id="debug-label-pulse-speed" min="0" max="10" step="0.1" value="3.0">
|
|
233
|
+
<span class="debug-value-display" id="debug-label-pulse-speed-value">3.0</span>
|
|
234
|
+
</div>
|
|
235
|
+
<div class="debug-field">
|
|
236
|
+
<label>Label Pulse Intensity</label>
|
|
237
|
+
<input type="range" id="debug-label-pulse-intensity" min="0" max="0.2" step="0.01" value="0.03">
|
|
238
|
+
<span class="debug-value-display" id="debug-label-pulse-intensity-value">0.03</span>
|
|
239
|
+
</div>
|
|
240
|
+
<div class="debug-field">
|
|
241
|
+
<label>Rope Length</label>
|
|
242
|
+
<input type="range" id="debug-rope-length" min="200" max="800" step="10" value="420">
|
|
243
|
+
<span class="debug-value-display" id="debug-rope-length-value">420</span>
|
|
244
|
+
</div>
|
|
245
|
+
<div class="debug-btn-group">
|
|
246
|
+
<button class="debug-btn danger" id="debug-reset">Reset Debug</button>
|
|
247
|
+
<button class="debug-btn" id="debug-export">Export Debug Config</button>
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
`}initialize(e,t){var f,m,y,v,w,S,A,I,T,C,L,O,_,E,B,M;this.options=t,this.root=e.querySelector('[data-panel="scene-tools"]');let n=(f=this.root)==null?void 0:f.querySelector("#debug-highlight-object");n==null||n.addEventListener("change",()=>{var x;return(x=this.options)==null?void 0:x.onHighlightObject(!!n.checked)});let i=(m=this.root)==null?void 0:m.querySelector("#debug-highlight-anchor");i==null||i.addEventListener("change",()=>{var x;return(x=this.options)==null?void 0:x.onHighlightAnchor(!!i.checked)});let a=(y=this.root)==null?void 0:y.querySelector("#debug-nudge-enabled"),o=(v=this.root)==null?void 0:v.querySelector("#debug-nudge-controls");if(a&&o){let x=()=>o.classList.toggle("hidden",!a.checked);a.addEventListener("change",x),x()}Array.from(((w=this.root)==null?void 0:w.querySelectorAll(".debug-arrow-btn"))||[]).forEach(x=>{x.addEventListener("click",()=>{var P,z,D,R;switch(x.dataset.nudge){case"up":(P=this.options)==null||P.onNudge(0,-1);break;case"down":(z=this.options)==null||z.onNudge(0,1);break;case"left":(D=this.options)==null||D.onNudge(-1,0);break;case"right":(R=this.options)==null||R.onNudge(1,0);break;default:break}})});let c=(()=>{var k;let x=window.getEditableEngineConfig;if(typeof x=="function"){let P=x();return(k=P==null?void 0:P.splash)!=null?k:{}}return{}})(),u=(S=this.root)==null?void 0:S.querySelector("#debug-loading-text"),d=(A=this.root)==null?void 0:A.querySelector("#debug-loading-text-scale"),p=(I=this.root)==null?void 0:I.querySelector("#debug-loading-text-scale-value"),h=(T=this.root)==null?void 0:T.querySelector("#debug-splash-on-start"),g=(C=this.root)==null?void 0:C.querySelector("#debug-show-splash");if(u&&(u.value=typeof c.loading_text=="string"&&c.loading_text.length>0?c.loading_text:"Y\xFCkleniyor...",u.addEventListener("input",()=>{var x,k;(k=(x=this.options)==null?void 0:x.onUpdateSplash)==null||k.call(x,{loading_text:u.value})})),d){let x=typeof c.loading_text_scale=="number"?c.loading_text_scale:.6;d.value=x.toString(),p&&(p.textContent=x.toFixed(2)),d.addEventListener("input",()=>{var P,z;let k=Number(d.value);p&&(p.textContent=Number.isFinite(k)?k.toFixed(2):"0.6"),Number.isFinite(k)&&((z=(P=this.options)==null?void 0:P.onUpdateSplash)==null||z.call(P,{loading_text_scale:k}))})}h&&(h.checked=!!c.show_on_start,h.addEventListener("change",()=>{var x,k;(k=(x=this.options)==null?void 0:x.onUpdateSplash)==null||k.call(x,{show_on_start:!!h.checked})})),g==null||g.addEventListener("click",()=>{var x,k;(k=(x=this.options)==null?void 0:x.onShowSplash)==null||k.call(x)}),this.infoEls={instance:(L=this.root)==null?void 0:L.querySelector("#debug-instance-id"),worldX:(O=this.root)==null?void 0:O.querySelector("#debug-world-x"),worldY:(_=this.root)==null?void 0:_.querySelector("#debug-world-y"),anchorX:(E=this.root)==null?void 0:E.querySelector("#debug-config-x"),anchorY:(B=this.root)==null?void 0:B.querySelector("#debug-config-y")};let b=(M=this.root)==null?void 0:M.querySelector("[data-advanced-toggle]");b&&b.addEventListener("click",()=>{let x=b.closest(".debug-collapsible");x==null||x.classList.toggle("collapsed")})}getNudgeStep(){var n,i;let e=(n=this.root)==null?void 0:n.querySelector("#debug-nudge-step"),t=Number((i=e==null?void 0:e.value)!=null?i:10);return Number.isFinite(t)?t:10}updateInfo(e){if(!e){this.infoEls.instance&&(this.infoEls.instance.textContent="\u2014"),this.infoEls.worldX&&(this.infoEls.worldX.textContent="0"),this.infoEls.worldY&&(this.infoEls.worldY.textContent="0"),this.infoEls.anchorX&&(this.infoEls.anchorX.textContent="\u2014"),this.infoEls.anchorY&&(this.infoEls.anchorY.textContent="\u2014");return}this.infoEls.instance&&(this.infoEls.instance.textContent=e.instanceId),this.infoEls.worldX&&(this.infoEls.worldX.textContent=e.worldX.toFixed(1)),this.infoEls.worldY&&(this.infoEls.worldY.textContent=e.worldY.toFixed(1)),this.infoEls.anchorX&&(this.infoEls.anchorX.textContent=e.anchorX==null?"\u2014":e.anchorX.toFixed(1)),this.infoEls.anchorY&&(this.infoEls.anchorY.textContent=e.anchorY==null?"\u2014":e.anchorY.toFixed(1))}};var Ks="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMB/VMWm7cAAAAASUVORK5CYII=";async function Qt(s,e,t,n={}){return Ks}function Qa(s,e={}){let{includeReference:t=!1,includeMagenta:n=!0,changeLevel:i=5}=e;return[`TASK: ${s}`,`CHANGE_STRENGTH: ${i}/10`,t?"REFERENCE: provided":"REFERENCE: none",n?"BACKGROUND: solid magenta #FF00FF (if possible)":""].filter(Boolean).join(`
|
|
255
|
+
`)}function Nn(s){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(s)})}function Za(s){var i;let[e,t]=s.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(i=n==null?void 0:n[1])!=null?i:"image/png"}}async function es(s){return await new Promise(e=>{let t=new Image;t.onload=()=>e({width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}),t.onerror=()=>e(null),t.src=s})}async function Zt(s){var e,t;try{let n=await fetch(s);if(!n.ok)return null;let i=await n.blob(),a=await Nn(i),o=await es(a),r=Za(a);return{base64:r.base64,mimeType:r.mimeType,dataUrl:a,width:(e=o==null?void 0:o.width)!=null?e:0,height:(t=o==null?void 0:o.height)!=null?t:0}}catch{return null}}async function yt(s){var e,t;try{let n=await Nn(s),i=await es(n),a=Za(n);return{base64:a.base64,mimeType:a.mimeType,dataUrl:n,width:(e=i==null?void 0:i.width)!=null?e:0,height:(t=i==null?void 0:i.height)!=null?t:0}}catch{return null}}function ts(s){return Nn(s).then(e=>e).catch(()=>null)}function $n(s,e){var t;try{let[n,i]=s.split(","),a=n.match(/data:(.*?);base64/),o=(t=a==null?void 0:a[1])!=null?t:"image/png",r=atob(i),l=new Uint8Array(r.length);for(let c=0;c<r.length;c++)l[c]=r.charCodeAt(c);return new File([l],e,{type:o})}catch{return null}}async function en(s){return s}function tn(s,e){if(!s||!e)return"1:1";let t=s/e;return t>1.3?"16:9":t<.77?"9:16":"1:1"}var Js=["background_color","text_color","cta_background","cta_text","warning_text_color","endgame_title_color","endgame_subtitle_color","endgame_cta_text_color","endgame_cta_hint_color","endgame_footer_color"],Qs=["cta_hint","cta_label_end"],ns=[{key:"warning_text",objectId:"label.warning",property:"ui.text"},{key:"endgame_title",objectId:"ui.endgame.title",property:"ui.text"},{key:"endgame_subtitle",objectId:"ui.endgame.subtitle",property:"ui.text"},{key:"endgame_cta_text",objectId:"ui.endgame.cta",property:"ui.text"},{key:"endgame_cta_hint_text",objectId:"ui.endgame.cta.hint",property:"ui.text"},{key:"endgame_footer_text",objectId:"ui.endgame.footer",property:"ui.text"}],Zs=["brand.primary","brand.heading","brand.body","brand.warning"],nn=class{constructor(){this.root=null;this.assetsContainer=null;this.colorsContainer=null;this.fontsContainer=null;this.textsContainer=null;this.audioContainer=null;this.options=null;this.previewModal=null;this.autoApplyTimer=null;this.activePreviewKey=null;this.activePreviewValue=null;this.activePreviewFileInput=null;this.retryTimer=null;this.aiModal=null;this.aiTargetKey=null;this.aiKeyInput=null;this.aiPromptInput=null;this.aiStrengthInput=null;this.aiStrengthValue=null;this.aiModelSelect=null;this.aiModalSubtitle=null;this.aiGalleryToggle=null;this.aiGalleryEl=null;this.aiGalleryGrid=null;this.aiReferenceInput=null;this.aiReferenceName=null;this.aiReferenceFile=null;this.aiMagentaToggle=null;this.aiRemoveMagentaToggle=null;this.aiUseOutputToggle=null;this.aiGenerateBtn=null;this.aiApplyBtn=null;this.aiCropBtn=null;this.aiDownloadBtn=null;this.aiPreviewImg=null;this.aiStatusEl=null;this.aiOutputDataUrl=null;this.aiBaseDataUrl=null;this.aiOutputKey=null;this.aiLoadingEl=null}render(){return`
|
|
256
|
+
<div class="scene-panel customize-panel panel-accent-blue" data-panel="customize-settings">
|
|
257
|
+
<div class="scene-panel-header" data-panel-handle>
|
|
258
|
+
<div class="panel-title">
|
|
259
|
+
<span class="panel-pill">Brand</span>
|
|
260
|
+
<span class="panel-title-text">Customize Settings</span>
|
|
261
|
+
</div>
|
|
262
|
+
<div class="scene-panel-actions">
|
|
263
|
+
<button class="scene-panel-toggle" type="button" data-panel-toggle>\u25BE</button>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
<div class="scene-panel-body">
|
|
267
|
+
<div class="panel-section">
|
|
268
|
+
<div class="panel-section-title">Assets</div>
|
|
269
|
+
<div class="customize-list" data-customize-assets></div>
|
|
270
|
+
</div>
|
|
271
|
+
<div class="panel-section">
|
|
272
|
+
<div class="panel-section-title">UI Colors</div>
|
|
273
|
+
<div class="customize-grid" data-customize-colors></div>
|
|
274
|
+
</div>
|
|
275
|
+
<div class="panel-section">
|
|
276
|
+
<div class="panel-section-title">Fonts</div>
|
|
277
|
+
<div class="customize-grid" data-customize-fonts></div>
|
|
278
|
+
<div class="customize-help">Font IDs only (ex: brand.primary). Mapping is applied later.</div>
|
|
279
|
+
</div>
|
|
280
|
+
<div class="panel-section">
|
|
281
|
+
<div class="panel-section-title">Texts</div>
|
|
282
|
+
<div class="customize-list" data-customize-texts></div>
|
|
283
|
+
</div>
|
|
284
|
+
<div class="panel-section">
|
|
285
|
+
<div class="panel-section-title">Audio</div>
|
|
286
|
+
<div class="customize-list" data-customize-audio></div>
|
|
287
|
+
</div>
|
|
288
|
+
<div class="debug-btn-group">
|
|
289
|
+
<button class="debug-btn primary" data-customize-apply>Apply & Restart</button>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
<div class="panel-resize-handle" data-panel-resize></div>
|
|
293
|
+
</div>
|
|
294
|
+
`}initialize(e,t){var i,a,o,r,l,c;this.options=t,this.root=e.querySelector('[data-panel="customize-settings"]'),this.assetsContainer=(i=this.root)==null?void 0:i.querySelector("[data-customize-assets]"),this.colorsContainer=(a=this.root)==null?void 0:a.querySelector("[data-customize-colors]"),this.fontsContainer=(o=this.root)==null?void 0:o.querySelector("[data-customize-fonts]"),this.textsContainer=(r=this.root)==null?void 0:r.querySelector("[data-customize-texts]"),this.audioContainer=(l=this.root)==null?void 0:l.querySelector("[data-customize-audio]");let n=(c=this.root)==null?void 0:c.querySelector("[data-customize-apply]");n==null||n.addEventListener("click",()=>this.handleApply()),this.setupResizeHandle(),this.refresh()}openAiEditor(e,t){this.openAiModal(e),t&&this.aiPromptInput&&(this.aiPromptInput.value=t,this.setAiStatus("Prompt loaded from Brand DNA."))}refresh(){var t,n,i,a,o,r,l,c;let e=this.getEngineSnapshot();if(!e){this.scheduleRetry();return}this.renderAssets(e.assets),this.renderColors((n=(t=e.runtime)==null?void 0:t.theme)!=null?n:{}),this.renderFonts((a=(i=e.runtime)==null?void 0:i.fonts)!=null?a:{}),this.renderTexts((r=(o=e.runtime)==null?void 0:o.ui)!=null?r:{}),this.renderAudio((c=(l=e.runtime)==null?void 0:l.audio)!=null?c:{})}getEngineSnapshot(){let e=window.getEditableEngineConfig;return typeof e!="function"?null:e()}renderAssets(e){if(!this.assetsContainer)return;this.assetsContainer.innerHTML="";let t=Object.entries(e!=null?e:{});if(!t.length){this.assetsContainer.innerHTML='<div class="customize-empty">No assets found.</div>',this.scheduleRetry();return}this.clearRetry(),t.forEach(([n,i])=>{var p;let a=document.createElement("div");a.className="customize-row";let o=document.createElement("span");o.className="customize-key",o.textContent=n;let r=document.createElement("input");r.type="text",r.value=i!=null?i:"",r.className="customize-input",r.dataset.assetKey=n,r.addEventListener("input",()=>{this.handleAssetValueChange(n,r)});let l=document.createElement("div");l.className="customize-actions";let c=document.createElement("button");c.type="button",c.className="customize-icon-btn",c.title="Preview asset",c.innerHTML=`
|
|
295
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
296
|
+
<path d="M12 5c5.2 0 9.2 3.7 10 6.8-.8 3.1-4.8 6.8-10 6.8S2.8 14.9 2 11.8C2.8 8.7 6.8 5 12 5z" />
|
|
297
|
+
<circle cx="12" cy="12" r="3.2" />
|
|
298
|
+
</svg>
|
|
299
|
+
`,c.addEventListener("click",()=>{this.previewAsset(n,r.value,r.dataset.assetType,d)});let u=document.createElement("button");u.type="button",u.className="customize-icon-btn",u.title="Upload asset",u.innerHTML=`
|
|
300
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
301
|
+
<path d="M12 3l4 4h-3v6h-2V7H8l4-4z" />
|
|
302
|
+
<path d="M5 14v4h14v-4h2v6H3v-6h2z" />
|
|
303
|
+
</svg>
|
|
304
|
+
`;let d=document.createElement("input");d.type="file",d.accept="image/*,audio/*,application/json",d.className="customize-file",d.addEventListener("change",()=>{var g;let h=(g=d.files)==null?void 0:g[0];h&&this.handleAssetUpload(h,r,n)}),u.addEventListener("click",()=>d.click()),l.appendChild(c),l.appendChild(u),l.appendChild(d),a.appendChild(o),a.appendChild(r),a.appendChild(l),(p=this.assetsContainer)==null||p.appendChild(a)})}renderColors(e){this.colorsContainer&&(this.colorsContainer.innerHTML="",Js.forEach(t=>{var l,c,u;let n=(l=e==null?void 0:e[t])!=null?l:"#ffffff";if(t.includes("_text_color")||t.includes("_color")){let p={warning_text_color:{objectId:"label.warning",property:"render.tint"},endgame_title_color:{objectId:"ui.endgame.title",property:"render.tint"},endgame_subtitle_color:{objectId:"ui.endgame.subtitle",property:"render.tint"},endgame_cta_text_color:{objectId:"ui.endgame.cta",property:"render.tint"},endgame_cta_hint_color:{objectId:"ui.endgame.cta.hint",property:"render.tint"},endgame_footer_color:{objectId:"ui.endgame.footer",property:"render.tint"}}[t];p&&(n=(c=this.getObjectPropertyValue(p.objectId,p.property))!=null?c:"#ffffff")}let i=document.createElement("label");i.className="customize-color-field";let a=document.createElement("span");a.textContent=t.replace(/_/g," ");let o=document.createElement("input");o.type="color",o.value=n,o.dataset.colorKey=t;let r=document.createElement("input");r.type="text",r.value=n,r.className="customize-color-text",r.dataset.colorTextKey=t,o.addEventListener("input",()=>{r.value=o.value}),r.addEventListener("input",()=>{/^#([0-9a-fA-F]{6})$/.test(r.value)&&(o.value=r.value)}),i.appendChild(a),i.appendChild(o),i.appendChild(r),(u=this.colorsContainer)==null||u.appendChild(i)}))}renderFonts(e){this.fontsContainer&&(this.fontsContainer.innerHTML="",Zs.forEach(t=>{var o,r;let n=document.createElement("div");n.className="customize-row";let i=document.createElement("span");i.className="customize-key",i.textContent=t;let a=document.createElement("input");a.type="text",a.value=(o=e==null?void 0:e[t])!=null?o:t,a.className="customize-input",a.dataset.fontKey=t,n.appendChild(i),n.appendChild(a),(r=this.fontsContainer)==null||r.appendChild(n)}))}renderTexts(e){this.textsContainer&&(this.textsContainer.innerHTML="",Qs.forEach(t=>{var o,r;let n=document.createElement("div");n.className="customize-row";let i=document.createElement("span");i.className="customize-key",i.textContent=t;let a=document.createElement("input");a.type="text",a.value=(o=this.readUiValue(e,t))!=null?o:"",a.className="customize-input",a.dataset.textKey=t,n.appendChild(i),n.appendChild(a),(r=this.textsContainer)==null||r.appendChild(n)}),ns.forEach(({key:t,objectId:n})=>{var r,l;let i=document.createElement("div");i.className="customize-row";let a=document.createElement("span");a.className="customize-key",a.textContent=t;let o=document.createElement("input");o.type="text",o.value=(r=this.getObjectTextValue(n))!=null?r:"",o.className="customize-input",o.dataset.objectTextKey=t,i.appendChild(a),i.appendChild(o),(l=this.textsContainer)==null||l.appendChild(i)}))}renderAudio(e){if(!this.audioContainer)return;this.audioContainer.innerHTML="",["background_file","background_volume","click_file","click_volume","success_file","success_volume","complete_file","complete_volume"].forEach(n=>{var r,l;let i=document.createElement("div");i.className="customize-row";let a=document.createElement("span");a.className="customize-key",a.textContent=n.replace("_"," ");let o=document.createElement("input");o.type=n.includes("volume")?"number":"text",o.min="0",o.max="1",o.step="0.1",o.value=String((r=e==null?void 0:e[n])!=null?r:""),o.className="customize-input",o.dataset.audioKey=n,n.includes("file")&&(o.placeholder="audio file path"),i.appendChild(a),i.appendChild(o),(l=this.audioContainer)==null||l.appendChild(i)})}readUiValue(e,t){if(t.includes(".")){let i=t.split("."),a=e;for(let o of i){if(a==null)return null;a=a[o]}return typeof a=="string"?a:null}let n=e==null?void 0:e[t];return typeof n=="string"?n:null}getObjectTextValue(e){var i,a;let t=window.getEditableObjectConfig;if(typeof t!="function")return null;let n=t(e);return(a=(i=n==null?void 0:n.ui)==null?void 0:i.text)!=null?a:null}getObjectPropertyValue(e,t){let n=window.getEditableObjectConfig;if(typeof n!="function")return null;let i=n(e);if(!i)return null;let a=t.split("."),o=i;for(let r of a){if(o==null)return null;o=o[r]}return typeof o=="string"?o:null}handleApply(){this.handleApplyWithSource("manual")}handleApplyWithSource(e){if(!this.root||!this.options)return;let t={};this.root.querySelectorAll("[data-asset-key]").forEach(r=>{let l=r;l.dataset.assetKey&&(t[l.dataset.assetKey]=l.value)});let n={};this.root.querySelectorAll("[data-color-text-key]").forEach(r=>{let l=r,c=l.dataset.colorTextKey;c&&(c.includes("_text_color")||c.includes("_color")?this.applyTextColorToObject(c,l.value):n[c]=l.value)});let i={};this.root.querySelectorAll("[data-font-key]").forEach(r=>{let l=r,c=l.dataset.fontKey;c&&(i[c]=l.value)});let a={};this.root.querySelectorAll("[data-text-key]").forEach(r=>{let l=r,c=l.dataset.textKey;c&&(a[c]=l.value)});let o={};this.root.querySelectorAll("[data-audio-key]").forEach(r=>{let l=r,c=l.dataset.audioKey;if(c)if(c.includes("volume")){let u=parseFloat(l.value);o[c]=isNaN(u)?0:u}else o[c]=l.value}),this.root.querySelectorAll("[data-object-text-key]").forEach(r=>{let l=r,c=l.dataset.objectTextKey;if(!c)return;let u=ns.find(d=>d.key===c);u&&this.applyObjectPropertyValue(u.objectId,u.property,l.value)}),this.options.onApply({assets:t,runtime:{theme:n,ui:a,fonts:i,audio:o}},{source:e})}setupAiPanel(){}setAiStatus(e){this.aiStatusEl&&(this.aiStatusEl.textContent=e)}getSelectedAssetKey(){return this.aiTargetKey}getSelectedAssetInput(){let e=this.getSelectedAssetKey();return!this.root||!e?null:this.root.querySelector(`input[data-asset-key="${e}"]`)}async getImageDataFromAsset(e){let t=this.resolveAssetUrls(e);for(let n of t){let i=await Zt(n);if(i)return{input:{base64:i.base64,mimeType:i.mimeType},dataUrl:i.dataUrl,width:i.width,height:i.height}}return null}async updateAiBasePreview(){var i,a,o;let e=this.getSelectedAssetInput(),t=(a=(i=e==null?void 0:e.value)==null?void 0:i.trim())!=null?a:"";if(!t){this.aiBaseDataUrl=null,this.updateAiPreview();return}let n=await this.getImageDataFromAsset(t);this.aiBaseDataUrl=(o=n==null?void 0:n.dataUrl)!=null?o:null,this.updateAiPreview()}updateAiPreview(){if(!this.aiPreviewImg)return;let e=this.aiOutputDataUrl||this.aiBaseDataUrl||"";if(!e){this.aiPreviewImg.removeAttribute("src");return}this.aiPreviewImg.src=e}updateAiModalPreview(e,t){if(!e)return;let n=t!=null?t:this.activePreviewKey;if(!n||!this.aiOutputDataUrl||this.aiOutputKey!==n){e.classList.add("hidden");return}let i=e.querySelector(".asset-preview-ai-image");i&&(i.src=this.aiOutputDataUrl),e.classList.remove("hidden")}setAiLoading(e){this.aiLoadingEl&&this.aiLoadingEl.classList.toggle("active",e),this.aiGenerateBtn&&(this.aiGenerateBtn.disabled=e)}toggleAiGallery(){if(!this.aiGalleryEl||!this.aiGalleryToggle)return;let e=this.aiGalleryEl.classList.toggle("hidden");this.aiGalleryToggle.textContent=e?"Gallery":"Hide Gallery",e||this.renderAiGallery()}renderAiGallery(){if(!this.aiGalleryGrid)return;let e=this.getAiGalleryEntries();if(!e.length){this.aiGalleryGrid.innerHTML='<div class="ai-gallery-empty">No image assets found.</div>';return}this.aiGalleryGrid.innerHTML="",e.forEach(({key:t,value:n})=>{var l;let i=document.createElement("button");i.type="button",i.className="ai-gallery-item",t===this.aiTargetKey&&i.classList.add("active");let a=document.createElement("img");a.className="ai-gallery-thumb",a.alt=t;let o=this.resolveAssetUrls(n);o[0]&&(a.src=o[0]);let r=document.createElement("span");r.className="ai-gallery-label",r.textContent=t,i.appendChild(a),i.appendChild(r),i.addEventListener("click",()=>this.selectAiGalleryAsset(t)),(l=this.aiGalleryGrid)==null||l.appendChild(i)})}getAiGalleryEntries(){if(!this.root)return[];let e=[];return this.root.querySelectorAll("[data-asset-key]").forEach(t=>{var o,r;let n=t,i=n.dataset.assetKey,a=(r=(o=n.value)==null?void 0:o.trim())!=null?r:"";!i||!a||this.isAiGalleryImage(a)&&e.push({key:i,value:a})}),e}isAiGalleryImage(e){let t=e.trim();if(!t)return!1;if(/^(data:image|blob:)/.test(t))return!0;let n=t.split("?")[0].toLowerCase();return![".mp3",".wav",".ogg",".json"].some(i=>n.endsWith(i))}selectAiGalleryAsset(e){this.aiTargetKey!==e&&(this.aiTargetKey=e,this.aiOutputDataUrl=null,this.aiOutputKey=null,this.aiReferenceFile=null,this.aiBaseDataUrl=null,this.aiReferenceInput&&(this.aiReferenceInput.value=""),this.aiReferenceName&&(this.aiReferenceName.textContent="Optional"),this.aiModalSubtitle&&(this.aiModalSubtitle.textContent=e),this.setAiOutputButtonsEnabled(!1),this.updateAiBasePreview(),this.updateAiPreview(),this.renderAiGallery())}openAiModal(e){var a,o,r,l,c,u,d;this.closeAiModal(),this.aiTargetKey=e,this.aiOutputDataUrl=null,this.aiOutputKey=null,this.aiReferenceFile=null,this.aiBaseDataUrl=null;let t=document.createElement("div");t.className="ai-modal",t.innerHTML=`
|
|
305
|
+
<div class="ai-modal-card">
|
|
306
|
+
<div class="ai-modal-header">
|
|
307
|
+
<div>
|
|
308
|
+
<div class="ai-modal-title">AI Image Edit</div>
|
|
309
|
+
<div class="ai-modal-subtitle">${e}</div>
|
|
310
|
+
</div>
|
|
311
|
+
<div class="ai-modal-actions">
|
|
312
|
+
<button class="ai-modal-gallery" type="button" data-ai-gallery-toggle>Gallery</button>
|
|
313
|
+
<button class="ai-modal-close" type="button">Close</button>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
<div class="ai-panel">
|
|
317
|
+
<label class="ai-label">API Key</label>
|
|
318
|
+
<input type="password" class="ai-input" data-ai-key placeholder="Paste Gemini API key">
|
|
319
|
+
|
|
320
|
+
<label class="ai-label">Model</label>
|
|
321
|
+
<select class="ai-select" data-ai-model>
|
|
322
|
+
<option value="gemini-2.5-flash-image">Gemini 2.5 Flash (fast)</option>
|
|
323
|
+
<option value="gemini-3-pro-image-preview">Gemini 3 Pro (preview)</option>
|
|
324
|
+
</select>
|
|
325
|
+
|
|
326
|
+
<label class="ai-label">Prompt</label>
|
|
327
|
+
<textarea class="ai-textarea" data-ai-prompt placeholder="Describe the change"></textarea>
|
|
328
|
+
|
|
329
|
+
<div class="ai-row ai-strength">
|
|
330
|
+
<span class="ai-label">Change strength</span>
|
|
331
|
+
<input type="range" min="1" max="10" value="5" data-ai-strength>
|
|
332
|
+
<span class="ai-strength-value" data-ai-strength-value>5</span>
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
<div class="ai-gallery hidden" data-ai-gallery>
|
|
336
|
+
<div class="ai-gallery-grid" data-ai-gallery-grid></div>
|
|
337
|
+
</div>
|
|
338
|
+
|
|
339
|
+
<div class="ai-row">
|
|
340
|
+
<button class="ai-btn" type="button" data-ai-ref-button>Reference Image</button>
|
|
341
|
+
<input class="ai-file" type="file" accept="image/*" data-ai-ref-input>
|
|
342
|
+
<span class="ai-file-name" data-ai-ref-name>Optional</span>
|
|
343
|
+
</div>
|
|
344
|
+
|
|
345
|
+
<div class="ai-row ai-toggles">
|
|
346
|
+
<label><input type="checkbox" data-ai-magenta checked disabled> Magenta BG</label>
|
|
347
|
+
<label><input type="checkbox" data-ai-remove checked disabled> Remove Magenta BG after</label>
|
|
348
|
+
<label><input type="checkbox" data-ai-use-output> Use output as input</label>
|
|
349
|
+
</div>
|
|
350
|
+
|
|
351
|
+
<div class="ai-row ai-actions">
|
|
352
|
+
<button class="debug-btn primary" type="button" data-ai-generate>Generate</button>
|
|
353
|
+
<button class="debug-btn" type="button" data-ai-apply disabled>Apply Output</button>
|
|
354
|
+
<button class="debug-btn" type="button" data-ai-crop disabled>Crop Output</button>
|
|
355
|
+
<button class="debug-btn" type="button" data-ai-download disabled>Download</button>
|
|
356
|
+
</div>
|
|
357
|
+
|
|
358
|
+
<div class="ai-status" data-ai-status>Idle</div>
|
|
359
|
+
<div class="ai-loading" data-ai-loading>
|
|
360
|
+
<div class="ai-loading-ring"></div>
|
|
361
|
+
<div class="ai-loading-bar"></div>
|
|
362
|
+
<div class="ai-loading-text">Generating\u2026</div>
|
|
363
|
+
</div>
|
|
364
|
+
<div class="ai-preview">
|
|
365
|
+
<img data-ai-preview alt="AI output preview">
|
|
366
|
+
</div>
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
`;let n=t.querySelector(".ai-modal-close");n==null||n.addEventListener("click",()=>this.closeAiModal()),t.addEventListener("click",p=>{p.target===t&&this.closeAiModal()}),this.aiModal=t,this.aiKeyInput=t.querySelector("[data-ai-key]"),this.aiModelSelect=t.querySelector("[data-ai-model]"),this.aiPromptInput=t.querySelector("[data-ai-prompt]"),this.aiStrengthInput=t.querySelector("[data-ai-strength]"),this.aiStrengthValue=t.querySelector("[data-ai-strength-value]"),this.aiModalSubtitle=t.querySelector(".ai-modal-subtitle"),this.aiGalleryToggle=t.querySelector("[data-ai-gallery-toggle]"),this.aiGalleryEl=t.querySelector("[data-ai-gallery]"),this.aiGalleryGrid=t.querySelector("[data-ai-gallery-grid]"),this.aiReferenceInput=t.querySelector("[data-ai-ref-input]"),this.aiReferenceName=t.querySelector("[data-ai-ref-name]"),this.aiMagentaToggle=t.querySelector("[data-ai-magenta]"),this.aiRemoveMagentaToggle=t.querySelector("[data-ai-remove]"),this.aiUseOutputToggle=t.querySelector("[data-ai-use-output]"),this.aiGenerateBtn=t.querySelector("[data-ai-generate]"),this.aiApplyBtn=t.querySelector("[data-ai-apply]"),this.aiCropBtn=t.querySelector("[data-ai-crop]"),this.aiDownloadBtn=t.querySelector("[data-ai-download]"),this.aiPreviewImg=t.querySelector("[data-ai-preview]"),this.aiStatusEl=t.querySelector("[data-ai-status]"),this.aiLoadingEl=t.querySelector("[data-ai-loading]");let i=t.querySelector("[data-ai-ref-button]");i==null||i.addEventListener("click",()=>{var p;return(p=this.aiReferenceInput)==null?void 0:p.click()}),(a=this.aiGalleryToggle)==null||a.addEventListener("click",()=>this.toggleAiGallery()),(o=this.aiStrengthInput)==null||o.addEventListener("input",()=>{var h,g;let p=(g=(h=this.aiStrengthInput)==null?void 0:h.value)!=null?g:"5";this.aiStrengthValue&&(this.aiStrengthValue.textContent=p)}),(r=this.aiReferenceInput)==null||r.addEventListener("change",()=>{var h,g,b;let p=(b=(g=(h=this.aiReferenceInput)==null?void 0:h.files)==null?void 0:g[0])!=null?b:null;this.aiReferenceFile=p,this.aiReferenceName&&(this.aiReferenceName.textContent=p?`${p.name} (loaded)`:"Optional"),p&&this.setAiStatus(`Reference attached: ${p.name}`)}),(l=this.aiGenerateBtn)==null||l.addEventListener("click",()=>{this.handleAiGenerate()}),(c=this.aiApplyBtn)==null||c.addEventListener("click",()=>this.handleAiApply()),(u=this.aiCropBtn)==null||u.addEventListener("click",()=>{this.handleAiCrop()}),(d=this.aiDownloadBtn)==null||d.addEventListener("click",()=>this.handleAiDownload()),document.body.appendChild(t),this.setAiOutputButtonsEnabled(!1),this.setAiStatus("Ready."),this.updateAiBasePreview(),this.updateAiPreview(),this.renderAiGallery()}closeAiModal(){this.aiModal&&(this.aiModal.remove(),this.aiModal=null),this.aiTargetKey=null,this.aiKeyInput=null,this.aiModelSelect=null,this.aiPromptInput=null,this.aiStrengthInput=null,this.aiStrengthValue=null,this.aiModalSubtitle=null,this.aiGalleryToggle=null,this.aiGalleryEl=null,this.aiGalleryGrid=null,this.aiReferenceInput=null,this.aiReferenceName=null,this.aiReferenceFile=null,this.aiMagentaToggle=null,this.aiRemoveMagentaToggle=null,this.aiUseOutputToggle=null,this.aiGenerateBtn=null,this.aiApplyBtn=null,this.aiCropBtn=null,this.aiDownloadBtn=null,this.aiPreviewImg=null,this.aiStatusEl=null,this.aiLoadingEl=null}async handleAiGenerate(){var c,u,d,p,h,g,b,f,m,y,v,w,S,A,I,T,C;if(!this.aiGenerateBtn)return;let e=(d=(u=(c=this.aiKeyInput)==null?void 0:c.value)==null?void 0:u.trim())!=null?d:"",t=(h=(p=this.aiModelSelect)==null?void 0:p.value)!=null?h:"gemini-2.5-flash-image",n=(f=(b=(g=this.aiPromptInput)==null?void 0:g.value)==null?void 0:b.trim())!=null?f:"",i=!0,a=!0,o=Number((y=(m=this.aiStrengthInput)==null?void 0:m.value)!=null?y:"5");if(!e){this.setAiStatus("Missing API key.");return}if(!n){this.setAiStatus("Add a prompt.");return}let r=this.getSelectedAssetInput(),l=(w=(v=r==null?void 0:r.value)==null?void 0:v.trim())!=null?w:"";if(!l&&!this.aiOutputDataUrl){this.setAiStatus("Select an asset first.");return}this.setAiLoading(!0),this.setAiStatus("Generating...");try{let L=null,O=(S=this.getSelectedAssetKey())!=null?S:"unknown",_=(A=this.aiUseOutputToggle)!=null&&A.checked&&this.aiOutputDataUrl?"ai-output":"asset-value";if((I=this.aiUseOutputToggle)!=null&&I.checked&&this.aiOutputDataUrl){let D=$n(this.aiOutputDataUrl,"ai-output.png");if(D){let R=await yt(D);R&&(L={input:{base64:R.base64,mimeType:R.mimeType},dataUrl:R.dataUrl,width:R.width,height:R.height})}}if(L||(L=await this.getImageDataFromAsset(l)),!L){this.setAiStatus("Unable to load the base image.");return}let E=[L.input],B=!1;if(this.aiReferenceFile){let D=await yt(this.aiReferenceFile);D?(E.push({base64:D.base64,mimeType:D.mimeType}),B=!0,this.setAiStatus(`Generating with reference: ${this.aiReferenceFile.name}`)):this.setAiStatus("Reference image failed to load, generating without reference.")}let M=Qa(n,{includeReference:B,includeMagenta:i,changeLevel:o}),x=(C=(T=this.aiReferenceFile)==null?void 0:T.name)!=null?C:"none";console.info("[AI] Final prompt:",M),console.info("[AI] Image sources:",{assetKey:O,base:_,reference:x});let k=tn(L.width,L.height),P=await Qt(e,M,E,{aspectRatio:k,model:t}),z=P;if(a){let D=await en(P);D&&(z=D)}this.setAiOutput(z),this.setAiStatus("Ready.")}catch(L){this.setAiStatus("Generation failed. Check console."),console.warn("[AI] Gemini generation failed:",L)}finally{this.setAiLoading(!1)}}setAiOutput(e){var n,i;this.aiOutputDataUrl=e,this.aiOutputKey=this.getSelectedAssetKey(),this.updateAiPreview(),this.setAiOutputButtonsEnabled(!0);let t=(n=this.previewModal)==null?void 0:n.querySelector("[data-asset-ai-preview]");this.updateAiModalPreview(t,(i=this.activePreviewKey)!=null?i:void 0)}setAiOutputButtonsEnabled(e){this.aiApplyBtn&&(this.aiApplyBtn.disabled=!e),this.aiCropBtn&&(this.aiCropBtn.disabled=!e),this.aiDownloadBtn&&(this.aiDownloadBtn.disabled=!e)}handleAiApply(){var t;let e=this.getSelectedAssetInput();if(!e||!this.aiOutputDataUrl){this.setAiStatus("Generate output first.");return}e.value=this.aiOutputDataUrl,this.handleAssetValueChange((t=e.dataset.assetKey)!=null?t:"",e),this.setAiStatus("Applied to asset.")}async handleAiCrop(){var r;if(!this.aiOutputDataUrl){this.setAiStatus("Generate output first.");return}let e=this.getSelectedAssetInput(),t=(r=e==null?void 0:e.value)!=null?r:"",n=await this.getImageDimensions(t);if(!n){this.setAiStatus("Unable to read target dimensions.");return}let i=$n(this.aiOutputDataUrl,"ai-output.png");if(!i)return;let a=await this.showManualCropModal(i,n,t);if(!a)return;let o=await ts(a);o&&this.setAiOutput(o)}handleAiDownload(){var n;if(!this.aiOutputDataUrl)return;let e=(n=this.getSelectedAssetKey())!=null?n:"ai-image",t=document.createElement("a");t.href=this.aiOutputDataUrl,t.download=`${e}-ai.png`,t.click()}handleAssetValueChange(e,t){this.previewModal&&this.closePreviewModal(),this.scheduleAutoApply(),this.updatePreviewIfOpen(e,t.value,t.dataset.assetType)}async handleAssetUpload(e,t,n){let i=t.value,a=e;if(e.type.startsWith("image/")){let l=await this.getImageDimensions(i);if(l){let c=await this.showManualCropModal(e,l,i);if(!c)return;a=c}}let o=URL.createObjectURL(a),r=t.dataset.objectUrl;if(r)try{URL.revokeObjectURL(r)}catch{}t.dataset.objectUrl=o,t.dataset.assetType=a.type,t.value=o,this.handleAssetValueChange(n,t)}scheduleAutoApply(){this.options&&(this.autoApplyTimer&&window.clearTimeout(this.autoApplyTimer),this.autoApplyTimer=window.setTimeout(()=>{this.autoApplyTimer=null,this.handleApplyWithSource("auto")},250))}previewAsset(e,t,n,i){if(!t)return;let a=this.resolveAssetUrls(t);if(a.length===0)return;let o=n||this.guessMimeType(t);this.activePreviewKey=e,this.activePreviewValue=t,this.activePreviewFileInput=i!=null?i:null,this.openPreviewModal(e,t,a,o)}resolveAssetUrls(e){let t=e.trim();if(!t)return[];if(/^(blob:|data:|https?:|\/)/.test(t))return[t];let n=t.replace(/^\.?\//,"");return n.startsWith("raw/")?[`/${n}`,`/assets/${n}`]:n.startsWith("assets/")?[`/${n}`]:[`/raw/${n}`,`/assets/raw/${n}`,`/assets/${n}`]}guessMimeType(e){let t=e.toLowerCase();return t.endsWith(".png")||t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".gif")||t.endsWith(".webp")||t.endsWith(".svg")?"image":t.endsWith(".mp3")||t.endsWith(".wav")||t.endsWith(".ogg")?"audio":t.endsWith(".json")?"json":"file"}openPreviewModal(e,t,n,i){this.closePreviewModal(!0);let a=document.createElement("div");a.className="asset-preview-modal",a.innerHTML=`
|
|
370
|
+
<div class="asset-preview-card">
|
|
371
|
+
<div class="asset-preview-header">
|
|
372
|
+
<div class="asset-preview-title">${e}</div>
|
|
373
|
+
<div class="asset-preview-actions">
|
|
374
|
+
<button class="asset-preview-change" type="button">Change</button>
|
|
375
|
+
<button class="asset-preview-ai" type="button">AI Edit</button>
|
|
376
|
+
<button class="asset-preview-close" type="button">Close</button>
|
|
377
|
+
</div>
|
|
378
|
+
</div>
|
|
379
|
+
<div class="asset-preview-body"></div>
|
|
380
|
+
<div class="asset-preview-ai-output hidden" data-asset-ai-preview>
|
|
381
|
+
<div class="asset-preview-ai-label">AI Output</div>
|
|
382
|
+
<img class="asset-preview-ai-image" alt="AI output preview">
|
|
383
|
+
</div>
|
|
384
|
+
</div>
|
|
385
|
+
`;let o=a.querySelector(".asset-preview-body"),r=a.querySelector(".asset-preview-close"),l=a.querySelector(".asset-preview-change"),c=a.querySelector(".asset-preview-ai"),u=a.querySelector("[data-asset-ai-preview]");if(r==null||r.addEventListener("click",()=>this.closePreviewModal()),c==null||c.addEventListener("click",()=>this.openAiModal(e)),l==null||l.addEventListener("click",()=>{this.activePreviewFileInput&&this.activePreviewFileInput.click()}),a.addEventListener("click",d=>{d.target===a&&this.closePreviewModal()}),o)if(i==="image"){let d=document.createElement("img");this.loadWithFallback(d,n),o.appendChild(d)}else if(i==="audio"){let d=document.createElement("audio");d.controls=!0,this.loadWithFallback(d,n),o.appendChild(d)}else if(i==="json"){let d=document.createElement("pre");this.fetchWithFallback(n).then(p=>{d.textContent=p!=null?p:"Unable to load JSON."}),o.appendChild(d)}else{let d=document.createElement("a");d.href=n[0],d.target="_blank",d.rel="noreferrer",d.textContent="Open asset",o.appendChild(d)}document.body.appendChild(a),this.previewModal=a,this.updateAiModalPreview(u,e)}loadWithFallback(e,t){if(t.length===0)return;let n=0,i=()=>{n>=t.length||(e.src=t[n],n+=1)};e.addEventListener("error",i),i()}async fetchWithFallback(e){for(let t of e)try{let n=await fetch(t);if(!n.ok)continue;return await n.text()}catch{}return null}applyObjectPropertyValue(e,t,n){let i=window.getEditableObjectConfig,a=window.applyEditableObjectConfig;if(typeof i!="function"||typeof a!="function")return;let o=i(e);if(!o)return;let r=JSON.parse(JSON.stringify(o)),l=t.split("."),c=r;for(let u=0;u<l.length-1;u++){let d=l[u];c[d]=c[d]||{},c=c[d]}c[l[l.length-1]]=n,a(e,r)}applyTextColorToObject(e,t){let i={warning_text_color:{objectId:"label.warning",property:"render.tint"},endgame_title_color:{objectId:"ui.endgame.title",property:"render.tint"},endgame_subtitle_color:{objectId:"ui.endgame.subtitle",property:"render.tint"},endgame_cta_text_color:{objectId:"ui.endgame.cta",property:"render.tint"},endgame_cta_hint_color:{objectId:"ui.endgame.cta.hint",property:"render.tint"},endgame_footer_color:{objectId:"ui.endgame.footer",property:"render.tint"}}[e];i&&this.applyObjectPropertyValue(i.objectId,i.property,t)}closePreviewModal(e){this.previewModal&&(this.previewModal.remove(),this.previewModal=null),e||(this.activePreviewKey=null,this.activePreviewValue=null,this.activePreviewFileInput=null)}updatePreviewIfOpen(e,t,n){var a;if(!this.previewModal||this.activePreviewKey!==e)return;let i=t!=null?t:"";this.activePreviewValue!==i&&this.previewAsset(e,i,n,(a=this.activePreviewFileInput)!=null?a:void 0)}scheduleRetry(){this.retryTimer||(this.retryTimer=window.setTimeout(()=>{this.retryTimer=null,this.refresh()},350))}clearRetry(){this.retryTimer&&(window.clearTimeout(this.retryTimer),this.retryTimer=null)}setupResizeHandle(){if(!this.root)return;let e=this.root.querySelector("[data-panel-resize]");if(!e)return;let t=window.localStorage.getItem("customizePanelWidth"),n=t?Number(t):NaN;Number.isFinite(n)&&n>0&&(this.root.style.width=`${n}px`);let i=a=>{var p,h;a.preventDefault();let o=a.clientX,r=(h=(p=this.root)==null?void 0:p.getBoundingClientRect().width)!=null?h:0,l=260,c=620,u=g=>{let b=g.clientX-o,f=Math.min(c,Math.max(l,r+b));this.root&&(this.root.style.width=`${f}px`)},d=()=>{var b,f;window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",d);let g=(f=(b=this.root)==null?void 0:b.getBoundingClientRect().width)!=null?f:0;g>0&&window.localStorage.setItem("customizePanelWidth",String(Math.round(g)))};window.addEventListener("pointermove",u),window.addEventListener("pointerup",d)};e.addEventListener("pointerdown",i)}async getImageDimensions(e){let t=this.resolveAssetUrls(e);if(t.length===0)return null;for(let n of t){let i=await this.loadImage(n);if(i!=null&&i.naturalWidth&&(i!=null&&i.naturalHeight))return{width:i.naturalWidth,height:i.naturalHeight}}return null}async loadImage(e){return await new Promise(t=>{let n=new Image;n.onload=()=>t(n),n.onerror=()=>t(null),n.src=e})}async showManualCropModal(e,t,n){let i=t.width/t.height,a=URL.createObjectURL(e),o=await this.loadImage(a);try{URL.revokeObjectURL(a)}catch{}if(!(o!=null&&o.naturalWidth)||!(o!=null&&o.naturalHeight))return null;let r=await this.loadImageForValue(n);return await new Promise(l=>{let c=document.createElement("div");c.className="asset-crop-modal";let u=Math.min(860,window.innerWidth-60),g=Math.max(220,Math.floor((u-32-16)/2)),b=Math.min(520,window.innerHeight-240),f=g,m=f/i;m>b&&(m=b,f=m*i),c.innerHTML=`
|
|
386
|
+
<div class="asset-crop-card" style="width:${u}px;">
|
|
387
|
+
<div class="asset-crop-header">
|
|
388
|
+
<div>
|
|
389
|
+
<div class="asset-crop-title">Crop to match current asset</div>
|
|
390
|
+
<div class="asset-crop-subtitle">${t.width}\xD7${t.height}px \u2022 ${i.toFixed(3)} ratio</div>
|
|
391
|
+
</div>
|
|
392
|
+
<button class="asset-crop-close" type="button">Close</button>
|
|
393
|
+
</div>
|
|
394
|
+
<div class="asset-crop-body">
|
|
395
|
+
<div class="asset-crop-column">
|
|
396
|
+
<div class="asset-crop-label">Crop</div>
|
|
397
|
+
<canvas class="asset-crop-canvas" width="${Math.round(f)}" height="${Math.round(m)}"></canvas>
|
|
398
|
+
</div>
|
|
399
|
+
<div class="asset-crop-column">
|
|
400
|
+
<div class="asset-crop-label">Compare</div>
|
|
401
|
+
<canvas class="asset-crop-preview" width="${Math.round(f)}" height="${Math.round(m)}"></canvas>
|
|
402
|
+
</div>
|
|
403
|
+
</div>
|
|
404
|
+
<div class="asset-crop-controls">
|
|
405
|
+
<label>Zoom</label>
|
|
406
|
+
<input class="asset-crop-zoom" type="range" min="0.5" max="3" step="0.01" value="1">
|
|
407
|
+
<span class="asset-crop-zoom-value">1.00\xD7</span>
|
|
408
|
+
<button class="asset-crop-reset" type="button">Center</button>
|
|
409
|
+
</div>
|
|
410
|
+
<div class="asset-crop-actions">
|
|
411
|
+
<button class="asset-crop-cancel" type="button">Cancel</button>
|
|
412
|
+
<button class="asset-crop-apply" type="button">Apply Crop</button>
|
|
413
|
+
</div>
|
|
414
|
+
</div>
|
|
415
|
+
`;let y=c.querySelector(".asset-crop-canvas"),v=c.querySelector(".asset-crop-preview"),w=c.querySelector(".asset-crop-zoom"),S=c.querySelector(".asset-crop-zoom-value"),A=c.querySelector(".asset-crop-close"),I=c.querySelector(".asset-crop-cancel"),T=c.querySelector(".asset-crop-apply"),C=c.querySelector(".asset-crop-reset");if(!y||!v||!w||!S){l(null);return}let L=y.getContext("2d"),O=v.getContext("2d");if(!L||!O){l(null);return}let _=o.naturalWidth,E=o.naturalHeight,B=Math.max(y.width/_,y.height/E),M=1,x=0,k=0,P=!1,z=0,D=0,R=0,V=0,ye=()=>{let H=B*M,te=Math.max(0,(_*H-y.width)/2),X=Math.max(0,(E*H-y.height)/2);x=Math.min(te,Math.max(-te,x)),k=Math.min(X,Math.max(-X,k))},de=()=>{let H=B*M;L.clearRect(0,0,y.width,y.height);let te=y.width/2-_*H/2+x,X=y.height/2-E*H/2+k;if(L.drawImage(o,te,X,_*H,E*H),O.clearRect(0,0,v.width,v.height),r!=null&&r.naturalWidth&&(r!=null&&r.naturalHeight)){let ne=Math.max(v.width/r.naturalWidth,v.height/r.naturalHeight),De=v.width/2-r.naturalWidth*ne/2,ve=v.height/2-r.naturalHeight*ne/2;O.drawImage(r,De,ve,r.naturalWidth*ne,r.naturalHeight*ne)}else O.fillStyle="rgba(255, 255, 255, 0.04)",O.fillRect(0,0,v.width,v.height),O.strokeStyle="rgba(255, 255, 255, 0.08)",O.strokeRect(4,4,v.width-8,v.height-8);let pe=v.width/y.width*(B*M),he=x*(v.width/y.width),Y=k*(v.height/y.height),Ee=v.width/2-_*pe/2+he,Be=v.height/2-E*pe/2+Y;O.save(),O.globalAlpha=.7,O.drawImage(o,Ee,Be,_*pe,E*pe),O.restore()},qe=()=>{x=0,k=0,ye(),de()};w.addEventListener("input",()=>{M=Number(w.value),S.textContent=`${M.toFixed(2)}\xD7`,ye(),de()}),y.addEventListener("pointerdown",H=>{P=!0,z=H.clientX,D=H.clientY,R=x,V=k,y.setPointerCapture(H.pointerId)}),y.addEventListener("pointermove",H=>{P&&(x=R+(H.clientX-z),k=V+(H.clientY-D),ye(),de())}),y.addEventListener("pointerup",H=>{P=!1,y.releasePointerCapture(H.pointerId)}),y.addEventListener("pointerleave",()=>{P=!1});let He=()=>{c.remove()},ue=()=>{He(),l(null)},Qe=async()=>{let H=document.createElement("canvas");H.width=t.width,H.height=t.height;let te=H.getContext("2d");if(!te){He(),l(null);return}let X=M,he=Math.max(H.width/_,H.height/E)*X,Y=H.width/y.width,Ee=x*Y,Be=k*Y,ne=H.width/2-_*he/2+Ee,De=H.height/2-E*he/2+Be;te.drawImage(o,ne,De,_*he,E*he);let ve=await new Promise(Le=>{H.toBlob(Ze=>Le(Ze),e.type||"image/png")});if(He(),!ve){l(null);return}l(new File([ve],e.name,{type:ve.type}))};A==null||A.addEventListener("click",ue),I==null||I.addEventListener("click",ue),C==null||C.addEventListener("click",qe),T==null||T.addEventListener("click",()=>{Qe()}),c.addEventListener("click",H=>{H.target===c&&ue()}),document.body.appendChild(c),qe()})}async loadImageForValue(e){let t=this.resolveAssetUrls(e);if(!t.length)return null;for(let n of t){let i=await this.loadImage(n);if(i)return i}return null}};function eo(s){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(s)})}function to(s){var i;let[e,t]=s.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(i=n==null?void 0:n[1])!=null?i:"image/png"}}function is(s){return["Analyze these screenshots and extract brand DNA.",s?`RULES: ${s}`:""].filter(Boolean).join(`
|
|
416
|
+
`)}function an(){let s=[],e="",t=null;return{async addSources(n){let i=[];for(let a of n){let o=await eo(a),r=to(o),l={id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,name:a.name,base64:r.base64,mimeType:r.mimeType,dataUrl:o};s.push(l),i.push(l)}return i},getSources(){return s.slice()},async analyze(n,i,a){return t={summary:e||`Brand DNA (stub). Model=${a||"unknown"}. Rules=${i||"none"}.`,palette:[]},t},setSummary(n){e=n,t&&(t={...t,summary:n})},getResult(){return t}}}var sn=class{constructor(){this.root=null;this.assetsContainer=null;this.apiKeyInput=null;this.rulesInput=null;this.analyzeBtn=null;this.statusEl=null;this.dnaSummaryInput=null;this.dnaPaletteContainer=null;this.dnaSourceInput=null;this.dnaSourceList=null;this.analysisModelSelect=null;this.editModelSelect=null;this.instructionInput=null;this.runBatchBtn=null;this.applyAllBtn=null;this.selectAllInput=null;this.referenceUploadInput=null;this.referenceUploadName=null;this.retryTimer=null;this.dnaAnalyzer=an();this.referenceOverride=null;this.assetValues={};this.batchOutputs=new Map;this.itemStatus=new Map;this.batchRunning=!1}render(){return`
|
|
417
|
+
<div class="scene-panel batch-ai panel-accent-violet" data-panel="batch-ai">
|
|
418
|
+
<div class="scene-panel-header" data-panel-handle>
|
|
419
|
+
<div class="panel-title">
|
|
420
|
+
<span class="panel-pill">AI</span>
|
|
421
|
+
<span class="panel-title-text">Batch AI Image Edit</span>
|
|
422
|
+
</div>
|
|
423
|
+
<div class="scene-panel-actions">
|
|
424
|
+
<button class="scene-panel-toggle" type="button" data-panel-toggle>\u25BE</button>
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
<div class="scene-panel-body">
|
|
428
|
+
<div class="panel-section">
|
|
429
|
+
<div class="panel-section-title">Brand DNA Builder</div>
|
|
430
|
+
<label class="batch-ai-label">API Key</label>
|
|
431
|
+
<input class="batch-ai-input" type="password" data-batch-api-key placeholder="Paste Gemini API key">
|
|
432
|
+
|
|
433
|
+
<label class="batch-ai-label">Screenshots</label>
|
|
434
|
+
<div class="batch-ai-row">
|
|
435
|
+
<button class="batch-ai-btn" type="button" data-batch-upload>Upload screenshots</button>
|
|
436
|
+
<input class="batch-ai-file" type="file" accept="image/*" multiple data-batch-upload-input>
|
|
437
|
+
<span class="batch-ai-file-name" data-batch-file-list>None</span>
|
|
438
|
+
</div>
|
|
439
|
+
|
|
440
|
+
<label class="batch-ai-label">Rules / Notes (optional)</label>
|
|
441
|
+
<textarea class="batch-ai-textarea" data-batch-rules placeholder="Ex: Neon pop brand, glossy UI, high contrast..."></textarea>
|
|
442
|
+
|
|
443
|
+
<label class="batch-ai-label">Analysis model</label>
|
|
444
|
+
<select class="batch-ai-select" data-batch-analysis-model>
|
|
445
|
+
<option value="gemini-2.5-flash">Gemini 2.5 Flash (text)</option>
|
|
446
|
+
<option value="gemini-3-pro-image-preview">Gemini 3 Pro (preview)</option>
|
|
447
|
+
</select>
|
|
448
|
+
|
|
449
|
+
<div class="batch-ai-row">
|
|
450
|
+
<button class="batch-ai-btn primary" type="button" data-batch-analyze>Analyze Brand DNA</button>
|
|
451
|
+
<span class="batch-ai-status" data-batch-status>Idle</span>
|
|
452
|
+
</div>
|
|
453
|
+
|
|
454
|
+
<div class="batch-ai-dna">
|
|
455
|
+
<label class="batch-ai-label">DNA Summary (editable)</label>
|
|
456
|
+
<textarea class="batch-ai-textarea" data-batch-dna-summary placeholder="DNA summary will appear here..."></textarea>
|
|
457
|
+
<div class="batch-ai-palette" data-batch-palette></div>
|
|
458
|
+
</div>
|
|
459
|
+
</div>
|
|
460
|
+
|
|
461
|
+
<div class="panel-section">
|
|
462
|
+
<div class="panel-section-title">Batch Edit</div>
|
|
463
|
+
<label class="batch-ai-label">Instruction</label>
|
|
464
|
+
<textarea class="batch-ai-textarea" data-batch-instruction placeholder="What should change? (applies to all selected assets)"></textarea>
|
|
465
|
+
|
|
466
|
+
<label class="batch-ai-label">Edit model</label>
|
|
467
|
+
<select class="batch-ai-select" data-batch-edit-model>
|
|
468
|
+
<option value="gemini-2.5-flash-image">Gemini 2.5 Flash (image)</option>
|
|
469
|
+
<option value="gemini-3-pro-image-preview">Gemini 3 Pro (preview)</option>
|
|
470
|
+
</select>
|
|
471
|
+
|
|
472
|
+
<label class="batch-ai-label">Reference override (optional)</label>
|
|
473
|
+
<div class="batch-ai-row">
|
|
474
|
+
<button class="batch-ai-btn" type="button" data-batch-ref-upload>Upload reference</button>
|
|
475
|
+
<input class="batch-ai-file" type="file" accept="image/*" data-batch-ref-input>
|
|
476
|
+
<span class="batch-ai-file-name" data-batch-ref-name>None</span>
|
|
477
|
+
</div>
|
|
478
|
+
|
|
479
|
+
<div class="batch-ai-row batch-ai-actions">
|
|
480
|
+
<label class="batch-ai-toggle">
|
|
481
|
+
<input type="checkbox" data-batch-select-all>
|
|
482
|
+
Select all
|
|
483
|
+
</label>
|
|
484
|
+
<button class="batch-ai-btn" type="button" data-batch-run>Run batch</button>
|
|
485
|
+
<button class="batch-ai-btn" type="button" data-batch-apply-all>Apply all</button>
|
|
486
|
+
</div>
|
|
487
|
+
|
|
488
|
+
<div class="batch-ai-asset-list" data-batch-assets></div>
|
|
489
|
+
</div>
|
|
490
|
+
</div>
|
|
491
|
+
<div class="panel-resize-handle" data-panel-resize></div>
|
|
492
|
+
</div>
|
|
493
|
+
`}initialize(e){var i,a,o,r,l,c,u;if(this.root=e.querySelector('[data-panel="batch-ai"]'),!this.root)return;this.assetsContainer=this.root.querySelector("[data-batch-assets]"),this.apiKeyInput=this.root.querySelector("[data-batch-api-key]"),this.rulesInput=this.root.querySelector("[data-batch-rules]"),this.analyzeBtn=this.root.querySelector("[data-batch-analyze]"),this.statusEl=this.root.querySelector("[data-batch-status]"),this.dnaSummaryInput=this.root.querySelector("[data-batch-dna-summary]"),this.dnaPaletteContainer=this.root.querySelector("[data-batch-palette]"),this.dnaSourceInput=this.root.querySelector("[data-batch-upload-input]"),this.dnaSourceList=this.root.querySelector("[data-batch-file-list]"),this.analysisModelSelect=this.root.querySelector("[data-batch-analysis-model]"),this.editModelSelect=this.root.querySelector("[data-batch-edit-model]"),this.instructionInput=this.root.querySelector("[data-batch-instruction]"),this.runBatchBtn=this.root.querySelector("[data-batch-run]"),this.applyAllBtn=this.root.querySelector("[data-batch-apply-all]"),this.selectAllInput=this.root.querySelector("[data-batch-select-all]"),this.referenceUploadInput=this.root.querySelector("[data-batch-ref-input]"),this.referenceUploadName=this.root.querySelector("[data-batch-ref-name]");let t=this.root.querySelector("[data-batch-upload]");t==null||t.addEventListener("click",()=>{var d;return(d=this.dnaSourceInput)==null?void 0:d.click()}),(i=this.dnaSourceInput)==null||i.addEventListener("change",()=>{this.handleSourceUpload()});let n=this.root.querySelector("[data-batch-ref-upload]");n==null||n.addEventListener("click",()=>{var d;return(d=this.referenceUploadInput)==null?void 0:d.click()}),(a=this.referenceUploadInput)==null||a.addEventListener("change",()=>{this.handleReferenceUpload()}),(o=this.analyzeBtn)==null||o.addEventListener("click",()=>{this.analyzeBrandDNA()}),(r=this.runBatchBtn)==null||r.addEventListener("click",()=>{this.runBatch()}),(l=this.applyAllBtn)==null||l.addEventListener("click",()=>this.applyAllOutputs()),(c=this.selectAllInput)==null||c.addEventListener("change",()=>{var p,h,g;let d=(h=(p=this.selectAllInput)==null?void 0:p.checked)!=null?h:!1;(g=this.root)==null||g.querySelectorAll("[data-batch-select]").forEach(b=>{b.checked=d})}),(u=this.dnaSummaryInput)==null||u.addEventListener("input",()=>{var p,h;let d=(h=(p=this.dnaSummaryInput)==null?void 0:p.value)!=null?h:"";this.dnaAnalyzer.setSummary(d)}),this.setupResizeHandle(),this.refresh()}refresh(){var n;let e=this.getEngineSnapshot();if(!e){this.renderEmpty(),this.scheduleRetry();return}this.assetValues=(n=e.assets)!=null?n:{},this.renderAssets(this.assetValues),this.updateSourceList();let t=this.dnaAnalyzer.getResult();t&&this.updateDna(t.summary,t.palette)}renderEmpty(){this.assetsContainer&&(this.assetsContainer.innerHTML='<div class="batch-ai-empty">No image assets found yet.</div>'),this.scheduleRetry()}scheduleRetry(){this.retryTimer||(this.retryTimer=window.setTimeout(()=>{this.retryTimer=null,this.refresh()},400))}clearRetry(){this.retryTimer&&(window.clearTimeout(this.retryTimer),this.retryTimer=null)}isImageAsset(e){let t=e.trim();if(!t)return!1;if(/^(data:image|blob:)/.test(t))return!0;let n=t.split("?")[0].toLowerCase();return[".mp3",".wav",".ogg",".json"].some(i=>n.endsWith(i))?!1:([".png",".jpg",".jpeg",".webp",".gif",".svg"].some(i=>n.endsWith(i)),!0)}getEngineSnapshot(){var n;let e=window.getEditableEngineConfig;return typeof e!="function"?null:{assets:(n=e().assets)!=null?n:{}}}setupResizeHandle(){if(!this.root)return;let e=this.root.querySelector("[data-panel-resize]");if(!e)return;let t=window.localStorage.getItem("batchAiPanelWidth"),n=t?Number(t):NaN;Number.isFinite(n)&&n>0&&(this.root.style.width=`${n}px`);let i=a=>{var p,h;a.preventDefault();let o=a.clientX,r=(h=(p=this.root)==null?void 0:p.getBoundingClientRect().width)!=null?h:0,l=300,c=680,u=g=>{let b=g.clientX-o,f=Math.min(c,Math.max(l,r+b));this.root&&(this.root.style.width=`${f}px`)},d=()=>{var b,f;window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",d);let g=(f=(b=this.root)==null?void 0:b.getBoundingClientRect().width)!=null?f:0;g>0&&window.localStorage.setItem("batchAiPanelWidth",String(Math.round(g)))};window.addEventListener("pointermove",u),window.addEventListener("pointerup",d)};e.addEventListener("pointerdown",i)}renderAssets(e){if(!this.assetsContainer)return;this.assetsContainer.innerHTML="";let t=Object.entries(e).filter(([,n])=>this.isImageAsset(n));if(!t.length){this.renderEmpty();return}this.clearRetry(),t.forEach(([n,i])=>{var v,w;let a=document.createElement("div");a.className="batch-ai-item",a.dataset.batchItem=n,a.dataset.batchValue=i!=null?i:"";let o=document.createElement("div");o.className="batch-ai-item-header";let r=document.createElement("label");r.className="batch-ai-toggle";let l=document.createElement("input");l.type="checkbox",l.dataset.batchSelect=n,r.appendChild(l);let c=document.createElement("span");c.textContent=n,r.appendChild(c);let u=document.createElement("select");u.className="batch-ai-select",u.dataset.batchRef=n,this.populateReferenceSelect(u),o.appendChild(r),o.appendChild(u);let d=document.createElement("div");d.className="batch-ai-item-body";let p=document.createElement("img");p.className="batch-ai-thumb",p.alt=`${n} preview`;let h=this.batchOutputs.get(n);h!=null&&h.dataUrl?(p.src=h.dataUrl,p.classList.remove("hidden")):p.classList.add("hidden");let g=document.createElement("div");g.className="batch-ai-item-status",g.textContent=(v=this.itemStatus.get(n))!=null?v:"Idle";let b=document.createElement("div");b.className="batch-ai-item-actions";let f=document.createElement("button");f.type="button",f.className="batch-ai-btn",f.textContent="Generate",f.dataset.batchGenerate=n,f.addEventListener("click",()=>{this.generateForAsset(n)});let m=document.createElement("button");m.type="button",m.className="batch-ai-btn",m.textContent="Apply",m.dataset.batchApply=n,m.disabled=!(h!=null&&h.dataUrl),m.addEventListener("click",()=>this.applyOutputForAsset(n));let y=document.createElement("button");y.type="button",y.className="batch-ai-btn",y.textContent="Download",y.dataset.batchDownload=n,y.disabled=!(h!=null&&h.dataUrl),y.addEventListener("click",()=>this.downloadOutputForAsset(n)),b.appendChild(f),b.appendChild(m),b.appendChild(y),d.appendChild(p),d.appendChild(g),d.appendChild(b),a.appendChild(o),a.appendChild(d),(w=this.assetsContainer)==null||w.appendChild(a)})}async handleSourceUpload(){var i;let e=(i=this.dnaSourceInput)==null?void 0:i.files;if(!e||e.length===0)return;let t=Array.from(e);(await this.dnaAnalyzer.addSources(t)).length&&(this.updateSourceList(),this.renderAssets(this.assetValues),this.refreshReferenceOptions())}async handleReferenceUpload(){var n,i;let e=(i=(n=this.referenceUploadInput)==null?void 0:n.files)==null?void 0:i[0];if(!e)return;let t=await yt(e);t&&(this.referenceOverride={id:"upload",name:e.name,base64:t.base64,mimeType:t.mimeType,dataUrl:t.dataUrl},this.referenceUploadName&&(this.referenceUploadName.textContent=`${e.name} (ready)`),this.renderAssets(this.assetValues),this.refreshReferenceOptions())}updateSourceList(){if(!this.dnaSourceList)return;let e=this.dnaAnalyzer.getSources();if(!e.length){this.dnaSourceList.textContent="None";return}this.dnaSourceList.textContent=`${e.length} screenshots loaded`}populateReferenceSelect(e){let t=e.value;e.innerHTML="";let n=document.createElement("option");if(n.value="",n.textContent="No reference",e.appendChild(n),this.dnaAnalyzer.getSources().forEach(i=>{let a=document.createElement("option");a.value=i.id,a.textContent=`DNA: ${i.name}`,e.appendChild(a)}),this.referenceOverride){let i=document.createElement("option");i.value="upload",i.textContent=`Upload: ${this.referenceOverride.name}`,e.appendChild(i)}this.batchOutputs.forEach((i,a)=>{if(!(i!=null&&i.dataUrl))return;let o=document.createElement("option");o.value=`output:${a}`,o.textContent=`AI: ${a}`,e.appendChild(o)}),e.value=t,e.value!==t&&(e.value="")}refreshReferenceOptions(){if(!this.root)return;Array.from(this.root.querySelectorAll("[data-batch-ref]")).forEach(t=>this.populateReferenceSelect(t))}getOutputReference(e){var r,l;let t=e.replace(/^output:/,""),n=(r=this.batchOutputs.get(t))==null?void 0:r.dataUrl;if(!n)return null;let[i,a]=n.split(","),o=i==null?void 0:i.match(/data:(.*?);base64/);return{id:`output:${t}`,name:t,base64:a!=null?a:n,mimeType:(l=o==null?void 0:o[1])!=null?l:"image/png",dataUrl:n}}setStatus(e){this.statusEl&&(this.statusEl.textContent=e)}setItemStatus(e,t){var a;this.itemStatus.set(e,t);let n=(a=this.assetsContainer)==null?void 0:a.querySelector(`[data-batch-item="${e}"]`),i=n==null?void 0:n.querySelector(".batch-ai-item-status");i&&(i.textContent=t)}updateItemOutput(e,t){var r;this.batchOutputs.set(e,{dataUrl:t,updatedAt:Date.now()});let n=(r=this.assetsContainer)==null?void 0:r.querySelector(`[data-batch-item="${e}"]`),i=n==null?void 0:n.querySelector(".batch-ai-thumb");i&&(i.src=t,i.classList.remove("hidden"));let a=n==null?void 0:n.querySelector(`[data-batch-apply="${e}"]`),o=n==null?void 0:n.querySelector(`[data-batch-download="${e}"]`);a&&(a.disabled=!1),o&&(o.disabled=!1),this.refreshReferenceOptions()}async analyzeBrandDNA(){var i,a,o,r,l,c,u,d;let e=(o=(a=(i=this.apiKeyInput)==null?void 0:i.value)==null?void 0:a.trim())!=null?o:"";if(!e){this.setStatus("Missing API key.");return}if(!this.dnaAnalyzer.getSources().length){this.setStatus("Upload screenshots first.");return}let t=(c=(l=(r=this.rulesInput)==null?void 0:r.value)==null?void 0:l.trim())!=null?c:"",n=(d=(u=this.analysisModelSelect)==null?void 0:u.value)!=null?d:"gemini-2.5-flash";this.setStatus("Analyzing..."),this.analyzeBtn&&(this.analyzeBtn.disabled=!0);try{let p=await this.dnaAnalyzer.analyze(e,t,n);this.updateDna(p.summary,p.palette),this.setStatus("DNA ready.")}catch(p){console.warn("[AI] DNA analysis failed:",p),this.setStatus("DNA analysis failed. Check console.")}finally{this.analyzeBtn&&(this.analyzeBtn.disabled=!1)}}updateDna(e,t){if(this.dnaSummaryInput&&(this.dnaSummaryInput.value=e,this.dnaAnalyzer.setSummary(e)),this.dnaPaletteContainer)if(this.dnaPaletteContainer.innerHTML="",t.length)t.forEach(n=>{var a;let i=document.createElement("div");i.className="batch-ai-swatch",i.style.background=n,i.title=n,(a=this.dnaPaletteContainer)==null||a.appendChild(i)});else{let n=document.createElement("span");n.className="batch-ai-muted",n.textContent="Palette not detected.",this.dnaPaletteContainer.appendChild(n)}}getSelectedKeys(){var t;let e=[];return(t=this.root)==null||t.querySelectorAll("[data-batch-select]").forEach(n=>{let i=n;i.checked&&i.dataset.batchSelect&&e.push(i.dataset.batchSelect)}),e}async runBatch(){if(this.batchRunning)return;let e=this.getSelectedKeys();if(!e.length){this.setStatus("Select assets to process.");return}this.batchRunning=!0,this.setStatus(`Running batch (${e.length})...`),this.runBatchBtn&&(this.runBatchBtn.disabled=!0);try{for(let t of e)await this.generateForAsset(t);this.setStatus("Batch complete.")}finally{this.batchRunning=!1,this.runBatchBtn&&(this.runBatchBtn.disabled=!1)}}async generateForAsset(e){var f,m,y,v,w,S,A,I,T,C,L,O,_,E,B,M,x,k,P;let t=(y=(m=(f=this.apiKeyInput)==null?void 0:f.value)==null?void 0:m.trim())!=null?y:"";if(!t){this.setItemStatus(e,"Missing API key.");return}let n=this.assetValues[e];if(!n){this.setItemStatus(e,"Missing asset path.");return}let i=(w=(v=this.editModelSelect)==null?void 0:v.value)!=null?w:"gemini-2.5-flash-image",a=(S=this.assetsContainer)==null?void 0:S.querySelector(`[data-batch-item="${e}"]`),o=a==null?void 0:a.querySelector(`[data-batch-ref="${e}"]`),r=(A=o==null?void 0:o.value)!=null?A:"";this.setItemStatus(e,"Loading base image...");let l=await this.getImageDataFromAsset(n);if(!l){this.setItemStatus(e,"Failed to load base image.");return}let c=null;r==="upload"?c=this.referenceOverride:r.startsWith("output:")?c=this.getOutputReference(r):r&&(c=(I=this.dnaAnalyzer.getSources().find(z=>z.id===r))!=null?I:null);let u=(L=(C=(T=this.dnaSummaryInput)==null?void 0:T.value)==null?void 0:C.trim())!=null?L:"",d=(E=(_=(O=this.instructionInput)==null?void 0:O.value)==null?void 0:_.trim())!=null?E:"",p=(x=(M=(B=this.rulesInput)==null?void 0:B.value)==null?void 0:M.trim())!=null?x:"",h=(P=(k=this.dnaAnalyzer.getResult())==null?void 0:k.palette)!=null?P:[],g=this.buildEditPrompt(u,p,d,!!c,h),b=[l.input];c?(b.push({base64:c.base64,mimeType:c.mimeType}),this.setItemStatus(e,"Generating with reference...")):this.setItemStatus(e,"Generating...");try{let z=tn(l.width,l.height),D=await Qt(t,g,b,{aspectRatio:z,model:i}),R=await en(D);this.updateItemOutput(e,R!=null?R:D),this.setItemStatus(e,"Ready.")}catch(z){console.warn("[AI] Batch generation failed:",z),this.setItemStatus(e,"Generation failed.")}}buildEditPrompt(e,t,n,i,a){var r;return`
|
|
494
|
+
Convert this image style to:
|
|
495
|
+
${(r=e==null?void 0:e.trim())!=null?r:""}
|
|
496
|
+
|
|
497
|
+
BACKGROUND:
|
|
498
|
+
- Replace the background with SOLID MAGENTA (#FF00FF).
|
|
499
|
+
- Background must be flat and uniform for easy removal after generation.
|
|
500
|
+
`.trim()}applyOutputForAsset(e){var i;let t=(i=this.batchOutputs.get(e))==null?void 0:i.dataUrl;if(!t){this.setItemStatus(e,"No output to apply.");return}let n=window.applyEditableEngineConfig;if(typeof n!="function"){this.setItemStatus(e,"Engine bridge missing.");return}n({assets:{[e]:t}}),this.setItemStatus(e,"Applied.")}applyAllOutputs(){let e=window.applyEditableEngineConfig;if(typeof e!="function"){this.setStatus("Engine bridge missing.");return}let t={};if(this.batchOutputs.forEach((n,i)=>{t[i]=n.dataUrl}),!Object.keys(t).length){this.setStatus("No outputs to apply.");return}e({assets:t}),this.setStatus("Applied all outputs.")}downloadOutputForAsset(e){var i;let t=(i=this.batchOutputs.get(e))==null?void 0:i.dataUrl;if(!t){this.setItemStatus(e,"No output to download.");return}let n=document.createElement("a");n.href=t,n.download=`${e}-batch.png`,n.click()}async getImageDataFromAsset(e){let t=this.resolveAssetUrls(e);for(let n of t){let i=await Zt(n);if(i)return{input:{base64:i.base64,mimeType:i.mimeType},dataUrl:i.dataUrl,width:i.width,height:i.height}}return null}resolveAssetUrls(e){let t=e.trim();if(!t)return[];if(/^(blob:|data:|https?:|\/)/.test(t))return[t];let n=t.replace(/^\.?\//,"");return n.startsWith("raw/")?[`/${n}`,`/assets/${n}`]:n.startsWith("assets/")?[`/${n}`]:[`/raw/${n}`,`/assets/raw/${n}`,`/assets/${n}`]}};async function as(s,e,t=[],n={}){return`AI stub response (model=${n.model||"unknown"}).
|
|
501
|
+
|
|
502
|
+
Prompt:
|
|
503
|
+
${e}`}var on=class{constructor(){this.root=null;this.apiKeyInput=null;this.rulesInput=null;this.analyzeBtn=null;this.statusEl=null;this.sourceInput=null;this.sourceList=null;this.modelSelect=null;this.summaryInput=null;this.paletteContainer=null;this.lastPromptEl=null;this.gamePromptInput=null;this.gameModelSelect=null;this.gameStatusEl=null;this.gameLastPromptEl=null;this.objectListEl=null;this.generateAllBtn=null;this.refreshObjectsBtn=null;this.gamePromptValue="";this.gamePromptLoading=null;this.analyzer=an();this.objectOutputs=new Map;this.objectStatus=new Map}render(){return`
|
|
504
|
+
<div class="scene-panel brand-dna panel-accent-blue" data-panel="brand-dna">
|
|
505
|
+
<div class="scene-panel-header" data-panel-handle>
|
|
506
|
+
<div class="panel-title">
|
|
507
|
+
<span class="panel-pill">AI</span>
|
|
508
|
+
<span class="panel-title-text">Brand DNA Analyzer</span>
|
|
509
|
+
</div>
|
|
510
|
+
<div class="scene-panel-actions">
|
|
511
|
+
<button class="scene-panel-toggle" type="button" data-panel-toggle>\u25BE</button>
|
|
512
|
+
</div>
|
|
513
|
+
</div>
|
|
514
|
+
<div class="scene-panel-body">
|
|
515
|
+
<div class="panel-section">
|
|
516
|
+
<div class="panel-section-title">DNA Analyzer</div>
|
|
517
|
+
<label class="brand-dna-label">API Key</label>
|
|
518
|
+
<input class="brand-dna-input" type="password" data-brand-api-key placeholder="Paste Gemini API key">
|
|
519
|
+
|
|
520
|
+
<label class="brand-dna-label">Screenshots</label>
|
|
521
|
+
<div class="brand-dna-row">
|
|
522
|
+
<button class="brand-dna-btn" type="button" data-brand-upload>Upload screenshots</button>
|
|
523
|
+
<input class="brand-dna-file" type="file" accept="image/*" multiple data-brand-upload-input>
|
|
524
|
+
<span class="brand-dna-file-name" data-brand-file-list>None</span>
|
|
525
|
+
</div>
|
|
526
|
+
|
|
527
|
+
<label class="brand-dna-label">Rules / Notes (optional)</label>
|
|
528
|
+
<textarea class="brand-dna-textarea" data-brand-rules placeholder="Extra notes for DNA analysis"></textarea>
|
|
529
|
+
|
|
530
|
+
<label class="brand-dna-label">Analysis model</label>
|
|
531
|
+
<select class="brand-dna-select" data-brand-model>
|
|
532
|
+
<option value="gemini-2.5-flash">Gemini 2.5 Flash (text)</option>
|
|
533
|
+
<option value="gemini-3-pro-image-preview">Gemini 3 Pro (preview)</option>
|
|
534
|
+
</select>
|
|
535
|
+
|
|
536
|
+
<div class="brand-dna-row">
|
|
537
|
+
<button class="brand-dna-btn primary" type="button" data-brand-analyze>Analyze DNA</button>
|
|
538
|
+
<span class="brand-dna-status" data-brand-status>Idle</span>
|
|
539
|
+
</div>
|
|
540
|
+
|
|
541
|
+
<div class="brand-dna-meta">
|
|
542
|
+
<label class="brand-dna-label">Last sent prompt</label>
|
|
543
|
+
<pre class="brand-dna-prompt" data-brand-last-prompt>No prompt yet.</pre>
|
|
544
|
+
</div>
|
|
545
|
+
|
|
546
|
+
<div class="brand-dna-output">
|
|
547
|
+
<label class="brand-dna-label">DNA Summary (editable)</label>
|
|
548
|
+
<textarea class="brand-dna-textarea" data-brand-summary placeholder="DNA summary will appear here..."></textarea>
|
|
549
|
+
<div class="brand-dna-palette" data-brand-palette></div>
|
|
550
|
+
</div>
|
|
551
|
+
</div>
|
|
552
|
+
|
|
553
|
+
<div class="panel-section">
|
|
554
|
+
<div class="panel-section-title">Game Mechanic Converter</div>
|
|
555
|
+
<label class="brand-dna-label">Game prompt (from engine runtime)</label>
|
|
556
|
+
<textarea class="brand-dna-textarea" data-brand-game-prompt placeholder="Loaded from engine.runtime.json" readonly></textarea>
|
|
557
|
+
|
|
558
|
+
<label class="brand-dna-label">Model</label>
|
|
559
|
+
<select class="brand-dna-select" data-brand-game-model>
|
|
560
|
+
<option value="gemini-2.5-flash">Gemini 2.5 Flash (text)</option>
|
|
561
|
+
<option value="gemini-3-pro-image-preview">Gemini 3 Pro (preview)</option>
|
|
562
|
+
</select>
|
|
563
|
+
|
|
564
|
+
<div class="brand-dna-row">
|
|
565
|
+
<button class="brand-dna-btn" type="button" data-brand-refresh>Refresh Objects</button>
|
|
566
|
+
<button class="brand-dna-btn primary" type="button" data-brand-generate-all>Generate All</button>
|
|
567
|
+
<span class="brand-dna-status" data-brand-game-status>Idle</span>
|
|
568
|
+
</div>
|
|
569
|
+
|
|
570
|
+
<div class="brand-dna-meta">
|
|
571
|
+
<label class="brand-dna-label">Last sent prompt</label>
|
|
572
|
+
<pre class="brand-dna-prompt" data-brand-game-prompt-log>No prompt yet.</pre>
|
|
573
|
+
</div>
|
|
574
|
+
|
|
575
|
+
<div class="brand-dna-object-list" data-brand-objects></div>
|
|
576
|
+
</div>
|
|
577
|
+
</div>
|
|
578
|
+
<div class="panel-resize-handle" data-panel-resize></div>
|
|
579
|
+
</div>
|
|
580
|
+
`}initialize(e){var n,i,a,o,r;if(this.root=e.querySelector('[data-panel="brand-dna"]'),!this.root)return;this.apiKeyInput=this.root.querySelector("[data-brand-api-key]"),this.rulesInput=this.root.querySelector("[data-brand-rules]"),this.analyzeBtn=this.root.querySelector("[data-brand-analyze]"),this.statusEl=this.root.querySelector("[data-brand-status]"),this.sourceInput=this.root.querySelector("[data-brand-upload-input]"),this.sourceList=this.root.querySelector("[data-brand-file-list]"),this.modelSelect=this.root.querySelector("[data-brand-model]"),this.summaryInput=this.root.querySelector("[data-brand-summary]"),this.paletteContainer=this.root.querySelector("[data-brand-palette]"),this.lastPromptEl=this.root.querySelector("[data-brand-last-prompt]"),this.gamePromptInput=this.root.querySelector("[data-brand-game-prompt]"),this.gameModelSelect=this.root.querySelector("[data-brand-game-model]"),this.gameStatusEl=this.root.querySelector("[data-brand-game-status]"),this.gameLastPromptEl=this.root.querySelector("[data-brand-game-prompt-log]"),this.objectListEl=this.root.querySelector("[data-brand-objects]"),this.generateAllBtn=this.root.querySelector("[data-brand-generate-all]"),this.refreshObjectsBtn=this.root.querySelector("[data-brand-refresh]");let t=this.root.querySelector("[data-brand-upload]");t==null||t.addEventListener("click",()=>{var l;return(l=this.sourceInput)==null?void 0:l.click()}),(n=this.sourceInput)==null||n.addEventListener("change",()=>{this.handleSourceUpload()}),(i=this.analyzeBtn)==null||i.addEventListener("click",()=>{this.analyzeDna()}),(a=this.summaryInput)==null||a.addEventListener("input",()=>{var c,u;let l=(u=(c=this.summaryInput)==null?void 0:c.value)!=null?u:"";this.analyzer.setSummary(l)}),(o=this.generateAllBtn)==null||o.addEventListener("click",()=>{this.generateAllObjects()}),(r=this.refreshObjectsBtn)==null||r.addEventListener("click",()=>{this.refreshObjects()}),this.setupResizeHandle(),this.refresh()}refresh(){this.updateSourceList(),this.updateDnaDisplay(),this.updateGamePrompt(),this.refreshObjects()}setupResizeHandle(){if(!this.root)return;let e=this.root.querySelector("[data-panel-resize]");if(!e)return;let t=window.localStorage.getItem("brandDnaPanelWidth"),n=t?Number(t):NaN;Number.isFinite(n)&&n>0&&(this.root.style.width=`${n}px`);let i=a=>{var p,h;a.preventDefault();let o=a.clientX,r=(h=(p=this.root)==null?void 0:p.getBoundingClientRect().width)!=null?h:0,l=300,c=700,u=g=>{let b=g.clientX-o,f=Math.min(c,Math.max(l,r+b));this.root&&(this.root.style.width=`${f}px`)},d=()=>{var b,f;window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",d);let g=(f=(b=this.root)==null?void 0:b.getBoundingClientRect().width)!=null?f:0;g>0&&window.localStorage.setItem("brandDnaPanelWidth",String(Math.round(g)))};window.addEventListener("pointermove",u),window.addEventListener("pointerup",d)};e.addEventListener("pointerdown",i)}setStatus(e,t){e&&(e.textContent=t)}updateSourceList(){if(!this.sourceList)return;let e=this.analyzer.getSources();this.sourceList.textContent=e.length?`${e.length} screenshots loaded`:"None"}updateDnaDisplay(){let e=this.analyzer.getResult();e&&(this.summaryInput&&(this.summaryInput.value=e.summary),this.renderPalette(e.palette))}updateGamePrompt(){if(this.gamePromptInput){if(this.gamePromptValue){this.gamePromptInput.value=this.gamePromptValue;return}this.loadGamePrompt()}}renderPalette(e){if(this.paletteContainer){if(this.paletteContainer.innerHTML="",!e.length){let t=document.createElement("span");t.className="brand-dna-muted",t.textContent="Palette not detected.",this.paletteContainer.appendChild(t);return}e.forEach(t=>{var i;let n=document.createElement("div");n.className="brand-dna-swatch",n.style.background=t,n.title=t,(i=this.paletteContainer)==null||i.appendChild(n)})}}async handleSourceUpload(){var i;let e=(i=this.sourceInput)==null?void 0:i.files;if(!e||e.length===0)return;let t=Array.from(e);(await this.analyzer.addSources(t)).length&&this.updateSourceList()}async analyzeDna(){var a,o,r,l,c,u,d,p;let e=(r=(o=(a=this.apiKeyInput)==null?void 0:a.value)==null?void 0:o.trim())!=null?r:"";if(!e){this.setStatus(this.statusEl,"Missing API key.");return}let t=(u=(c=(l=this.rulesInput)==null?void 0:l.value)==null?void 0:c.trim())!=null?u:"",n=(p=(d=this.modelSelect)==null?void 0:d.value)!=null?p:"gemini-2.5-flash";if(this.analyzer.getSources().length===0){this.setStatus(this.statusEl,"Upload screenshots first.");return}let i=is(t);this.lastPromptEl&&(this.lastPromptEl.textContent=i),this.setStatus(this.statusEl,"Analyzing..."),this.analyzeBtn&&(this.analyzeBtn.disabled=!0);try{let h=await this.analyzer.analyze(e,t,n);this.updateDnaDisplay(),this.setStatus(this.statusEl,"DNA ready.")}catch(h){console.warn("[AI] DNA analysis failed:",h),this.setStatus(this.statusEl,"DNA analysis failed. Check console.")}finally{this.analyzeBtn&&(this.analyzeBtn.disabled=!1)}}refreshObjects(){if(!this.objectListEl)return;let e=this.getObjectEntries();if(!e.length){this.objectListEl.innerHTML='<div class="brand-dna-empty">No objects found yet.</div>';return}this.objectListEl.innerHTML="",e.forEach(t=>{var g,b,f;let n=document.createElement("div");n.className="brand-dna-object",n.dataset.brandObject=t.id;let i=document.createElement("div");i.className="brand-dna-object-header";let a=document.createElement("div");a.className="brand-dna-object-title",a.textContent=t.label;let o=this.getObjectConfig(t.id),r=this.resolveAssetKey(o),l=(g=this.objectOutputs.get(t.id))!=null?g:"",c=l.trim().length>0,u=document.createElement("button");u.type="button",u.className="brand-dna-btn",u.textContent="Generate",u.addEventListener("click",()=>{this.generateForObject(t.id)});let d=document.createElement("button");d.type="button",d.className="brand-dna-btn",d.textContent="Change",d.disabled=!r||!c,r||(d.title="No image asset found for this object."),d.addEventListener("click",()=>{this.handleChangeObject(t.id)}),i.appendChild(a),i.appendChild(u),i.appendChild(d);let p=document.createElement("div");p.className="brand-dna-object-status",p.textContent=(b=this.objectStatus.get(t.id))!=null?b:"Idle";let h=document.createElement("textarea");h.className="brand-dna-textarea",h.value=l,h.addEventListener("input",()=>{let m=h.value;this.objectOutputs.set(t.id,m),d.disabled=!r||m.trim().length===0}),n.appendChild(i),n.appendChild(p),n.appendChild(h),(f=this.objectListEl)==null||f.appendChild(n)})}getObjectEntries(){let e=window.getEditableObjectList,t=window.getEditableObjectConfig,n=[];if(typeof e=="function"&&(n=e()),!Array.isArray(n)||n.length===0){let i=window.__editableObjectConfigs;i&&typeof i.keys=="function"&&(n=Array.from(i.keys()))}return Array.isArray(n)?n.map(i=>{var l,c;let a=typeof t=="function"?t(i):null,o=(((l=a==null?void 0:a.identity)==null?void 0:l.id)||i).toString(),r=(((c=a==null?void 0:a.identity)==null?void 0:c.category)||"scene").toString();return{id:i,label:o,category:r}}):[]}async generateAllObjects(){let e=this.getObjectEntries();if(!e.length){this.setStatus(this.gameStatusEl,"No objects to generate.");return}this.setStatus(this.gameStatusEl,`Generating ${e.length} objects...`);for(let t of e)await this.generateForObject(t.id);this.setStatus(this.gameStatusEl,"Generation complete.")}async generateForObject(e){var l,c,u,d,p,h,g;let t=(u=(c=(l=this.apiKeyInput)==null?void 0:l.value)==null?void 0:c.trim())!=null?u:"";if(!t){this.setObjectStatus(e,"Missing API key.");return}this.gamePromptValue||await this.loadGamePrompt();let n=this.gamePromptValue;if(!n){this.setObjectStatus(e,"Missing game prompt in configs/engine/game.prompt.json.");return}let i=(p=(d=this.gameModelSelect)==null?void 0:d.value)!=null?p:"gemini-2.5-flash",a=(g=(h=this.analyzer.getResult())==null?void 0:h.summary)!=null?g:"",o=this.getObjectConfig(e),r=this.buildMechanicPrompt(n,a,e,o);this.gameLastPromptEl&&(this.gameLastPromptEl.textContent=r),this.setObjectStatus(e,"Generating...");try{let b=await as(t,r,[],{model:i});this.objectOutputs.set(e,b),this.setObjectStatus(e,"Ready."),this.refreshObjects()}catch(b){console.warn("[AI] Mechanic conversion failed:",b),this.setObjectStatus(e,"Failed.")}}handleChangeObject(e){var o;let t=((o=this.objectOutputs.get(e))!=null?o:"").trim();if(!t){this.setObjectStatus(e,"Add a prompt first.");return}let n=this.getObjectConfig(e),i=this.resolveAssetKey(n);if(!i){this.setObjectStatus(e,"No image asset found.");return}let a=window.__openAiEditor;typeof a=="function"?(a(i,t),this.setObjectStatus(e,`Open AI for ${i}.`)):this.setObjectStatus(e,"AI editor not available.")}setObjectStatus(e,t){var a;this.objectStatus.set(e,t);let n=(a=this.objectListEl)==null?void 0:a.querySelector(`[data-brand-object="${e}"]`),i=n==null?void 0:n.querySelector(".brand-dna-object-status");i&&(i.textContent=t)}getObjectConfig(e){let t=window.getEditableObjectConfig;if(typeof t=="function")return t(e);let n=window.__editableObjectConfigs;return n&&typeof n.get=="function"?n.get(e):null}getEngineAssets(){var n;let e=window.getEditableEngineConfig;if(typeof e!="function")return{};let t=e();return(n=t==null?void 0:t.assets)!=null?n:{}}resolveAssetKey(e){var r,l,c,u,d,p,h,g;if(!e)return null;let t=(l=(r=e==null?void 0:e.render)==null?void 0:r.asset)==null?void 0:l.type;if(t&&t!=="image")return null;let n=(u=(c=e==null?void 0:e.render)==null?void 0:c.asset)==null?void 0:u.id;if(typeof n=="string"&&n.trim())return n;let i=(p=(d=e==null?void 0:e.render)==null?void 0:d.asset)==null?void 0:p.path;if(typeof i!="string")return null;let a=(h=i.split("/").pop())!=null?h:i,o=this.getEngineAssets();for(let[b,f]of Object.entries(o)){if(typeof f!="string")continue;if(((g=f.split("/").pop())!=null?g:f)===a)return b}return null}async loadGamePrompt(){if(this.gamePromptLoading){await this.gamePromptLoading;return}this.gamePromptLoading=(async()=>{try{let e=await this.fetchGamePromptConfig(),t=((e==null?void 0:e.game_prompt)||(e==null?void 0:e.prompt)||"").toString();this.gamePromptValue=t,this.gamePromptInput&&(this.gamePromptInput.value=t)}catch(e){console.warn("[AI] Failed to load game prompt config:",e)}})(),await this.gamePromptLoading,this.gamePromptLoading=null}async fetchGamePromptConfig(){let e=["./configs/engine/game.prompt.json","./engine/game.prompt.json","./engine.game.prompt.json","./game.prompt.json"];for(let t of e)try{let n=await fetch(t,{cache:"force-cache"});if(!n.ok)continue;return await n.json()}catch{}return{}}buildMechanicPrompt(e,t,n,i){let a=this.summarizeObjectConfig(i),o=this.getObjectEntries().map(r=>`- ${r.id} (${r.category})`).join(`
|
|
581
|
+
`);return`
|
|
582
|
+
You are a senior game ad designer.
|
|
583
|
+
GAME PROMPT:
|
|
584
|
+
${e}
|
|
585
|
+
|
|
586
|
+
BRAND DNA:
|
|
587
|
+
${t||"No DNA provided."}
|
|
588
|
+
|
|
589
|
+
OBJECT LIST:
|
|
590
|
+
${o||"No objects found."}
|
|
591
|
+
|
|
592
|
+
OBJECT:
|
|
593
|
+
ID: ${n}
|
|
594
|
+
SUMMARY: ${a}
|
|
595
|
+
|
|
596
|
+
TASK:
|
|
597
|
+
Describe what this object should become in the theme. Be explicit about visual identity, role, materials, and ad language.
|
|
598
|
+
Align the object's vibe and audience fit with the Brand DNA.
|
|
599
|
+
Return 3-6 bullet points, no extra formatting.
|
|
600
|
+
`.trim()}summarizeObjectConfig(e){var n,i,a,o,r,l,c,u,d,p,h,g;if(!e)return"No config.";let t={id:(n=e.identity)==null?void 0:n.id,category:(i=e.identity)==null?void 0:i.category,asset:(o=(a=e.render)==null?void 0:a.asset)==null?void 0:o.path,text:(r=e.ui)==null?void 0:r.text,anchor:(u=(l=e.transform)==null?void 0:l.anchor)!=null?u:(c=e.render)==null?void 0:c.anchor,offset:(h=(d=e.transform)==null?void 0:d.offset)!=null?h:(p=e.transform)==null?void 0:p.position,scale:(g=e.transform)==null?void 0:g.scale};return JSON.stringify(t)}};var rn=class{constructor(){this.root=null;this.categoryTabs=null;this.assetGrid=null;this.currentCategory="backgrounds";this.selectedAsset=null;this.options=null}render(){return`
|
|
601
|
+
<div class="scene-panel library-panel panel-accent-teal" data-panel="library">
|
|
602
|
+
<div class="scene-panel-header" data-panel-handle>
|
|
603
|
+
<div class="panel-title">
|
|
604
|
+
<span class="panel-pill">Library</span>
|
|
605
|
+
<span class="panel-title-text">Assets</span>
|
|
606
|
+
</div>
|
|
607
|
+
<div class="scene-panel-actions">
|
|
608
|
+
<button class="scene-panel-toggle" type="button" data-panel-toggle>\u25BE</button>
|
|
609
|
+
</div>
|
|
610
|
+
</div>
|
|
611
|
+
<div class="scene-panel-body">
|
|
612
|
+
<div class="library-category-tabs" data-category-tabs>
|
|
613
|
+
<button class="library-category-tab active" data-category="backgrounds">Backgrounds</button>
|
|
614
|
+
<button class="library-category-tab" data-category="machines">Machines</button>
|
|
615
|
+
<button class="library-category-tab" data-category="draggables">Draggables</button>
|
|
616
|
+
<button class="library-category-tab" data-category="characters">Characters</button>
|
|
617
|
+
<button class="library-category-tab" data-category="collectedkeys">Collected Keys</button>
|
|
618
|
+
</div>
|
|
619
|
+
|
|
620
|
+
<div class="panel-section">
|
|
621
|
+
<div class="panel-section-title" data-category-title>Background Library</div>
|
|
622
|
+
<div class="library-grid" data-asset-grid>
|
|
623
|
+
<!-- Asset thumbnails will be loaded here -->
|
|
624
|
+
</div>
|
|
625
|
+
</div>
|
|
626
|
+
|
|
627
|
+
<div class="library-selected" data-selected-info>
|
|
628
|
+
<strong>Current:</strong> <span data-selected-name>Default</span>
|
|
629
|
+
</div>
|
|
630
|
+
|
|
631
|
+
<div class="debug-btn-group">
|
|
632
|
+
<button class="debug-btn secondary" id="force-refresh">Force Refresh</button>
|
|
633
|
+
<button class="debug-btn" id="reset-asset">Reset to Default</button>
|
|
634
|
+
</div>
|
|
635
|
+
</div>
|
|
636
|
+
</div>
|
|
637
|
+
`}initialize(e,t){var a,o,r,l,c;this.options=t,this.root=e.querySelector('[data-panel="library"]'),this.categoryTabs=(a=this.root)==null?void 0:a.querySelector("[data-category-tabs]"),this.assetGrid=(o=this.root)==null?void 0:o.querySelector("[data-asset-grid]");let n=(r=this.root)==null?void 0:r.querySelector("#reset-asset"),i=(l=this.root)==null?void 0:l.querySelector("#force-refresh");i==null||i.addEventListener("click",()=>{this.forceRefreshLibrary()}),n==null||n.addEventListener("click",async()=>{var u;await((u=this.options)==null?void 0:u.onReset(this.currentCategory)),this.updateCurrentDisplay("Default")}),(c=this.categoryTabs)==null||c.addEventListener("click",u=>{let p=u.target.closest("[data-category]");if(p){let h=p.dataset.category;h&&this.switchCategory(h)}}),this.loadAssetLibrary()}switchCategory(e){var i,a;this.currentCategory=e,this.selectedAsset=null,(((i=this.categoryTabs)==null?void 0:i.querySelectorAll(".library-category-tab"))||[]).forEach(o=>{o.classList.toggle("active",o.dataset.category===e)});let n=(a=this.root)==null?void 0:a.querySelector("[data-category-title]");if(n){let o={backgrounds:"Background Library",machines:"Machine Library",draggables:"Draggable Library",characters:"Character Library",collectedkeys:"Collected Keys Library"};n.textContent=o[e]}this.loadAssetLibrary()}async loadAssetLibrary(){if(this.assetGrid)try{let e=await this.getCategoryAssets(this.currentCategory),t=Date.now(),n=e.map(i=>`
|
|
638
|
+
<div class="library-item ${this.selectedAsset===i?"selected":""}" data-asset="${i}">
|
|
639
|
+
<img src="/raw/library/${this.currentCategory}/${i}?t=${t}" alt="${this.currentCategory} ${i}" class="library-thumbnail" onerror="this.style.display='none'">
|
|
640
|
+
<div class="library-label">${i}</div>
|
|
641
|
+
</div>
|
|
642
|
+
`).join("");this.assetGrid.innerHTML=n,this.assetGrid.addEventListener("click",async i=>{let o=i.target.closest("[data-asset]");if(o){let r=o.dataset.asset;r&&await this.selectAsset(r)}})}catch(e){console.error("[LIBRARY] Failed to load asset library:",e),this.assetGrid.innerHTML='<div class="library-empty">Failed to load assets</div>'}}async getCategoryAssets(e){try{let t=await fetch(`/raw/library/${e}/`);if(t.ok){let i=(await t.text()).match(/href="([^"]*\.png)"/g);if(i&&i.length>0)return i.map(a=>a.replace(/href="/,"").replace(/"/,"")).sort()}}catch(t){console.warn(`[LIBRARY] Could not fetch assets for ${e}, using fallback:`,t)}return this.getCategoryAssetsFallback(e)}getCategoryAssetsFallback(e){if(e==="collectedkeys")return["13.png","14.png"];if(e==="draggables")return["12.png","22.png"];{let n={backgrounds:10,machines:2,characters:2}[e]||0,i=[];for(let a=1;a<=n;a++)i.push(`${a}.png`);return i}}async selectAsset(e){var n,i;await((n=this.options)==null?void 0:n.onApply(this.currentCategory,e)),this.updateCurrentDisplay(`${this.currentCategory} ${e}`),(((i=this.assetGrid)==null?void 0:i.querySelectorAll(".library-item"))||[]).forEach(a=>{a.classList.toggle("selected",a.dataset.asset===e)})}async forceRefreshLibrary(){console.log("[LIBRARY] ===== FORCE REFRESH LIBRARY ====="),console.log("[LIBRARY] Current category:",this.currentCategory);let e=["backgrounds","machines","draggables","characters","collectedkeys"];console.log("[LIBRARY] Available library assets by category:");for(let t of e){let n=await this.getCategoryAssets(t);console.log(`[LIBRARY] ${t}: ${n.length} assets - ${n.join(", ")}`)}console.log("[LIBRARY] Current selected asset:",this.selectedAsset),console.log("[LIBRARY] Asset grid element:",this.assetGrid),console.log("[LIBRARY] Category tabs element:",this.categoryTabs),console.log("[LIBRARY] Refreshing current category display..."),this.loadAssetLibrary(),console.log("[LIBRARY] ===== REFRESH COMPLETE =====")}logCategoryAssetsFallback(e){let n={backgrounds:10,machines:2,draggables:2,characters:2,collectedkeys:2}[e]||0,i=[];if(e==="collectedkeys")i.push("13.png","14.png");else for(let a=1;a<=n;a++)i.push(`${a}.png`);console.log(`[LIBRARY] ${e}: ${i.length} assets - ${i.join(", ")}`)}updateCurrentDisplay(e){var n;let t=(n=this.root)==null?void 0:n.querySelector("[data-selected-name]");t&&(t.textContent=e)}refresh(){this.loadAssetLibrary()}};var no=3e3;function ss(s,e,t){let n=t!=null?t:s.offsetParent;if(!n)return;e.style.cursor="move";let i=0,a=0,o=0,r=0,l=!1,c=d=>{if(!l)return;let p=d.clientX-i,h=d.clientY-a;s.style.left=`${o+p}px`,s.style.top=`${r+h}px`},u=()=>{l&&(l=!1,window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u))};e.addEventListener("pointerdown",d=>{if(d.button!==0)return;let p=d.target;if(p!=null&&p.closest("button, input, select, textarea"))return;d.preventDefault();let h=s.getBoundingClientRect(),g=n.getBoundingClientRect();o=h.left-g.left,r=h.top-g.top,i=d.clientX,a=d.clientY,s.style.left=`${o}px`,s.style.top=`${r}px`,s.style.right="auto",s.style.bottom="auto",s.style.zIndex=String(++no),l=!0,window.addEventListener("pointermove",c),window.addEventListener("pointerup",u)})}function os(s,e,t){e.style.cursor="nwse-resize";let n=0,i=0,a=0,o=0,r=!1,l=u=>{if(!r)return;let d=u.clientX-a,p=u.clientY-o,h=Math.max(100,n+d),g=Math.max(100,i+p);s.style.width=`${h}px`,s.style.height=`${g}px`,t==null||t(h,g)},c=()=>{r&&(r=!1,window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",c))};e.addEventListener("pointerdown",u=>{if(u.button!==0)return;u.preventDefault(),u.stopPropagation();let d=s.getBoundingClientRect();n=d.width,i=d.height,a=u.clientX,o=u.clientY,r=!0,window.addEventListener("pointermove",l),window.addEventListener("pointerup",c)})}var at=()=>window.debugConfig||{},io=()=>window.resolveAnchorVec2||(s=>({x:.5,y:.5})),ao=()=>window.resolveScreenAnchorPoint||(()=>new Gn),so=()=>window.resolveScreenRatioPoint||(()=>new Gn),cn=()=>window.createCharacterFrames,dn=class{constructor(){this.debugOverlay=null;this.isDebugOpen=!1;this.selectedObjectId=null;this.configViewer=null;this.container=null;this.objectAutoApplyTimer=null;this.objectDebugRaf=null;this.objectBoundsGfx=null;this.objectAnchorGfx=null;this.highlightObject=!1;this.highlightAnchor=!1;this.sceneObjectsPanel=new Xt;this.sceneEditPanel=new Kt;this.sceneToolsPanel=new Jt;this.customizeSettingsPanel=new nn;this.libraryPanel=new rn;this.batchAiPanel=new sn;this.brandDnaPanel=new on;this.activeTab="hierarchy"}initialize(e){var t;this.container=e,this.debugOverlay=e.querySelector(".debug-overlay"),this.configViewer=e.querySelector("#config-viewer");try{let n=localStorage.getItem("preview_workbench_state");if(n){let i=JSON.parse(n);i.activeTab&&(this.activeTab=i.activeTab)}}catch(n){console.warn("[PREVIEW] Failed to load workbench tab state",n)}this.sceneObjectsPanel.initialize(e,{onSelect:n=>this.handleObjectSelect(n)}),this.sceneEditPanel.initialize(e,{onApply:()=>this.applyObjectConfig(),onCopy:()=>this.copyConfigValues(),onChange:()=>this.scheduleObjectAutoApply()}),this.sceneToolsPanel.initialize(e,{onHighlightObject:n=>{this.highlightObject=n,this.startObjectVisuals()},onHighlightAnchor:n=>{this.highlightAnchor=n,this.startObjectVisuals()},onNudge:(n,i)=>this.nudgeSelectedObject(n,i),onShowSplash:()=>{let n=window.__previewShowSplash;typeof n=="function"&&n()},onUpdateSplash:n=>{let i=window.applyEditableEngineConfig;typeof i=="function"&&i({splash:n});let a=window.__previewUpdateSplash;typeof a=="function"&&a()}}),this.customizeSettingsPanel.initialize(e,{onApply:(n,i)=>this.applyCustomizeSettings(n,i)}),this.libraryPanel.initialize(e,{onApply:(n,i)=>this.applyAssetChange(n,i),onReset:n=>this.resetAsset(n)}),this.batchAiPanel.initialize(e),this.brandDnaPanel.initialize(e),window.__openAiEditor=(n,i)=>{this.activeTab="settings",this.updateWorkbenchTabs(),this.customizeSettingsPanel.openAiEditor(n,i)},this.setupPanelLayout(),this.updateWorkbenchTabs(),this.isDebugOpen=!0,(t=this.debugOverlay)==null||t.classList.remove("hidden"),this.updateDebugBadge(),this.sceneObjectsPanel.refreshObjects(),window.__previewSelectObject=n=>this.selectObject(n)}selectObject(e){this.handleObjectSelect(e),this.activeTab!=="inspector"&&(this.activeTab="inspector",this.updateWorkbenchTabs())}getDebugOverlayHTML(){return`
|
|
643
|
+
<div class="debug-overlay hidden" id="debug-overlay">
|
|
644
|
+
<div class="debug-workbench" id="debug-workbench">
|
|
645
|
+
<div class="workbench-header" id="workbench-handle">
|
|
646
|
+
<div class="panel-title">
|
|
647
|
+
<span class="panel-pill">Workbench</span>
|
|
648
|
+
<span class="panel-title-text">Debug Console</span>
|
|
649
|
+
</div>
|
|
650
|
+
<div class="scene-panel-actions">
|
|
651
|
+
<button class="scene-panel-action" type="button" id="debug-close">Close</button>
|
|
652
|
+
</div>
|
|
653
|
+
</div>
|
|
654
|
+
<div class="workbench-tabs">
|
|
655
|
+
<button class="workbench-tab ${this.activeTab==="hierarchy"?"active":""}" data-tab="hierarchy">Hierarchy</button>
|
|
656
|
+
<button class="workbench-tab ${this.activeTab==="inspector"?"active":""}" data-tab="inspector">Inspector</button>
|
|
657
|
+
<button class="workbench-tab ${this.activeTab==="settings"?"active":""}" data-tab="settings">Settings</button>
|
|
658
|
+
<button class="workbench-tab ${this.activeTab==="library"?"active":""}" data-tab="library">Library</button>
|
|
659
|
+
<button class="workbench-tab ${this.activeTab==="brand"?"active":""}" data-tab="brand">Brand</button>
|
|
660
|
+
<button class="workbench-tab ${this.activeTab==="ai"?"active":""}" data-tab="ai">AI</button>
|
|
661
|
+
</div>
|
|
662
|
+
<div class="workbench-content">
|
|
663
|
+
<div class="workbench-tab-panel ${this.activeTab==="hierarchy"?"active":""}" data-tab-panel="hierarchy">
|
|
664
|
+
${this.sceneObjectsPanel.render()}
|
|
665
|
+
</div>
|
|
666
|
+
<div class="workbench-tab-panel ${this.activeTab==="inspector"?"active":""}" data-tab-panel="inspector">
|
|
667
|
+
${this.sceneEditPanel.render()}
|
|
668
|
+
${this.sceneToolsPanel.render()}
|
|
669
|
+
</div>
|
|
670
|
+
<div class="workbench-tab-panel ${this.activeTab==="settings"?"active":""}" data-tab-panel="settings">
|
|
671
|
+
${this.customizeSettingsPanel.render()}
|
|
672
|
+
</div>
|
|
673
|
+
<div class="workbench-tab-panel ${this.activeTab==="library"?"active":""}" data-tab-panel="library">
|
|
674
|
+
${this.libraryPanel.render()}
|
|
675
|
+
</div>
|
|
676
|
+
<div class="workbench-tab-panel ${this.activeTab==="brand"?"active":""}" data-tab-panel="brand">
|
|
677
|
+
${this.brandDnaPanel.render()}
|
|
678
|
+
</div>
|
|
679
|
+
<div class="workbench-tab-panel ${this.activeTab==="ai"?"active":""}" data-tab-panel="ai">
|
|
680
|
+
${this.batchAiPanel.render()}
|
|
681
|
+
</div>
|
|
682
|
+
</div>
|
|
683
|
+
<div class="workbench-resize-handle" id="workbench-resize"></div>
|
|
684
|
+
</div>
|
|
685
|
+
</div>
|
|
686
|
+
`}setupDebugEventListeners(){var i,a,o;if(!this.container)return;let e=this.container,t=e.querySelector("#debug-toggle");t||console.warn("[PREVIEW] Debug toggle not found in DOM"),t==null||t.addEventListener("click",()=>{console.log("[PREVIEW] Debug toggle clicked"),this.toggleDebug()}),(i=e.querySelector("#debug-close"))==null||i.addEventListener("click",()=>this.toggleDebug(!1)),(a=e.querySelector("#debug-reset"))==null||a.addEventListener("click",()=>this.resetDebugConfig()),(o=e.querySelector("#debug-export"))==null||o.addEventListener("click",()=>this.exportDebugConfig()),e.querySelectorAll(".workbench-tab").forEach(r=>{r.addEventListener("click",()=>{let l=r.dataset.tab;this.activeTab=l,this.updateWorkbenchTabs(),this.saveWorkbenchState()})}),this.setupCollapsiblePanels(e),this.setupDebugInputListeners(e)}updateWorkbenchTabs(){if(!this.container)return;let e=this.container;e.querySelectorAll(".workbench-tab").forEach(i=>{let a=i.dataset.tab;i.classList.toggle("active",a===this.activeTab)}),e.querySelectorAll(".workbench-tab-panel").forEach(i=>{let a=i.dataset.tabPanel;i.classList.toggle("active",a===this.activeTab)})}toggleDebug(e){var t;this.isDebugOpen=e!=null?e:!this.isDebugOpen,(t=this.debugOverlay)==null||t.classList.toggle("hidden",!this.isDebugOpen),this.updateDebugBadge(),this.isDebugOpen?(this.sceneObjectsPanel.refreshObjects(),this.customizeSettingsPanel.refresh(),this.libraryPanel.refresh(),this.batchAiPanel.refresh(),this.brandDnaPanel.refresh()):this.stopObjectVisuals()}async applyAssetChange(e,t){var n,i,a,o,r;console.log("[LIBRARY] applyAssetChange called with:",e,t);try{if(e==="collectedkeys"){console.log("[LIBRARY] Updating global collected key texture...");let g=Date.now(),b=`/raw/library/${e}/${t}?t=${g}`;try{ln.load(b).then(f=>{var m;f&&((m=window.CustomAssets)!=null&&m.key_collected_1)?(window.CustomAssets.key_collected_1.texture=f,console.log(`[LIBRARY] Global collected key texture updated to: ${t}`),console.log("[LIBRARY] All future collected keys will use this texture")):console.warn("[LIBRARY] Could not update global collected key texture")}).catch(f=>{console.error("[LIBRARY] Failed to load collected key texture:",f)}),console.log(`[LIBRARY] Selected collected key asset: ${t}`),console.log("[LIBRARY] Future collected keys will use this texture when you collect them in-game")}catch(f){console.error("[LIBRARY] Error updating collected key texture:",f)}return}let c={backgrounds:{assetKey:"background_1",defaultFile:"background.png"},machines:{assetKey:"machine_1",defaultFile:"wood_machine.png"},draggables:{assetKey:"key_collected_1",defaultFile:"keyCollected.png"},characters:{assetKey:"character_1",defaultFile:"character_animation.png"}}[e];if(!c){console.warn("[LIBRARY] Unknown asset type:",e);return}let u=window.CustomAssets;console.log("[LIBRARY] CustomAssets available:",!!u);let d=u==null?void 0:u[c.assetKey];if(console.log(`[LIBRARY] ${e} from CustomAssets (${c.assetKey}):`,!!d,d),d||console.log(`[LIBRARY] ${e} not found in CustomAssets, checking all CustomAssets keys:`,Object.keys(u||{})),!d){let g=window.gameObjectManager;console.log("[LIBRARY] gameObjectManager available:",!!g);let f={backgrounds:"background_1",machines:"machine_1",draggables:"key_1",characters:"character_1"}[e],m=g==null?void 0:g.get(f);console.log(`[LIBRARY] ${e} object from manager:`,!!m,m),m&&(d=((n=m.getDisplayObject)==null?void 0:n.call(m))||m.pixiObject||m,console.log(`[LIBRARY] ${e} sprite:`,d,"has texture:",!!(d!=null&&d.texture)),console.log(`[LIBRARY] ${e} object properties:`,Object.keys(m)),console.log(`[LIBRARY] ${e} object _config:`,m._config),console.log(`[LIBRARY] ${e} object config:`,m.config))}if(!d){console.warn(`[LIBRARY] ${e} sprite not found`);return}if(!d.texture){console.warn(`[LIBRARY] ${e} sprite has no texture`);return}let p=Date.now(),h=`/raw/library/${e}/${t}?t=${p}`;console.log("[LIBRARY] Loading image from:",h);try{let g=await ln.load(h);if(console.log("[LIBRARY] Texture loaded via PIXI Assets:",!!g,g),g)if(e==="characters"&&d instanceof ls){console.log("[LIBRARY] Handling character animation sprite sheet");let b=window.getEditableEngineConfig;console.log("[LIBRARY] getEditableEngineConfig function:",typeof b,b);let f=typeof b=="function"?b():null;console.log("[LIBRARY] currentConfig:",f);let m=null;if(f!=null&&f.objects)m=f.objects.get("character_1");else{let y=window.gameObjectManager;if(y){let v=y.get("character_1");v&&v._config&&(m=v._config,console.log("[LIBRARY] Got character config from game object:",m))}}if(m){let y=cn()(g,m);d.textures=y,d.texture=(i=y[0])!=null?i:g,(a=d.play)==null||a.call(d),console.log(`[LIBRARY] Character animation updated with ${y.length} frames using createCharacterFrames`)}else{let y={gameplay:{tuning:{frame_cols:3,frame_rows:2,frame_width:180,frame_height:120,anim_speed:.003}}};console.log("[LIBRARY] Using hardcoded character config as last resort");let v=cn()(g,y);d.textures=v,d.texture=(o=v[0])!=null?o:g,(r=d.play)==null||r.call(d),console.log(`[LIBRARY] Character animation updated with ${v.length} frames using hardcoded config`)}}else d.texture=g,console.log(`[LIBRARY] ${e} texture replaced successfully:`,t);else console.warn("[LIBRARY] Failed to create texture from image")}catch(g){console.error("[LIBRARY] Failed to load texture:",g)}}catch(l){console.error(`[LIBRARY] Error applying ${e} change:`,l)}}async resetAsset(e){var t,n,i,a,o;if(console.log("[LIBRARY] resetAsset called for:",e),e==="collectedkeys"){console.log("[LIBRARY] Resetting global collected key texture to default...");let l=`/raw/keyCollected.png?t=${Date.now()}`;try{ln.load(l).then(c=>{var u;c&&((u=window.CustomAssets)!=null&&u.key_collected_1)?(window.CustomAssets.key_collected_1.texture=c,console.log("[LIBRARY] Global collected key texture reset to default")):console.warn("[LIBRARY] Could not reset global collected key texture")}).catch(c=>{console.error("[LIBRARY] Failed to load default collected key texture:",c)})}catch(c){console.error("[LIBRARY] Error resetting collected key texture:",c)}return}try{let l={backgrounds:{assetKey:"background_1",defaultFile:"background.png"},machines:{assetKey:"machine_1",defaultFile:"wood_machine.png"},draggables:{assetKey:"key_collected_1",defaultFile:"keyCollected.png"},characters:{assetKey:"character_1",defaultFile:"character_animation.png"}}[e];if(!l){console.warn("[LIBRARY] Unknown asset type:",e);return}let c=window.CustomAssets,u=c==null?void 0:c[l.assetKey];if(!u){let h=window.gameObjectManager,b={backgrounds:"background_1",machines:"machine_1",draggables:"key_1",characters:"character_1"}[e],f=h==null?void 0:h.get(b);f&&(u=((t=f.getDisplayObject)==null?void 0:t.call(f))||f.pixiObject||f)}if(!u){console.warn(`[LIBRARY] ${e} sprite not found for reset`);return}if(!u.texture){console.warn(`[LIBRARY] ${e} sprite has no texture for reset`);return}let d=Date.now(),p=`/raw/${l.defaultFile}?t=${d}`;console.log("[LIBRARY] Loading default image from:",p);try{let h=await ln.load(p);if(console.log("[LIBRARY] Default texture loaded via PIXI Assets:",!!h),h)if(e==="characters"&&u instanceof ls){console.log("[LIBRARY] Resetting character animation to default sprite sheet");let g=window.getEditableEngineConfig,b=typeof g=="function"?g():null,f=null;if(b!=null&&b.objects)f=b.objects.get("character_1");else{let m=window.gameObjectManager;if(m){let y=m.get("character_1");y&&y._config&&(f=y._config)}}if(f){let m=cn()(h,f);u.textures=m,u.texture=(n=m[0])!=null?n:h,(i=u.play)==null||i.call(u),console.log(`[LIBRARY] Character animation reset with ${m.length} frames using createCharacterFrames`)}else{let m={gameplay:{tuning:{frame_cols:3,frame_rows:2,frame_width:180,frame_height:120,anim_speed:.003}}};console.log("[LIBRARY] Using hardcoded character config for reset as last resort");let y=cn()(h,m);u.textures=y,u.texture=(a=y[0])!=null?a:h,(o=u.play)==null||o.call(u),console.log(`[LIBRARY] Character animation reset with ${y.length} frames using hardcoded config`)}}else u.texture=h,console.log(`[LIBRARY] ${e} reset to default successfully`);else console.warn("[LIBRARY] Failed to create default texture")}catch(h){console.error("[LIBRARY] Failed to load default texture:",h)}}catch(r){console.error(`[LIBRARY] Error resetting ${e}:`,r)}}updateDebugBadge(){if(!this.container)return;let e=this.container.querySelector("#debug-badge");e&&e.classList.toggle("active",this.isDebugOpen)}setupDebugInputListeners(e){this.setupRangeInput(e,"debug-scene-scale","engine.scale","#debug-scene-scale-value"),this.setupRangeInput(e,"debug-layout-scale","layout.scale_multiplier","#debug-layout-scale-value"),this.setupRangeInput(e,"debug-layout-offset-x","layout.position_offset.x","#debug-layout-offset-x-value"),this.setupRangeInput(e,"debug-layout-offset-y","layout.position_offset.y","#debug-layout-offset-y-value"),this.setupRangeInput(e,"debug-rect-thickness","layout.debug_rect_thickness","#debug-rect-thickness-value"),this.setupRangeInput(e,"debug-engine-scale","engine.scale","#debug-engine-scale-value"),this.setupRangeInput(e,"debug-background-scale","engine.background_scale","#debug-background-scale-value"),this.setupRangeInput(e,"debug-label-pulse-speed","engine.label_pulse_speed","#debug-label-pulse-speed-value"),this.setupRangeInput(e,"debug-label-pulse-intensity","engine.label_pulse_intensity","#debug-label-pulse-intensity-value"),this.setupRangeInput(e,"debug-rope-length","physics.rope_length","#debug-rope-length-value");let t=e.querySelector("#debug-rect-visible");t==null||t.addEventListener("change",()=>{let i=at();i.layout&&(i.layout.debug_rect_visible=!!t.checked)});let n=e.querySelector("#debug-rect-color");n==null||n.addEventListener("input",()=>{let i=n.value.replace("#",""),a=parseInt(i,16),o=at();o.layout&&(o.layout.debug_rect_color=Number.isFinite(a)?a:16711680)})}setupPanelLayout(){if(!this.container||!this.debugOverlay)return;let e=this.container.querySelector("#debug-workbench"),t=this.container.querySelector("#workbench-handle"),n=this.container.querySelector("#workbench-resize");e&&t&&(!e.style.left&&!e.style.right&&!e.style.top&&!e.style.bottom&&(e.style.right="16px",e.style.top="72px"),ss(e,t,this.debugOverlay),t.addEventListener("pointerup",()=>this.saveWorkbenchState())),e&&n&&os(e,n,()=>this.saveWorkbenchState()),this.loadWorkbenchState()}saveWorkbenchState(){if(!this.container)return;let e=this.container.querySelector("#debug-workbench");if(!e)return;let t={activeTab:this.activeTab,width:e.style.width,height:e.style.height,left:e.style.left,top:e.style.top};localStorage.setItem("preview_workbench_state",JSON.stringify(t))}loadWorkbenchState(){try{let e=localStorage.getItem("preview_workbench_state");if(!e)return;let t=JSON.parse(e);t.activeTab&&(this.activeTab=t.activeTab),window.requestAnimationFrame(()=>{var i;let n=(i=this.container)==null?void 0:i.querySelector("#debug-workbench");n&&(t.width&&(n.style.width=t.width),t.height&&(n.style.height=t.height),t.left&&(n.style.left=t.left),t.top&&(n.style.top=t.top))})}catch(e){console.warn("[PREVIEW] Failed to load workbench state",e)}}setupCollapsiblePanels(e){Array.from(e.querySelectorAll("[data-panel-toggle]")).forEach(n=>{n.addEventListener("click",()=>{let i=n.closest(".scene-panel");i&&i.classList.toggle("collapsed")})})}handleObjectSelect(e){this.selectedObjectId=e,this.sceneObjectsPanel.setSelected(e),this.sceneEditPanel.setSelected(e),this.loadObjectConfig(e),this.startObjectVisuals()}nudgeSelectedObject(e,t){var d,p,h,g,b,f,m,y,v;if(!this.container||!this.selectedObjectId)return;let i=this.sceneToolsPanel.getNudgeStep(),a=this.container.querySelector("#config-pos-x"),o=this.container.querySelector("#config-pos-y"),r=Number((d=a==null?void 0:a.value)!=null?d:0),l=Number((p=o==null?void 0:o.value)!=null?p:0);if(!Number.isFinite(r)||!Number.isFinite(l)){let w=this.getSelectedObjectConfig();r=(b=(g=(h=w==null?void 0:w.transform)==null?void 0:h.position)==null?void 0:g.x)!=null?b:0,l=(y=(m=(f=w==null?void 0:w.transform)==null?void 0:f.position)==null?void 0:m.y)!=null?y:0}let c=r+e*i,u=l+t*i;a&&(a.value=String(c)),o&&(o.value=String(u)),(v=this.configViewer)==null||v.style.setProperty("display","block"),this.scheduleObjectAutoApply()}startObjectVisuals(){this.shouldRunObjectVisuals()&&(this.objectDebugRaf||(this.objectDebugRaf=window.requestAnimationFrame(()=>this.updateObjectVisuals())))}stopObjectVisuals(){this.objectDebugRaf&&(window.cancelAnimationFrame(this.objectDebugRaf),this.objectDebugRaf=null),this.clearObjectVisuals()}shouldRunObjectVisuals(){return this.isDebugOpen}updateObjectVisuals(){var a,o,r;if(!this.shouldRunObjectVisuals()){this.objectDebugRaf=null;return}this.objectDebugRaf=window.requestAnimationFrame(()=>this.updateObjectVisuals());let e=this.getSelectedInstanceId();if(!e){this.updateObjectInfo(null),this.clearObjectVisuals();return}let t=this.getDisplayObjectById(e);if(!t){this.updateObjectInfo(null),this.clearObjectVisuals();return}let n=new Gn;(a=t.getGlobalPosition)==null||a.call(t,n);let i=this.getConfigAnchorWorldPoint(t);this.updateObjectInfo({instanceId:e,worldX:n.x,worldY:n.y,configX:(o=i==null?void 0:i.x)!=null?o:null,configY:(r=i==null?void 0:i.y)!=null?r:null}),this.highlightObject?this.drawBounds(t):this.clearBounds(),this.highlightAnchor&&i?this.drawAnchor(i):this.clearAnchor()}getSelectedInstanceId(){var i;let e=this.selectedObjectId;if(!e)return null;let t=window.__editableObjectInstances,n=(i=t==null?void 0:t.get)==null?void 0:i.call(t,e);return Array.isArray(n)&&n.length>0?n[0]:e}getDisplayObjectById(e){var i,a;let t=window.gameObjectManager,n=(i=t==null?void 0:t.get)==null?void 0:i.call(t,e);return n?((a=n.getDisplayObject)==null?void 0:a.call(n))||n.pixiObject||n:null}getSelectedObjectConfig(){let e=this.selectedObjectId;if(!e)return null;let t=window.getEditableObjectConfig;return typeof t!="function"?null:t(e)}getConfigAnchorWorldPoint(e){var o,r;let t=this.getSelectedObjectConfig();if(!t)return null;let n=(o=t.transform)!=null?o:{},i=this.getScreenSize();if(!i)return null;if(n.position_ratio!=null)return so()(i.width,i.height,n.position_ratio);let a=(r=n.anchor)!=null?r:"center";return ao()(i.width,i.height,a)}getScreenSize(){var a;let e=(a=this.container)==null?void 0:a.querySelector(".game-container"),t=Number(e==null?void 0:e.dataset.screenWidth),n=Number(e==null?void 0:e.dataset.screenHeight);if(Number.isFinite(t)&&t>0&&Number.isFinite(n)&&n>0)return{width:t,height:n};let i=window.gameApp;return i!=null&&i.renderer?{width:i.renderer.width,height:i.renderer.height}:null}ensureBoundsGfx(){let e=window.gameApp;return e!=null&&e.stage?(this.objectBoundsGfx&&this.objectBoundsGfx.parent!==e.stage&&(this.objectBoundsGfx.destroy(),this.objectBoundsGfx=null),this.objectBoundsGfx||(this.objectBoundsGfx=new rs,this.objectBoundsGfx.zIndex=999999,e.stage.addChild(this.objectBoundsGfx)),this.objectBoundsGfx):null}ensureAnchorGfx(){let e=window.gameApp;return e!=null&&e.stage?(this.objectAnchorGfx&&this.objectAnchorGfx.parent!==e.stage&&(this.objectAnchorGfx.destroy(),this.objectAnchorGfx=null),this.objectAnchorGfx||(this.objectAnchorGfx=new rs,this.objectAnchorGfx.zIndex=1e6,e.stage.addChild(this.objectAnchorGfx)),this.objectAnchorGfx):null}drawBounds(e){var i;let t=this.ensureBoundsGfx();if(!t)return;let n=(i=e.getBounds)==null?void 0:i.call(e);n&&(t.clear(),t.rect(n.x,n.y,n.width,n.height).stroke({width:2,color:16726832,alpha:.9}))}drawAnchor(e){let t=this.ensureAnchorGfx();if(!t)return;let n=6;t.clear(),t.moveTo(e.x-n,e.y),t.lineTo(e.x+n,e.y),t.moveTo(e.x,e.y-n),t.lineTo(e.x,e.y+n),t.stroke({width:2,color:3066993,alpha:.9})}clearBounds(){this.objectBoundsGfx&&this.objectBoundsGfx.clear()}clearAnchor(){this.objectAnchorGfx&&this.objectAnchorGfx.clear()}clearObjectVisuals(){this.objectBoundsGfx&&(this.objectBoundsGfx.destroy(),this.objectBoundsGfx=null),this.objectAnchorGfx&&(this.objectAnchorGfx.destroy(),this.objectAnchorGfx=null)}updateObjectInfo(e){this.sceneToolsPanel.updateInfo(e?{instanceId:e.instanceId,worldX:e.worldX,worldY:e.worldY,anchorX:e.configX,anchorY:e.configY}:null)}scheduleObjectAutoApply(){this.selectedObjectId&&(this.objectAutoApplyTimer&&window.clearTimeout(this.objectAutoApplyTimer),this.objectAutoApplyTimer=window.setTimeout(()=>{this.objectAutoApplyTimer=null,this.applyObjectConfig({silent:!0})},150))}setupRangeInput(e,t,n,i){let a=e.querySelector(`#${t}`),o=e.querySelector(i);if(!a||!o)return;let r=this.getNestedValue(at(),n);typeof r=="number"&&(a.value=String(r),o.textContent=String(r)),a.addEventListener("input",()=>{let l=Number(a.value);o.textContent=String(l),this.setNestedValue(at(),n,l)})}getNestedValue(e,t){return t.split(".").reduce((n,i)=>n?n[i]:void 0,e)}setNestedValue(e,t,n){var r;let i=t.split("."),a=i.pop(),o=e;for(let l of i)o[l]=(r=o[l])!=null?r:{},o=o[l];o[a]=n}resetDebugConfig(){let e=at();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()}applyDebugConfig(){window.location.reload()}exportDebugConfig(){let e=JSON.stringify(at(),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 loadObjectConfig(e){var t,n,i;if(!(!this.configViewer||!this.container))try{let a=window.getEditableObjectConfig,o=typeof a=="function"?a(e):null;if(!o){let{loadObjectCentricConfig:r,loadObjectConfig:l}=await import("./config-QLS2MDB6.mjs"),d=(((t=(await r("scene.main")).scene)==null?void 0:t.objects)||[]).find(h=>h.object_config===e||h.instance_id===e);if(!d)return;let p=await l(d.object_config);console.log("[PREVIEW] Loaded object config (fallback)",e,p),this.fillConfigViewer(p),(n=this.configViewer)==null||n.style.setProperty("display","block");return}console.log("[PREVIEW] Loaded object config",e,o),this.fillConfigViewer(o),(i=this.configViewer)==null||i.style.setProperty("display","block");return}catch(a){console.error("[DEBUG] Failed to load object config:",a)}}fillConfigViewer(e){var d,p,h,g,b,f,m,y,v,w;if(!this.container)return;let t=this.container.querySelector("#config-pos-x"),n=this.container.querySelector("#config-pos-y"),i=this.container.querySelector("#config-scale"),a=this.container.querySelector("#config-anchor-x"),o=this.container.querySelector("#config-anchor-y"),l=this.shouldUseOffsetPosition(e)?(d=e.transform)==null?void 0:d.offset:(p=e.transform)==null?void 0:p.position;t&&(t.value=String((h=l==null?void 0:l.x)!=null?h:0)),n&&(n.value=String((g=l==null?void 0:l.y)!=null?g:0)),i&&(i.value=String((f=(b=e.transform)==null?void 0:b.scale)!=null?f:1));let c=(w=(v=(m=e.transform)==null?void 0:m.anchor)!=null?v:(y=e.render)==null?void 0:y.anchor)!=null?w:{x:.5,y:.5},u=io()(c);a&&(a.value=String(u.x)),o&&(o.value=String(u.y))}copyConfigValues(){var l,c,u,d,p,h,g,b,f,m;let e=this.selectedObjectId;if(!e||!this.container)return;let t=(c=(l=this.container.querySelector("#config-pos-x"))==null?void 0:l.value)!=null?c:"0",n=(d=(u=this.container.querySelector("#config-pos-y"))==null?void 0:u.value)!=null?d:"0",i=(h=(p=this.container.querySelector("#config-scale"))==null?void 0:p.value)!=null?h:"1",a=(b=(g=this.container.querySelector("#config-anchor-x"))==null?void 0:g.value)!=null?b:"0.5",o=(m=(f=this.container.querySelector("#config-anchor-y"))==null?void 0:f.value)!=null?m:"0.5",r=`${e}:
|
|
687
|
+
position: (${t}, ${n})
|
|
688
|
+
scale: ${i}
|
|
689
|
+
anchor: (${a}, ${o})`;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 applyObjectConfig(e){var d,p,h,g,b,f,m,y,v,w,S;if(!this.container)return;let t=this.selectedObjectId;if(!t){console.warn("[PREVIEW] Apply object config clicked with no selection");return}let n=Number((p=(d=this.container.querySelector("#config-pos-x"))==null?void 0:d.value)!=null?p:0),i=Number((g=(h=this.container.querySelector("#config-pos-y"))==null?void 0:h.value)!=null?g:0),a=Number((f=(b=this.container.querySelector("#config-scale"))==null?void 0:b.value)!=null?f:1),o=Number((y=(m=this.container.querySelector("#config-anchor-x"))==null?void 0:m.value)!=null?y:.5),r=Number((w=(v=this.container.querySelector("#config-anchor-y"))==null?void 0:v.value)!=null?w:.5),{applyConfigOverride:l}=await import("./ConfigOverride-6YH2ILBJ.mjs");l({objectId:t,path:"transform.position",value:{x:n,y:i}},{silent:e==null?void 0:e.silent}),l({objectId:t,path:"transform.scale",value:a},{silent:e==null?void 0:e.silent}),l({objectId:t,path:"transform.anchor",value:{x:o,y:r}},{silent:e==null?void 0:e.silent});let c=this.getSelectedObjectConfig();this.shouldUseOffsetPosition(c)&&l({objectId:t,path:"transform.offset",value:{x:n,y:i}},{silent:!0});let u=window.applyEditableObjectConfig;if(typeof u=="function"){let A=(S=window.getEditableObjectConfig)==null?void 0:S.call(window,t);A&&u(t,A)}}applyCustomizeSettings(e,t){let n=window.applyEditableEngineConfig;if(typeof n!="function"){console.warn("[PREVIEW] Engine config bridge not available");return}let i={theme:e.runtime.theme,fonts:e.runtime.fonts,audio:e.runtime.audio},a={};Object.entries(e.runtime.ui).forEach(([c,u])=>{var d;if(c)if(c.includes(".")){let p=c.split("."),h=a;for(let g=0;g<p.length-1;g++){let b=p[g];h[b]=(d=h[b])!=null?d:{},h=h[b]}h[p[p.length-1]]=u}else a[c]=u}),i.ui=a,n({runtime:i,assets:e.assets});let o=Object.values(e.assets).some(c=>/^(blob:|data:)/.test(c)),r=(t==null?void 0:t.source)!=="auto"&&!o,l=window.__previewShell;r&&(l!=null&&l.refresh)&&l.refresh()}shouldUseOffsetPosition(e){var i,a,o,r,l;if(!e)return!1;if((i=e.transform)!=null&&i.offset)return!0;let t=((o=(a=e.identity)==null?void 0:a.category)!=null?o:"").toString().toLowerCase(),n=((l=(r=e.identity)==null?void 0:r.id)!=null?l:"").toString().toLowerCase();return t.includes("ui")||n.startsWith("ui")||n.includes("label")}};var qn=class{constructor(e={}){this.isLandscape=!1;this.autoScale=1;this.userScaleMultiplier=1;this.viewMode="single";this.comparePresets=[it("playable-portrait"),it("iphone-14"),it("ipad-mini")];this.activeCompareId="playable-portrait";this.compareViewports=new Map;this.resizeObserver=null;this.rafFitHandle=null;this.ignoreNextWindowResize=!1;this.frameDragOffsetX=0;this.frameDragOffsetY=0;this.frameDragActive=!1;this.frameDragStartX=0;this.frameDragStartY=0;this.frameDragOriginX=0;this.frameDragOriginY=0;this.consolePanel=null;this.consoleMessages=[];this.isConsoleOpen=!1;this.hasInitialFit=!1;this.isMounted=!1;this.isInitialized=!1;this.gameReady=!1;this.resizeListenersDisabled=!1;this.compareSnapshotTimer=null;this.onWindowResize=e=>{if(this.ignoreNextWindowResize){this.ignoreNextWindowResize=!1;return}this.resizeListenersDisabled||!this.gameReady||this.scheduleFit()};this.onFrameDragMove=e=>{if(!this.frameDragActive)return;let t=e.clientX-this.frameDragStartX,n=e.clientY-this.frameDragStartY;this.frameDragOffsetX=this.frameDragOriginX+t,this.frameDragOffsetY=this.frameDragOriginY+n,this.applyFrameDrag()};this.onFrameDragEnd=()=>{this.frameDragActive&&(this.frameDragActive=!1,window.removeEventListener("pointermove",this.onFrameDragMove),window.removeEventListener("pointerup",this.onFrameDragEnd))};this.options=e,this.currentPreset=it(e.defaultDevice||Fn.id),this.debugPanel=new dn,this.container=this.createShell(),this.previewContainer=this.mustQuery(".preview-container"),this.singleStage=this.mustQuery('[data-preview-stage="single"]'),this.compareStage=this.mustQuery('[data-preview-stage="compare"]'),this.frameDragger=this.mustQuery(".frame-dragger"),this.frameWrapper=this.mustQuery(".frame-wrapper"),this.deviceFrame=this.mustQuery(".device-frame"),this.gameContainer=this.mustQuery(".game-container"),this.lastSinglePresetId=this.currentPreset.id,this.consolePanel=this.container.querySelector(".console-panel"),this.debugPanel.initialize(this.container),this.debugPanel.setupDebugEventListeners(),this.applyDeviceFrameStyles(),this.setupCompareViewports(),this.setupConsoleInterceptor(),this.setupObserversAndListeners(),this.setupFrameDragging(),this.setDevice(this.currentPreset.id,{suppressCallback:!0}),this.isInitialized=!0}mount(e=document.body){e.innerHTML="",e.appendChild(this.container),this.isMounted=!0,this.scheduleFit()}destroy(){if(this.disableResizeListeners(),this.resizeObserver){try{this.resizeObserver.disconnect()}catch{}this.resizeObserver=null}window.removeEventListener("resize",this.onWindowResize),this.rafFitHandle&&(cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=null),this.compareSnapshotTimer&&(window.clearInterval(this.compareSnapshotTimer),this.compareSnapshotTimer=null),this.gameReady=!1}getGameContainer(){return this.gameContainer}getScreen(){let e=this.getEffectivePreset();return{width:e.width,height:e.height}}getEffectivePreset(){var e;return this.isLandscape?{...this.currentPreset,width:this.currentPreset.height,height:this.currentPreset.width,ratio:((e=this.currentPreset.ratio)==null?void 0:e.split(":").reverse().join(":"))||this.currentPreset.ratio}:this.currentPreset}notifyGameLoaded(){this.gameReady=!0,this.enableResizeListeners(),this.scheduleFit()}notifyGameDestroyed(){this.gameReady=!1,this.disableResizeListeners()}disableResizeListeners(){this.resizeListenersDisabled=!0,this.rafFitHandle&&(cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=null)}enableResizeListeners(){this.resizeListenersDisabled=!1}refresh(){this.options.onRefresh?this.options.onRefresh():window.location.reload()}setDevice(e,t={}){var i,a;let n=this.autoScale*this.userScaleMultiplier;this.isLandscape=!1,this.currentPreset=it(e),this.viewMode==="single"&&(this.lastSinglePresetId=this.currentPreset.id),this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale:n}),t.suppressCallback||(a=(i=this.options).onDeviceChange)==null||a.call(i,this.getEffectivePreset()),this.emitScreenChange()}createShell(){var t;let e=document.createElement("div");return e.className="preview-shell",e.innerHTML=`
|
|
690
|
+
<div class="preview-toolbar">
|
|
691
|
+
<div class="preview-toolbar-left">
|
|
692
|
+
<span class="preview-logo">PREVIEWER</span>
|
|
693
|
+
</div>
|
|
694
|
+
|
|
695
|
+
<div class="preview-toolbar-center">
|
|
696
|
+
<div class="device-selector-wrapper">
|
|
697
|
+
<select class="device-dropdown" id="device-select">
|
|
698
|
+
${Ja.map(n=>`
|
|
699
|
+
<optgroup label="${n.label}">
|
|
700
|
+
${n.devices.map(i=>`
|
|
701
|
+
<option value="${i.id}" ${i.id===this.currentPreset.id?"selected":""}>
|
|
702
|
+
${i.label} (${i.width}\xD7${i.height})
|
|
703
|
+
</option>
|
|
704
|
+
`).join("")}
|
|
705
|
+
</optgroup>
|
|
706
|
+
`).join("")}
|
|
707
|
+
</select>
|
|
708
|
+
</div>
|
|
709
|
+
|
|
710
|
+
<div class="view-toggle" role="group" aria-label="Preview mode">
|
|
711
|
+
<button class="view-toggle-btn active" data-view-toggle="single" type="button">Single</button>
|
|
712
|
+
<button class="view-toggle-btn" data-view-toggle="compare" type="button">Compare 3</button>
|
|
713
|
+
</div>
|
|
714
|
+
|
|
715
|
+
<button class="preview-btn icon-btn" id="rotate-btn" title="Rotate">
|
|
716
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
717
|
+
<path d="M21 12a9 9 0 11-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/>
|
|
718
|
+
<path d="M21 3v5h-5"/>
|
|
719
|
+
</svg>
|
|
720
|
+
</button>
|
|
721
|
+
|
|
722
|
+
<div class="toolbar-divider"></div>
|
|
723
|
+
|
|
724
|
+
<button class="preview-btn icon-btn" id="zoom-out-btn" title="Zoom Out">
|
|
725
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
726
|
+
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
727
|
+
</svg>
|
|
728
|
+
</button>
|
|
729
|
+
|
|
730
|
+
<span class="zoom-label" id="zoom-label">100%</span>
|
|
731
|
+
|
|
732
|
+
<button class="preview-btn icon-btn" id="zoom-in-btn" title="Zoom In">
|
|
733
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
734
|
+
<line x1="12" y1="5" x2="12" y2="19"></line>
|
|
735
|
+
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
736
|
+
</svg>
|
|
737
|
+
</button>
|
|
738
|
+
</div>
|
|
739
|
+
|
|
740
|
+
<div class="preview-toolbar-right">
|
|
741
|
+
<button class="preview-btn" id="refresh-btn">Restart</button>
|
|
742
|
+
<button class="preview-btn debug-toggle" id="debug-toggle">
|
|
743
|
+
Scene Edit Panel <span class="debug-toggle-badge" id="debug-badge"></span>
|
|
744
|
+
</button>
|
|
745
|
+
<button class="preview-btn console-toggle" id="console-toggle">
|
|
746
|
+
Console <span class="console-badge" id="console-badge">0</span>
|
|
747
|
+
</button>
|
|
748
|
+
</div>
|
|
749
|
+
</div>
|
|
750
|
+
|
|
751
|
+
<div class="preview-main">
|
|
752
|
+
<div class="preview-container">
|
|
753
|
+
<div class="preview-stage" data-preview-stage="single">
|
|
754
|
+
<div class="frame-dragger">
|
|
755
|
+
<div class="frame-wrapper">
|
|
756
|
+
<div class="device-frame">
|
|
757
|
+
<div class="game-container"></div>
|
|
758
|
+
</div>
|
|
759
|
+
</div>
|
|
760
|
+
</div>
|
|
761
|
+
</div>
|
|
762
|
+
|
|
763
|
+
<div class="preview-stage hidden" data-preview-stage="compare">
|
|
764
|
+
<div class="compare-grid" data-compare-grid>
|
|
765
|
+
${this.comparePresets.map(n=>`
|
|
766
|
+
<div class="compare-viewport" data-viewport="${n.id}">
|
|
767
|
+
<div class="compare-header">
|
|
768
|
+
<div class="compare-title">
|
|
769
|
+
<span class="compare-title-text">${n.label}</span>
|
|
770
|
+
<span class="compare-meta">${n.ratio} | ${n.width}x${n.height}</span>
|
|
771
|
+
</div>
|
|
772
|
+
<button class="compare-focus" data-compare-focus type="button">Focus</button>
|
|
773
|
+
</div>
|
|
774
|
+
<div class="compare-body">
|
|
775
|
+
<div class="compare-slot" data-compare-slot></div>
|
|
776
|
+
<div class="compare-ghost" data-compare-ghost>
|
|
777
|
+
<div class="frame-wrapper" data-compare-wrapper>
|
|
778
|
+
<div class="device-frame" data-compare-frame>
|
|
779
|
+
<canvas class="snapshot-canvas" data-compare-snapshot></canvas>
|
|
780
|
+
</div>
|
|
781
|
+
</div>
|
|
782
|
+
</div>
|
|
783
|
+
<div class="compare-overlay" data-compare-overlay>Click to focus</div>
|
|
784
|
+
</div>
|
|
785
|
+
</div>
|
|
786
|
+
`).join("")}
|
|
787
|
+
</div>
|
|
788
|
+
</div>
|
|
789
|
+
</div>
|
|
790
|
+
|
|
791
|
+
${((t=this.debugPanel)==null?void 0:t.getDebugOverlayHTML())||""}
|
|
792
|
+
|
|
793
|
+
<div class="console-panel closed">
|
|
794
|
+
<div class="console-header">
|
|
795
|
+
<span class="console-title">Debug Console</span>
|
|
796
|
+
<div class="console-actions">
|
|
797
|
+
<button class="console-action-btn" id="console-clear">Clear</button>
|
|
798
|
+
<button class="console-action-btn" id="console-close">Close</button>
|
|
799
|
+
</div>
|
|
800
|
+
</div>
|
|
801
|
+
<div class="console-messages" id="console-messages"></div>
|
|
802
|
+
</div>
|
|
803
|
+
</div>
|
|
804
|
+
`,this.setupEventListeners(e),e}setupEventListeners(e){var i,a,o,r,l,c,u;let t=e.querySelector("#device-select");t==null||t.addEventListener("change",d=>{if(this.viewMode==="compare")return;let p=d.target.value;this.setDevice(p)}),Array.from(e.querySelectorAll("[data-view-toggle]")).forEach(d=>{d.addEventListener("click",()=>{let p=d.dataset.viewToggle;p&&this.setViewMode(p)})}),(i=e.querySelector("#rotate-btn"))==null||i.addEventListener("click",()=>this.toggleRotation()),(a=e.querySelector("#zoom-in-btn"))==null||a.addEventListener("click",()=>this.adjustUserZoom(.1)),(o=e.querySelector("#zoom-out-btn"))==null||o.addEventListener("click",()=>this.adjustUserZoom(-.1)),(r=e.querySelector("#refresh-btn"))==null||r.addEventListener("click",()=>this.refresh()),(l=e.querySelector("#console-toggle"))==null||l.addEventListener("click",()=>this.toggleConsole()),(c=e.querySelector("#console-close"))==null||c.addEventListener("click",()=>this.toggleConsole(!1)),(u=e.querySelector("#console-clear"))==null||u.addEventListener("click",()=>this.clearConsole())}applyDeviceFrameStyles(){Object.assign(this.frameDragger.style,{display:"flex",justifyContent:"center",alignItems:"center",transform:"translate(0px, 0px)",touchAction:"none"}),Object.assign(this.frameWrapper.style,{display:"flex",justifyContent:"center",alignItems:"center",transformOrigin:"center center",transition:"transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)",boxShadow:"0 20px 50px rgba(0,0,0,0.5)",borderRadius:"0px",willChange:"transform"}),Object.assign(this.deviceFrame.style,{overflow:"hidden",position:"relative",borderRadius:"0px"}),Object.assign(this.gameContainer.style,{position:"relative",overflow:"hidden",minWidth:"0px",minHeight:"0px"})}setupObserversAndListeners(){this.resizeObserver=new ResizeObserver(()=>{this.resizeListenersDisabled||!this.gameReady||this.scheduleFit()}),this.resizeObserver.observe(this.previewContainer),window.addEventListener("resize",this.onWindowResize,{passive:!0})}scheduleFit(){this.rafFitHandle&&cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=requestAnimationFrame(()=>{this.rafFitHandle=null,this.fitToScreen()})}applyPresetDimensions(){let e=this.getEffectivePreset(),t=`${e.width}px`,n=`${e.height}px`;this.deviceFrame.style.width=t,this.deviceFrame.style.height=n,this.gameContainer.style.width=t,this.gameContainer.style.height=n,this.gameContainer.style.maxWidth=t,this.gameContainer.style.maxHeight=n,this.gameContainer.style.minWidth=t,this.gameContainer.style.minHeight=n,this.gameContainer.dataset.screenWidth=String(e.width),this.gameContainer.dataset.screenHeight=String(e.height),this.container.style.setProperty("--preview-screen-width",String(e.width)),this.container.style.setProperty("--preview-screen-height",String(e.height))}fitToScreen(e){if(!this.previewContainer)return;let t=this.getEffectivePreset(),n=this.getFitBounds(),i=Math.max(0,n.width),a=Math.max(0,n.height);if(i<=0||a<=0)return;this.applyPresetDimensions(),this.viewMode==="compare"&&this.applyCompareDimensions();let o=i/t.width,r=a/t.height;if(this.autoScale=Math.max(.01,Math.min(o,r)),!this.hasInitialFit){this.hasInitialFit=!0;let l=.6;this.userScaleMultiplier=l/this.autoScale}e!=null&&e.keepVisibleScale&&e.keepVisibleScale>0&&(this.userScaleMultiplier=e.keepVisibleScale/this.autoScale),this.applyTransform(),this.viewMode==="compare"&&this.fitCompareGhosts(),this.emitScreenChange()}applyTransform(){let e=this.autoScale*this.userScaleMultiplier;this.frameWrapper.style.transform=`scale(${e})`;let t=this.container.querySelector("#zoom-label");t&&(t.textContent=`${Math.round(e*100)}%`)}applyFrameDrag(){this.frameDragger.style.transform=`translate(${this.frameDragOffsetX}px, ${this.frameDragOffsetY}px)`}setupFrameDragging(){this.frameDragger.addEventListener("pointerdown",e=>{this.gameContainer.contains(e.target)||e.button===0&&(e.preventDefault(),this.frameDragActive=!0,this.frameDragStartX=e.clientX,this.frameDragStartY=e.clientY,this.frameDragOriginX=this.frameDragOffsetX,this.frameDragOriginY=this.frameDragOffsetY,window.addEventListener("pointermove",this.onFrameDragMove),window.addEventListener("pointerup",this.onFrameDragEnd))})}adjustUserZoom(e){this.userScaleMultiplier=Math.max(.1,Math.min(6,this.userScaleMultiplier+e)),this.applyTransform(),this.emitScreenChange()}toggleRotation(){var t,n;if(this.viewMode==="compare")return;let e=this.autoScale*this.userScaleMultiplier;this.isLandscape=!this.isLandscape,this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale:e}),(n=(t=this.options).onDeviceChange)==null||n.call(t,this.getEffectivePreset()),this.emitScreenChange()}emitScreenChange(){if(!this.gameReady)return;let e=this.getEffectivePreset(),t={width:e.width,height:e.height,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:e.id,isLandscape:this.isLandscape};if(window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:t})),this.viewMode==="compare"&&this.refreshCompareSnapshots(),this.isInitialized&&this.isMounted&&this.gameReady){let n=window.gameApp;if(!(n!=null&&n.renderer))return;this.ignoreNextWindowResize=!0,window.dispatchEvent(new Event("resize"))}}safeStringify(e){var n;let t=new WeakSet;try{return JSON.stringify(e,(i,a)=>{if(typeof a=="object"&&a!==null){if(t.has(a))return"[Circular]";t.add(a)}return a},2)}catch{try{if(e&&((n=e.constructor)!=null&&n.name))return`[object ${e.constructor.name}]`}catch{}return String(e)}}setupConsoleInterceptor(){let e=console.log.bind(console),t=console.warn.bind(console),n=console.error.bind(console),i=console.info.bind(console),a=(o,...r)=>{let l=r.map(u=>typeof u=="object"?this.safeStringify(u):String(u)).join(" ");this.consoleMessages.push({type:o,message:l,timestamp:new Date}),this.appendConsoleMessage(this.consoleMessages[this.consoleMessages.length-1]);let c=this.container.querySelector("#console-badge");if(c){let u=this.consoleMessages.filter(d=>d.type==="error").length;c.textContent=u>0?`${u}!`:"0",c.classList.toggle("has-errors",u>0)}};console.log=(...o)=>{e(...o),a("log",...o)},console.warn=(...o)=>{t(...o),a("warn",...o)},console.error=(...o)=>{n(...o),a("error",...o)},console.info=(...o)=>{i(...o),a("info",...o)}}appendConsoleMessage(e){let t=this.container.querySelector("#console-messages");if(!t)return;let n=document.createElement("div");n.className=`console-msg type-${e.type}`;let i=e.timestamp.toLocaleTimeString();n.innerHTML=`<span class="time">${this.escapeHtml(i)}</span> <pre>${this.escapeHtml(e.message)}</pre>`,t.appendChild(n),t.scrollTop=t.scrollHeight}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}toggleConsole(e){var t;this.isConsoleOpen=e!=null?e:!this.isConsoleOpen,(t=this.consolePanel)==null||t.classList.toggle("closed",!this.isConsoleOpen)}clearConsole(){this.consoleMessages=[];let e=this.container.querySelector("#console-messages");e&&(e.innerHTML="");let t=this.container.querySelector("#console-badge");t&&(t.textContent="0")}setupCompareViewports(){Array.from(this.container.querySelectorAll("[data-viewport]")).forEach(t=>{let n=t.dataset.viewport;if(!n)return;let i=this.comparePresets.find(d=>d.id===n);if(!i)return;let a=t.querySelector("[data-compare-slot]"),o=t.querySelector("[data-compare-ghost]"),r=t.querySelector("[data-compare-wrapper]"),l=t.querySelector("[data-compare-frame]"),c=t.querySelector("[data-compare-snapshot]"),u=t.querySelector("[data-compare-focus]");!a||!o||!r||!l||(t.addEventListener("click",d=>{let p=d.target;if(p!=null&&p.closest("[data-compare-focus]")){d.preventDefault(),this.activateCompareViewport(n);return}t.classList.contains("is-active")||this.activateCompareViewport(n)}),this.compareViewports.set(n,{preset:i,root:t,slot:a,ghost:o,wrapper:r,frame:l,canvas:c,focus:u}))})}setViewMode(e){if(this.viewMode===e)return;this.viewMode=e,this.container.classList.toggle("compare-mode",e==="compare"),this.singleStage.classList.toggle("hidden",e!=="single"),this.compareStage.classList.toggle("hidden",e!=="compare");let t=this.container.querySelector("#device-select");t&&(t.disabled=e==="compare");let n=this.container.querySelector("#rotate-btn");if(n&&(n.disabled=e==="compare"),this.updateViewToggleUI(),e==="compare"){this.lastSinglePresetId=this.currentPreset.id,this.activateCompareViewport(this.activeCompareId),this.refreshCompareSnapshots(),this.startCompareSnapshots();return}this.stopCompareSnapshots(),this.singleStage.appendChild(this.frameDragger),this.setDevice(this.lastSinglePresetId,{suppressCallback:!0}),this.fitToScreen()}updateViewToggleUI(){Array.from(this.container.querySelectorAll("[data-view-toggle]")).forEach(t=>{t.classList.toggle("active",t.dataset.viewToggle===this.viewMode)})}activateCompareViewport(e){var a,o;let t=this.compareViewports.get(e);if(!t)return;let n=this.autoScale*this.userScaleMultiplier,i=this.activeCompareId;i&&i!==e&&this.captureCompareSnapshot(i),this.activeCompareId=e,this.currentPreset=t.preset,this.isLandscape=!1,t.slot.appendChild(this.frameDragger),this.frameDragOffsetX=0,this.frameDragOffsetY=0,this.applyFrameDrag(),this.compareViewports.forEach((r,l)=>{r.root.classList.toggle("is-active",l===e),r.ghost.classList.toggle("hidden",l===e),r.focus&&(r.focus.textContent=l===e?"Live":"Focus")}),this.applyPresetDimensions(),this.applyCompareDimensions(),this.fitToScreen({keepVisibleScale:n}),(o=(a=this.options).onDeviceChange)==null||o.call(a,this.getEffectivePreset())}applyCompareDimensions(){this.compareViewports.forEach(e=>{let t=e.preset,n=`${t.width}px`,i=`${t.height}px`;e.frame.style.width=n,e.frame.style.height=i,e.canvas&&(e.canvas.width=t.width,e.canvas.height=t.height)})}fitCompareGhosts(){this.compareViewports.forEach(e=>{let t=e.root.querySelector(".compare-body");if(!t)return;let n=Math.max(0,t.clientWidth-24),i=Math.max(0,t.clientHeight-24);if(n<=0||i<=0)return;let a=n/e.preset.width,o=i/e.preset.height,r=Math.max(.01,Math.min(a,o));e.wrapper.style.transform=`scale(${r})`})}captureCompareSnapshot(e){let t=this.compareViewports.get(e);if(!(t!=null&&t.canvas))return;let n=this.gameContainer.querySelector("canvas");if(!n)return;let i=t.canvas.getContext("2d");if(!i)return;let a=t.canvas.width,o=t.canvas.height,r=Math.min(a/n.width,o/n.height),l=n.width*r,c=n.height*r,u=(a-l)/2,d=(o-c)/2;i.clearRect(0,0,a,o),i.drawImage(n,u,d,l,c)}refreshCompareSnapshots(){this.compareViewports.forEach((e,t)=>{t!==this.activeCompareId&&this.captureCompareSnapshot(t)})}startCompareSnapshots(){this.compareSnapshotTimer||(this.compareSnapshotTimer=window.setInterval(()=>{this.viewMode==="compare"&&this.refreshCompareSnapshots()},500))}stopCompareSnapshots(){this.compareSnapshotTimer&&(window.clearInterval(this.compareSnapshotTimer),this.compareSnapshotTimer=null)}getFitBounds(){if(this.viewMode!=="compare")return{width:this.previewContainer.clientWidth-40,height:this.previewContainer.clientHeight-40};let e=this.compareViewports.get(this.activeCompareId),t=e==null?void 0:e.root.querySelector(".compare-body");return t?{width:t.clientWidth-24,height:t.clientHeight-24}:{width:this.previewContainer.clientWidth-40,height:this.previewContainer.clientHeight-40}}mustQuery(e){let t=this.container.querySelector(e);if(!t)throw new Error(`PreviewShell missing element: ${e}`);return t}};function cs(s={}){let e=new qn(s);return typeof window!="undefined"&&(window.__previewShell=e),e.mount(),e}function ds(s){try{if(s&&typeof s.keys=="function")return Array.from(s.keys())}catch{}return[]}function us(s){var e;return s?((e=s.getDisplayObject)==null?void 0:e.call(s))||s.pixiObject||s:null}function ps(s,e){var a,o,r,l,c;if(!s||!e)return;let t=e.transform||{},n=t.offset||t.position;n&&typeof n.x=="number"&&typeof n.y=="number"&&((a=s.position)!=null&&a.set?s.position.set(n.x,n.y):(typeof s.x=="number"&&(s.x=n.x),typeof s.y=="number"&&(s.y=n.y))),typeof t.scale=="number"&&((o=s.scale)!=null&&o.set?s.scale.set(t.scale):s.scale&&(s.scale.x=t.scale,s.scale.y=t.scale));let i=(l=t.anchor)!=null?l:(r=e.render)==null?void 0:r.anchor;i&&((c=s.anchor)!=null&&c.set)&&typeof i.x=="number"&&typeof i.y=="number"&&s.anchor.set(i.x,i.y)}function hs(s){if(typeof window=="undefined")return;let e=s==null?void 0:s.objects,t=ds(e);window.__editableObjectConfigs=e;let n=new Map;t.forEach(i=>n.set(i,[i])),window.__editableObjectInstances=n,window.refreshEditableConfigIndex=()=>hs(window.__editableConfig),window.getEditableObjectList=()=>{var i;return ds((i=window.__editableConfig)==null?void 0:i.objects)},window.getEditableObjectConfig=i=>{var a,o,r,l;return(l=(r=(o=(a=window.__editableConfig)==null?void 0:a.objects)==null?void 0:o.get)==null?void 0:r.call(o,i))!=null?l:null},window.getEditableEngineConfig=()=>{var i;return(i=window.__editableConfig)!=null?i:null}}function oo(){typeof window!="undefined"&&(window.applyLiveEditOverrides=s=>{try{let e=Rn();Array.isArray(e)&&e.length&&(window.__editableConfig=s,On(e,{silent:!0,persist:!1}))}catch{}},window.applyEngineOverrides=s=>{try{let e=Rn();Array.isArray(e)&&e.length&&(window.__editableConfig=s,On(e,{silent:!0,persist:!1}))}catch{}},window.applyEditableEngineConfig=s=>{let e=window.__editableConfig;if(!(e!=null&&e.engine))return;let t={...e.engine.runtime||{},...(s==null?void 0:s.runtime)||{}},n={...e.engine.assets||{},...(s==null?void 0:s.assets)||{}},i={...e.engine.splash||{},...(s==null?void 0:s.splash)||{}};Ut({path:"runtime",value:t},{silent:!0,persist:!0}),Ut({path:"assets",value:n},{silent:!0,persist:!0}),Ut({path:"splash",value:i},{silent:!0,persist:!0})})}function Un(s){let{getConfig:e,gameObjectManager:t,onObjectConfigApplied:n}=s;typeof window!="undefined"&&(oo(),window.applyEditableObjectConfig=(a,o)=>{var r,l;try{let c=window.__editableConfig;(r=c==null?void 0:c.objects)!=null&&r.set&&c.objects.set(a,o);let u=(l=t==null?void 0:t.get)==null?void 0:l.call(t,a),d=us(u);ps(d,o)}catch{}});let i={async applyObjectConfig(a,o){var d,p;let r=e();(d=r==null?void 0:r.objects)!=null&&d.set&&r.objects.set(a,o);let l=(p=t==null?void 0:t.get)==null?void 0:p.call(t,a),c=us(l);ps(c,o);let u=[a];n==null||n(a,o,u)},rebuildIndexes(){let a=e();typeof window!="undefined"&&(window.__editableConfig=a,hs(a))}};return i.rebuildIndexes(),i}import ro from"lottie-web";Xn(Xa);typeof window!="undefined"&&!window.lottie&&(window.lottie=ro);var st=null,lo=async()=>{if(!st){let s=typeof window!="undefined"?window.INLINE_ASSETS:null,e=(s==null?void 0:s["handler.config"])||(s==null?void 0:s["handler.config.json"]);if(e)try{if(e.startsWith("data:")){let n=atob(e.split(",")[1]);st=JSON.parse(n)}else st=JSON.parse(e);return st}catch(n){console.warn("[CONFIG] Failed to parse inline handler.config.json:",n)}st=await(await fetch("./handler.config.json")).json()}return st},Kn,xt,fs,ot,Wn,Vn;function _l(s){Kn=s.initGame,xt=s.CustomAssets,fs=s.updateScreenState,ot=s.globalResponsiveMultipliers,Wn=s.layout,Vn=s.clearResponsiveElements}var un="web_embed",vt="https://example.com",gs={profile_id:un},je=null,xe=null,Yn={width:0,height:0},co=!0,Al=async()=>{var l,c,u,d;document.title="Handler Pixi Game";let s=await lo();gs={...s.ids||{},profile_id:un},vt=s.destination_url||((c=(l=s.export_profiles)==null?void 0:l[un])==null?void 0:c.destination_url)||vt,Me.init({ids:gs,profile:un,destinationUrl:vt});let e=Me.getRoot();if(typeof __PREVIEW_SHELL__!="undefined"&&__PREVIEW_SHELL__){console.log("[BOOTSTRAP] Initializing Preview Shell..."),xe=cs({onDeviceChange:h=>{console.log(`[PREVIEW] Device switched to ${h.width}x${h.height}, restarting game...`),bs()},onRefresh:bs});let p=xe.getGameContainer();p&&(e=p),window.addEventListener("handler-preview:screen",h=>{var y,v,w,S,A,I,T,C,L,O,_;let g=window.gameApp,b=window.gameObjectManager,{width:f,height:m}=h.detail;if(Yn.width=f,Yn.height=m,fs(f,m),!(!g||!g.renderer)){b&&o(g,b);try{g.renderer.resize(f,m);let E=g.view;E&&(E.style.width="100%",E.style.height="100%",E.style.display="block")}catch(E){console.warn("[SCREEN] Error resizing renderer:",E);return}if(t&&b&&Wn)try{let E=(y=window.__mainContainer)!=null?y:g.stage,B=(T=(I=(S=window.__tutorialLabel)!=null?S:(w=(v=b.get("label_1"))==null?void 0:v.getDisplayObject)==null?void 0:w.call(v))!=null?I:(A=b.get("label_1"))==null?void 0:A.pixiObject)!=null?T:b.get("label_1"),M=b.get("background_1"),x=(_=(O=(L=window.__background)!=null?L:(C=M==null?void 0:M.getDisplayObject)==null?void 0:C.call(M))!=null?O:M==null?void 0:M.pixiObject)!=null?_:M;if(E){let k=E===g.stage;Wn({mainContainer:E,label:B,background:x,backgroundTexture:null,app:g},t,0,Yn,b,{skipMainContainerTransform:k})}}catch(E){console.warn("[SCREEN] Error in layout:",E)}}})}let t=await Yt("scene.main");window.__editableConfig=t,(d=(u=t.engine.runtime)==null?void 0:u.layout)!=null&&d.design_width_portrait||(console.warn("[BOOTSTRAP] Config layout missing, retrying..."),await new Promise(p=>setTimeout(p,100)),t=await Yt("scene.main"));let n=await Kn(e,t,vt,xe);je=n.app;let i=n.gameObjectManager;window.gameApp=je,window.gameObjectManager=i;try{window.__liveEditBridge=Un({getConfig:()=>window.__editableConfig,gameObjectManager:i,assets:xt})}catch(p){console.warn("[BOOTSTRAP] Failed to initialize live-edit bridge",p)}xe&&xe.notifyGameLoaded();let a=window.__debugScale;a&&typeof a=="number"&&(ot.scale=a,console.log(`[DEBUG] Applied persisted debug scale: ${a}`)),o(je,i);function o(p,h){if(co){console.log("[RESPONSIVE] Skipping global scaling; using config-driven layout");return}if(console.log("[RESPONSIVE] ===== APPLYING GLOBAL RESPONSIVE SCALING ====="),console.log(`[RESPONSIVE] Scale multiplier: ${ot.scale.toFixed(3)}`),p.stage){let b=function(f,m=0){if(!f||!f.children)return;let y=" ".repeat(m);f.children.forEach((v,w)=>{if(v&&v.zIndex===9999){console.log(`${y}[RESPONSIVE] Skipping debug border (zIndex 9999)`);return}if(v&&v.scale){let S=v.scale.x||1,A=v.scale.y||1;v.__originalScale||(v.__originalScale={x:S,y:A},console.log(`${y}[RESPONSIVE] Stored original scale for child[${w}]: ${S.toFixed(3)}, ${A.toFixed(3)}`));let I=v.__originalScale.x*ot.scale,T=v.__originalScale.y*ot.scale;typeof v.scale.set=="function"?v.scale.set(I,T):(v.scale.x=I,v.scale.y=T),console.log(`${y}[RESPONSIVE] Child[${w}] scale: ${S.toFixed(3)}\u2192${v.scale.x.toFixed(3)} (type: ${v.constructor.name})`),b(v,m+1)}else v&&console.log(`${y}[RESPONSIVE] Child[${w}] has no scale (type: ${v.constructor.name})`)})};var g=b;console.log("[RESPONSIVE] Applying scale to PIXI stage children"),b(p.stage)}else console.warn("[RESPONSIVE] No app.stage found!");console.log("[REDDEBUG] Debug border left unscaled (fixed boundaries)"),console.log("[RESPONSIVE] ===== GLOBAL RESPONSIVE SCALING COMPLETE =====")}function r(p){if(p!==void 0){ot.scale=p,console.log(`[RESPONSIVE] Updated global scale multiplier to: ${p.toFixed(3)}`);let h=window.gameApp,g=window.gameObjectManager;h&&g?(o(h,g),h.renderer&&(h.renderer.render(h.stage),console.log("[RESPONSIVE] Forced PIXI renderer update"))):console.warn(`[RESPONSIVE] No gameApp (${!!h}) or gameObjectManager (${!!g}) found in window for live update`)}}window.updateGlobalResponsiveMultipliers=r,Me.start()},bs=async()=>{var e,t,n,i;console.log("[PREVIEW] Restarting game in 1 seconds...");let s=(e=window.gameObjectManager)==null?void 0:e.get("character_1");if(s){let a=((t=s.getDisplayObject)==null?void 0:t.call(s))||s;a&&a.scale&&console.log(`[CHARACTER] Before restart - Current scale - x: ${((n=a.scale.x)!=null?n:1).toFixed(3)}, y: ${((i=a.scale.y)!=null?i:1).toFixed(3)}`)}if(xe){xe.notifyGameDestroyed();try{Vn&&Vn()}catch(a){console.warn("Failed to clear responsive elements",a)}setTimeout(()=>{console.log("[PREVIEW] Executing restart...");let a=xe.getGameContainer();if(je){try{je.destroy(!0,{children:!0,texture:!1})}catch(o){console.warn("[PREVIEW] Destroy warning:",o)}je=null}window.gameApp=null,window.gameObjectManager=null,a&&(a.innerHTML="");try{typeof xt.resetScene=="function"&&xt.resetScene()}catch(o){console.warn("Asset reset failed",o)}setTimeout(()=>{Yt("scene.main").then(o=>{window.__editableConfig=o,Kn(a,o,vt).then(r=>{je=r.app,window.gameApp=je,window.gameObjectManager=r.gameObjectManager;try{window.__liveEditBridge=Un({getConfig:()=>window.__editableConfig,gameObjectManager:window.gameObjectManager,assets:xt})}catch(l){console.warn("[BOOTSTRAP] Failed to re-initialize live-edit bridge",l)}xe&&xe.notifyGameLoaded(),console.log("[PREVIEW] Game restarted successfully");try{Me.start()}catch{}})})},100)},1e3)}};var Jn="0.3.1",Ss={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},uo=Math.random().toString(36).slice(2),rt=null,St={...Ss},Es="web_embed",po={},Qn=!1,wt=!1,Lt=!1,Ls=!1,ni=1,ei=0,bn=!1,ke=!1,gn="",lt=Math.floor(window.innerWidth),ct=Math.floor(window.innerHeight),ti=lt>ct,Ie=!1,Et=!1,ms=!1,ys=!1,Zn=!1,pn=null;function vs(){if(rt)return rt;let s=document.createElement("div");return s.id="handler-root",s.setAttribute("data-handler-root","true"),document.body.appendChild(s),rt=s,s}function hn(s){switch(s){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return s}}function _s(s,e){return{event_name:s,ts:Date.now(),session_id:uo,deployment_id:St.deployment_id,variant_id:St.variant_id,export_profile_id:St.profile_id,instance_id:St.instance_id||"default",env:Es==="mraid"?"mraid":"web",payload:e}}function F(s,e){let t=hn(s),n=_s(t,e);Vt(t,n),t!==s&&Vt(s,n)}function _t(){pn&&(pn(lt,ct),pn=null)}function dt(s){ni=s,F("volume",s)}function ut(s){s&&(Ls=!0),!Lt&&(Lt=!0,F("pause"),dt(0))}function At(s){!s&&Ls||Lt&&(Lt=!1,F("resume"),dt(ni))}function Ne(s,e){lt=Math.floor(s||window.innerWidth),ct=Math.floor(e||window.innerHeight),ti=lt>ct,F("resize",{width:lt,height:ct})}function ho(){if(Na())try{let s=mraid.getMaxSize();Ne(s.width,s.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?At():ut()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let t=mraid.getMaxSize();Ne(t.width,t.height)}),mraid.getAudioVolume){let t=mraid.getAudioVolume();dt(t?1:0)}if(mraid.addEventListener("audioVolumeChange",t=>{t!==null&&dt(t>0?1:0)}),mraid.addEventListener("error",(t,n)=>{console.warn("mraid error:",t,"action:",n)}),bn=!0,mraid.isViewable()&&mraid.getState()!=="hidden")Ie=!0,F("boot"),F("view"),F("ready"),ke=!0,_t();else{let t=()=>{Ie=!0,F("boot"),F("view"),F("ready"),ke=!0,_t()};mraid.addEventListener("ready",t)}}catch(s){console.warn("MRAID hook skipped",s)}}function go(){if($a())try{let s=dapi.getScreenSize();Ne(s.width,s.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?At():ut()}),dapi.addEventListener("adResized",t=>{let n=dapi.getScreenSize();Ne(t.width||n.width,t.height||n.height)});let e=dapi.getAudioVolume();if(dt(e?1:0),dapi.addEventListener("audioVolumeChange",t=>dt(t?1:0)),bn=!0,dapi.isViewable())Ie=!0,F("boot"),F("view"),F("ready"),ke=!0,_t();else{let t=()=>{Ie=!0,F("boot"),F("view"),F("ready"),ke=!0,_t()};dapi.addEventListener("ready",t)}}catch(s){console.warn("DAPI hook skipped",s)}}function xs(){let s=()=>{Ie||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(Ie=!0,F("boot"),F("view"),F("ready"),ke=!0,_t(),Et&&(Et=!1,Fe.start()))};window.addEventListener("resize",()=>Ne()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(At(),s()):ut()}),document.readyState==="complete"||document.readyState==="interactive"?s():window.addEventListener("load",s),bn=!0}function bo(){let s=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(ms=!0),!(ms&&e instanceof MouseEvent)&&(ei+=1,F("interaction",ei))};document.addEventListener("mousedown",s),document.addEventListener("touchstart",s)}function fo(s){var n,i,a,o,r,l,c,u,d,p,h,g;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(n=window.ExitApi)==null||n.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(s||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(nt())(a=(i=window.TJ_API)==null?void 0:i.click)==null||a.call(i);else if(Ga())(r=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||r.call(o);else if(Wa())(c=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||c.call(l);else if(Ya())try{(d=(u=window.smxTracking)==null?void 0:u.redirect)==null||d.call(u)}catch(b){console.warn("Smadex redirect failed",b)}else if(qa()){let b=window.ExitApi;b&&typeof b.exit=="function"?b.exit(s||gn||""):s&&window.open(s)}else tt()?(p=window.install)==null||p.call(window):Ua()?(h=window.openAppStore)==null||h.call(window):Bn()?(g=parent==null?void 0:parent.postMessage)==null||g.call(parent,"download","*"):s&&window.open(s)}function mo(){let s=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let n=new Image;n.src=t};if(s==="bigabid"){let t=window.BIGABID_BIDTIMEMACROS;if(!t)return;re("view",()=>e(t.mraid_viewable)),re("start",()=>e(t.game_viewable)),re("engagement",()=>e(t.engagement));let n=()=>e(t.complete);re("complete",n),Wt("engagement",i=>{var a;((a=i==null?void 0:i.payload)==null?void 0:a.count)>3&&n()}),re("cta_click",()=>e(t.click))}else if(s==="inmobi"){let t=window.INMOBI_DSPMACROS;if(!t)return;re("view",()=>e(t.Ad_Load_Start)),re("start",()=>e(t.Ad_Viewable)),re("engagement",()=>e(t.First_Engagement)),re("complete",()=>e(t.Gameplay_Complete)),re("cta_click",()=>e(t.DSP_Click)),re("start",()=>{[5,10,15,20,25,30].forEach(n=>setTimeout(()=>e(t[`Spent_${n}_Seconds`]),n*1e3))})}}function yo(){if(!nt())return;let s=window.TJ_API;s&&s.setPlayableAPI&&s.setPlayableAPI({skipAd:()=>{try{Fe.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function ws(){var e,t,n;let s=window.TJ_API;(e=s==null?void 0:s.objectiveComplete)==null||e.call(s),(t=s==null?void 0:s.playableFinished)==null||t.call(s),(n=s==null?void 0:s.gameplayFinished)==null||n.call(s)}function vo(){tt()&&(window.mintGameStart=()=>{At(!0),Ne()},window.mintGameClose=()=>{ut(!0)})}function xo(){if(!Dn())return;let s=window.NUC;!s||!s.trigger||(Fe.on("cta_click",()=>{var e,t;return(t=(e=s.trigger).convert)==null?void 0:t.call(e,gn)}),Fe.on("complete",()=>{var e,t;return(t=(e=s.trigger).tryAgain)==null?void 0:t.call(e)}))}var Fe={init(s={},e){if(Es=s.profile||"web_embed",po=s.consent||{},St={...Ss,...s.ids||{}},rt=s.rootEl||rt,gn=s.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(pn=e),F("init"),document.body.oncontextmenu=()=>!1,vs(),wo(rt),Va(),ho(),go(),!bn){if(document.readyState==="complete")xs();else if(!ys){ys=!0;let t=()=>{xs(),window.removeEventListener("load",t),document.removeEventListener("DOMContentLoaded",t)};window.addEventListener("load",t),document.addEventListener("DOMContentLoaded",t)}}bo(),mo(),yo(),vo(),xo(),console.log(`%c @handler/playable-sdk %c v${Jn} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),Ie&&!ke&&(F("boot"),F("view"),F("ready"),Et&&(Et=!1,Fe.start()),ke=!0),ke=Ie},getRoot(){return vs()},get version(){return Jn},get maxWidth(){return lt},get maxHeight(){return ct},get isLandscape(){return ti},get isReady(){return ke},get isStarted(){return Qn},get isPaused(){return Lt},get isFinished(){return wt},get volume(){return ni},get interactions(){return ei},on(s,e){Wt(hn(s),e)},off(s,e){Hn(hn(s),e)},start(){var s,e;if(!Qn){if(!Ie){Et=!0;return}if(Qn=!0,F("start"),Ne(),tt())ut(),(s=window.gameReady)==null||s.call(window);else if(nt()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:ti?"landscape":"portrait",buildID:Jn})}}},finish(){var s,e;wt||(wt=!0,F("complete"),tt()?(s=window.gameEnd)==null||s.call(window):Bn()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):nt()&&ws())},install(s){if(!wt){wt=!0,nt()?(ws(),setTimeout(()=>Fe.install(s),300)):(F("complete"),setTimeout(()=>Fe.install(s),0));return}Zn||(Zn=!0,setTimeout(()=>Zn=!1,500),F("cta_click"),F("conversion"),fo(s||gn))},emit(s,e){let t=hn(s);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(t)&&!t.startsWith("custom."))throw new Error(`Event ${s} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let n=_s(t,e);Vt(t,n)},retry(){var s,e,t;if(tt())(s=window.gameRetry)==null||s.call(window);else if(Dn()){let n=window.NUC;(t=(e=n==null?void 0:n.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}F("engagement",{action:"retry"})},pause(){ut(!0)},resume(){At(!0)},resize(s,e){Ne(s,e)}},Me=Fe;function wo(s){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
|
|
805
|
+
(function(){
|
|
806
|
+
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
807
|
+
function unlock(){
|
|
808
|
+
if(window.AudioContext && AudioContext.prototype.resume){
|
|
809
|
+
if(!window.__handler_audio_ctx){
|
|
810
|
+
window.__handler_audio_ctx = new AudioContext();
|
|
811
|
+
}
|
|
812
|
+
if(window.__handler_audio_ctx.state === 'suspended'){
|
|
813
|
+
window.__handler_audio_ctx.resume();
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
events.forEach(function(e){ document.removeEventListener(e, unlock); });
|
|
817
|
+
}
|
|
818
|
+
events.forEach(function(e){ document.addEventListener(e, unlock, false); });
|
|
819
|
+
})();
|
|
820
|
+
`,s.appendChild(e)}async function ii(s,e={}){let t=new So;await t.init({resizeTo:s,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let n=a=>{var l,c,u,d,p,h;if(!t.renderer)return;let o=(u=(c=(l=a==null?void 0:a.width)!=null?l:s.clientWidth)!=null?c:window.innerWidth)!=null?u:320,r=(h=(p=(d=a==null?void 0:a.height)!=null?d:s.clientHeight)!=null?p:window.innerHeight)!=null?h:480;t.renderer.resize(o,r)};s.innerHTML="",s.style.position="relative",s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="stretch",s.style.width="100%",s.style.height="100dvh",s.style.minHeight="100vh",s.style.maxWidth="100%",s.style.maxHeight="100%",s.style.boxSizing="border-box",s.style.overflow="hidden",e.background&&(s.style.background=e.background),s.appendChild(t.canvas);let i=document.createElement("div");return i.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),s.appendChild(i),Me.on("pause",()=>{t.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),Me.on("resume",()=>{t.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),Me.on("resize",({payload:a})=>{n({width:a==null?void 0:a.width,height:a==null?void 0:a.height})}),window.addEventListener("resize",()=>n()),requestAnimationFrame(()=>n()),{app:t,stage:t.stage,overlay:i,applySize:n}}var fn=class{constructor(e){var t,n;this.position=(e==null?void 0:e.position)||{x:0,y:0},this.scale=(t=e==null?void 0:e.scale)!=null?t:1,this.rotation=(n=e==null?void 0:e.rotation)!=null?n:0}update(e){e.position!==void 0&&(this.position={...e.position}),e.scale!==void 0&&(this.scale=e.scale),e.rotation!==void 0&&(this.rotation=e.rotation)}syncToPixi(e){e.position.set(this.position.x,this.position.y),e.scale.set(this.scale),e.rotation=this.rotation}},mn=class{constructor(e){var t,n,i,a;this.z_index=(t=e==null?void 0:e.z_index)!=null?t:0,this.alpha=(n=e==null?void 0:e.alpha)!=null?n:1,this.visible=(i=e==null?void 0:e.visible)!=null?i:!0,this.tint=(a=e==null?void 0:e.tint)!=null?a:null}update(e){e.z_index!==void 0&&(this.z_index=e.z_index),e.alpha!==void 0&&(this.alpha=e.alpha),e.visible!==void 0&&(this.visible=e.visible),e.tint!==void 0&&(this.tint=e.tint)}syncToPixi(e){e.zIndex=this.z_index,e.alpha=this.alpha,e.visible=this.visible,this.tint!==null&&"tint"in e&&(e.tint=this.tint)}},yn=class{constructor(e,t,n,i){this.instanceId=e,this.objectConfig=t,this.pixiObject=n,this._config=i,this.transform=new fn(i.transform),this.renderer=new mn(i.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject),this.applyAnchor(),this.applyEffectsScale()}updateConfig(e){this._config=e,e.transform&&this.transform.update(e.transform),e.render&&this.renderer.update(e.render),this.sync()}applyAnchor(){var i,a,o,r;if(!this.pixiObject||!("anchor"in this.pixiObject)||!this.pixiObject.anchor)return;let e=(a=(i=this._config)==null?void 0:i.render)==null?void 0:a.anchor,t=(r=(o=this._config)==null?void 0:o.transform)==null?void 0:r.anchor,n=e&&typeof e=="object"?e:t&&typeof t=="object"?t:null;n&&typeof n.x=="number"&&typeof n.y=="number"&&this.pixiObject.anchor.set(n.x,n.y)}applyEffectsScale(){var a,o,r;if(!((a=this.pixiObject)!=null&&a.scale))return;let e=(o=this._config)==null?void 0:o.effects,t=typeof(e==null?void 0:e.scale_x)=="number"?e.scale_x:1,n=typeof(e==null?void 0:e.scale_y)=="number"?e.scale_y:1;if(t===1&&n===1)return;let i=(r=this.transform.scale)!=null?r:1;typeof this.pixiObject.scale.set=="function"?this.pixiObject.scale.set(i*t,i*n):(this.pixiObject.scale.x=i*t,this.pixiObject.scale.y=i*n)}getComponent(e){return this._config[e]}getPosition(){return{...this.transform.position}}setPosition(e,t){this.transform.position={x:e,y:t},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(e){this.renderer.alpha=e,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(e){this.renderer.visible=e,this.renderer.syncToPixi(this.pixiObject)}},Tt=class{constructor(e){this.objects=new Map;this.config=e}create(e,t){let n=this.config.objects.get(e);if(!n)throw new Error(`Object config not found: ${e}`);let i=new yn(e,n.object_config||e,t,n);return this.objects.set(e,i),i}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[t,n]of this.objects.entries()){let i=e.objects.get(t);i&&n.updateConfig(i)}}getAll(){return Array.from(this.objects.values())}remove(e){this.objects.delete(e)}clear(){this.objects.clear()}};var vn={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function be(s){let e=vn[s];return e?e.family:(console.warn(`Font ID "${s}" not found in registry, using fallback`),"Arial, sans-serif")}function fe(s){var t;let e=vn[s];return e&&(t=e.weight)!=null?t:"400"}function Eo(s,e){vn[s]=e}function Lo(){return Object.keys(vn)}import{Container as _o,Graphics as xn,Text as Ct,Sprite as As,Texture as ai}from"pixi.js";function Ao(s,e,t){var Si,Ei,Li,_i,Ai,Ti,Ci,Mi,ki,Ii,Pi,Oi,Ri,Hi,Bi,Di,zi,ji,Fi,Ni,$i,Gi,qi,Ui,Yi,Wi,Vi,Xi,Ki,Ji,Qi,Zi,ea,ta,na,ia,aa,sa,oa,ra,la,ca,da,ua,pa,ha,ga,ba,fa,ma,ya,va,xa,wa,Sa,Ea,La,_a,Aa,Ta;let n=s.objects.get("ui_endgame_1"),i=s.objects.get("ui_endgame_logo_1"),a=s.objects.get("ui_endgame_title_1"),o=s.objects.get("ui_endgame_subtitle_1"),r=s.objects.get("ui_endgame_footer_1"),l=s.objects.get("ui_endgame_cta_1"),c=s.objects.get("ui_endgame_cta_hint_1"),u=s.objects.get("ui_endgame_hand_1"),d=s.engine.runtime||{},p=new _o;p.alpha=0,p.visible=!1;let h=((Si=n==null?void 0:n.gameplay)==null?void 0:Si.tuning)||{},g=(n==null?void 0:n.render)||{},b=(Ei=h.panel_width)!=null?Ei:320,f=(Li=h.panel_height)!=null?Li:400,m=(_i=h.panel_padding)!=null?_i:32,y=(Ai=h.panel_radius)!=null?Ai:24,v=g.background_color||h.panel_bg_color||"#1a0a0a",w=g.background_alpha!==void 0&&g.background_alpha!==null?g.background_alpha:(Ti=h.panel_bg_alpha)!=null?Ti:.98,S=g.border_color||h.panel_border_color||"#ffffff",A=(Ci=h.panel_border_width)!=null?Ci:2,I=(Mi=h.panel_border_alpha)!=null?Mi:.3,T=new xn;T.roundRect(-b/2,-f/2,b,f,y);let C=v.replace("#","");T.fill({color:parseInt(C,16),alpha:w});let L=S.replace("#","");T.stroke({color:parseInt(L,16),width:A,alpha:I});let O=new xn;O.roundRect(-b/2+2,-f/2+2,b-4,f-4,y-2),O.stroke({color:16777215,width:1,alpha:.1}),T.addChild(O),p.addChild(T);let _=((ki=i==null?void 0:i.gameplay)==null?void 0:ki.tuning)||{},E=(i==null?void 0:i.transform)||{},B=(Ii=_.logo_size)!=null?Ii:56,M=(Pi=E.scale)!=null?Pi:1,x=(Ri=(Oi=E.offset)==null?void 0:Oi.y)!=null?Ri:-130,k=(Hi=_.logo_alpha)!=null?Hi:1,P=new As(t||ai.EMPTY);P.anchor.set(.5);let z=0,D=0;if(t&&t!==ai.EMPTY){let Z=t.frame,Ce=t.baseTexture;Z&&Z.width&&Z.height?(z=Z.width,D=Z.height):Ce&&Ce.width&&Ce.height?(z=Ce.width,D=Ce.height):t.width&&t.height&&(z=t.width,D=t.height)}if(z>0&&D>0){let Z=z/D,Ce,Pn;Z>1?(Ce=B,Pn=B/Z):(Pn=B,Ce=B*Z);let Ca=Ce/z,Ma=Pn/D;Ca*=M,Ma*=M,P.scale.set(Ca,Ma)}else{let Z=B/100*M;P.scale.set(Z)}P.position.set(0,x),P.alpha=0,P.visible=!0,P.targetAlpha=k,P.baseScaleX=P.scale.x,P.baseScaleY=P.scale.y,p.addChild(P);let R=a==null?void 0:a.ui,V=((Bi=a==null?void 0:a.gameplay)==null?void 0:Bi.tuning)||{},ye=(R==null?void 0:R.text)||"MISSION ACCOMPLISHED",de=(R==null?void 0:R.font)||"brand.heading",qe=(R==null?void 0:R.fontSize)||24,He=(Di=R==null?void 0:R.letterSpacing)!=null?Di:1,ue=(zi=a==null?void 0:a.render)==null?void 0:zi.tint,Qe=typeof ue=="string"?ue:ue?`#${ue.toString(16).padStart(6,"0")}`:"#00FF88",H=b-m*2-30,te=V.font_weight_override?V.font_weight_override:fe(de),X=new Ct({text:ye,style:{fontFamily:be(de),fontSize:qe,fontWeight:te,fill:Qe,align:"center",letterSpacing:He,wordWrap:!1,stroke:{color:V.stroke_color||"#000000",width:(ji=V.stroke_width)!=null?ji:2},dropShadow:{color:V.shadow_color||"#000000",alpha:(Fi=V.shadow_alpha)!=null?Fi:.9,angle:(Ni=V.shadow_angle)!=null?Ni:0,blur:($i=V.shadow_blur)!=null?$i:8,distance:(Gi=V.shadow_distance)!=null?Gi:4}}});if(X.width>H){let Z=H/X.width;X.scale.set(Z)}X.anchor.set(.5);let pe=(qi=h.title_offset_y)!=null?qi:30,he=pe+((Ui=V.animation_start_y_offset)!=null?Ui:-20);X.position.set(0,he),X.alpha=0,p.addChild(X);let Y=o==null?void 0:o.ui,Ee=((Yi=o==null?void 0:o.gameplay)==null?void 0:Yi.tuning)||{},Be=(Y==null?void 0:Y.text)||"RESCUE COMPLETE",ne=(Y==null?void 0:Y.font)||"brand.body",De=(Y==null?void 0:Y.fontSize)||11,ve=(Wi=Y==null?void 0:Y.letterSpacing)!=null?Wi:.5,Le=(Vi=o==null?void 0:o.render)==null?void 0:Vi.tint,Ze=typeof Le=="string"?Le:Le?`#${Le.toString(16).padStart(6,"0")}`:"#B0B0B0",_e=new Ct({text:Be,style:{fontFamily:be(ne),fontSize:De,fontWeight:fe(ne),fill:Ze,align:"center",letterSpacing:ve}});_e.anchor.set(.5);let Bt=pe+20+((Xi=Ee.animation_start_y_offset)!=null?Xi:-10);_e.position.set(0,Bt),_e.alpha=0,_e.animationStartYOffset=(Ki=Ee.animation_start_y_offset)!=null?Ki:-10,p.addChild(_e);let ie=r==null?void 0:r.ui,gt=((Ji=r==null?void 0:r.gameplay)==null?void 0:Ji.tuning)||{},Dt=(ie==null?void 0:ie.text)||((Qi=d.ui)==null?void 0:Qi.cta_hint)||"Continue the adventure!",bt=(ie==null?void 0:ie.font)||"brand.body",zt=(ie==null?void 0:ie.fontSize)||16,Ue=(Zi=r==null?void 0:r.render)==null?void 0:Zi.tint,jt=typeof Ue=="string"?Ue:Ue?`#${Ue.toString(16).padStart(6,"0")}`:"#FFFFFF",Ft=(ea=gt.max_width)!=null?ea:b-m*2,Nt=(ta=gt.line_height)!=null?ta:1.4,Ae=new Ct({text:Dt,style:{fontFamily:be(bt),fontSize:zt,fontWeight:fe(bt),fill:jt,align:"center",wordWrap:!0,wordWrapWidth:Ft,lineHeight:Nt}});Ae.anchor.set(.5);let $t=(na=h.footer_offset_y)!=null?na:120;Ae.position.set(0,$t);let Gt=((ia=r==null?void 0:r.render)==null?void 0:ia.alpha)!==void 0&&((aa=r==null?void 0:r.render)==null?void 0:aa.alpha)!==null?r.render.alpha:1;Ae.alpha=0,Ae.targetAlpha=Gt,p.addChild(Ae);let ae=((sa=l==null?void 0:l.gameplay)==null?void 0:sa.tuning)||{},Q=l==null?void 0:l.ui,Ye=(oa=ae.button_width)!=null?oa:260,N=(ra=ae.button_height)!=null?ra:56,K=(la=ae.button_radius)!=null?la:16,q=ae.button_bg_color||((ca=d.theme)==null?void 0:ca.cta_background)||"#ffb43b",j=(da=ae.button_bg_alpha)!=null?da:1,se=ae.button_border_color||"#ffffff",ge=(ua=ae.button_border_width)!=null?ua:2,We=(pa=ae.button_border_alpha)!=null?pa:.2,Te=(ha=h.cta_offset_y)!=null?ha:160,J=new xn;J.roundRect(-Ye/2,-N/2,Ye,N,K);let Ve=q.replace("#","");J.fill({color:parseInt(Ve,16),alpha:j});let ft=se.replace("#","");J.stroke({color:parseInt(ft,16),width:ge,alpha:We});let kn=new xn;kn.roundRect(-Ye/2+2,-N/2+2,Ye-4,N-4,K-2),kn.stroke({color:0,width:1,alpha:.15}),J.addChild(kn),J.position.set(0,Te),J.alpha=0,J.eventMode="static",J.cursor="pointer",p.addChild(J);let Ds=(Q==null?void 0:Q.text)||((ga=d.ui)==null?void 0:ga.cta_label_end)||"DOWNLOAD",vi=(Q==null?void 0:Q.font)||"brand.heading",zs=(Q==null?void 0:Q.fontSize)||20,js=ae.button_text_color||((ba=d.theme)==null?void 0:ba.cta_text)||"#1a0a0a",mt=new Ct({text:Ds,style:{fontFamily:be(vi),fontSize:zs,fontWeight:fe(vi),fill:js,align:"center",letterSpacing:(fa=Q==null?void 0:Q.letterSpacing)!=null?fa:1}});mt.anchor.set(.5),mt.position.set(0,Te),mt.alpha=0,p.addChild(mt);let oe=c==null?void 0:c.ui,xi=((ma=c==null?void 0:c.gameplay)==null?void 0:ma.tuning)||{},Fs=(oe==null?void 0:oe.text)||"Play the full game",wi=(oe==null?void 0:oe.font)||"brand.body",Ns=(oe==null?void 0:oe.fontSize)||11,$s=(ya=oe==null?void 0:oe.letterSpacing)!=null?ya:0,qt=(va=c==null?void 0:c.render)==null?void 0:va.tint,Gs=typeof qt=="string"?qt:qt?`#${qt.toString(16).padStart(6,"0")}`:"#CCCCCC",et=new Ct({text:Fs,style:{fontFamily:be(wi),fontSize:Ns,fontWeight:fe(wi),fill:Gs,align:"center",letterSpacing:$s}});et.anchor.set(.5);let qs=Te+35+((xa=xi.animation_start_y_offset)!=null?xa:5);et.position.set(0,qs),et.alpha=0,et.animationStartYOffset=(wa=xi.animation_start_y_offset)!=null?wa:5,p.addChild(et);let In=((Sa=u==null?void 0:u.gameplay)==null?void 0:Sa.tuning)||{},Us=(Ea=In.hand_offset_x)!=null?Ea:50,Ys=(La=In.hand_offset_y)!=null?La:50,Ws=(Aa=(_a=u==null?void 0:u.transform)==null?void 0:_a.scale)!=null?Aa:.1875,Vs=(Ta=In.hand_scale_multiplier)!=null?Ta:2.5,Xe=new As(e||ai.EMPTY);return Xe.anchor.set(.5),Xe.scale.set(Ws*Vs),Xe.position.set(Us,Te+Ys),Xe.alpha=0,Xe.visible=!1,p.addChild(Xe),{panel:p,logo:P,title:X,subtitle:_e,footer:Ae,ctaButton:J,ctaText:mt,ctaHint:et,hand:Xe}}function To(s,e,t){var A,I,T,C,L,O,_,E;let n=e.objects.get("ui_endgame_1"),i=((A=n==null?void 0:n.gameplay)==null?void 0:A.tuning)||{},a=(I=i.animation_duration_ms)!=null?I:800,o=(T=i.fade_in_duration_ms)!=null?T:600,r=(C=i.scale_animation_intensity)!=null?C:.1,l=(L=i.logo_animation_delay_ms)!=null?L:100,c=(O=i.title_animation_delay_ms)!=null?O:200,u=(_=i.footer_animation_delay_ms)!=null?_:300,d=(E=i.cta_animation_delay_ms)!=null?E:400,{panel:p,logo:h,title:g,subtitle:b,footer:f,ctaButton:m,ctaText:y,ctaHint:v}=s;p.visible=!0;let w=Date.now(),S=()=>{let B=Date.now()-w,M=Math.min(B/o,1),x=1-Math.pow(1-M,3);p.alpha=x,p.scale.set(1+r*(1-x)),M<1?requestAnimationFrame(S):(setTimeout(()=>Co(h,a,e),l),setTimeout(()=>{Mo(g,a),setTimeout(()=>ko(b,a),50)},c),setTimeout(()=>Io(f,a),u),setTimeout(()=>{Po(m,y,a),setTimeout(()=>Oo(v,a),50),t&&t()},d))};S()}function Co(s,e,t){var p,h,g,b,f;let n=t==null?void 0:t.objects.get("ui_endgame_logo_1"),a=(h=(((p=n==null?void 0:n.gameplay)==null?void 0:p.tuning)||{}).animation_start_scale)!=null?h:1.2,o=Date.now(),r=s.alpha,l=(g=s.targetAlpha)!=null?g:1,c=(b=s.baseScaleX)!=null?b:s.scale.x,u=(f=s.baseScaleY)!=null?f:s.scale.y,d=()=>{let m=Date.now()-o,y=Math.min(m/e,1),v=1-Math.pow(1-y,2);s.alpha=r+(l-r)*v;let w=a+(1-a)*v;s.scale.set(c*w,u*w),y<1&&requestAnimationFrame(d)};d()}function Mo(s,e){let t=Date.now(),n=s.alpha,i=s.y,a=()=>{let o=Date.now()-t,r=Math.min(o/e,1),l=1-Math.pow(1-r,2);s.alpha=n+(1-n)*l,s.y=i-20*(1-l),r<1&&requestAnimationFrame(a)};a()}function ko(s,e){var r;let t=Date.now(),n=s.alpha,i=s.position.y,a=i-((r=s.animationStartYOffset)!=null?r:-10),o=()=>{let l=Date.now()-t,c=Math.min(l/e,1),u=1-Math.pow(1-c,2);s.alpha=n+(1-n)*u,s.position.y=i+(a-i)*u,c<1&&requestAnimationFrame(o)};o()}function Io(s,e){var o;let t=Date.now(),n=s.alpha,i=(o=s.targetAlpha)!=null?o:1,a=()=>{let r=Date.now()-t,l=Math.min(r/e,1),c=1-Math.pow(1-l,2);s.alpha=n+(i-n)*c,l<1&&requestAnimationFrame(a)};a()}function Po(s,e,t){let n=Date.now(),i=s.alpha,a=()=>{let o=Date.now()-n,r=Math.min(o/t,1),l=1-Math.pow(1-r,2);s.alpha=i+(1-i)*l,e.alpha=i+(1-i)*l,s.scale.set(1+.1*(1-l)),r<1&&requestAnimationFrame(a)};a()}function Oo(s,e){var r;let t=Date.now(),n=s.alpha,i=s.position.y,a=i-((r=s.animationStartYOffset)!=null?r:5),o=()=>{let l=Date.now()-t,c=Math.min(l/e,1),u=1-Math.pow(1-c,2);s.alpha=n+(1-n)*u,s.position.y=i+(a-i)*u,c<1&&requestAnimationFrame(o)};o()}function Ro(s,e,t,n){var u,d,p,h;let i=t.objects.get("ui_endgame_hand_1"),a=((u=i==null?void 0:i.gameplay)==null?void 0:u.tuning)||{},o=(d=a.click_animation_duration_ms)!=null?d:600,r=(p=a.click_delay_ms)!=null?p:2e3,l=(h=a.click_repeat_delay_ms)!=null?h:3e3,c=()=>{var A,I;s.visible=!0,s.alpha=1;let g=s.x,b=s.y,f=(A=a.hand_offset_x)!=null?A:50,m=(I=a.hand_offset_y)!=null?I:50,y=e.x+f,v=e.y+m,w=Date.now(),S=()=>{var B,M,x;let T=Date.now()-w,C=Math.min(T/o,1),L=C<.5?2*C*C:1-Math.pow(-2*C+2,2)/2;s.x=g+(y-g)*L,s.y=b+(v-b)*L;let O=(M=(B=i==null?void 0:i.transform)==null?void 0:B.scale)!=null?M:.1875,_=(x=a.hand_scale_multiplier)!=null?x:2.5,E=O*_;s.scale.set(E+E*.2*Math.sin(C*Math.PI)),C<1?requestAnimationFrame(S):(e.scale.set(.95),setTimeout(()=>{e.scale.set(1),n()},100),setTimeout(()=>{s.alpha=0,setTimeout(()=>{s.x=g,s.y=b,c()},l)},500))};S()};setTimeout(c,r)}import{Container as Ts,Graphics as si,Text as wn,BlurFilter as Ho}from"pixi.js";var Mt={enabled:!0,show_on_start:!1,background_color:"#120b14",background_alpha:.8,title:"Rope Rescue",subtitle:"Drag the key to save the hero.",button_label:"Start",title_color:"#FFFFFF",subtitle_color:"#D6C9E0",button_bg:"#FFB43B",button_text:"#1A0A0A",button_width:180,button_height:48,button_radius:14,loading_blur:!0,loading_blur_strength:8,loading_overlay_alpha:.35,font_family:"Arial, sans-serif",title_size:28,subtitle_size:14,loading_text:"Y\xFCkleniyor...",loading_text_scale:.6},kt=class{constructor(e,t,n){this.loadingTime=0;this.tickLoadingHandler=null;var i,a,o;this.app=e,this.stage=t,this.activeConfig=n,this.splashConfig={...Mt,...(a=(i=n.engine)==null?void 0:i.splash)!=null?a:{}},this.splashEnabled=this.splashConfig.enabled!==!1,this.loadingBlurEnabled=this.splashConfig.loading_blur!==!1,this.loadingBlurStrength=typeof this.splashConfig.loading_blur_strength=="number"?this.splashConfig.loading_blur_strength:8,this.loadingOverlayAlpha=typeof this.splashConfig.loading_overlay_alpha=="number"?this.splashConfig.loading_overlay_alpha:.35,this.splashLayer=new Ts,this.splashLayer.visible=!1,this.splashLayer.zIndex=1e4,this.splashLayer.eventMode="static",this.splashLayer.cursor="default",this.splashBg=new si,this.splashBg.eventMode="static",this.splashTitle=new wn(this.splashConfig.title,{fontFamily:this.splashConfig.font_family,fontSize:this.splashConfig.title_size,fill:this.splashConfig.title_color,align:"center"}),this.splashTitle.anchor.set(.5),this.splashSubtitle=new wn(this.splashConfig.subtitle,{fontFamily:this.splashConfig.font_family,fontSize:this.splashConfig.subtitle_size,fill:this.splashConfig.subtitle_color,align:"center"}),this.splashSubtitle.anchor.set(.5),this.splashButton=new si,this.splashButton.eventMode="static",this.splashButton.cursor="pointer",this.splashButtonText=new wn(this.splashConfig.button_label,{fontFamily:this.splashConfig.font_family,fontSize:Math.round(this.splashConfig.subtitle_size+2),fill:this.splashConfig.button_text,align:"center"}),this.splashButtonText.anchor.set(.5),this.splashButton.addChild(this.splashButtonText),this.splashLayer.addChild(this.splashBg,this.splashTitle,this.splashSubtitle,this.splashButton),this.stage.addChild(this.splashLayer),this.loadingLayer=new Ts,this.loadingLayer.zIndex=10001,this.loadingLayer.eventMode="static",this.loadingBg=new si,this.loadingText=new wn((o=this.splashConfig.loading_text)!=null?o:Mt.loading_text,this.resolveLoadingTextStyle(this.splashConfig)),this.loadingText.anchor.set(.5),this.loadingLayer.addChild(this.loadingBg,this.loadingText),this.stage.addChild(this.loadingLayer),this.syncConfig(),this.updateLoadingLayout(),this.setupWindowGlobals(),this.startLoadingAnimation()}resolveLoadingTextStyle(e){var d,p,h,g,b,f,m;let t=this.activeConfig.objects.get("label_1"),n=(d=t==null?void 0:t.ui)!=null?d:{},i=(p=t==null?void 0:t.render)!=null?p:{},a=(h=n.font)!=null?h:"brand.warning",o=(g=n.fontSize)!=null?g:50,r=(b=n.letterSpacing)!=null?b:0,l=(f=i.tint)!=null?f:"#FFF1C1",c=typeof l=="string"?l:`#${l.toString(16).padStart(6,"0")}`,u=typeof e.loading_text_scale=="number"?e.loading_text_scale:Mt.loading_text_scale;return{fontFamily:be(a),fontSize:Math.round(o*u),fontWeight:fe(a),fill:c,align:(m=n.align)!=null?m:"center",letterSpacing:r}}syncConfig(e){var n,i,a;let t={...Mt,...(i=e!=null?e:(n=this.activeConfig.engine)==null?void 0:n.splash)!=null?i:{}};if(this.splashConfig=t,this.splashEnabled=t.enabled!==!1,this.loadingBlurEnabled=t.loading_blur!==!1,this.loadingBlurStrength=typeof t.loading_blur_strength=="number"?t.loading_blur_strength:8,this.loadingOverlayAlpha=typeof t.loading_overlay_alpha=="number"?t.loading_overlay_alpha:.35,this.splashTitle.text=t.title,this.splashTitle.style.fontFamily=t.font_family,this.splashTitle.style.fontSize=t.title_size,this.splashTitle.style.fill=t.title_color,this.splashSubtitle.text=t.subtitle,this.splashSubtitle.style.fontFamily=t.font_family,this.splashSubtitle.style.fontSize=t.subtitle_size,this.splashSubtitle.style.fill=t.subtitle_color,this.splashButtonText.text=t.button_label,this.splashButtonText.style.fontFamily=t.font_family,this.splashButtonText.style.fontSize=Math.round(t.subtitle_size+2),this.splashButtonText.style.fill=t.button_text,this.loadingText){let o=this.resolveLoadingTextStyle(t);this.loadingText.text=(a=t.loading_text)!=null?a:Mt.loading_text,this.loadingText.style.fontFamily=o.fontFamily,this.loadingText.style.fontSize=o.fontSize,this.loadingText.style.fontWeight=o.fontWeight,this.loadingText.style.fill=o.fill,this.loadingText.style.align=o.align,this.loadingText.style.letterSpacing=o.letterSpacing}}updateLayout(e,t){this.updateSplashLayout(e,t),this.loadingBg&&this.updateLoadingLayout()}updateSplashLayout(e,t){this.splashBg.clear().rect(0,0,e,t).fill({color:Number.parseInt(this.splashConfig.background_color.replace("#",""),16),alpha:this.splashConfig.background_alpha});let n=e/2,i=t/2;this.splashTitle.position.set(n,i-48),this.splashSubtitle.position.set(n,i-16);let a=this.splashConfig.button_width,o=this.splashConfig.button_height,r=this.splashConfig.button_radius;this.splashButton.clear().roundRect(-a/2,-o/2,a,o,r).fill({color:Number.parseInt(this.splashConfig.button_bg.replace("#",""),16),alpha:1}),this.splashButton.position.set(n,i+32),this.splashButtonText.position.set(0,0)}updateLoadingLayout(){var n,i;let{width:e,height:t}=this.app.renderer;(n=this.loadingBg)==null||n.clear().rect(0,0,e,t).fill({color:0,alpha:this.loadingOverlayAlpha}),(i=this.loadingText)==null||i.position.set(e/2,t/2)}show(){this.syncConfig(),this.splashEnabled&&(this.updateSplashLayout(this.app.renderer.width,this.app.renderer.height),this.splashLayer.visible=!0)}hide(){this.splashLayer.visible=!1}startLoadingAnimation(){this.tickLoadingHandler=e=>{let t=e.deltaTime;this.loadingTime+=t,this.loadingText&&(this.loadingText.alpha=.6+Math.sin(this.loadingTime*.08)*.4)},this.app.ticker.add(this.tickLoadingHandler)}stopLoadingAnimation(){this.tickLoadingHandler&&(this.app.ticker.remove(this.tickLoadingHandler),this.tickLoadingHandler=null)}destroyLoadingLayer(){this.stopLoadingAnimation(),this.loadingLayer.destroy({children:!0}),this.loadingText=null,this.loadingBg=null}applyLoadingBlur(e){var t;if(this.loadingBlurEnabled&&e){let n=new Ho(this.loadingBlurStrength),i=(t=e.filters)!=null?t:null;return e.filters=[...i!=null?i:[],n],i}return null}removeLoadingBlur(e,t){e&&(t?e.filters=t:e.filters=null)}setupWindowGlobals(){if(typeof window=="undefined")return;let e=window;if(e.__updateSplashLayout=(t,n)=>{this.loadingBg&&this.updateLoadingLayout(),this.updateSplashLayout(t,n)},e.__previewShowSplash=()=>this.show(),e.__previewHideSplash=()=>this.hide(),e.__previewUpdateSplash=()=>{this.syncConfig(),this.loadingBg&&this.updateLoadingLayout(),this.updateSplashLayout(this.app.renderer.width,this.app.renderer.height),this.splashEnabled||(this.splashLayer.visible=!1)},!e.__splashScreenListener){let t=n=>{var r;let{width:i,height:a}=(r=n==null?void 0:n.detail)!=null?r:{};if(typeof i!="number"||typeof a!="number")return;let o=window.__updateSplashLayout;typeof o=="function"&&o(i,a)};e.__splashScreenListener=t,window.addEventListener("handler-preview:screen",t)}}getSplashButton(){return this.splashButton}shouldShowOnStart(){return this.splashEnabled&&this.splashConfig.show_on_start}destroy(){this.stopLoadingAnimation(),this.loadingLayer.destroy({children:!0}),this.splashLayer.destroy({children:!0})}};import{Sprite as Bo,Text as Do}from"pixi.js";function zo(s,e,t){var d,p,h,g;let n=e.objects.get("hand_tutorial_1")||e.objects.get("hand_1")||Array.from(e.objects.values()).find(b=>{var f;return((f=b==null?void 0:b.identity)==null?void 0:f.id)==="hand.tutorial"}),i=((d=n==null?void 0:n.gameplay)==null?void 0:d.tuning)||{},a=(n==null?void 0:n.render)||{},o=(n==null?void 0:n.transform)||{},r=new Bo(s),l=a==null?void 0:a.anchor;l&&typeof l.x=="number"&&typeof l.y=="number"?r.anchor.set(l.x,l.y):r.anchor.set(.5),r.alpha=0;let c=(p=i.hand_scale_multiplier)!=null?p:2.5,u=(h=o.scale)!=null?h:.1875;return r.scale.set(u*c),r.zIndex=(g=a.z_index)!=null?g:99999,r}function jo(s){var b,f,m,y,v,w,S,A,I,T;let e=s.objects.get("ui_tutorial_1")||s.objects.get("label_1")||Array.from(s.objects.values()).find(C=>{var L;return["ui.tutorial","label.warning"].includes((L=C==null?void 0:C.identity)==null?void 0:L.id)}),t=e==null?void 0:e.ui,n=(e==null?void 0:e.render)||{},i=((b=s.engine.runtime)==null?void 0:b.ui_styles)||{},a=((f=s.engine.runtime)==null?void 0:f.ui)||{},o=(t==null?void 0:t.text)||a.tutorial_label||a.label_text||"CLEAN!",r=(t==null?void 0:t.font)||"brand.warning",l=(t==null?void 0:t.fontSize)||i.label_font_size||52,c=(y=t==null?void 0:t.letterSpacing)!=null?y:(m=i.label_letter_spacing)!=null?m:-1,u=(t==null?void 0:t.align)||"center",d=n.tint,p=typeof d=="string"?d:d?`#${d.toString(16).padStart(6,"0")}`:i.label_fill||"#FFF1C1",h=new Do({text:o,style:{fontFamily:be(r),fontSize:l,fontWeight:fe(r),fill:p,align:u,letterSpacing:c,stroke:{color:i.label_stroke||"#8B0000",width:2},dropShadow:{color:i.label_shadow_color||"#000000",alpha:(v=i.label_shadow_alpha)!=null?v:.8,angle:(w=i.label_shadow_angle)!=null?w:0,blur:(S=i.label_shadow_blur)!=null?S:4,distance:(A=i.label_shadow_distance)!=null?A:2}}}),g=n==null?void 0:n.anchor;return g&&typeof g.x=="number"&&typeof g.y=="number"?h.anchor.set(g.x,g.y):h.anchor.set(.5,.5),h.alpha=(I=n.alpha)!=null?I:0,h.visible=(T=n.visible)!=null?T:!0,h}function Fo(s,e,t,n,i){var l,c,u,d,p,h,g,b,f,m,y,v,w,S,A,I,T;let a=i.objects.get("hand_tutorial_1")||i.objects.get("hand_1")||Array.from(i.objects.values()).find(C=>{var L;return((L=C==null?void 0:C.identity)==null?void 0:L.id)==="hand.tutorial"}),o=((l=a==null?void 0:a.gameplay)==null?void 0:l.tuning)||{},r=(a==null?void 0:a.transform)||{};if(!n){let C=(c=o.animation_duration)!=null?c:1.5,L=t%C/C,O=L<.5?2*L*L:-1+(4-2*L)*L,_=(g=(h=(p=(u=r.position)==null?void 0:u.x)!=null?p:(d=r.offset)==null?void 0:d.x)!=null?h:o.start_x_offset)!=null?g:0,E=(v=(y=(m=(b=r.position)==null?void 0:b.y)!=null?m:(f=r.offset)==null?void 0:f.y)!=null?y:o.start_y_offset)!=null?v:0,B=(w=o.x_offset)!=null?w:0,M=(S=o.y_offset)!=null?S:0,x=(A=o.animation_range)!=null?A:40,k=x*.7,P=x,z=e.x+_+B+k,D=e.y+E+M+P,R=z+k,V=D+P;s.x=z+(R-z)*O,s.y=D+(V-D)*O;let ye=(I=r.scale)!=null?I:.1875,de=(T=o.hand_scale_multiplier)!=null?T:2.5;s.scale.set(ye*de)}}var It=null;function No(){return It||(typeof window!="undefined"&&window.lottie?It=window.lottie:(console.warn("[LottieOverlay] lottie-web is not available globally. Make sure it is loaded before using Lottie animations."),It=null)),It}function Xn(s){It=s}function $o(s,e,t,n){var S,A,I,T,C,L,O,_,E,B,M,x,k;let i=t.objects.get(s);if(!i)return console.warn(`[LottieOverlay] Object config not found: ${s}`),null;let a=((S=i.effects)==null?void 0:S.lottie)||{},o=i.transform||{},r=i.render||{};if(a.enabled===!1||r.visible===!1)return null;let l=n[s];if(!l||typeof l!="object")return console.warn(`[LottieOverlay] Asset data not found or invalid for: ${s}`),null;let c=No();if(!c)return console.warn(`[LottieOverlay] lottie-web is not available. Cannot play animation: ${s}`),null;let u=(A=a.width)!=null?A:300,d=(I=a.height)!=null?I:300,p=(T=o.scale)!=null?T:1,h=(L=(C=o.position)==null?void 0:C.x)!=null?L:0,g=(_=(O=o.position)==null?void 0:O.y)!=null?_:0,b=(E=o.rotation)!=null?E:0,f=(B=r.z_index)!=null?B:100,m=(M=r.alpha)!=null?M:1,y=document.createElement("div");y.style.cssText=`
|
|
821
|
+
position: absolute;
|
|
822
|
+
top: calc(50% + ${g}px);
|
|
823
|
+
left: calc(50% + ${h}px);
|
|
824
|
+
transform: translate(-50%, -50%) scale(${p}) rotate(${b}deg);
|
|
825
|
+
width: ${u}px;
|
|
826
|
+
height: ${d}px;
|
|
827
|
+
pointer-events: none;
|
|
828
|
+
z-index: ${f};
|
|
829
|
+
opacity: ${m};
|
|
830
|
+
`,e.appendChild(y);let v=c.loadAnimation({container:y,renderer:a.renderer||"svg",loop:(x=a.loop)!=null?x:!1,autoplay:(k=a.autoplay)!=null?k:!0,animationData:l});a.speed!==void 0&&v.setSpeed(a.speed);let w=()=>{v.destroy(),y.parentNode&&y.parentNode.removeChild(y)};return a.loop||v.addEventListener("complete",w),{animation:v,cleanup:w}}import{Assets as pt,Texture as Go}from"pixi.js";var Pe=class{static get(e){var t;return(t=this.store.get(e))==null?void 0:t.data}static set(e,t){this.store.set(e,{data:t})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};Pe.store=new Map;function qo(){var s,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(s=document.querySelector("script"))==null?void 0:s.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),n=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!n)}catch{return!1}}async function Uo(){try{if(typeof window!="undefined"){let s=await fetch("./build-settings.json");if(s.ok){let e=await s.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Yo(){try{if(typeof window!="undefined"){let s=new XMLHttpRequest;if(s.open("GET","./build-settings.json",!1),s.send(),s.status===200&&s.responseText){let e=JSON.parse(s.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}var Cs=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Ms=qo(),Ke=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,G=Ms?"publish":Cs,we=Ke==null?void 0:Ke.assetsInlined;Ke!=null&&Ke.buildMode&&(G=Ke.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${G}`));var $e=Yo();$e!=null&&$e.buildMode&&(G=$e.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${G}`));($e==null?void 0:$e.assetsInlined)!==void 0&&(we=$e.assetsInlined);Uo().then(s=>{s!=null&&s.buildMode&&s.buildMode!==G&&(G=s.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${G}`)),(s==null?void 0:s.assetsInlined)!==void 0&&(we=s.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${Cs}, Runtime: ${Ms?"publish":"dev"}, Effective: ${G}`);var Oe={},oi=null;async function Wo(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${G}`),Object.keys(Oe).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(Oe)),Oe;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),Oe={...window.INLINE_ASSETS},Oe;if(!(G==="publish"&&we!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),Oe;if(!oi){let e=typeof window!="undefined"?new URL("inline-assets.js",window.location.href).href:"./inline-assets.js";console.log("[AssetLoader] Loading inline assets from:",e),oi=(async()=>{try{try{let a=await import(e+"?t="+Date.now());if(a.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(a.INLINE_ASSETS)),a.INLINE_ASSETS}catch(a){console.warn("[AssetLoader] ES module import failed, trying text parse:",a)}let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.text();console.log("[AssetLoader] Received JS code, length:",n.length);let i=n.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(i)try{let a=i[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let o=new Function("return "+a)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(o)),o}catch(a){return console.warn("[AssetLoader] Failed to parse inline assets:",a),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",n.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return Oe=await oi,console.log("[AssetLoader] Final inline assets cache:",Object.keys(Oe)),Oe}var ks=new Map;function ri(s){return s===null||typeof s!="object"||(Object.freeze(s),Object.values(s).forEach(e=>ri(e))),s}function Vo(s=64,e=64,t=16711680){let n=document.createElement("canvas");n.width=s,n.height=e;let i=n.getContext("2d");return i.fillStyle=`#${t.toString(16).padStart(6,"0")}`,i.fillRect(0,0,s,e),i.strokeStyle="#000",i.strokeRect(0,0,s,e),i.fillStyle="#fff",i.font="10px sans-serif",i.textAlign="center",i.fillText("MISSING",s/2,e/2),Go.from(n)}function li(s,e){ks.set(s,e)}var Pt=class{static async load(e,t,n){let i=Pe.get(e);if(i!==void 0)return i;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${G}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let a=await Wo(),o=a[e];if(!o&&t.path){let c=t.path.split("/");if(c.length>=2){let u=c[c.length-1].split(".")[0],d=c[0],p=[`${u}.layer`,`${u}.player`,`${u}.tutorial`,`effects.${u}`,`ui.endgame.${u}`,u];for(let h of p)if(a[h]){o=a[h],console.log(`[AssetLoader] Found inline data for ${e} using derived key: ${h}`);break}}}if(console.log("[AssetLoader] Inline data for",e,":",o?"FOUND":"NOT FOUND"),G==="publish"&&we!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!o))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${t.path}`);let l=ks.get(t.type);if(l)try{let c=await l(t.path,o,e,n);return Pe.set(e,c),c}catch(c){return this.handleFailure(e,t.type,c)}try{let c;switch(t.type){case"image":c=await this.loadImage(t.path,o);break;case"json":c=await this.loadJSON(t.path,o),c=ri(c);break;default:throw new Error(`Unknown asset type: ${t.type}`)}return Pe.set(e,c),c}catch(c){return this.handleFailure(e,t.type,c)}}static async loadImage(e,t){let n=G==="publish",i=n&&we!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${G}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(!t.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI, got: ${t.substring(0,50)}...`);try{return await pt.load(t)}catch(a){throw console.error("[AssetLoader] Failed to load texture from data URI:",a),a}}if(t&&t.startsWith("data:"))try{return await pt.load(t)}catch(a){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",a),await pt.load(e)}return await pt.load(e)}static async loadJSON(e,t){let n=G==="publish",i=n&&we!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${G}, isPublishMode: ${n}, inlineData: ${t?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(t.startsWith("data:")){let o=atob(t.split(",")[1]);return JSON.parse(o)}return JSON.parse(t)}if(t){if(t.startsWith("data:")){let o=atob(t.split(",")[1]);return JSON.parse(o)}return JSON.parse(t)}let a=await fetch(e);if(!a.ok)throw new Error(`JSON fetch failed: ${e}`);return a.json()}static handleFailure(e,t,n){if(G==="dev"){let a=t==="image"?Vo():ri({__placeholder:!0,type:t});return Pe.set(e,a),a}throw n}};li("image",async(s,e)=>{let t=G==="publish",n=t&&we!==!1,i=G==="brand",a=t&&we===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${G}, isPublishMode: ${t}, isBrandMode: ${i}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${s}`);if(!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI, got: ${e.substring(0,50)}...`);return pt.load(e)}let o=s;return(i||a)&&s&&!s.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=s,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${s}" as-is`)):(o=`assets/${s}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${s}" -> "${o}"`))),pt.load(e||o)});li("json",async(s,e)=>{let t=G==="publish",n=t&&we!==!1,i=G==="brand",a=t&&we===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${G}, isPublishMode: ${t}, isBrandMode: ${i}, inlineData: ${e?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${s}`);return e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let o=s;if((i||a)&&s&&!s.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=s,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${s}" as-is`)):(o=`assets/${s}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${s}" -> "${o}"`))),e)return e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let r=await fetch(o);if(!r.ok)throw new Error(`JSON fetch failed: ${s}`);return r.json()});import{Sprite as Xo,Container as Is}from"pixi.js";var Ko=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",ci=Ko;if(typeof window!="undefined")try{let s=new XMLHttpRequest;if(s.open("GET","./build-settings.json",!1),s.send(),s.status===200&&s.responseText){let e=JSON.parse(s.responseText);e!=null&&e.buildMode&&(ci=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${ci}`))}}catch{}var ht=class{static async create(e,t,n){var r,l,c,u,d,p;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${ci}`);let i=(r=t==null?void 0:t.render)==null?void 0:r.asset;if(!i){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let h=new Is;return this.applyTransform(h,t==null?void 0:t.transform),h}console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, type: ${i.type}, path: ${i.path}`);let a=await Pt.load(e,i,n);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(l=a==null?void 0:a.constructor)==null?void 0:l.name}`);let o;if(i.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",a,"for object:",e),o=new Xo(a),console.log("[ObjectFactory] Created object:",o,"type:",(c=o==null?void 0:o.constructor)==null?void 0:c.name),this.applyTransform(o,t==null?void 0:t.transform);else if(i.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(u=a==null?void 0:a.constructor)==null?void 0:u.name,a),a&&(((d=a.constructor)==null?void 0:d.name)==="Container"||a instanceof Is)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[i.path,`/assets/${i.path}`,`assets/${i.path}`,`../assets/${i.path}`],g=!1;for(let b of h)try{let f=await fetch(b);if(f.ok){o=await f.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(p=o==null?void 0:o.constructor)==null?void 0:p.name),g=!0;break}}catch{continue}g||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=a)}else o=a;else o=a,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,t==null?void 0:t.transform);return o}static applyTransform(e,t){var n,i,a,o;!t||!e||(t.position&&("x"in e&&"y"in e?(e.x=(n=t.position.x)!=null?n:0,e.y=(i=t.position.y)!=null?i:0):"position"in e&&e.position&&e.position.set((a=t.position.x)!=null?a:0,(o=t.position.y)!=null?o:0)),t.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(t.scale):e.scale=t.scale),t.rotation!==void 0&&"rotation"in e&&(e.rotation=t.rotation),t.anchor&&"anchor"in e&&e.anchor&&Array.isArray(t.anchor)&&("set"in e.anchor?e.anchor.set(t.anchor[0],t.anchor[1]):(e.anchor.x=t.anchor[0],e.anchor.y=t.anchor[1])))}};var di=class{constructor(e,t,n){this.systems=[];this.totalTime=0;this.root=e,this.config=t,this.destinationUrl=n}async init(e){let{app:t,stage:n}=await ii(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=n,this.gameObjectManager=new Tt(this.config),this.stage.eventMode="passive",this.stage.interactive=!1,this.stage.interactiveChildren=!0,this.stage.sortableChildren=!0;let i={app:this.app,stage:this.stage,config:this.config,gameObjectManager:this.gameObjectManager,destinationUrl:this.destinationUrl,root:this.root,engine:this};for(let a of this.systems)a.setContext(i),a.init&&await a.init();return{app:this.app,gameObjectManager:this.gameObjectManager}}registerSystems(e){this.systems.push(...e)}async start(){for(let e of this.systems)e.onStart&&await e.onStart();this.app.ticker.add(this.update.bind(this)),window.addEventListener("handler-preview:screen",e=>{let{width:t,height:n}=e.detail;this.resize(t,n)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let n of this.systems)n.update&&n.update(t,this.totalTime)}resize(e,t){for(let n of this.systems)n.onResize&&n.onResize(e,t)}updateConfig(e){this.config=e;for(let t of this.systems)t.context.config=e,t.onConfigUpdate&&t.onConfigUpdate(e)}destroy(){for(let e of this.systems)e.onDestroy&&e.onDestroy();this.app.ticker.remove(this.update.bind(this)),this.app.destroy(!0,{children:!0,texture:!1})}getApp(){return this.app}getGameObjectManager(){return this.gameObjectManager}getTotalTime(){return this.totalTime}getSystem(e){let t=this.systems.find(n=>n instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var Ot=class{setContext(e){this.context=e}};var Rt=class{constructor(){this.config=null}init(e){this.config=e}get(e){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(e)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(e){return this.config?this.config.objects.has(e):!1}};import*as Ps from"pixi.js";var Jo=Ps;typeof window!="undefined"&&(window.__basePixi=Ps);var ui=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Rt}init(e,t){this.registry.init(e),this.app=t}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let t=this.registry.getAllIds().filter(i=>!this.instanceCache.has(i));if(t.length===0)return;let n=async i=>{i.length&&(console.log("[Assets] Loading objects:",i),await Promise.all(i.map(async a=>{var r;let o=this.registry.get(a);if(!o){console.warn("[Assets] No config found for object:",a);return}try{let l=await ht.create(a,o,this.app);this.instanceCache.set(a,l),console.log("[Assets] Loaded object:",a,(r=l==null?void 0:l.constructor)==null?void 0:r.name)}catch(l){console.error("[Assets] Failed to load object:",a,l)}})))};return this.readyPromise=(async()=>{await n(t);let i=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));i.length>0&&(console.warn("[Assets] Retrying missing assets:",i),await n(i)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let t=this.registry.get(e);if(t){let n=await ht.create(e,t,this.app);this.instanceCache.set(e,n)}}get(e){return this.instanceCache.get(e)}},Os=new ui,Ge=new Proxy(Os,{get(s,e){if(e in s&&typeof s[e]=="function")return s[e].bind(s);if(s.get(e))return s.get(e)}});function pi(s,e){Os.init(s,e)}import{Sprite as Rs,Graphics as Hs}from"pixi.js";var hi=class extends Ot{constructor(){super(...arguments);this.splashScreen=null}async init(){pi(this.context.config,this.context.app),this.splashScreen=new kt(this.context.app,this.context.stage,this.context.config),this.splashScreen.getSplashButton().on("pointerdown",()=>this.splashScreen.hide());let t=null;try{await Ge.reloadObject("background_1");let n=Ge.background_1;n&&(n instanceof Rs||n instanceof Hs)&&(n.parent||this.context.stage.addChildAt(n,0),t=this.splashScreen.applyLoadingBlur(n))}catch(n){console.warn("[AssetSystem] Background preload failed:",n)}if(await Ge.ready(),this.splashScreen){this.splashScreen.stopLoadingAnimation(),this.splashScreen.destroyLoadingLayer();let n=Ge.background_1;n&&(n instanceof Rs||n instanceof Hs)&&this.splashScreen.removeLoadingBlur(n,t)}console.log("[AssetSystem] All assets preloaded and ready")}async onStart(){this.splashScreen&&this.splashScreen.shouldShowOnStart()&&this.splashScreen.show()}onConfigUpdate(){typeof Ge.updateConfig=="function"&&Ge.updateConfig(this.context.config)}};import{Graphics as Qo,Point as Zo}from"pixi.js";var Re={width:400,height:600,designWidth:400,scaleFactor:1},En={scale:1,position:1},Ln=[];function er(s,e,t,n,i,a,o){Ln.push({element:s,originalScale:a,positionHelper:e,heightPercent:i}),e(s,t,n,i,a,o,!1)}function tr(){Ln.forEach(({element:s,originalScale:e,positionHelper:t,heightPercent:n})=>{let i=e*Re.scaleFactor;t(s,Re.width,Re.height,n,i,!0,!1)})}function nr(){Ln.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function gi(s,e){console.log(`[SCREEN] updateScreenState called: ${s}x${e}`),Re.width=s,Re.height=e,Re.scaleFactor=Math.min(s/Re.designWidth,1.15),En.scale=Re.scaleFactor,En.position=1,console.log(`[SCREEN] Global multipliers - scale: ${En.scale.toFixed(3)}`),tr()}var $={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03},physics:{rope_length:420,gravity:9.8,friction:.1}};function ir(s,e,t){let n=$[s];n&&n[e]!==void 0&&(n[e]=t,console.log(`Updated ${s}.${e} = ${t}`))}function ar(){return $}var sr={center:{x:.5,y:.5},"center-center":{x:.5,y:.5},middle:{x:.5,y:.5},"middle-center":{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},"left-center":{x:0,y:.5},"right-center":{x:1,y:.5},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};function Sn(s,e){return typeof s=="number"&&Number.isFinite(s)?s:e}function fi(s,e={x:.5,y:.5}){var t;if(Array.isArray(s))return{x:Sn(s[0],e.x),y:Sn(s[1],e.y)};if(s&&typeof s=="object"){let n=s;return{x:Sn(n.x,e.x),y:Sn(n.y,e.y)}}if(typeof s=="string"){let n=s.trim().toLowerCase();return(t=sr[n])!=null?t:e}return e}function mi(s,e,t,n={}){var h,g,b,f,m,y;let i=fi(t),a=(h=n.inset)!=null?h:{},o=(g=n.padding)!=null?g:{x:0,y:0},r=((b=a.left)!=null?b:0)+o.x,l=((f=a.right)!=null?f:0)+o.x,c=((m=a.top)!=null?m:0)+o.y,u=((y=a.bottom)!=null?y:0)+o.y,d=Math.max(0,s-r-l),p=Math.max(0,e-c-u);return{x:r+d*i.x,y:c+p*i.y}}function yi(s,e,t,n={}){var b,f,m,y,v,w;let i=(b=n.inset)!=null?b:{},a=(f=n.padding)!=null?f:{x:0,y:0},o=((m=i.left)!=null?m:0)+a.x,r=((y=i.right)!=null?y:0)+a.x,l=((v=i.top)!=null?v:0)+a.y,c=((w=i.bottom)!=null?w:0)+a.y,u=Math.max(0,s-o-r),d=Math.max(0,e-l-c),p=fi(t,{x:.5,y:.5}),h=Math.min(Math.max(p.x,0),1),g=Math.min(Math.max(p.y,0),1);return{x:o+u*h,y:l+d*g}}function bi(s,e,t,n={}){var u,d,p;if(!s)return;let i=n.positionRatio?yi(e,t,n.positionRatio,{inset:n.inset,padding:n.screenPadding}):mi(e,t,n.anchor,{inset:n.inset,padding:n.screenPadding}),a=(u=n.offset)!=null?u:{x:0,y:0},o=i.x+a.x,r=i.y+a.y;s.anchor&&n.renderAnchor&&s.anchor.set(n.renderAnchor.x,n.renderAnchor.y),me(s,o,r);let l=(d=n.scale)!=null?d:1,c=(p=n.scaleMultiplier)!=null?p:1;(n.scale!==void 0||n.scaleMultiplier!==void 0)&&Se(s,l*c)}if(typeof window!="undefined"){let s=window.innerWidth,e=window.innerHeight,t=()=>{let n=window.innerWidth,i=window.innerHeight;(n!==s||i!==e)&&(s=n,e=i,gi(n,i))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),gi(window.innerWidth,window.innerHeight),window.updateDebugConfig=ir,window.getDebugConfig=ar,window.copyConfig=fr,window.applyConfig=Ht,window.applyConfigForRatio=mr,window.positionAtBottom=Bs,window.positionAtTop=lr,window.positionAtCenter=cr,window.positionAtLeft=dr,window.positionAtRight=ur,window.positionAtBottomLeft=pr,window.positionAtBottomRight=hr,window.positionAtTopLeft=gr,window.positionAtTopRight=br,window.applyPositionContract=rr,console.log("\u{1F3AE} Debug Config Functions Available:"),console.log("\u2022 updateDebugConfig(category, key, value)"),console.log("\u2022 getDebugConfig()"),console.log("\u2022 copyConfig(presetName)"),console.log("\u2022 applyConfig(config)"),console.log("\u2022 applyConfigForRatio(width, height)"),console.log("\u{1F4CD} Positioning Helpers Available (with scale):"),console.log("\u2022 positionAtBottom(element, w, h, percent, scale)"),console.log("\u2022 positionAtTop(element, w, h, percent, scale)"),console.log("\u2022 positionAtCenter(element, w, h, offsetX, offsetY, scale)"),console.log("\u2022 positionAtLeft/Right(element, w, h, percent, scale)"),console.log("\u2022 Corner positions: BottomLeft/Right, TopLeft/Right (all with scale)"),console.log("\u2022 applyPositionContract(element, w, h, contract)"),console.log("Example: positionAtCenter(mySprite, 400, 600, 0, -50, 1.2)")}function _n(s,e,t=0){return s*e+t}function An(s,e,t=0){return s*(1-e)+t}function Tn(s,e,t=0){return s*e+t}function Cn(s,e,t=0){return s*(1-e)+t}function ce(s,e=0){return s/2+e}function or(s,e){return s*e}function rr(s,e,t,n){var o,r,l,c,u,d,p,h,g,b,f,m,y,v,w,S,A,I,T,C;let i=0,a=0;switch(n.type){case"top":i=ce(e,(r=(o=n.offset)==null?void 0:o.x)!=null?r:0),a=_n(t,n.percent,(c=(l=n.offset)==null?void 0:l.y)!=null?c:0);break;case"bottom":i=ce(e,(d=(u=n.offset)==null?void 0:u.x)!=null?d:0),a=An(t,n.percent,(h=(p=n.offset)==null?void 0:p.y)!=null?h:0);break;case"left":i=Tn(e,n.percent,(b=(g=n.offset)==null?void 0:g.x)!=null?b:0),a=ce(t,(m=(f=n.offset)==null?void 0:f.y)!=null?m:0);break;case"right":i=Cn(e,n.percent,(v=(y=n.offset)==null?void 0:y.x)!=null?v:0),a=ce(t,(S=(w=n.offset)==null?void 0:w.y)!=null?S:0);break;case"center":i=ce(e,(I=(A=n.offset)==null?void 0:A.x)!=null?I:0),a=ce(t,(C=(T=n.offset)==null?void 0:T.y)!=null?C:0);break}s.position?s.position.set(i,a):(s.x=i,s.y=a),n.scale!==void 0&&n.scale!==1&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(n.scale,n.scale):(s.scale.x=n.scale,s.scale.y=n.scale))}function Bs(s,e,t,n=.2,i=1,a=!0,o=!1){let r=or(t,n),l=An(t,n/2);me(s,ce(e),l);let c=a?i*Re.scaleFactor:i;Se(s,c),o&&!Ln.find(u=>u.element===s)&&er(s,Bs,e,t,n,i,a)}function lr(s,e,t,n=.1,i=1){me(s,ce(e),_n(t,n)),Se(s,i)}function cr(s,e,t,n=0,i=0,a=1){me(s,ce(e,n),ce(t,i)),Se(s,a)}function dr(s,e,t,n=.1,i=1){me(s,Tn(e,n),ce(t)),Se(s,i)}function ur(s,e,t,n=.1,i=1){me(s,Cn(e,n),ce(t)),Se(s,i)}function pr(s,e,t,n=.05,i=.05,a=1){me(s,Tn(e,i),An(t,n)),Se(s,a)}function hr(s,e,t,n=.05,i=.05,a=1){me(s,Cn(e,i),An(t,n)),Se(s,a)}function gr(s,e,t,n=.05,i=.05,a=1){me(s,Tn(e,i),_n(t,n)),Se(s,a)}function br(s,e,t,n=.05,i=.05,a=1){me(s,Cn(e,i),_n(t,n)),Se(s,a)}function me(s,e,t){s&&s.position?typeof s.position.set=="function"?s.position.set(e,t):(s.position.x=e,s.position.y=t):s&&(s.x=e,s.y=t)}function Se(s,e){e!==1&&s&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(e,e):s.scale.x!==void 0&&s.scale.y!==void 0&&(s.scale.x=e,s.scale.y=e))}var Je={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03},physics:{rope_length:420,gravity:9.8,friction:.1}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03},physics:{rope_length:420,gravity:9.8,friction:.1}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03},physics:{rope_length:380,gravity:9.8,friction:.1}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03},physics:{rope_length:450,gravity:9.8,friction:.1}}};function fr(s){return s&&Je[s]?JSON.parse(JSON.stringify(Je[s])):JSON.parse(JSON.stringify($))}function Ht(s){Object.keys(s).forEach(e=>{let t=e;$[t]&&s[t]&&Object.assign($[t],s[t])}),console.log("Config applied:",s)}function mr(s,e){let t=s/e;t>1.6?(Ht(Je.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(Ht(Je.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(Ht(Je.square),console.log("Applied SQUARE config for ratio:",t)):(Ht(Je.default),console.log("Applied DEFAULT config for ratio:",t))}typeof window!="undefined"&&(window.configPresets=Je);var ee=null;function yr(s,e,t,n,i,a={}){var x,k,P,z,D,R,V,ye,de,qe,He,ue,Qe,H,te,X,pe,he,Y,Ee,Be,ne,De,ve,Le,Ze,_e,Mn,Bt,ie,gt,Dt,bt,zt,Ue,jt,Ft,Nt,Ae,$t,Gt,ae,Q,Ye;let o=(x=a.enableDebugLogs)!=null?x:!1;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:n.width,height:n.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",a));let{mainContainer:r,label:l,background:c,backgroundTexture:u,app:d}=s;if(!d||!d.renderer){o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:d.renderer.width,height:d.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:d.screen.width,height:d.screen.height}));let p=n.width,h=n.height;o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:p,baseHeight:h});let g=p*$.layout.screen_scale_x,b=h*$.layout.screen_scale_y,f=p/2,m=e.engine.runtime||{},y=m.layout||{};o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:$.layout.screen_scale_x,screen_scale_y:$.layout.screen_scale_y}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Calculated dimensions:",{width:g,height:b,midX:f}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",m),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",y));let v=y.design_width_portrait||400,w=g/v;w=Math.min(w,1.15);let S=w*((k=$.engine.scale)!=null?k:1),A=(P=a.skipMainContainerTransform)!=null?P:!1;!A&&r&&r.scale&&(typeof r.scale.set=="function"?r.scale.set(S):(r.scale.x=S,r.scale.y=S));let T=((z=$.physics.rope_length)!=null?z:420)*S,C=p/h>.6,L;C?L=b*.65:L=T+b*.1,!A&&r&&r.position&&(typeof r.position.set=="function"?r.position.set(f+$.layout.position_offset.x,L+$.layout.position_offset.y):(r.position.x=f+$.layout.position_offset.x,r.position.y=L+$.layout.position_offset.y));let O=new Set((D=a.skipInstanceIds)!=null?D:[]);if(i&&(r!=null&&r.toLocal))for(let[N,K]of e.objects.entries()){let q=K==null?void 0:K.transform;if(!q||O.has(N))continue;let j=(R=i.get)==null?void 0:R.call(i,N),se=((V=j==null?void 0:j.getDisplayObject)==null?void 0:V.call(j))||(j==null?void 0:j.pixiObject)||j;if(!se||se.parent!==r)continue;let ge=q.position_ratio!=null?yi(p,h,q.position_ratio):mi(p,h,(ye=q.anchor)!=null?ye:"center"),We=r.toLocal(new Zo(ge.x,ge.y)),Te=(de=q.position)!=null?de:{x:0,y:0},J=We.x+Te.x,Ve=We.y+Te.y;typeof(j==null?void 0:j.setPosition)=="function"?j.setPosition(J,Ve):(me(se,J,Ve),(qe=j==null?void 0:j.transform)!=null&&qe.position&&(j.transform.position.x=J,j.transform.position.y=Ve))}if($.layout.debug_rect_visible){(!ee||ee.parent!==d.stage)&&(ee==null||ee.destroy(),ee=new Qo,ee.zIndex=9999,d.stage.addChild(ee)),ee.clear();let N=$.layout.debug_rect_scale_x,K=$.layout.debug_rect_scale_y,q=(p-4)*N,j=(h-4)*K,se=(p-q)/2,ge=(h-j)/2;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:h,rectW:q,rectH:j,offsetX:se,offsetY:ge}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+se,y:2+ge,width:q,height:j})),ee.rect(2+se,2+ge,q,j).stroke({width:$.layout.debug_rect_thickness,color:$.layout.debug_rect_color})}else ee&&(ee.destroy(),ee=null);let _=e.objects.get("label_1")||e.objects.get("ui_tutorial_1"),E=e.objects.get("hazard_1"),B=(X=(te=(ue=(He=E==null?void 0:E.gameplay)==null?void 0:He.rules)==null?void 0:ue.hazard_height)!=null?te:(H=(Qe=E==null?void 0:E.gameplay)==null?void 0:Qe.tuning)==null?void 0:H.hazard_height)!=null?X:0;if(l&&l.position){let N=(pe=_==null?void 0:_.render)==null?void 0:pe.anchor,K=(Y=(he=_==null?void 0:_.transform)==null?void 0:he.anchor)!=null?Y:"center",q=(Ee=_==null?void 0:_.transform)==null?void 0:Ee.position_ratio,j=((Be=_==null?void 0:_.transform)==null?void 0:Be.offset)||{x:0,y:0};bi(l,p,h,{anchor:K,positionRatio:q,offset:{x:j.x*S,y:j.y*S},inset:{bottom:B},renderAnchor:N})}if(l&&l.alpha>0){let N=1+Math.sin(t*$.engine.label_pulse_speed)*$.engine.label_pulse_intensity,K=(De=(ne=_==null?void 0:_.transform)==null?void 0:ne.scale)!=null?De:1,q=N*S*K;l.scale&&(typeof l.scale.set=="function"?l.scale.set(q):(l.scale.x=q,l.scale.y=q))}if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),c){o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!c),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(ve=c.constructor)==null?void 0:ve.name)),c.alpha=((Ze=(Le=m.background)==null?void 0:Le.alpha)!=null?Ze:.98)*$.engine.background_alpha,o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",c.alpha);let N=e.objects.get("background_1");o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",N);let K=(N==null?void 0:N.transform)||{};o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",K);let q=K.offset||{x:0,y:0},j=((Mn=(_e=m.background)==null?void 0:_e.offset_y)!=null?Mn:0)+$.engine.background_offset_y,se=(ie=(Bt=N==null?void 0:N.render)==null?void 0:Bt.anchor)!=null?ie:{x:.5,y:.5},ge=(gt=K.anchor)!=null?gt:"center",We=K.position_ratio;if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:q,bgRuntimeOffsetY:j,bgRenderAnchor:se,bgScreenAnchor:ge,bgPositionRatio:We,baseWidth:p,baseHeight:h,finalScale:S}),bi(c,p,h,{anchor:ge,positionRatio:We,offset:{x:q.x*S,y:q.y*S+j},renderAnchor:se}),o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:c.x,y:c.y,scaleX:(Dt=c.scale)==null?void 0:Dt.x,scaleY:(bt=c.scale)==null?void 0:bt.y,anchorX:(zt=c.anchor)==null?void 0:zt.x,anchorY:(Ue=c.anchor)==null?void 0:Ue.y,pivotX:(jt=c.pivot)==null?void 0:jt.x,pivotY:(Ft=c.pivot)==null?void 0:Ft.y,width:c.width,height:c.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background texture dimensions:",{textureWidth:u==null?void 0:u.width,textureHeight:u==null?void 0:u.height})),u){let Te=Math.max(g/u.width,b/u.height),J=(Ae=(Nt=m.background)==null?void 0:Nt.scale_multiplier)!=null?Ae:1.05,Ve=($t=K.scale)!=null?$t:1,ft=Te*J*$.engine.background_scale*Ve;c.scale&&(typeof c.scale.set=="function"?c.scale.set(ft):(c.scale.x=ft,c.scale.y=ft))}else c&&typeof c.clear=="function"&&(c.clear(),c.rect(-g/2,-b/2,g,b).fill({color:1444375}))}let M=(Gt=window.gameObjectManager)==null?void 0:Gt.get("character_1");if(M){let N=((ae=M.getDisplayObject)==null?void 0:ae.call(M))||M;N&&N.scale&&(console.log(`[CHARACTER] After layout - Adjusted scale - x: ${((Q=N.scale.x)!=null?Q:1).toFixed(3)}, y: ${((Ye=N.scale.y)!=null?Ye:1).toFixed(3)}`),console.log(`[CHARACTER] Layout finalScale: ${S.toFixed(3)}`))}}function vr(s){var r,l,c;let{setState:e,updateLabelAlpha:t,updateHandAlpha:n,config:i,states:a}=s,o=((l=(r=i.engine)==null?void 0:r.runtime)==null?void 0:l.timeline)||{};e(a.showHook),setTimeout(()=>{t(1),n(1),e(a.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(c=o.tutorial_delay_ms)!=null?c:1500)}export{Xa as a,ii as b,fn as c,mn as d,yn as e,Tt as f,be as g,fe as h,Eo as i,Lo as j,Ao as k,To as l,Ro as m,kt as n,zo as o,jo as p,Fo as q,Xn as r,$o as s,Pe as t,li as u,Pt as v,ht as w,di as x,Ot as y,Rt as z,Jo as A,Ge as B,pi as C,hi as D,En as E,nr as F,gi as G,fi as H,mi as I,yi as J,bi as K,yr as L,vr as M,Ka as N,Ja as O,Fn as P,it as Q,Cr as R,dn as S,qn as T,cs as U,Un as V,_l as W,Al as X,Fe as Y,Me as Z};
|