handler-playable-sdk 1.0.103 → 1.0.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/chunk-FL4VTM6W.js +1 -0
  2. package/dist/{chunk-NOMTJOWU.js → chunk-M4ULXPTP.js} +2 -2
  3. package/dist/cli/brand-dna.mjs +1 -1
  4. package/dist/cli/canva-import.mjs +1 -1
  5. package/dist/cli/cleanup-assets.mjs +1 -1
  6. package/dist/cli/fix-scales.mjs +1 -1
  7. package/dist/cli/index.js +1 -1
  8. package/dist/cli/screen-helper.mjs +1 -1
  9. package/dist/cli/setup-library.mjs +1 -1
  10. package/dist/cli/student-helper/add-logic.mjs +1 -1
  11. package/dist/cli/student-helper/add-object.mjs +1 -1
  12. package/dist/cli/student-helper/arg-parsing.mjs +1 -1
  13. package/dist/cli/student-helper/asset-registry.mjs +1 -1
  14. package/dist/cli/student-helper/bullet-system.mjs +1 -1
  15. package/dist/cli/student-helper/collectable-system.mjs +1 -1
  16. package/dist/cli/student-helper/constants.mjs +1 -1
  17. package/dist/cli/student-helper/drag-snap-couples.mjs +1 -1
  18. package/dist/cli/student-helper/endgame-screen.mjs +1 -1
  19. package/dist/cli/student-helper/fs-io.mjs +1 -1
  20. package/dist/cli/student-helper/logic-defaults.mjs +1 -1
  21. package/dist/cli/student-helper/print-help.mjs +1 -1
  22. package/dist/cli/student-helper/prompts.mjs +1 -1
  23. package/dist/cli/student-helper/scratch-card.mjs +1 -1
  24. package/dist/cli/student-helper/screen-utils.mjs +1 -1
  25. package/dist/cli/student-helper/snippets.mjs +1 -1
  26. package/dist/cli/student-helper/start-screen.mjs +1 -1
  27. package/dist/cli/student-helper/swerve-collect.mjs +1 -1
  28. package/dist/cli/student-helper/tap-destroy.mjs +1 -1
  29. package/dist/cli/student-helper/template-packs.mjs +1 -1
  30. package/dist/cli/student-helper.mjs +1 -1
  31. package/dist/cli/sync-screens.mjs +1 -1
  32. package/dist/cli/validate-assets.mjs +1 -1
  33. package/dist/cli/validate.mjs +1 -1
  34. package/dist/{config-HQX4AQNX.js → config-VHVTBJGB.js} +1 -1
  35. package/dist/index.cjs +34 -34
  36. package/dist/index.js +1 -1
  37. package/dist/pixi/index.cjs +1 -1
  38. package/dist/pixi/index.js +1 -1
  39. package/dist/three/index.cjs +1 -1
  40. package/dist/three/index.js +1 -1
  41. package/package.json +1 -1
  42. package/dist/chunk-FOTLNUIS.js +0 -1
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{E as K,F as L,G as M,H as N,I as O,J as P,K as Q,L as R,M as S,N as T,O as U,P as V,Q as W,R as X,S as Y,T as Z,U as _,a}from"./chunk-NOMTJOWU.js";import"./chunk-NSZ7GCS3.js";import"./chunk-I5OOVR5U.js";import{a as v,b as w,c as x,d as y,e as z,f as A,g as B,h as C,i as D,j as E,k as F,l as G,m as H,n as I,o as J}from"./chunk-FOTLNUIS.js";import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t,t as u}from"./chunk-2MR65LDX.js";import"./chunk-E6WJCS24.js";import"./chunk-JXBG6UFL.js";export{V as COLORS,G as ConfigWatcher,P as DebugPanel,F as DefaultReloadStrategy,Z as Handler,Y as PlayableLoadingScreen,Q as PreviewShell,W as STROKE_WIDTH,X as THEME,d as applyConfigOverride,e as applyConfigOverrides,s as applyConfigsToDisk,C as applyDefaults,a as baseLottie,U as bootstrap,f as clearConfigOverrides,g as clearConfigOverridesForObject,j as configOverrideManager,R as createPreviewShell,o as deepClone,_ as default,M as defaultPreset,L as deviceGroups,K as devicePresets,H as diffConfigs,p as exportConfigsAsJSON,q as exportConfigsFromActiveCache,i as getConfigOverrides,r as getConfigStateSummary,b as getOverrideMode,N as getPresetById,O as getPresetsByCategory,x as loadAllObjectConfigs,v as loadComponentSchemas,y as loadEngineConfig,z as loadGamePromptConfig,D as loadObjectCentricConfig,w as loadObjectConfig,A as loadSceneConfig,l as redoLastConfigChange,I as rehydrateObject,h as removeConfigOverride,t as resetToApplied,u as resetToOriginal,T as setBootstrapDependencies,c as setOverrideMode,J as setupHotReload,S as setupLiveEditBridge,E as toLegacyFormat,m as trackObjectCreation,n as trackObjectDeletion,k as undoLastConfigChange,B as validateObjectConfig};
1
+ import{E as K,F as L,G as M,H as N,I as O,J as P,K as Q,L as R,M as S,N as T,O as U,P as V,Q as W,R as X,S as Y,T as Z,U as _,a}from"./chunk-M4ULXPTP.js";import"./chunk-NSZ7GCS3.js";import"./chunk-I5OOVR5U.js";import{a as v,b as w,c as x,d as y,e as z,f as A,g as B,h as C,i as D,j as E,k as F,l as G,m as H,n as I,o as J}from"./chunk-FL4VTM6W.js";import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t,t as u}from"./chunk-2MR65LDX.js";import"./chunk-E6WJCS24.js";import"./chunk-JXBG6UFL.js";export{V as COLORS,G as ConfigWatcher,P as DebugPanel,F as DefaultReloadStrategy,Z as Handler,Y as PlayableLoadingScreen,Q as PreviewShell,W as STROKE_WIDTH,X as THEME,d as applyConfigOverride,e as applyConfigOverrides,s as applyConfigsToDisk,C as applyDefaults,a as baseLottie,U as bootstrap,f as clearConfigOverrides,g as clearConfigOverridesForObject,j as configOverrideManager,R as createPreviewShell,o as deepClone,_ as default,M as defaultPreset,L as deviceGroups,K as devicePresets,H as diffConfigs,p as exportConfigsAsJSON,q as exportConfigsFromActiveCache,i as getConfigOverrides,r as getConfigStateSummary,b as getOverrideMode,N as getPresetById,O as getPresetsByCategory,x as loadAllObjectConfigs,v as loadComponentSchemas,y as loadEngineConfig,z as loadGamePromptConfig,D as loadObjectCentricConfig,w as loadObjectConfig,A as loadSceneConfig,l as redoLastConfigChange,I as rehydrateObject,h as removeConfigOverride,t as resetToApplied,u as resetToOriginal,T as setBootstrapDependencies,c as setOverrideMode,J as setupHotReload,S as setupLiveEditBridge,E as toLegacyFormat,m as trackObjectCreation,n as trackObjectDeletion,k as undoLastConfigChange,B as validateObjectConfig};
@@ -94,7 +94,7 @@
94
94
  <button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
95
95
  </div>
96
96
  </div>
97
- `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.image&&this.image.naturalWidth>0&&this.image.naturalHeight>0?(console.log("[AssetCropModal] Image loaded:",this.image.naturalWidth,"x",this.image.naturalHeight),this.initializeCrop(),this.render()):(console.error("[AssetCropModal] Image loaded but invalid dimensions"),this.showError("Failed to load image"))},this.image.onerror=e=>{console.error("[AssetCropModal] Image load error:",e),this.showError("Failed to load image. Please check the image URL.")},this.image.src=this.options.imageSrc,this.canvas&&this.ctx&&(this.ctx.fillStyle="rgba(128, 128, 128, 0.3)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 255, 255, 0.7)",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText("Loading image...",this.canvas.width/2,this.canvas.height/2)))}showError(e){var n;if(!this.canvas||!this.ctx)return;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 0, 0, 0.2)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="#ff4444",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText(e,this.canvas.width/2,this.canvas.height/2);let t=(n=this.modal)==null?void 0:n.querySelector(".asset-crop-preview-canvas");if(t){let a=t.getContext("2d");a&&(a.fillStyle="rgba(255, 0, 0, 0.2)",a.fillRect(0,0,t.width,t.height))}}initializeCrop(){var n;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(n=this.options)!=null&&n.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,n=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,n-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){if(!(!this.ctx||!this.canvas)){if(!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0){console.warn("[AssetCropModal] Image not ready for rendering"),this.showError("Image not loaded");return}this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);try{this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore()}catch(e){console.error("[AssetCropModal] Error drawing image:",e),this.showError("Error drawing image");return}this.drawCropOverlay(),this.updatePreview()}}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,n=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,n,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,n,a),this.ctx.fillStyle="#ffffff";let s=8;[[e,t],[e+n-s,t],[e,t+a-s],[e+n-s,t+a-s]].forEach(([o,c])=>{var l;(l=this.ctx)==null||l.fillRect(o,c,s,s)})}updatePreview(){if(!this.modal||!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let n=150;e.width=n,e.height=n,t.clearRect(0,0,n,n);let a=n/this.cropWidth,s=n/this.cropHeight,r=Math.min(a,s),o=this.cropWidth*r,c=this.cropHeight*r,l=(n-o)/2,u=(n-c)/2;try{t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,l,u,o,c)}catch(d){console.error("[AssetCropModal] Error drawing preview:",d),t.fillStyle="rgba(255, 0, 0, 0.2)",t.fillRect(0,0,n,n)}}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",n=>{let a=parseFloat(n.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",n=>{let a=n.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",n=>{switch(n.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",n=>{n.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,n=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,n=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let n=e.toDataURL("image/png");this.options.onCrop(n),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(i){new Pi().open(i)}});var fr={};mn(fr,{AssetCache:()=>re,AssetLoader:()=>ke,AssetSystem:()=>li,AssetTextures:()=>Pe,Assets:()=>Fa,BaseSystem:()=>rt,GameEngine:()=>oi,GameObject:()=>Ot,GameObjectManager:()=>at,ObjectFactory:()=>ye,Renderer:()=>_t,RuntimeObjectRegistry:()=>ot,Transform:()=>jt,applyScreenAnchor:()=>Ft,basePixi:()=>$a,clearResponsiveElements:()=>ia,createPixiBase:()=>si,getRegisteredFontIds:()=>_a,globalResponsiveMultipliers:()=>St,initAssetTextures:()=>Zt,initAssets:()=>Ba,layout:()=>aa,playLottieOverlay:()=>Ra,registerFont:()=>ja,registerType:()=>Xt,resolveAnchorVec2:()=>Te,resolveFont:()=>Pa,resolveFontWeight:()=>Ma,resolveScreenAnchorPoint:()=>De,resolveScreenRatioPoint:()=>Ne,runInitSequence:()=>Ga,setLottieInstance:()=>Qt,spawnSceneFromConfig:()=>Na,updateScreenState:()=>Ht});module.exports=Ka(fr);var ka=require("pixi.js");var Le={};function zt(i,e,t=!1){Le[i]||(Le[i]=[]),Le[i].push({fn:e,once:t})}function di(i,e){if(Le[i]){if(!e){delete Le[i];return}Le[i]=Le[i].filter(t=>t.fn!==e)}}function $t(i,...e){let t=Le[i];if(t)for(let n of[...t])n.fn(...e),n.once&&di(i,n.fn)}function ee(i,e){zt(i,e,!0)}var $=null,ae=[],Ye=null;function wn(i){$=i,ae=[],Ye!==null&&(clearTimeout(Ye),Ye=null)}function xn(){var i,e,t;return{endpoint:($==null?void 0:$.endpoint)||"",transport:($==null?void 0:$.transport)||"beacon",batchSize:(i=$==null?void 0:$.batchSize)!=null?i:10,flushIntervalMs:(e=$==null?void 0:$.flushIntervalMs)!=null?e:300,maxQueue:(t=$==null?void 0:$.maxQueue)!=null?t:200,debug:!!($!=null&&$.debug)}}async function yn(i,e,t,n){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let s=navigator.sendBeacon(i,new Blob([a],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",s,e);return}catch(s){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",s)}try{await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",e)}catch(s){n&&console.warn("[handler.telemetry] fetch failed",s)}}function pi(i,e){let t=xn();if(e&&t.endpoint){if(ae.push(i),ae.length>t.maxQueue&&(ae=ae.slice(ae.length-t.maxQueue)),ae.length>=t.batchSize){vn();return}Ye===null&&(Ye=window.setTimeout(()=>{Ye=null,vn()},t.flushIntervalMs))}}async function vn(){let i=xn();if(!i.endpoint||ae.length===0)return;let e=ae.splice(0,i.batchSize);await yn(i.endpoint,{events:e},i.transport,i.debug),ae.length>0&&await yn(i.endpoint,{events:ae.splice(0,i.batchSize)},i.transport,i.debug)}function Sn(i){return Math.max(0,Math.min(1,i))}function Xa(i){let e=String(i!=null?i:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),n=t?Number(t[1]):1.8;return a=>1+(n+1)*Math.pow(a-1,3)+n*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function wt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Ja(i,e){let t=i==null?void 0:i[e];return typeof t=="number"?t:0}function En(i,e,t){try{i[e]=t}catch{}}function Za(i){let e=i==null?void 0:i.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,n=typeof e.y=="number"?e.y:1;return{x:t,y:n}}function Cn(i,e){let t=i==null?void 0:i.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function An(i,e){let t=Za(i);if(!t)return{from:null,to:null};let n=null,a=null;return typeof e.scale=="number"?(n=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(n=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(n=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),n===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:n!=null?n:t.x,y:a!=null?a:t.y}}}function Ln(){let i=new Set,e=new WeakMap,t=null,n=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),i.size>0&&n()})},a=u=>{var p;i.add(u);let d=(p=e.get(u.target))!=null?p:new Set;d.add(u),e.set(u.target,d),n()},s=u=>{i.delete(u);let d=e.get(u.target);d&&(d.delete(u),d.size===0&&e.delete(u.target))},r=u=>{u.killed||(u.killed=!0,s(u))},o=()=>{var d,p;let u=wt();for(let g of Array.from(i)){if(g.killed||g.paused)continue;let h=u-g.startMs-g.delayMs;if(h<0)continue;let m=g.durationMs>0?h/g.durationMs:1,C=Sn(m),b=g.repeat>=0?g.repeat+1:1,f=g.repeat>0?Math.min(Math.floor(m),b-1):0;if(g.repeat>0&&m>=1){let x=m-f;C=Sn(x)}let y=g.ease(C);g.yoyo&&f%2===1&&(y=1-y);for(let x of g.props)En(g.target,x.key,x.from+(x.to-x.from)*y);g.scaleFrom&&g.scaleTo&&Cn(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*y,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*y});try{(d=g.onUpdate)==null||d.call(g)}catch{}if(m>=b){r(g);try{(p=g.onComplete)==null||p.call(g)}catch{}}}},c=(u,d,p)=>{var x;let g=Math.max(0,(typeof d.duration=="number"?d.duration:.5)*1e3),h=Math.max(0,(typeof d.delay=="number"?d.delay:0)*1e3+((x=p==null?void 0:p.delayMsOverride)!=null?x:0)),m=Xa(d.ease),C=typeof d.repeat=="number"?Math.max(0,d.repeat|0):0,b=d.yoyo===!0,f=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),y=[];for(let k of Object.keys(d)){if(f.has(k))continue;let L=d[k];typeof L=="number"&&y.push({key:k,from:Ja(u,k),to:L})}let w=An(u,d);return{target:u,startMs:wt(),delayMs:h,durationMs:g,ease:m,props:y,scaleFrom:w.from,scaleTo:w.to,repeat:C,yoyo:b,onUpdate:typeof d.onUpdate=="function"?d.onUpdate:void 0,onComplete:typeof d.onComplete=="function"?d.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},l={to(u,d){let p=c(u,d);return a(p),{kill:()=>r(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=wt())},resume:()=>{var m;if(!p.paused)return;let g=(m=p.pauseAtMs)!=null?m:wt(),h=wt()-g;p.startMs+=h,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(u,d,p){return l.set(u,d),l.to(u,p)},set(u,d){if(!u||!d)return;for(let g of Object.keys(d)){let h=d[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof h=="number"&&En(u,g,h)}let p=An(u,d);p.to&&Cn(u,p.to)},killTweensOf(u){let d=e.get(u);if(d)for(let p of Array.from(d))r(p)},timeline(u={}){let d=[],p=0,g=!1,h=[],m=f=>{if(typeof f=="number")return Math.max(0,f*1e3);let y=typeof f=="string"?f.trim():"";return y.startsWith("+=")?p+Math.max(0,Number(y.slice(2))*1e3||0):y?Math.max(0,Number(y)*1e3||0):p},C=f=>{d.push(f);let y=Math.max(0,(typeof f.vars.duration=="number"?f.vars.duration:.5)*1e3);p=Math.max(p,f.atMs+y)},b={to(f,y,w){return C({kind:"to",target:f,vars:y,atMs:m(w)}),b},fromTo(f,y,w,x){return C({kind:"fromTo",target:f,vars:w,from:y,atMs:m(x)}),b},play(){var f,y;if(g)return b;g=!0,h=[];for(let w of d)w.kind==="fromTo"&&l.set(w.target,(f=w.from)!=null?f:{}),h.push(l.to(w.target,{...w.vars,delay:w.atMs/1e3+((y=w.vars.delay)!=null?y:0)}));return b},pause(){for(let f of h)f.pause();return b},kill(){for(let f of h)f.kill();h=[],g=!1}};return u.paused||b.play(),b}};return l}function Tn(){if(typeof window=="undefined")return;let i=window;if(!i.gsap)try{i.gsap=Ln()}catch{}}var In={name:"handler-playable-sdk",version:"1.0.103",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs dist/cli/student-helper/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var te=0,es=te++,kn=te++,Pn=te++,Mn=te++,jn=te++,_n=te++,On=te++,Rn=te++,zn=te++,$n=te++,Dn=te++,Nn=te++,j=es;function Hn(){return j===kn}function Fn(){return j===Pn}function Bn(){return j===Mn}function Gn(){return j===jn}function We(){return j===_n}function Ke(){return j===On}function Un(){return j===Rn}function qn(){return j===zn}function Vn(){return j===$n}function ui(){return j===Dn}function gi(){return j===Nn}function Yn(){let i=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(i==="mraid")try{mraid.getState(),j=kn;return}catch{}else if(i==="dapi")try{dapi.isReady(),j=Pn;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(j=Mn)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(j=jn)}catch{}else if(e==="mintegral")window.gameReady&&(j=_n);else if(e==="tapjoy")window.TJ_API&&(j=On);else if(e==="tiktok")window.openAppStore&&(j=Rn);else if(e==="smadex")try{window.smxTracking&&(j=zn)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(j=$n)}catch{}else e==="vungle"?j=Dn:(i==="nucleo"||e==="nucleo")&&(j=Nn)}var Dt=ci(require("lottie-web"),1),Wn=Dt.default;typeof window!="undefined"&&(window.lottie=Dt.default,window.__baseLottie=Dt.default);mi();function D(i,e){let t=(a,s)=>s===0?a:t(s,a%s),n=t(i,e);return`${i/n}:${e/n}`}var Wr=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:D(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:D(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:D(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:D(360,780)}],Kr=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:D(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:D(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:D(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:D(412,915)}],Xr=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:D(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:D(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:D(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:D(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:D(800,1280)}],Zn=[{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:D(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:D(768,1024),mraidScale:.7}];var Jr=[...Zn];var ls=Zn[0];de();var ta=require("pixi.js"),fe={width:400,height:600,designWidth:400,scaleFactor:1},St={scale:1,position:1},Bt=[];function ds(i,e,t,n,a,s,r){Bt.push({element:i,originalScale:s,positionHelper:e,heightPercent:a}),e(i,t,n,a,s,r,!1)}function ps(){Bt.forEach(({element:i,originalScale:e,positionHelper:t,heightPercent:n})=>{let a=e*fe.scaleFactor;t(i,fe.width,fe.height,n,a,!0,!1)})}function ia(){Bt.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Ht(i,e){console.log(`[SCREEN] updateScreenState called: ${i}x${e}`),fe.width=i,fe.height=e,fe.scaleFactor=Math.min(i/fe.designWidth,1.15),St.scale=fe.scaleFactor,St.position=1,console.log(`[SCREEN] Global multipliers - scale: ${St.scale.toFixed(3)}`),ps()}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}};function us(i,e,t){let n=_[i];n&&n[e]!==void 0&&(n[e]=t,console.log(`Updated ${i}.${e} = ${t}`))}function gs(){return _}var hs={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 Nt(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function Te(i,e={x:.5,y:.5}){var t;if(Array.isArray(i))return{x:Nt(i[0],e.x),y:Nt(i[1],e.y)};if(i&&typeof i=="object"){let n=i;return{x:Nt(n.x,e.x),y:Nt(n.y,e.y)}}if(typeof i=="string"){let n=i.trim().toLowerCase();return(t=hs[n])!=null?t:e}return e}function De(i,e,t,n={}){var g,h,m,C,b,f;let a=Te(t),s=(g=n.inset)!=null?g:{},r=(h=n.padding)!=null?h:{x:0,y:0},o=((m=s.left)!=null?m:0)+r.x,c=((C=s.right)!=null?C:0)+r.x,l=((b=s.top)!=null?b:0)+r.y,u=((f=s.bottom)!=null?f:0)+r.y,d=Math.max(0,i-o-c),p=Math.max(0,e-l-u);return{x:o+d*a.x,y:l+p*a.y}}function Ne(i,e,t,n={}){var m,C,b,f,y,w;let a=(m=n.inset)!=null?m:{},s=(C=n.padding)!=null?C:{x:0,y:0},r=((b=a.left)!=null?b:0)+s.x,o=((f=a.right)!=null?f:0)+s.x,c=((y=a.top)!=null?y:0)+s.y,l=((w=a.bottom)!=null?w:0)+s.y,u=Math.max(0,i-r-o),d=Math.max(0,e-c-l),p=Te(t,{x:.5,y:.5}),g=Math.min(Math.max(p.x,0),1),h=Math.min(Math.max(p.y,0),1);return{x:r+u*g,y:c+d*h}}function Ft(i,e,t,n={}){var u,d,p;if(!i)return;let a=n.positionRatio?Ne(e,t,n.positionRatio,{inset:n.inset,padding:n.screenPadding}):De(e,t,n.anchor,{inset:n.inset,padding:n.screenPadding}),s=(u=n.offset)!=null?u:{x:0,y:0},r=a.x+s.x,o=a.y+s.y;i.anchor&&n.renderAnchor&&i.anchor.set(n.renderAnchor.x,n.renderAnchor.y),se(i,r,o);let c=(d=n.scale)!=null?d:1,l=(p=n.scaleMultiplier)!=null?p:1;(n.scale!==void 0||n.scaleMultiplier!==void 0)&&pe(i,c*l)}if(typeof window!="undefined"){let i=window.innerWidth,e=window.innerHeight,t=()=>{let n=window.innerWidth,a=window.innerHeight;(n!==i||a!==e)&&(i=n,e=a,Ht(n,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Ht(window.innerWidth,window.innerHeight),window.updateDebugConfig=us,window.getDebugConfig=gs,window.copyConfig=As,window.applyConfig=xt,window.applyConfigForRatio=Ls,window.positionAtBottom=na,window.positionAtTop=bs,window.positionAtCenter=ys,window.positionAtLeft=vs,window.positionAtRight=ws,window.positionAtBottomLeft=xs,window.positionAtBottomRight=Ss,window.positionAtTopLeft=Es,window.positionAtTopRight=Cs,window.applyPositionContract=ms,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 Gt(i,e,t=0){return i*e+t}function Ut(i,e,t=0){return i*(1-e)+t}function qt(i,e,t=0){return i*e+t}function Vt(i,e,t=0){return i*(1-e)+t}function ie(i,e=0){return i/2+e}function fs(i,e){return i*e}function ms(i,e,t,n){var r,o,c,l,u,d,p,g,h,m,C,b,f,y,w,x,k,L,B,R;let a=0,s=0;switch(n.type){case"top":a=ie(e,(o=(r=n.offset)==null?void 0:r.x)!=null?o:0),s=Gt(t,n.percent,(l=(c=n.offset)==null?void 0:c.y)!=null?l:0);break;case"bottom":a=ie(e,(d=(u=n.offset)==null?void 0:u.x)!=null?d:0),s=Ut(t,n.percent,(g=(p=n.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=qt(e,n.percent,(m=(h=n.offset)==null?void 0:h.x)!=null?m:0),s=ie(t,(b=(C=n.offset)==null?void 0:C.y)!=null?b:0);break;case"right":a=Vt(e,n.percent,(y=(f=n.offset)==null?void 0:f.x)!=null?y:0),s=ie(t,(x=(w=n.offset)==null?void 0:w.y)!=null?x:0);break;case"center":a=ie(e,(L=(k=n.offset)==null?void 0:k.x)!=null?L:0),s=ie(t,(R=(B=n.offset)==null?void 0:B.y)!=null?R:0);break}i.position?i.position.set(a,s):(i.x=a,i.y=s),n.scale!==void 0&&n.scale!==1&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(n.scale,n.scale):(i.scale.x=n.scale,i.scale.y=n.scale))}function na(i,e,t,n=.2,a=1,s=!0,r=!1){let o=fs(t,n),c=Ut(t,n/2);se(i,ie(e),c);let l=s?a*fe.scaleFactor:a;pe(i,l),r&&!Bt.find(u=>u.element===i)&&ds(i,na,e,t,n,a,s)}function bs(i,e,t,n=.1,a=1){se(i,ie(e),Gt(t,n)),pe(i,a)}function ys(i,e,t,n=0,a=0,s=1){se(i,ie(e,n),ie(t,a)),pe(i,s)}function vs(i,e,t,n=.1,a=1){se(i,qt(e,n),ie(t)),pe(i,a)}function ws(i,e,t,n=.1,a=1){se(i,Vt(e,n),ie(t)),pe(i,a)}function xs(i,e,t,n=.05,a=.05,s=1){se(i,qt(e,a),Ut(t,n)),pe(i,s)}function Ss(i,e,t,n=.05,a=.05,s=1){se(i,Vt(e,a),Ut(t,n)),pe(i,s)}function Es(i,e,t,n=.05,a=.05,s=1){se(i,qt(e,a),Gt(t,n)),pe(i,s)}function Cs(i,e,t,n=.05,a=.05,s=1){se(i,Vt(e,a),Gt(t,n)),pe(i,s)}function se(i,e,t){i&&i.position?typeof i.position.set=="function"?i.position.set(e,t):(i.position.x=e,i.position.y=t):i&&(i.x=e,i.y=t)}function pe(i,e){e!==1&&i&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(e,e):i.scale.x!==void 0&&i.scale.y!==void 0&&(i.scale.x=e,i.scale.y=e))}var $e={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function As(i){return i&&$e[i]?JSON.parse(JSON.stringify($e[i])):JSON.parse(JSON.stringify(_))}function xt(i){Object.keys(i).forEach(e=>{let t=e;_[t]&&i[t]&&Object.assign(_[t],i[t])}),console.log("Config applied:",i)}function Ls(i,e){let t=i/e;t>1.6?(xt($e.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(xt($e.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(xt($e.square),console.log("Applied SQUARE config for ratio:",t)):(xt($e.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let i=window;i.configPresets=$e,i.resolveAnchorVec2=i.resolveAnchorVec2||Te,i.resolveScreenAnchorPoint=i.resolveScreenAnchorPoint||De,i.resolveScreenRatioPoint=i.resolveScreenRatioPoint||Ne}var K=null,ea=new Map;function aa(i,e,t,n,a,s={}){var Se,Ee,Ce,Ae,Y,_e,lt,ct,dt,pt,ut,gt,ht,ft,mt,bt,F,Z,U,Q,Ue,Oe,Bi,Gi,Ui,qi,Vi,Yi,Wi,Ki,Xi,Ji,Zi,Qi,en,tn,nn,an,sn,rn,on,ln,cn,dn,pn,un,gn,hn,fn;let r=(Se=s.enableDebugLogs)!=null?Se:!1;r&&(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:",s));let{mainContainer:o,label:c,background:l,backgroundTexture:u,app:d}=i;if(!d||!d.renderer){r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width: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,g=n.height;r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:p,baseHeight:g});let h=p*_.layout.screen_scale_x,m=g*_.layout.screen_scale_y,C=p/2,b=e.engine.runtime||{},f=b.layout||{};r&&(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:h,height:m,midX:C}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",b),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",f));let y=m>h,w=(Ee=f.design_width_portrait)!=null?Ee:y?400:600,x=(Ce=f.design_height_portrait)!=null?Ce:y?600:400,k=Math.min(h/w,m/x);k=Math.min(k,1.15);let L=k*((Ae=_.engine.scale)!=null?Ae:1),B=(Y=s.skipMainContainerTransform)!=null?Y:!1;!B&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(L):(o.scale.x=L,o.scale.y=L));let R=(_e=f.main_container_anchor)!=null?_e:"center",H=(lt=f.main_container_position_ratio)!=null?lt:{x:.5,y:.5},z=(ct=f.main_container_offset)!=null?ct:{x:0,y:0},T=f.main_container_position_ratio?Ne(p,g,H):De(p,g,R),E=T.x+z.x+_.layout.position_offset.x,S=T.y+z.y+_.layout.position_offset.y;if(!B&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(E,S):(o.position.x=E,o.position.y=S)),a&&(o!=null&&o.toLocal)){let G=g>p,W=(dt=f.design_width_portrait)!=null?dt:G?320:480,N=(pt=f.design_height_portrait)!=null?pt:G?480:320;for(let[oe,le]of e.objects.entries()){let q=le==null?void 0:le.transform;if(!q||((ut=q.position_mode)!=null?ut:"static")!=="static")continue;let I=(gt=a.get)==null?void 0:gt.call(a,oe),yt=((ht=I==null?void 0:I.getDisplayObject)==null?void 0:ht.call(I))||(I==null?void 0:I.pixiObject)||I;if(!yt||yt.parent!==o)continue;let he=(ft=q.anchor)!=null?ft:"bottom-left";he==="bottom-left"&&q.anchor==null&&console.log("[DEBUG FALLBACK] LayoutManager transform.anchor \u2192 bottom-left");let qe=q.position_ratio!=null?Ne(W,N,q.position_ratio):De(W,N,he),Ve=(mt=q.position)!=null?mt:{x:0,y:0},vt=qe.x-W/2+Ve.x,Re=qe.y-N/2+Ve.y;typeof(I==null?void 0:I.setPosition)=="function"?I.setPosition(vt,Re):(se(yt,vt,Re),(bt=I==null?void 0:I.transform)!=null&&bt.position&&(I.transform.position.x=vt,I.transform.position.y=Re))}}let A=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,J=((A==null?void 0:A.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(_.layout.debug_rect_visible&&J){(!K||K.parent!==d.stage)&&(K==null||K.destroy(),K=new ta.Graphics,K.zIndex=9999,d.stage.addChild(K)),K.clear();let G=_.layout.debug_rect_scale_x,W=_.layout.debug_rect_scale_y,N=(p-4)*G,oe=(g-4)*W,le=(p-N)/2,q=(g-oe)/2;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:N,rectH:oe,offsetX:le,offsetY:q}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+le,y:2+q,width:N,height:oe})),K.rect(2+le,2+q,N,oe).stroke({width:_.layout.debug_rect_thickness,color:_.layout.debug_rect_color})}else K&&(K.destroy(),K=null);let O=((F=i.label)==null?void 0:F.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(c&&c.position&&O){let G=(U=(Z=O==null?void 0:O.transform)==null?void 0:Z.anchor)!=null?U:"center",W=(Q=O==null?void 0:O.transform)==null?void 0:Q.position_ratio,N=((Ue=O==null?void 0:O.transform)==null?void 0:Ue.offset)||{x:0,y:0};Ft(c,p,g,{anchor:G,positionRatio:W,offset:{x:N.x*L,y:N.y*L},renderAnchor:Te(G)})}if(c&&c.alpha>0){let G=1+Math.sin(t*_.engine.label_pulse_speed)*_.engine.label_pulse_intensity,W=(Bi=(Oe=O==null?void 0:O.transform)==null?void 0:Oe.scale)!=null?Bi:1,N=G*L*W;c.scale&&(typeof c.scale.set=="function"?c.scale.set(N):(c.scale.x=N,c.scale.y=N))}r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING =====");let ne=l?e.objects.get("background_1"):null,je=!!ne&&(l==null?void 0:l.parent)===o;if(l&&!je){r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!l),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(Gi=l.constructor)==null?void 0:Gi.name)),l.alpha=((qi=(Ui=b.background)==null?void 0:Ui.alpha)!=null?qi:.98)*_.engine.background_alpha,r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",l.alpha),r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",ne);let G=(ne==null?void 0:ne.transform)||{};r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",G);let W=G.offset||{x:0,y:0},N=((Yi=(Vi=b.background)==null?void 0:Vi.offset_y)!=null?Yi:0)+_.engine.background_offset_y,oe=(Wi=G.anchor)!=null?Wi:"center",le=G.position_ratio;if(r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:W,bgRuntimeOffsetY:N,bgScreenAnchor:oe,bgPositionRatio:le,baseWidth:p,baseHeight:g,finalScale:L}),Ft(l,p,g,{anchor:oe,positionRatio:le,offset:{x:W.x*L,y:W.y*L+N},renderAnchor:Te(oe)}),r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:l.x,y:l.y,scaleX:(Ki=l.scale)==null?void 0:Ki.x,scaleY:(Xi=l.scale)==null?void 0:Xi.y,anchorX:(Ji=l.anchor)==null?void 0:Ji.x,anchorY:(Zi=l.anchor)==null?void 0:Zi.y,pivotX:(Qi=l.pivot)==null?void 0:Qi.x,pivotY:(en=l.pivot)==null?void 0:en.y,width:l.width,height:l.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 qe=Math.max(h/u.width,m/u.height),Ve=(nn=(tn=b.background)==null?void 0:tn.scale_multiplier)!=null?nn:1.05,vt=(an=G.scale)!=null?an:1,Re=qe*Ve*_.engine.background_scale*vt;l.scale&&(typeof l.scale.set=="function"?l.scale.set(Re):(l.scale.x=Re,l.scale.y=Re))}else l&&typeof l.clear=="function"&&(l.clear(),l.rect(-h/2,-m/2,h,m).fill({color:1444375}));let q=`${p}x${g}`,P=ea.get(q),I={x:Number((sn=l.x)!=null?sn:0),y:Number((rn=l.y)!=null?rn:0),scaleX:Number((ln=(on=l.scale)==null?void 0:on.x)!=null?ln:1),scaleY:Number((dn=(cn=l.scale)==null?void 0:cn.y)!=null?dn:1),rotation:Number.isFinite(l.rotation)?l.rotation:void 0,anchorX:Number.isFinite((pn=l.anchor)==null?void 0:pn.x)?l.anchor.x:void 0,anchorY:Number.isFinite((un=l.anchor)==null?void 0:un.y)?l.anchor.y:void 0,pivotX:Number.isFinite((gn=l.pivot)==null?void 0:gn.x)?l.pivot.x:void 0,pivotY:Number.isFinite((hn=l.pivot)==null?void 0:hn.y)?l.pivot.y:void 0},yt=Number.isFinite(I.x)&&Number.isFinite(I.y)&&Number.isFinite(I.scaleX)&&Number.isFinite(I.scaleY),he=I;if(P){let qe=Math.hypot(I.x-P.x,I.y-P.y),Ve=Math.max(p,g)*.5;(!yt||qe>Ve)&&((fn=l.position)!=null&&fn.set?l.position.set(P.x,P.y):(l.x=P.x,l.y=P.y),l.scale&&(typeof l.scale.set=="function"?l.scale.set(P.scaleX,P.scaleY):(l.scale.x=P.scaleX,l.scale.y=P.scaleY)),Number.isFinite(P.rotation)&&typeof l.rotation=="number"&&(l.rotation=P.rotation),l.anchor&&Number.isFinite(P.anchorX)&&Number.isFinite(P.anchorY)&&l.anchor.set(P.anchorX,P.anchorY),l.pivot&&Number.isFinite(P.pivotX)&&Number.isFinite(P.pivotY)&&l.pivot.set(P.pivotX,P.pivotY),he=P)}Number.isFinite(he.x)&&Number.isFinite(he.y)&&Number.isFinite(he.scaleX)&&Number.isFinite(he.scaleY)&&ea.set(q,he)}}function Ts(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Is(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}async function ks(i){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=i})}async function yi(i){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",i);let n=await fetch(i);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,i),null;let a=await n.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let s=await Ts(a),r=await ks(s),o=Is(s);return console.log("[ImageUtils] Success resolution:",r==null?void 0:r.width,"x",r==null?void 0:r.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:s,width:(e=r==null?void 0:r.width)!=null?e:0,height:(t=r==null?void 0:r.height)!=null?t:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function Yt(i,e=30){try{console.log("[ImageUtils] Removing background color...");let t=await new Promise((d,p)=>{let g=new Image;g.onload=()=>d(g),g.onerror=()=>p(new Error("Failed to load image")),g.src=i}),n=document.createElement("canvas");n.width=t.width,n.height=t.height;let a=n.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),i;a.drawImage(t,0,0);let s=a.getImageData(0,0,n.width,n.height),r=s.data,c=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(d=>({r:r[d.offset],g:r[d.offset+1],b:r[d.offset+2]})),l=0;for(let d=0;d<r.length;d+=4){let p=r[d],g=r[d+1],h=r[d+2],m=!1;for(let C of c)if(Math.sqrt(Math.pow(p-C.r,2)+Math.pow(g-C.g,2)+Math.pow(h-C.b,2))<e){m=!0;break}m&&(r[d+3]=0,l++)}return console.log(`[ImageUtils] Removed background from ${l} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(s,0,0),n.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),i}}var sa=require("@google/genai");async function vi(i,e,t=[],n={}){var a,s,r,o,c,l,u;try{if(!(i!=null&&i.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let b=0;b<t.length;b++){let f=t[b];if(!f.base64||!f.mimeType)throw new Error(`Image ${b+1} is missing required data`);if(f.base64.length<1e3&&console.warn(`Image ${b+1} data appears very small, may be corrupted`),!f.mimeType.startsWith("image/"))throw new Error(`Image ${b+1} has invalid MIME type: ${f.mimeType}`)}let d=new sa.GoogleGenAI({apiKey:i}),p="gemini-2.5-flash",g=[e];t.length>0&&t.forEach((b,f)=>{g.push({inlineData:{data:b.base64,mimeType:b.mimeType}}),console.log(`[Gemini] Added image ${f+1}: ${b.mimeType}, size: ${Math.round(b.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${t.length} images and prompt length: ${e.length}`);let h=await d.models.generateContent({model:p,contents:g}),m="",C=(r=(s=(a=h.candidates)==null?void 0:a[0])==null?void 0:s.content)==null?void 0:r.parts;if(C)for(let b of C)b.text&&(m+=b.text);if(!m.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${m.length}`),m}catch(d){throw console.error("[Gemini] API error:",d),(o=d.message)!=null&&o.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(c=d.message)!=null&&c.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(l=d.message)!=null&&l.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(u=d.message)!=null&&u.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):d}}var ra=require("@google/genai");async function Wt(i,e,t=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new ra.GoogleGenAI({apiKey:i}),s=[{text:e}];t.length>0&&t.forEach((o,c)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${c}`),s.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let r=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:s});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!r.candidates||!r.candidates[0]||!r.candidates[0].content||!r.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of r.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let c=o.inlineData.data,l=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${l};base64,${c}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(a){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(a,Object.getOwnPropertyNames(a),2)),a}}var Rs=require("pixi.js");Et();Kt();de();var ua=require("pixi.js");var $s=require("pixi.js");de();function Ws(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Ks(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}function Xs(i){return`
97
+ `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.image&&this.image.naturalWidth>0&&this.image.naturalHeight>0?(console.log("[AssetCropModal] Image loaded:",this.image.naturalWidth,"x",this.image.naturalHeight),this.initializeCrop(),this.render()):(console.error("[AssetCropModal] Image loaded but invalid dimensions"),this.showError("Failed to load image"))},this.image.onerror=e=>{console.error("[AssetCropModal] Image load error:",e),this.showError("Failed to load image. Please check the image URL.")},this.image.src=this.options.imageSrc,this.canvas&&this.ctx&&(this.ctx.fillStyle="rgba(128, 128, 128, 0.3)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 255, 255, 0.7)",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText("Loading image...",this.canvas.width/2,this.canvas.height/2)))}showError(e){var n;if(!this.canvas||!this.ctx)return;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 0, 0, 0.2)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="#ff4444",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText(e,this.canvas.width/2,this.canvas.height/2);let t=(n=this.modal)==null?void 0:n.querySelector(".asset-crop-preview-canvas");if(t){let a=t.getContext("2d");a&&(a.fillStyle="rgba(255, 0, 0, 0.2)",a.fillRect(0,0,t.width,t.height))}}initializeCrop(){var n;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(n=this.options)!=null&&n.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,n=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,n-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){if(!(!this.ctx||!this.canvas)){if(!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0){console.warn("[AssetCropModal] Image not ready for rendering"),this.showError("Image not loaded");return}this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);try{this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore()}catch(e){console.error("[AssetCropModal] Error drawing image:",e),this.showError("Error drawing image");return}this.drawCropOverlay(),this.updatePreview()}}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,n=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,n,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,n,a),this.ctx.fillStyle="#ffffff";let s=8;[[e,t],[e+n-s,t],[e,t+a-s],[e+n-s,t+a-s]].forEach(([o,c])=>{var l;(l=this.ctx)==null||l.fillRect(o,c,s,s)})}updatePreview(){if(!this.modal||!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let n=150;e.width=n,e.height=n,t.clearRect(0,0,n,n);let a=n/this.cropWidth,s=n/this.cropHeight,r=Math.min(a,s),o=this.cropWidth*r,c=this.cropHeight*r,l=(n-o)/2,u=(n-c)/2;try{t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,l,u,o,c)}catch(d){console.error("[AssetCropModal] Error drawing preview:",d),t.fillStyle="rgba(255, 0, 0, 0.2)",t.fillRect(0,0,n,n)}}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",n=>{let a=parseFloat(n.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",n=>{let a=n.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",n=>{switch(n.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",n=>{n.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,n=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,n=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let n=e.toDataURL("image/png");this.options.onCrop(n),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(i){new Pi().open(i)}});var fr={};mn(fr,{AssetCache:()=>re,AssetLoader:()=>ke,AssetSystem:()=>li,AssetTextures:()=>Pe,Assets:()=>Fa,BaseSystem:()=>rt,GameEngine:()=>oi,GameObject:()=>Ot,GameObjectManager:()=>at,ObjectFactory:()=>ye,Renderer:()=>_t,RuntimeObjectRegistry:()=>ot,Transform:()=>jt,applyScreenAnchor:()=>Ft,basePixi:()=>$a,clearResponsiveElements:()=>ia,createPixiBase:()=>si,getRegisteredFontIds:()=>_a,globalResponsiveMultipliers:()=>St,initAssetTextures:()=>Zt,initAssets:()=>Ba,layout:()=>aa,playLottieOverlay:()=>Ra,registerFont:()=>ja,registerType:()=>Xt,resolveAnchorVec2:()=>Te,resolveFont:()=>Pa,resolveFontWeight:()=>Ma,resolveScreenAnchorPoint:()=>De,resolveScreenRatioPoint:()=>Ne,runInitSequence:()=>Ga,setLottieInstance:()=>Qt,spawnSceneFromConfig:()=>Na,updateScreenState:()=>Ht});module.exports=Ka(fr);var ka=require("pixi.js");var Le={};function zt(i,e,t=!1){Le[i]||(Le[i]=[]),Le[i].push({fn:e,once:t})}function di(i,e){if(Le[i]){if(!e){delete Le[i];return}Le[i]=Le[i].filter(t=>t.fn!==e)}}function $t(i,...e){let t=Le[i];if(t)for(let n of[...t])n.fn(...e),n.once&&di(i,n.fn)}function ee(i,e){zt(i,e,!0)}var $=null,ae=[],Ye=null;function wn(i){$=i,ae=[],Ye!==null&&(clearTimeout(Ye),Ye=null)}function xn(){var i,e,t;return{endpoint:($==null?void 0:$.endpoint)||"",transport:($==null?void 0:$.transport)||"beacon",batchSize:(i=$==null?void 0:$.batchSize)!=null?i:10,flushIntervalMs:(e=$==null?void 0:$.flushIntervalMs)!=null?e:300,maxQueue:(t=$==null?void 0:$.maxQueue)!=null?t:200,debug:!!($!=null&&$.debug)}}async function yn(i,e,t,n){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let s=navigator.sendBeacon(i,new Blob([a],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",s,e);return}catch(s){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",s)}try{await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",e)}catch(s){n&&console.warn("[handler.telemetry] fetch failed",s)}}function pi(i,e){let t=xn();if(e&&t.endpoint){if(ae.push(i),ae.length>t.maxQueue&&(ae=ae.slice(ae.length-t.maxQueue)),ae.length>=t.batchSize){vn();return}Ye===null&&(Ye=window.setTimeout(()=>{Ye=null,vn()},t.flushIntervalMs))}}async function vn(){let i=xn();if(!i.endpoint||ae.length===0)return;let e=ae.splice(0,i.batchSize);await yn(i.endpoint,{events:e},i.transport,i.debug),ae.length>0&&await yn(i.endpoint,{events:ae.splice(0,i.batchSize)},i.transport,i.debug)}function Sn(i){return Math.max(0,Math.min(1,i))}function Xa(i){let e=String(i!=null?i:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),n=t?Number(t[1]):1.8;return a=>1+(n+1)*Math.pow(a-1,3)+n*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function wt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Ja(i,e){let t=i==null?void 0:i[e];return typeof t=="number"?t:0}function En(i,e,t){try{i[e]=t}catch{}}function Za(i){let e=i==null?void 0:i.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,n=typeof e.y=="number"?e.y:1;return{x:t,y:n}}function Cn(i,e){let t=i==null?void 0:i.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function An(i,e){let t=Za(i);if(!t)return{from:null,to:null};let n=null,a=null;return typeof e.scale=="number"?(n=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(n=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(n=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),n===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:n!=null?n:t.x,y:a!=null?a:t.y}}}function Ln(){let i=new Set,e=new WeakMap,t=null,n=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),i.size>0&&n()})},a=u=>{var p;i.add(u);let d=(p=e.get(u.target))!=null?p:new Set;d.add(u),e.set(u.target,d),n()},s=u=>{i.delete(u);let d=e.get(u.target);d&&(d.delete(u),d.size===0&&e.delete(u.target))},r=u=>{u.killed||(u.killed=!0,s(u))},o=()=>{var d,p;let u=wt();for(let g of Array.from(i)){if(g.killed||g.paused)continue;let h=u-g.startMs-g.delayMs;if(h<0)continue;let m=g.durationMs>0?h/g.durationMs:1,C=Sn(m),b=g.repeat>=0?g.repeat+1:1,f=g.repeat>0?Math.min(Math.floor(m),b-1):0;if(g.repeat>0&&m>=1){let x=m-f;C=Sn(x)}let y=g.ease(C);g.yoyo&&f%2===1&&(y=1-y);for(let x of g.props)En(g.target,x.key,x.from+(x.to-x.from)*y);g.scaleFrom&&g.scaleTo&&Cn(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*y,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*y});try{(d=g.onUpdate)==null||d.call(g)}catch{}if(m>=b){r(g);try{(p=g.onComplete)==null||p.call(g)}catch{}}}},c=(u,d,p)=>{var x;let g=Math.max(0,(typeof d.duration=="number"?d.duration:.5)*1e3),h=Math.max(0,(typeof d.delay=="number"?d.delay:0)*1e3+((x=p==null?void 0:p.delayMsOverride)!=null?x:0)),m=Xa(d.ease),C=typeof d.repeat=="number"?Math.max(0,d.repeat|0):0,b=d.yoyo===!0,f=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),y=[];for(let k of Object.keys(d)){if(f.has(k))continue;let L=d[k];typeof L=="number"&&y.push({key:k,from:Ja(u,k),to:L})}let w=An(u,d);return{target:u,startMs:wt(),delayMs:h,durationMs:g,ease:m,props:y,scaleFrom:w.from,scaleTo:w.to,repeat:C,yoyo:b,onUpdate:typeof d.onUpdate=="function"?d.onUpdate:void 0,onComplete:typeof d.onComplete=="function"?d.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},l={to(u,d){let p=c(u,d);return a(p),{kill:()=>r(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=wt())},resume:()=>{var m;if(!p.paused)return;let g=(m=p.pauseAtMs)!=null?m:wt(),h=wt()-g;p.startMs+=h,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(u,d,p){return l.set(u,d),l.to(u,p)},set(u,d){if(!u||!d)return;for(let g of Object.keys(d)){let h=d[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof h=="number"&&En(u,g,h)}let p=An(u,d);p.to&&Cn(u,p.to)},killTweensOf(u){let d=e.get(u);if(d)for(let p of Array.from(d))r(p)},timeline(u={}){let d=[],p=0,g=!1,h=[],m=f=>{if(typeof f=="number")return Math.max(0,f*1e3);let y=typeof f=="string"?f.trim():"";return y.startsWith("+=")?p+Math.max(0,Number(y.slice(2))*1e3||0):y?Math.max(0,Number(y)*1e3||0):p},C=f=>{d.push(f);let y=Math.max(0,(typeof f.vars.duration=="number"?f.vars.duration:.5)*1e3);p=Math.max(p,f.atMs+y)},b={to(f,y,w){return C({kind:"to",target:f,vars:y,atMs:m(w)}),b},fromTo(f,y,w,x){return C({kind:"fromTo",target:f,vars:w,from:y,atMs:m(x)}),b},play(){var f,y;if(g)return b;g=!0,h=[];for(let w of d)w.kind==="fromTo"&&l.set(w.target,(f=w.from)!=null?f:{}),h.push(l.to(w.target,{...w.vars,delay:w.atMs/1e3+((y=w.vars.delay)!=null?y:0)}));return b},pause(){for(let f of h)f.pause();return b},kill(){for(let f of h)f.kill();h=[],g=!1}};return u.paused||b.play(),b}};return l}function Tn(){if(typeof window=="undefined")return;let i=window;if(!i.gsap)try{i.gsap=Ln()}catch{}}var In={name:"handler-playable-sdk",version:"1.0.104",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs dist/cli/student-helper/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var te=0,es=te++,kn=te++,Pn=te++,Mn=te++,jn=te++,_n=te++,On=te++,Rn=te++,zn=te++,$n=te++,Dn=te++,Nn=te++,j=es;function Hn(){return j===kn}function Fn(){return j===Pn}function Bn(){return j===Mn}function Gn(){return j===jn}function We(){return j===_n}function Ke(){return j===On}function Un(){return j===Rn}function qn(){return j===zn}function Vn(){return j===$n}function ui(){return j===Dn}function gi(){return j===Nn}function Yn(){let i=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(i==="mraid")try{mraid.getState(),j=kn;return}catch{}else if(i==="dapi")try{dapi.isReady(),j=Pn;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(j=Mn)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(j=jn)}catch{}else if(e==="mintegral")window.gameReady&&(j=_n);else if(e==="tapjoy")window.TJ_API&&(j=On);else if(e==="tiktok")window.openAppStore&&(j=Rn);else if(e==="smadex")try{window.smxTracking&&(j=zn)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(j=$n)}catch{}else e==="vungle"?j=Dn:(i==="nucleo"||e==="nucleo")&&(j=Nn)}var Dt=ci(require("lottie-web"),1),Wn=Dt.default;typeof window!="undefined"&&(window.lottie=Dt.default,window.__baseLottie=Dt.default);mi();function D(i,e){let t=(a,s)=>s===0?a:t(s,a%s),n=t(i,e);return`${i/n}:${e/n}`}var Wr=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:D(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:D(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:D(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:D(360,780)}],Kr=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:D(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:D(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:D(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:D(412,915)}],Xr=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:D(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:D(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:D(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:D(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:D(800,1280)}],Zn=[{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:D(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:D(768,1024),mraidScale:.7}];var Jr=[...Zn];var ls=Zn[0];de();var ta=require("pixi.js"),fe={width:400,height:600,designWidth:400,scaleFactor:1},St={scale:1,position:1},Bt=[];function ds(i,e,t,n,a,s,r){Bt.push({element:i,originalScale:s,positionHelper:e,heightPercent:a}),e(i,t,n,a,s,r,!1)}function ps(){Bt.forEach(({element:i,originalScale:e,positionHelper:t,heightPercent:n})=>{let a=e*fe.scaleFactor;t(i,fe.width,fe.height,n,a,!0,!1)})}function ia(){Bt.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Ht(i,e){console.log(`[SCREEN] updateScreenState called: ${i}x${e}`),fe.width=i,fe.height=e,fe.scaleFactor=Math.min(i/fe.designWidth,1.15),St.scale=fe.scaleFactor,St.position=1,console.log(`[SCREEN] Global multipliers - scale: ${St.scale.toFixed(3)}`),ps()}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}};function us(i,e,t){let n=_[i];n&&n[e]!==void 0&&(n[e]=t,console.log(`Updated ${i}.${e} = ${t}`))}function gs(){return _}var hs={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 Nt(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function Te(i,e={x:.5,y:.5}){var t;if(Array.isArray(i))return{x:Nt(i[0],e.x),y:Nt(i[1],e.y)};if(i&&typeof i=="object"){let n=i;return{x:Nt(n.x,e.x),y:Nt(n.y,e.y)}}if(typeof i=="string"){let n=i.trim().toLowerCase();return(t=hs[n])!=null?t:e}return e}function De(i,e,t,n={}){var g,h,m,C,b,f;let a=Te(t),s=(g=n.inset)!=null?g:{},r=(h=n.padding)!=null?h:{x:0,y:0},o=((m=s.left)!=null?m:0)+r.x,c=((C=s.right)!=null?C:0)+r.x,l=((b=s.top)!=null?b:0)+r.y,u=((f=s.bottom)!=null?f:0)+r.y,d=Math.max(0,i-o-c),p=Math.max(0,e-l-u);return{x:o+d*a.x,y:l+p*a.y}}function Ne(i,e,t,n={}){var m,C,b,f,y,w;let a=(m=n.inset)!=null?m:{},s=(C=n.padding)!=null?C:{x:0,y:0},r=((b=a.left)!=null?b:0)+s.x,o=((f=a.right)!=null?f:0)+s.x,c=((y=a.top)!=null?y:0)+s.y,l=((w=a.bottom)!=null?w:0)+s.y,u=Math.max(0,i-r-o),d=Math.max(0,e-c-l),p=Te(t,{x:.5,y:.5}),g=Math.min(Math.max(p.x,0),1),h=Math.min(Math.max(p.y,0),1);return{x:r+u*g,y:c+d*h}}function Ft(i,e,t,n={}){var u,d,p;if(!i)return;let a=n.positionRatio?Ne(e,t,n.positionRatio,{inset:n.inset,padding:n.screenPadding}):De(e,t,n.anchor,{inset:n.inset,padding:n.screenPadding}),s=(u=n.offset)!=null?u:{x:0,y:0},r=a.x+s.x,o=a.y+s.y;i.anchor&&n.renderAnchor&&i.anchor.set(n.renderAnchor.x,n.renderAnchor.y),se(i,r,o);let c=(d=n.scale)!=null?d:1,l=(p=n.scaleMultiplier)!=null?p:1;(n.scale!==void 0||n.scaleMultiplier!==void 0)&&pe(i,c*l)}if(typeof window!="undefined"){let i=window.innerWidth,e=window.innerHeight,t=()=>{let n=window.innerWidth,a=window.innerHeight;(n!==i||a!==e)&&(i=n,e=a,Ht(n,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Ht(window.innerWidth,window.innerHeight),window.updateDebugConfig=us,window.getDebugConfig=gs,window.copyConfig=As,window.applyConfig=xt,window.applyConfigForRatio=Ls,window.positionAtBottom=na,window.positionAtTop=bs,window.positionAtCenter=ys,window.positionAtLeft=vs,window.positionAtRight=ws,window.positionAtBottomLeft=xs,window.positionAtBottomRight=Ss,window.positionAtTopLeft=Es,window.positionAtTopRight=Cs,window.applyPositionContract=ms,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 Gt(i,e,t=0){return i*e+t}function Ut(i,e,t=0){return i*(1-e)+t}function qt(i,e,t=0){return i*e+t}function Vt(i,e,t=0){return i*(1-e)+t}function ie(i,e=0){return i/2+e}function fs(i,e){return i*e}function ms(i,e,t,n){var r,o,c,l,u,d,p,g,h,m,C,b,f,y,w,x,k,L,B,R;let a=0,s=0;switch(n.type){case"top":a=ie(e,(o=(r=n.offset)==null?void 0:r.x)!=null?o:0),s=Gt(t,n.percent,(l=(c=n.offset)==null?void 0:c.y)!=null?l:0);break;case"bottom":a=ie(e,(d=(u=n.offset)==null?void 0:u.x)!=null?d:0),s=Ut(t,n.percent,(g=(p=n.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=qt(e,n.percent,(m=(h=n.offset)==null?void 0:h.x)!=null?m:0),s=ie(t,(b=(C=n.offset)==null?void 0:C.y)!=null?b:0);break;case"right":a=Vt(e,n.percent,(y=(f=n.offset)==null?void 0:f.x)!=null?y:0),s=ie(t,(x=(w=n.offset)==null?void 0:w.y)!=null?x:0);break;case"center":a=ie(e,(L=(k=n.offset)==null?void 0:k.x)!=null?L:0),s=ie(t,(R=(B=n.offset)==null?void 0:B.y)!=null?R:0);break}i.position?i.position.set(a,s):(i.x=a,i.y=s),n.scale!==void 0&&n.scale!==1&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(n.scale,n.scale):(i.scale.x=n.scale,i.scale.y=n.scale))}function na(i,e,t,n=.2,a=1,s=!0,r=!1){let o=fs(t,n),c=Ut(t,n/2);se(i,ie(e),c);let l=s?a*fe.scaleFactor:a;pe(i,l),r&&!Bt.find(u=>u.element===i)&&ds(i,na,e,t,n,a,s)}function bs(i,e,t,n=.1,a=1){se(i,ie(e),Gt(t,n)),pe(i,a)}function ys(i,e,t,n=0,a=0,s=1){se(i,ie(e,n),ie(t,a)),pe(i,s)}function vs(i,e,t,n=.1,a=1){se(i,qt(e,n),ie(t)),pe(i,a)}function ws(i,e,t,n=.1,a=1){se(i,Vt(e,n),ie(t)),pe(i,a)}function xs(i,e,t,n=.05,a=.05,s=1){se(i,qt(e,a),Ut(t,n)),pe(i,s)}function Ss(i,e,t,n=.05,a=.05,s=1){se(i,Vt(e,a),Ut(t,n)),pe(i,s)}function Es(i,e,t,n=.05,a=.05,s=1){se(i,qt(e,a),Gt(t,n)),pe(i,s)}function Cs(i,e,t,n=.05,a=.05,s=1){se(i,Vt(e,a),Gt(t,n)),pe(i,s)}function se(i,e,t){i&&i.position?typeof i.position.set=="function"?i.position.set(e,t):(i.position.x=e,i.position.y=t):i&&(i.x=e,i.y=t)}function pe(i,e){e!==1&&i&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(e,e):i.scale.x!==void 0&&i.scale.y!==void 0&&(i.scale.x=e,i.scale.y=e))}var $e={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function As(i){return i&&$e[i]?JSON.parse(JSON.stringify($e[i])):JSON.parse(JSON.stringify(_))}function xt(i){Object.keys(i).forEach(e=>{let t=e;_[t]&&i[t]&&Object.assign(_[t],i[t])}),console.log("Config applied:",i)}function Ls(i,e){let t=i/e;t>1.6?(xt($e.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(xt($e.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(xt($e.square),console.log("Applied SQUARE config for ratio:",t)):(xt($e.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let i=window;i.configPresets=$e,i.resolveAnchorVec2=i.resolveAnchorVec2||Te,i.resolveScreenAnchorPoint=i.resolveScreenAnchorPoint||De,i.resolveScreenRatioPoint=i.resolveScreenRatioPoint||Ne}var K=null,ea=new Map;function aa(i,e,t,n,a,s={}){var Se,Ee,Ce,Ae,Y,_e,lt,ct,dt,pt,ut,gt,ht,ft,mt,bt,F,Z,U,Q,Ue,Oe,Bi,Gi,Ui,qi,Vi,Yi,Wi,Ki,Xi,Ji,Zi,Qi,en,tn,nn,an,sn,rn,on,ln,cn,dn,pn,un,gn,hn,fn;let r=(Se=s.enableDebugLogs)!=null?Se:!1;r&&(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:",s));let{mainContainer:o,label:c,background:l,backgroundTexture:u,app:d}=i;if(!d||!d.renderer){r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width: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,g=n.height;r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:p,baseHeight:g});let h=p*_.layout.screen_scale_x,m=g*_.layout.screen_scale_y,C=p/2,b=e.engine.runtime||{},f=b.layout||{};r&&(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:h,height:m,midX:C}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",b),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",f));let y=m>h,w=(Ee=f.design_width_portrait)!=null?Ee:y?400:600,x=(Ce=f.design_height_portrait)!=null?Ce:y?600:400,k=Math.min(h/w,m/x);k=Math.min(k,1.15);let L=k*((Ae=_.engine.scale)!=null?Ae:1),B=(Y=s.skipMainContainerTransform)!=null?Y:!1;!B&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(L):(o.scale.x=L,o.scale.y=L));let R=(_e=f.main_container_anchor)!=null?_e:"center",H=(lt=f.main_container_position_ratio)!=null?lt:{x:.5,y:.5},z=(ct=f.main_container_offset)!=null?ct:{x:0,y:0},T=f.main_container_position_ratio?Ne(p,g,H):De(p,g,R),E=T.x+z.x+_.layout.position_offset.x,S=T.y+z.y+_.layout.position_offset.y;if(!B&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(E,S):(o.position.x=E,o.position.y=S)),a&&(o!=null&&o.toLocal)){let G=g>p,W=(dt=f.design_width_portrait)!=null?dt:G?320:480,N=(pt=f.design_height_portrait)!=null?pt:G?480:320;for(let[oe,le]of e.objects.entries()){let q=le==null?void 0:le.transform;if(!q||((ut=q.position_mode)!=null?ut:"static")!=="static")continue;let I=(gt=a.get)==null?void 0:gt.call(a,oe),yt=((ht=I==null?void 0:I.getDisplayObject)==null?void 0:ht.call(I))||(I==null?void 0:I.pixiObject)||I;if(!yt||yt.parent!==o)continue;let he=(ft=q.anchor)!=null?ft:"bottom-left";he==="bottom-left"&&q.anchor==null&&console.log("[DEBUG FALLBACK] LayoutManager transform.anchor \u2192 bottom-left");let qe=q.position_ratio!=null?Ne(W,N,q.position_ratio):De(W,N,he),Ve=(mt=q.position)!=null?mt:{x:0,y:0},vt=qe.x-W/2+Ve.x,Re=qe.y-N/2+Ve.y;typeof(I==null?void 0:I.setPosition)=="function"?I.setPosition(vt,Re):(se(yt,vt,Re),(bt=I==null?void 0:I.transform)!=null&&bt.position&&(I.transform.position.x=vt,I.transform.position.y=Re))}}let A=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,J=((A==null?void 0:A.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(_.layout.debug_rect_visible&&J){(!K||K.parent!==d.stage)&&(K==null||K.destroy(),K=new ta.Graphics,K.zIndex=9999,d.stage.addChild(K)),K.clear();let G=_.layout.debug_rect_scale_x,W=_.layout.debug_rect_scale_y,N=(p-4)*G,oe=(g-4)*W,le=(p-N)/2,q=(g-oe)/2;r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:N,rectH:oe,offsetX:le,offsetY:q}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+le,y:2+q,width:N,height:oe})),K.rect(2+le,2+q,N,oe).stroke({width:_.layout.debug_rect_thickness,color:_.layout.debug_rect_color})}else K&&(K.destroy(),K=null);let O=((F=i.label)==null?void 0:F.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(c&&c.position&&O){let G=(U=(Z=O==null?void 0:O.transform)==null?void 0:Z.anchor)!=null?U:"center",W=(Q=O==null?void 0:O.transform)==null?void 0:Q.position_ratio,N=((Ue=O==null?void 0:O.transform)==null?void 0:Ue.offset)||{x:0,y:0};Ft(c,p,g,{anchor:G,positionRatio:W,offset:{x:N.x*L,y:N.y*L},renderAnchor:Te(G)})}if(c&&c.alpha>0){let G=1+Math.sin(t*_.engine.label_pulse_speed)*_.engine.label_pulse_intensity,W=(Bi=(Oe=O==null?void 0:O.transform)==null?void 0:Oe.scale)!=null?Bi:1,N=G*L*W;c.scale&&(typeof c.scale.set=="function"?c.scale.set(N):(c.scale.x=N,c.scale.y=N))}r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING =====");let ne=l?e.objects.get("background_1"):null,je=!!ne&&(l==null?void 0:l.parent)===o;if(l&&!je){r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!l),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(Gi=l.constructor)==null?void 0:Gi.name)),l.alpha=((qi=(Ui=b.background)==null?void 0:Ui.alpha)!=null?qi:.98)*_.engine.background_alpha,r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",l.alpha),r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",ne);let G=(ne==null?void 0:ne.transform)||{};r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",G);let W=G.offset||{x:0,y:0},N=((Yi=(Vi=b.background)==null?void 0:Vi.offset_y)!=null?Yi:0)+_.engine.background_offset_y,oe=(Wi=G.anchor)!=null?Wi:"center",le=G.position_ratio;if(r&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:W,bgRuntimeOffsetY:N,bgScreenAnchor:oe,bgPositionRatio:le,baseWidth:p,baseHeight:g,finalScale:L}),Ft(l,p,g,{anchor:oe,positionRatio:le,offset:{x:W.x*L,y:W.y*L+N},renderAnchor:Te(oe)}),r&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:l.x,y:l.y,scaleX:(Ki=l.scale)==null?void 0:Ki.x,scaleY:(Xi=l.scale)==null?void 0:Xi.y,anchorX:(Ji=l.anchor)==null?void 0:Ji.x,anchorY:(Zi=l.anchor)==null?void 0:Zi.y,pivotX:(Qi=l.pivot)==null?void 0:Qi.x,pivotY:(en=l.pivot)==null?void 0:en.y,width:l.width,height:l.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 qe=Math.max(h/u.width,m/u.height),Ve=(nn=(tn=b.background)==null?void 0:tn.scale_multiplier)!=null?nn:1.05,vt=(an=G.scale)!=null?an:1,Re=qe*Ve*_.engine.background_scale*vt;l.scale&&(typeof l.scale.set=="function"?l.scale.set(Re):(l.scale.x=Re,l.scale.y=Re))}else l&&typeof l.clear=="function"&&(l.clear(),l.rect(-h/2,-m/2,h,m).fill({color:1444375}));let q=`${p}x${g}`,P=ea.get(q),I={x:Number((sn=l.x)!=null?sn:0),y:Number((rn=l.y)!=null?rn:0),scaleX:Number((ln=(on=l.scale)==null?void 0:on.x)!=null?ln:1),scaleY:Number((dn=(cn=l.scale)==null?void 0:cn.y)!=null?dn:1),rotation:Number.isFinite(l.rotation)?l.rotation:void 0,anchorX:Number.isFinite((pn=l.anchor)==null?void 0:pn.x)?l.anchor.x:void 0,anchorY:Number.isFinite((un=l.anchor)==null?void 0:un.y)?l.anchor.y:void 0,pivotX:Number.isFinite((gn=l.pivot)==null?void 0:gn.x)?l.pivot.x:void 0,pivotY:Number.isFinite((hn=l.pivot)==null?void 0:hn.y)?l.pivot.y:void 0},yt=Number.isFinite(I.x)&&Number.isFinite(I.y)&&Number.isFinite(I.scaleX)&&Number.isFinite(I.scaleY),he=I;if(P){let qe=Math.hypot(I.x-P.x,I.y-P.y),Ve=Math.max(p,g)*.5;(!yt||qe>Ve)&&((fn=l.position)!=null&&fn.set?l.position.set(P.x,P.y):(l.x=P.x,l.y=P.y),l.scale&&(typeof l.scale.set=="function"?l.scale.set(P.scaleX,P.scaleY):(l.scale.x=P.scaleX,l.scale.y=P.scaleY)),Number.isFinite(P.rotation)&&typeof l.rotation=="number"&&(l.rotation=P.rotation),l.anchor&&Number.isFinite(P.anchorX)&&Number.isFinite(P.anchorY)&&l.anchor.set(P.anchorX,P.anchorY),l.pivot&&Number.isFinite(P.pivotX)&&Number.isFinite(P.pivotY)&&l.pivot.set(P.pivotX,P.pivotY),he=P)}Number.isFinite(he.x)&&Number.isFinite(he.y)&&Number.isFinite(he.scaleX)&&Number.isFinite(he.scaleY)&&ea.set(q,he)}}function Ts(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Is(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}async function ks(i){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=i})}async function yi(i){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",i);let n=await fetch(i);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,i),null;let a=await n.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let s=await Ts(a),r=await ks(s),o=Is(s);return console.log("[ImageUtils] Success resolution:",r==null?void 0:r.width,"x",r==null?void 0:r.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:s,width:(e=r==null?void 0:r.width)!=null?e:0,height:(t=r==null?void 0:r.height)!=null?t:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function Yt(i,e=30){try{console.log("[ImageUtils] Removing background color...");let t=await new Promise((d,p)=>{let g=new Image;g.onload=()=>d(g),g.onerror=()=>p(new Error("Failed to load image")),g.src=i}),n=document.createElement("canvas");n.width=t.width,n.height=t.height;let a=n.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),i;a.drawImage(t,0,0);let s=a.getImageData(0,0,n.width,n.height),r=s.data,c=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(d=>({r:r[d.offset],g:r[d.offset+1],b:r[d.offset+2]})),l=0;for(let d=0;d<r.length;d+=4){let p=r[d],g=r[d+1],h=r[d+2],m=!1;for(let C of c)if(Math.sqrt(Math.pow(p-C.r,2)+Math.pow(g-C.g,2)+Math.pow(h-C.b,2))<e){m=!0;break}m&&(r[d+3]=0,l++)}return console.log(`[ImageUtils] Removed background from ${l} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(s,0,0),n.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),i}}var sa=require("@google/genai");async function vi(i,e,t=[],n={}){var a,s,r,o,c,l,u;try{if(!(i!=null&&i.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let b=0;b<t.length;b++){let f=t[b];if(!f.base64||!f.mimeType)throw new Error(`Image ${b+1} is missing required data`);if(f.base64.length<1e3&&console.warn(`Image ${b+1} data appears very small, may be corrupted`),!f.mimeType.startsWith("image/"))throw new Error(`Image ${b+1} has invalid MIME type: ${f.mimeType}`)}let d=new sa.GoogleGenAI({apiKey:i}),p="gemini-2.5-flash",g=[e];t.length>0&&t.forEach((b,f)=>{g.push({inlineData:{data:b.base64,mimeType:b.mimeType}}),console.log(`[Gemini] Added image ${f+1}: ${b.mimeType}, size: ${Math.round(b.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${t.length} images and prompt length: ${e.length}`);let h=await d.models.generateContent({model:p,contents:g}),m="",C=(r=(s=(a=h.candidates)==null?void 0:a[0])==null?void 0:s.content)==null?void 0:r.parts;if(C)for(let b of C)b.text&&(m+=b.text);if(!m.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${m.length}`),m}catch(d){throw console.error("[Gemini] API error:",d),(o=d.message)!=null&&o.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(c=d.message)!=null&&c.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(l=d.message)!=null&&l.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(u=d.message)!=null&&u.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):d}}var ra=require("@google/genai");async function Wt(i,e,t=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new ra.GoogleGenAI({apiKey:i}),s=[{text:e}];t.length>0&&t.forEach((o,c)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${c}`),s.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let r=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:s});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!r.candidates||!r.candidates[0]||!r.candidates[0].content||!r.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of r.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let c=o.inlineData.data,l=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${l};base64,${c}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(a){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(a,Object.getOwnPropertyNames(a),2)),a}}var Rs=require("pixi.js");Et();Kt();de();var ua=require("pixi.js");var $s=require("pixi.js");de();function Ws(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Ks(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}function Xs(i){return`
98
98
  Analyze these screenshots of a brand or game and extract its "Brand DNA".
99
99
 
100
100
  Provide a concise summary (2-3 sentences) covering:
@@ -1 +1 @@
1
- (function(_0x497200,_0x15791b){var a0_0x2b187e={_0x4f8d70:0x3fb,_0x2a9ca7:0x3fb,_0x1aee0b:0x405,_0x5018fa:'cYd)',_0x76f197:0x3fc,_0x5a5311:0x409,_0x222151:0x3fd,_0xfc6126:'Sbdv',_0x4c22af:0x444,_0x27f5b5:0x43d,_0x490280:'oN9S',_0x49c93e:0x449,_0x5074a0:0x445,_0x4dd5e9:0x40b,_0x231f8f:0x40a,_0x17d9d2:0x415,_0x3e8ab9:'oN9S',_0x40f1a1:0x16a,_0x56f655:0x15c,_0x3d392e:'8ZGz',_0x1c3c61:0x406,_0x38ae57:0x409,_0x5486f5:0x400,_0x270082:0x14f,_0x1010b0:0x15d,_0x4e32a3:'MHrB',_0x2879fd:0x151,_0x2072b7:0x156,_0x6d94c2:0x162,_0x278f4b:'C0U2',_0x37076b:0x15a,_0x46d0e7:0x44c,_0x32739f:0x440,_0x393e29:'HcMH',_0x55a268:0x44a,_0x289dc5:0x43b},a0_0xad2f25={_0x2b4c7f:0x3bb},a0_0x40b1c8={_0x20f8ff:0x37c},a0_0x788b1d={_0x381c13:0xd1},_0x1ec4f9=_0x497200();function _0x7fe9a4(_0x589cc5,_0x4a20b7,_0x3e75be,_0x5c4ffc,_0x23c3e0){return a0_0x452f(_0x23c3e0-a0_0x788b1d._0x381c13,_0x5c4ffc);}function _0x121c04(_0x58fa0b,_0x258f85,_0x5e6aa7,_0x346d5f,_0x38b3c2){return a0_0x452f(_0x5e6aa7-a0_0x40b1c8._0x20f8ff,_0x38b3c2);}function _0x4a84ea(_0x4417a1,_0x211e25,_0x16be1a,_0x248c68,_0x24568a){return a0_0x452f(_0x211e25-a0_0xad2f25._0x2b4c7f,_0x16be1a);}while(!![]){try{var _0x34843b=parseInt(_0x121c04(a0_0x2b187e._0x4f8d70,a0_0x2b187e._0x2a9ca7,0x402,a0_0x2b187e._0x1aee0b,a0_0x2b187e._0x5018fa))/(0x299*0x5+-0x1*-0xb8b+-0x1887)+-parseInt(_0x121c04(0x415,a0_0x2b187e._0x76f197,a0_0x2b187e._0x5a5311,a0_0x2b187e._0x222151,a0_0x2b187e._0xfc6126))/(-0x185*0xd+-0x4a*0x1c+0x1bdb)+-parseInt(_0x4a84ea(a0_0x2b187e._0x4c22af,a0_0x2b187e._0x27f5b5,a0_0x2b187e._0x490280,a0_0x2b187e._0x49c93e,a0_0x2b187e._0x5074a0))/(0x9*-0x2e9+-0x280*-0x8+0x634)+parseInt(_0x121c04(0x404,a0_0x2b187e._0x4dd5e9,a0_0x2b187e._0x231f8f,a0_0x2b187e._0x17d9d2,a0_0x2b187e._0x3e8ab9))/(0x1*0xe9b+0x178d+-0x2624)+parseInt(_0x7fe9a4(a0_0x2b187e._0x40f1a1,a0_0x2b187e._0x56f655,0x16a,a0_0x2b187e._0x3d392e,0x15d))/(0xf77*0x2+-0x1a43+-0x4a6)*(-parseInt(_0x121c04(a0_0x2b187e._0x1c3c61,a0_0x2b187e._0x38ae57,a0_0x2b187e._0x5486f5,a0_0x2b187e._0x38ae57,'VVjg'))/(0xf3*-0x29+0x7*0x3a1+0x1*0xd8a))+parseInt(_0x7fe9a4(a0_0x2b187e._0x270082,0x15c,a0_0x2b187e._0x1010b0,a0_0x2b187e._0x4e32a3,0x15c))/(-0x130+0x1708+0x15d1*-0x1)+-parseInt(_0x7fe9a4(a0_0x2b187e._0x2879fd,a0_0x2b187e._0x2072b7,a0_0x2b187e._0x6d94c2,a0_0x2b187e._0x278f4b,a0_0x2b187e._0x37076b))/(-0x930+-0x1*-0xe8b+-0x553)*(-parseInt(_0x4a84ea(a0_0x2b187e._0x46d0e7,a0_0x2b187e._0x32739f,a0_0x2b187e._0x393e29,a0_0x2b187e._0x55a268,a0_0x2b187e._0x289dc5))/(-0xc85*0x3+-0x315*-0x7+0x1005));if(_0x34843b===_0x15791b)break;else _0x1ec4f9['push'](_0x1ec4f9['shift']());}catch(_0x314e2d){_0x1ec4f9['push'](_0x1ec4f9['shift']());}}}(a0_0xfe94,-0x15ff7+-0x2ce9*0xb+-0x1940e*-0x4));var a0_0xa7b642=(function(){var _0x2c2088=!![];return function(_0x303bbc,_0x29b6c9){var a0_0x1e34f1={_0x39601c:'HcMH',_0x1d2199:0x304,_0x5a98f2:0x2fe,_0xa101c5:0x2f8},a0_0x5ce117={_0x5bc166:0x267},_0x42d62c=_0x2c2088?function(){function _0x14c392(_0x4ae0e9,_0x436df5,_0x39adaa,_0x139e2c,_0x3a9810){return a0_0x452f(_0x139e2c-a0_0x5ce117._0x5bc166,_0x4ae0e9);}if(_0x29b6c9){var _0x27ddc9=_0x29b6c9[_0x14c392(a0_0x1e34f1._0x39601c,0x30a,a0_0x1e34f1._0x1d2199,a0_0x1e34f1._0x5a98f2,a0_0x1e34f1._0xa101c5)](_0x303bbc,arguments);return _0x29b6c9=null,_0x27ddc9;}}:function(){};return _0x2c2088=![],_0x42d62c;};}()),a0_0x515b97=a0_0xa7b642(this,function(){var a0_0x38b569={_0x37cf14:0x30a,_0x1887f6:0x31f,_0x1ac85f:0x145,_0x180a04:0x14a,_0x89fa2f:0x146,_0x229500:0x149,_0x4a4fc1:0x148,_0x53a2ec:'CDuC',_0x2d59a4:0x144,_0x166205:0x14f,_0x19335e:0x161,_0x293c54:0x157,_0x207374:'rM(9',_0x330a9f:0x14d,_0x19d119:0x156,_0x40861d:0x155,_0x18636c:'cYd)',_0x56f7e9:'$A&d',_0x5dad2b:0x158,_0x383d51:'V76G',_0x1076e2:0x326,_0xb9b74b:0x328,_0x3e0732:0x31d,_0x1556c9:'HcMH',_0x4f2138:0x312,_0x58fd3c:0x306,_0x3ff722:0x2fa,_0x58497d:'WMva',_0x293ab8:0x147,_0x5a35e0:0x142,_0x1840b0:0x325,_0x5b9015:0x15f,_0x2f2a8a:0x15c,_0x14db6a:'7uF#',_0x1a587a:0x152,_0x4e2df3:0x14e},a0_0x311c79={_0x430f2a:0x1df},a0_0x5dae22={_0x36a7fe:0x285},a0_0x4f0e97={_0x3ebf41:0x1e5},_0x484880={};function _0x13f5b7(_0x434382,_0x44197c,_0x4f372a,_0xe65213,_0x23c08a){return a0_0x452f(_0x44197c- -a0_0x4f0e97._0x3ebf41,_0x4f372a);}function _0x104de1(_0x129e2a,_0x4fa99b,_0x2acebf,_0x1049d6,_0x1bb862){return a0_0x452f(_0x1049d6-a0_0x5dae22._0x36a7fe,_0x129e2a);}_0x484880[_0x104de1('kxe6',a0_0x38b569._0x37cf14,0x31d,0x317,a0_0x38b569._0x1887f6)]='(((.+'+_0x1867d4(-a0_0x38b569._0x1ac85f,-a0_0x38b569._0x180a04,'7uF#',-a0_0x38b569._0x89fa2f,-a0_0x38b569._0x229500)+'+$';var _0x5a334f=_0x484880;function _0x1867d4(_0x250bd5,_0xe41b36,_0x430a80,_0x2bcae8,_0x7f4797){return a0_0x452f(_0xe41b36- -a0_0x311c79._0x430f2a,_0x430a80);}return a0_0x515b97[_0x1867d4(-a0_0x38b569._0x4a4fc1,-0x144,a0_0x38b569._0x53a2ec,-a0_0x38b569._0x2d59a4,-a0_0x38b569._0x166205)+'ing']()[_0x1867d4(-a0_0x38b569._0x19335e,-a0_0x38b569._0x293c54,a0_0x38b569._0x207374,-a0_0x38b569._0x330a9f,-0x153)+'h'](_0x5a334f[_0x13f5b7(-a0_0x38b569._0x19d119,-a0_0x38b569._0x40861d,a0_0x38b569._0x18636c,-0x153,-0x159)])[_0x1867d4(-0x13f,-0x14c,a0_0x38b569._0x56f7e9,-a0_0x38b569._0x5dad2b,-0x13f)+_0x104de1(a0_0x38b569._0x383d51,a0_0x38b569._0x1076e2,a0_0x38b569._0xb9b74b,a0_0x38b569._0x3e0732,0x315)]()[_0x104de1(a0_0x38b569._0x1556c9,0x301,a0_0x38b569._0x4f2138,a0_0x38b569._0x58fd3c,a0_0x38b569._0x3ff722)+_0x1867d4(-0x13d,-0x145,a0_0x38b569._0x58497d,-a0_0x38b569._0x293ab8,-a0_0x38b569._0x5a35e0)+'r'](a0_0x515b97)[_0x104de1('GPp9',0x31c,0x311,0x31e,a0_0x38b569._0x1840b0)+'h'](_0x5a334f[_0x1867d4(-a0_0x38b569._0x5b9015,-a0_0x38b569._0x2f2a8a,a0_0x38b569._0x14db6a,-a0_0x38b569._0x1a587a,-a0_0x38b569._0x4e2df3)]);});function a0_0x452f(_0x4183dd,_0x4c6e9a){_0x4183dd=_0x4183dd-(0x1e7*-0xb+0x26ab+-0x113e);var _0x480872=a0_0xfe94();var _0x450013=_0x480872[_0x4183dd];if(a0_0x452f['POMabp']===undefined){var _0x14a6f3=function(_0x593063){var _0x1858a7='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0xa0c3c4='',_0x30177='',_0x4eb103=_0xa0c3c4+_0x14a6f3;for(var _0x5e9ecf=-0x1b*-0xa7+0xb*0x1b1+-0x121c*0x2,_0x4dad65,_0x4a3e85,_0x437521=0x420+-0xc*-0x43+-0x744;_0x4a3e85=_0x593063['charAt'](_0x437521++);~_0x4a3e85&&(_0x4dad65=_0x5e9ecf%(-0x1fa5+-0x3ab+-0x1c*-0x143)?_0x4dad65*(-0xc91+-0x1462+-0x1*-0x2133)+_0x4a3e85:_0x4a3e85,_0x5e9ecf++%(0x1*0x4d2+-0x4a*-0x31+-0x12f8))?_0xa0c3c4+=_0x4eb103['charCodeAt'](_0x437521+(-0x24b0+-0xe1*-0x16+0x35*0x54))-(-0x2*-0x9d+-0x10f5*0x1+0xfc5*0x1)!==-0x1ee9+-0x4ef+0x23d8?String['fromCharCode'](0x135*-0x8+-0x1d8b+0x2832&_0x4dad65>>(-(-0x1*-0x1b1d+-0x1*-0x15f5+-0x13a*0x28)*_0x5e9ecf&0x1*0x81+-0x2296+0x221b)):_0x5e9ecf:-0x1f51*-0x1+0x29d*0xd+-0x414a){_0x4a3e85=_0x1858a7['indexOf'](_0x4a3e85);}for(var _0x58683e=0x1*0x197f+-0x73b+-0x1244*0x1,_0x34fb66=_0xa0c3c4['length'];_0x58683e<_0x34fb66;_0x58683e++){_0x30177+='%'+('00'+_0xa0c3c4['charCodeAt'](_0x58683e)['toString'](-0x12ad+0x950+0x96d))['slice'](-(0x2e3+0x3c*-0x2f+0x823));}return decodeURIComponent(_0x30177);};var _0x46b9bd=function(_0x2e3dba,_0x4bcbe3){var _0x150df1=[],_0x170c34=-0x1269+0x2405+-0x2*0x8ce,_0x51df6c,_0x57e042='';_0x2e3dba=_0x14a6f3(_0x2e3dba);var _0x24791c;for(_0x24791c=0x1*-0x527+-0x18b+0x6b2;_0x24791c<-0xcdf*-0x2+0x4a3*0x2+-0x2204;_0x24791c++){_0x150df1[_0x24791c]=_0x24791c;}for(_0x24791c=0x1f7e+-0xca*-0x8+-0x25ce;_0x24791c<0xfe+-0x1*-0x1d6e+-0x1d6c;_0x24791c++){_0x170c34=(_0x170c34+_0x150df1[_0x24791c]+_0x4bcbe3['charCodeAt'](_0x24791c%_0x4bcbe3['length']))%(-0x10a9+-0x2483+-0x1*-0x362c),_0x51df6c=_0x150df1[_0x24791c],_0x150df1[_0x24791c]=_0x150df1[_0x170c34],_0x150df1[_0x170c34]=_0x51df6c;}_0x24791c=0x7d8*0x2+-0x669+-0x13*0x7d,_0x170c34=-0x154b+-0x1*-0x2284+-0xd39;for(var _0x41704a=0xfad*-0x1+-0xa71+-0xd0f*-0x2;_0x41704a<_0x2e3dba['length'];_0x41704a++){_0x24791c=(_0x24791c+(-0x1ae+0x17c0+-0x1*0x1611))%(-0x25b*0x2+0xecc+0x2*-0x48b),_0x170c34=(_0x170c34+_0x150df1[_0x24791c])%(-0x11ba+0xbd2*-0x3+0x3630),_0x51df6c=_0x150df1[_0x24791c],_0x150df1[_0x24791c]=_0x150df1[_0x170c34],_0x150df1[_0x170c34]=_0x51df6c,_0x57e042+=String['fromCharCode'](_0x2e3dba['charCodeAt'](_0x41704a)^_0x150df1[(_0x150df1[_0x24791c]+_0x150df1[_0x170c34])%(-0x7ed+-0x8ae+0x119b*0x1)]);}return _0x57e042;};a0_0x452f['fLaGlk']=_0x46b9bd,a0_0x452f['OlgvPC']={},a0_0x452f['POMabp']=!![];}var _0x1dca9a=_0x480872[0x3*0x4ec+-0x2c*0x1f+-0x1*0x970],_0x55701e=_0x4183dd+_0x1dca9a,_0xfa2216=a0_0x452f['OlgvPC'][_0x55701e];if(!_0xfa2216){if(a0_0x452f['GtlMjf']===undefined){var _0x187d84=function(_0x5aacad){this['MwFZJf']=_0x5aacad,this['pUAxsh']=[0x201a+0x1669+-0x3682,0x16b7+-0xf8a+0x1*-0x72d,-0x1a2*-0xb+-0x1709+0x513*0x1],this['rlzPlw']=function(){return'newState';},this['iIvLbA']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['jpgZRI']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x187d84['prototype']['IpMDdb']=function(){var _0x2d920d=new RegExp(this['iIvLbA']+this['jpgZRI']),_0x2c77a8=_0x2d920d['test'](this['rlzPlw']['toString']())?--this['pUAxsh'][-0x169f+0x13*-0x6b+0x1e91*0x1]:--this['pUAxsh'][0x262a+-0x3b7+-0x2273];return this['eXVCYO'](_0x2c77a8);},_0x187d84['prototype']['eXVCYO']=function(_0x1d9470){if(!Boolean(~_0x1d9470))return _0x1d9470;return this['iqzjRg'](this['MwFZJf']);},_0x187d84['prototype']['iqzjRg']=function(_0x4a05c7){for(var _0x3b7fe2=-0xc9*-0x14+-0x1d1d+0xd69,_0xaa7561=this['pUAxsh']['length'];_0x3b7fe2<_0xaa7561;_0x3b7fe2++){this['pUAxsh']['push'](Math['round'](Math['random']())),_0xaa7561=this['pUAxsh']['length'];}return _0x4a05c7(this['pUAxsh'][0x140*0x10+0xa7e+-0x1e7e]);},new _0x187d84(a0_0x452f)['IpMDdb'](),a0_0x452f['GtlMjf']=!![];}_0x450013=a0_0x452f['fLaGlk'](_0x450013,_0x4c6e9a),a0_0x452f['OlgvPC'][_0x55701e]=_0x450013;}else _0x450013=_0xfa2216;return _0x450013;}function a0_0xfe94(){var _0x3c9474=['WO7cUSotfSoj','W44FWP9dWQ0','s8o1prRdISkqjttdUSkeW4G','W4/cP8keor4','FCoZW511W5j+iSkFySof','W4tdMmoIDru','zuq9','mmk9WPjTWRi','m8otcaRdGq','eH/cOeaE','W7mRF8kDW50xnCk0w2u','W4BdH8o8AHG','udeowwmea8kNaL7dRt8','WP/dUCoeueq','xcvjcuJdUCoAWQf3W7G','WPtcM8kRla1/rYVcHhS','WQNdGmkIFJ84W7RcN8oWW5pdLG','vZipWQ7cRsP4lSkCWQvtFW','W5zyW5VdJr4','owtdIhpcSmo8WRxcL3JcPq','A8oizmopW6FdGCkFlmkeCW','FCoZW59/WO8eACkVv8oSW6yNya','AxHmWQzldYFcSCoLgq','jZONwCoLW7NcLmo/WRWqA8kQ','vZyduM4jECkLfexdMbTk','W4vvWPBcLhNdLsRcPCoPW7qTWR8','W6hcGCo9d3G','WQNdH8kTFJn1WPRcNmoXW6FdNCodW64'];a0_0xfe94=function(){return _0x3c9474;};return a0_0xfe94();}a0_0x515b97();import{A as a0_0x1937c6,B as a0_0x5ba70d,C as a0_0xe9a510,D as a0_0xc2d9b2,b as a0_0x38f92c,c as a0_0x2ae331,d as a0_0x296624,e as a0_0x2dce6f,f as a0_0x485c20,g as a0_0x45ad63,h as a0_0x1f1747,i as a0_0x25b2df,j as a0_0x4f1c12,k as a0_0x3b01d2,l as a0_0x3c7de6,m as a0_0x6750ad,n as a0_0x2fc363,o as a0_0x4e1c8d,p as a0_0x1db4c6,q as a0_0x56209d,r as a0_0x376437,s as a0_0x251589,t as a0_0x40ca6e,u as a0_0xe8ef0c,v as a0_0x9010d6,w as a0_0x30e6de,x as a0_0x539c1c,y as a0_0x508957,z as a0_0x46f7db}from'../chunk-NOMTJOWU.js';import'../chunk-NSZ7GCS3.js';import{a as a0_0x2c96e4,b as a0_0x20caff,c as a0_0x1b5a4b,d as a0_0x31f919,e as a0_0x2acf01}from'../chunk-I5OOVR5U.js';import'../chunk-FOTLNUIS.js';import'../chunk-2MR65LDX.js';import'../chunk-E6WJCS24.js';import'../chunk-JXBG6UFL.js';export{a0_0x2c96e4 as AssetCache,a0_0x1b5a4b as AssetLoader,a0_0xe8ef0c as AssetSystem,a0_0x31f919 as AssetTextures,a0_0x251589 as Assets,a0_0x4e1c8d as BaseSystem,a0_0x2fc363 as GameEngine,a0_0x2dce6f as GameObject,a0_0x485c20 as GameObjectManager,a0_0x6750ad as ObjectFactory,a0_0x296624 as Renderer,a0_0x1db4c6 as RuntimeObjectRegistry,a0_0x2ae331 as Transform,a0_0x5ba70d as applyScreenAnchor,a0_0x56209d as basePixi,a0_0x30e6de as clearResponsiveElements,a0_0x38f92c as createPixiBase,a0_0x4f1c12 as getRegisteredFontIds,a0_0x9010d6 as globalResponsiveMultipliers,a0_0x2acf01 as initAssetTextures,a0_0x40ca6e as initAssets,a0_0xe9a510 as layout,a0_0x3c7de6 as playLottieOverlay,a0_0x25b2df as registerFont,a0_0x20caff as registerType,a0_0x508957 as resolveAnchorVec2,a0_0x45ad63 as resolveFont,a0_0x1f1747 as resolveFontWeight,a0_0x46f7db as resolveScreenAnchorPoint,a0_0x1937c6 as resolveScreenRatioPoint,a0_0xc2d9b2 as runInitSequence,a0_0x3b01d2 as setLottieInstance,a0_0x376437 as spawnSceneFromConfig,a0_0x539c1c as updateScreenState};
1
+ (function(_0x6ec1e3,_0x2244e0){var a0_0x558fd2={_0x55b759:0x187,_0x1605fd:0x191,_0xb0c8b0:0x18c,_0x2b8549:0x18a,_0x28e382:'JY[c',_0x27b739:'wgnH',_0x181bb4:0x6b,_0x542af8:0x74,_0x2efc4b:0x188,_0x38ccb3:0x192,_0x112eea:'D0Q0',_0x39a6ab:0x196,_0x4bb293:0x197,_0x31ac21:0x18b,_0x5ad13c:'O5qQ',_0x5ee4ae:0x189,_0x5124a8:0x17d,_0x3c922d:'kRF2',_0x4c65cb:0x19a,_0x407b0e:0x1a2,_0x255bcc:'y#xG',_0x2456d0:0x8c,_0xf4b594:0x8f,_0x4037e5:'vqD^',_0x1b5663:0x72,_0x261497:0x7e,_0x451365:0x69,_0x54628f:0x1aa,_0x3a3158:0x1b9,_0x5d484c:0x1af,_0x2469a3:0x18f,_0x2756e2:0x19b},a0_0x50ada3={_0x11d544:0x9c},a0_0x449715={_0x268e94:0x8e};function _0x25e0bb(_0x2e5688,_0xcfcf52,_0x5e5528,_0x54b3d2,_0x25544b){return a0_0x2512(_0x5e5528- -a0_0x449715._0x268e94,_0x2e5688);}function _0x80628d(_0x21d01a,_0xc65bb8,_0x2acdf9,_0x5ce42b,_0x5f45a4){return a0_0x2512(_0x5ce42b-a0_0x50ada3._0x11d544,_0x2acdf9);}function _0x44540e(_0x19730b,_0x30a56d,_0x4dbdd8,_0x13999d,_0x3847ef){return a0_0x2512(_0x19730b- -0x291,_0x3847ef);}var _0xa217b9=_0x6ec1e3();while(!![]){try{var _0x1408c3=-parseInt(_0x44540e(-a0_0x558fd2._0x55b759,-a0_0x558fd2._0x1605fd,-a0_0x558fd2._0xb0c8b0,-a0_0x558fd2._0x2b8549,a0_0x558fd2._0x28e382))/(-0x997*-0x2+-0x69a*0x4+0x73b)+-parseInt(_0x25e0bb(a0_0x558fd2._0x27b739,0x66,0x6e,a0_0x558fd2._0x181bb4,a0_0x558fd2._0x542af8))/(0x1127+-0x1b75+-0x30*-0x37)*(parseInt(_0x44540e(-a0_0x558fd2._0x2efc4b,-0x195,-0x183,-a0_0x558fd2._0x38ccb3,a0_0x558fd2._0x112eea))/(-0x1*-0x24d4+-0xfe9+-0x14e8))+-parseInt(_0x44540e(-a0_0x558fd2._0x2b8549,-a0_0x558fd2._0x39a6ab,-a0_0x558fd2._0x4bb293,-a0_0x558fd2._0x31ac21,a0_0x558fd2._0x5ad13c))/(-0xc*-0x15f+0x1600+-0x2670)*(parseInt(_0x44540e(-a0_0x558fd2._0x5ee4ae,-0x188,-a0_0x558fd2._0x5124a8,-0x17d,a0_0x558fd2._0x3c922d))/(0x1*0x25f9+0x1e08+-0x43fc))+parseInt(_0x80628d(a0_0x558fd2._0x4c65cb,0x19f,'qS]7',a0_0x558fd2._0x407b0e,0x1a7))/(0x2*0x33d+-0x397*-0x8+-0x232c)+-parseInt(_0x25e0bb(a0_0x558fd2._0x255bcc,a0_0x558fd2._0x2456d0,0x81,a0_0x558fd2._0xf4b594,0x81))/(0x1*-0x352+0xfaa+0x41b*-0x3)+parseInt(_0x25e0bb(a0_0x558fd2._0x4037e5,0x6e,a0_0x558fd2._0x1b5663,a0_0x558fd2._0x261497,a0_0x558fd2._0x451365))/(0x16d2+-0x1*0x21d7+0xb0d)*(-parseInt(_0x80628d(a0_0x558fd2._0x54628f,a0_0x558fd2._0x3a3158,'a@lP',a0_0x558fd2._0x5d484c,0x1ae))/(-0x4d*0x6a+0x1a5*-0x7+-0x1*-0x2b6e))+parseInt(_0x44540e(-a0_0x558fd2._0x2469a3,-0x191,-0x191,-a0_0x558fd2._0x2756e2,a0_0x558fd2._0x27b739))/(0x639+0x20d2+0x2701*-0x1);if(_0x1408c3===_0x2244e0)break;else _0xa217b9['push'](_0xa217b9['shift']());}catch(_0x373749){_0xa217b9['push'](_0xa217b9['shift']());}}}(a0_0x34da,-0x1f*0x1741+-0x23dc3+-0x1bd7*-0x3e));var a0_0x22bc30=(function(){var _0x55cfed=!![];return function(_0x140ebf,_0x40fc80){var _0x483cc5=_0x55cfed?function(){if(_0x40fc80){var _0x490377=_0x40fc80['apply'](_0x140ebf,arguments);return _0x40fc80=null,_0x490377;}}:function(){};return _0x55cfed=![],_0x483cc5;};}()),a0_0x4163eb=a0_0x22bc30(this,function(){var a0_0x6978e3={_0x26276a:0x111,_0x1e82be:0x104,_0x2e0742:0x10e,_0x285eb3:0x106,_0x4033be:0x18,_0x5ae03d:'vqD^',_0x150e52:0xf,_0x4e4c8f:0x11,_0x31bdab:0x130,_0x2b753b:0x128,_0x1f49e0:'y#xG',_0x1cfebd:0x113,_0x5ae250:0x12b,_0x2a8e4d:0x11d,_0x42d314:'wgnH',_0xf52671:0x26,_0x49405a:'7&PA',_0x50405e:0x22,_0x49e1e6:0x12d,_0xa5a657:0x123,_0x3b1a1e:'sjdH',_0x546411:0x1f,_0x277015:'qS]7',_0x1bc421:0x26,_0x1defc6:0x16,_0x32f73c:'63!I',_0x1299a1:0x27,_0x42b200:0x1b,_0x550eec:0x11e,_0x32a4b7:0x126,_0x5146a9:'6b^l'},a0_0x449da3={_0x2b6f92:0xd},a0_0x8befe3={_0x5c3d44:0x22b},a0_0x483470={_0x17cd74:0xec};function _0x1da739(_0xdcd221,_0x4e2125,_0x485a3d,_0x2a72a1,_0x40b99a){return a0_0x2512(_0xdcd221- -a0_0x483470._0x17cd74,_0x4e2125);}var _0x44f996={};function _0x1ab1c4(_0x306d50,_0x59ce1d,_0x3ad5e1,_0x57c068,_0x250b01){return a0_0x2512(_0x57c068- -a0_0x8befe3._0x5c3d44,_0x250b01);}_0x44f996[_0x532011('nUbx',a0_0x6978e3._0x26276a,a0_0x6978e3._0x1e82be,a0_0x6978e3._0x2e0742,a0_0x6978e3._0x285eb3)]='(((.+'+_0x1da739(a0_0x6978e3._0x4033be,a0_0x6978e3._0x5ae03d,0x1a,a0_0x6978e3._0x150e52,a0_0x6978e3._0x4e4c8f)+'+$';function _0x532011(_0x30252a,_0xbb2716,_0x3a1c58,_0x4a9d2d,_0x188ef7){return a0_0x2512(_0x4a9d2d-a0_0x449da3._0x2b6f92,_0x30252a);}var _0x13d43c=_0x44f996;return a0_0x4163eb[_0x1ab1c4(-a0_0x6978e3._0x31bdab,-0x12d,-0x128,-a0_0x6978e3._0x2b753b,a0_0x6978e3._0x1f49e0)+_0x1ab1c4(-0x11d,-a0_0x6978e3._0x1cfebd,-a0_0x6978e3._0x5ae250,-a0_0x6978e3._0x2a8e4d,a0_0x6978e3._0x42d314)]()['searc'+'h'](_0x13d43c['OGWZn'])['toStr'+_0x1da739(a0_0x6978e3._0xf52671,a0_0x6978e3._0x49405a,0x2b,a0_0x6978e3._0x50405e,0x26)]()[_0x1ab1c4(-0x136,-a0_0x6978e3._0x49e1e6,-a0_0x6978e3._0xa5a657,-0x130,a0_0x6978e3._0x3b1a1e)+_0x1da739(a0_0x6978e3._0x546411,a0_0x6978e3._0x277015,a0_0x6978e3._0x1bc421,0x1a,a0_0x6978e3._0x1defc6)+'r'](a0_0x4163eb)['searc'+'h'](_0x1da739(0x20,a0_0x6978e3._0x32f73c,a0_0x6978e3._0x1299a1,a0_0x6978e3._0x42b200,0x17)+_0x1ab1c4(-0x121,-0x131,-a0_0x6978e3._0x550eec,-a0_0x6978e3._0x32a4b7,a0_0x6978e3._0x5146a9)+'+$');});a0_0x4163eb();import{A as a0_0x4690a7,B as a0_0x41f949,C as a0_0x32970e,D as a0_0x41340c,b as a0_0x26210a,c as a0_0x2ef5de,d as a0_0x278d50,e as a0_0x5bf7c3,f as a0_0x5acb4f,g as a0_0x3db07a,h as a0_0x1b68f9,i as a0_0x40f8ef,j as a0_0x133459,k as a0_0x529ce1,l as a0_0x476638,m as a0_0x39ea9f,n as a0_0x289978,o as a0_0x23cccb,p as a0_0x3120a4,q as a0_0x3e105d,r as a0_0x1f505a,s as a0_0xf43197,t as a0_0x418ffc,u as a0_0x1d9e12,v as a0_0x52da72,w as a0_0x17f9f5,x as a0_0x1d2add,y as a0_0x534180,z as a0_0x270b13}from'../chunk-M4ULXPTP.js';import'../chunk-NSZ7GCS3.js';import{a as a0_0x44ef53,b as a0_0x44a225,c as a0_0x382def,d as a0_0x4e0f00,e as a0_0x10b869}from'../chunk-I5OOVR5U.js';import'../chunk-FL4VTM6W.js';import'../chunk-2MR65LDX.js';function a0_0x34da(){var _0x33e762=['WRz4WOu5W6xdS3NdHYKJ','tSoiW5fkA1tdQc7dPCov','WOJdH8k7W7ZdRG','WO0wWRWlCmoMjCkQW6W','g8omW7NdSCo0WOddIq','z0ZcPSkHBSk5WOZdJI1deSko','W7S2WR0ZW5rKcmoXrmkHmrFcPq','lCorW4i4W6D4W7a','W653W7/cGdu','WOWyWR5RcSk/ECk7W6GcWPFdMaG','texdLK4Q','pmkFWOX0WP0','iYChWPyO','D01RWQ/dN3BcGh1HC8kDW7yV','xrSrsG5pymkMEa','qCkOqCkZrsddJ3GKvG','vmkUhWVdOsO3oSk/WOy','vCoCW5zAgK90WOJdOCkW','naO9W6pcIa','uu7cQmoktW','yulcP8ochSoMWRtdHHu','W5zoW60','dblcSG9QEgL9W5lcHfL4','s8ogW5a3qNhdKZldGa','W5NcNCoNWRNdNSoZn8orW4NdUG','rcTf','xKDLW6tcSeabW5WfpdlcSSo4','jmkgWPbNWOWAWOWdhSkXD8kQW68'];a0_0x34da=function(){return _0x33e762;};return a0_0x34da();}import'../chunk-E6WJCS24.js';import'../chunk-JXBG6UFL.js';function a0_0x2512(_0x379836,_0x52be06){_0x379836=_0x379836-(0x3*-0x95f+-0x1fc8+-0x4*-0xf38);var _0x5c06f2=a0_0x34da();var _0x472255=_0x5c06f2[_0x379836];if(a0_0x2512['pklvmG']===undefined){var _0x3c9dcc=function(_0x4c594f){var _0x33966c='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x15724d='',_0x52c75a='',_0x51c172=_0x15724d+_0x3c9dcc;for(var _0x4b8b11=0x8e1*-0x4+0xc2f+0x1755,_0x6631c5,_0x1ca677,_0x5cb6c4=-0x3c7+-0x12f*-0x1b+-0x1c2e*0x1;_0x1ca677=_0x4c594f['charAt'](_0x5cb6c4++);~_0x1ca677&&(_0x6631c5=_0x4b8b11%(-0x182d+-0x6e6+0x1f17)?_0x6631c5*(0xa75*0x1+0x1*0x1c6a+-0x269f)+_0x1ca677:_0x1ca677,_0x4b8b11++%(0x1ee3*0x1+-0x5be+-0x1*0x1921))?_0x15724d+=_0x51c172['charCodeAt'](_0x5cb6c4+(-0x1*0x23ba+-0x1799+-0x3b5d*-0x1))-(-0x1*-0x572+0x3*0x256+-0xc6a)!==0x2623+0x1965+0xd6*-0x4c?String['fromCharCode'](-0x4*-0x41b+0x1*0xc51+-0x1bbe&_0x6631c5>>(-(-0x2346+0xb53*-0x1+0x2e9b)*_0x4b8b11&-0x2ab+0x1be9+-0x1938)):_0x4b8b11:-0x5*-0x2ed+0x1*0x338+-0x11d9){_0x1ca677=_0x33966c['indexOf'](_0x1ca677);}for(var _0x2cabd1=-0xffa+0xb*-0x129+0x7*0x41b,_0x1fc239=_0x15724d['length'];_0x2cabd1<_0x1fc239;_0x2cabd1++){_0x52c75a+='%'+('00'+_0x15724d['charCodeAt'](_0x2cabd1)['toString'](0x2131+0x1*0x259d+0xa*-0x713))['slice'](-(0x261+0xe5a+-0x10b9));}return decodeURIComponent(_0x52c75a);};var _0x42ce8d=function(_0x8c6dff,_0x21a389){var _0x57a936=[],_0x17f7e7=-0x25*-0xfb+-0x2351*-0x1+0x74*-0x9e,_0x37fe58,_0x50664a='';_0x8c6dff=_0x3c9dcc(_0x8c6dff);var _0x4ff9e2;for(_0x4ff9e2=0x861+0x1*-0x5cf+-0x292;_0x4ff9e2<-0x1a91+-0x17*-0xa3+0xcec;_0x4ff9e2++){_0x57a936[_0x4ff9e2]=_0x4ff9e2;}for(_0x4ff9e2=0x14*0x175+0x31*-0x25+-0x160f;_0x4ff9e2<0x7cf*0x4+0x3d*-0x5f+-0x799;_0x4ff9e2++){_0x17f7e7=(_0x17f7e7+_0x57a936[_0x4ff9e2]+_0x21a389['charCodeAt'](_0x4ff9e2%_0x21a389['length']))%(-0x2628+-0x16a+-0x6*-0x6c3),_0x37fe58=_0x57a936[_0x4ff9e2],_0x57a936[_0x4ff9e2]=_0x57a936[_0x17f7e7],_0x57a936[_0x17f7e7]=_0x37fe58;}_0x4ff9e2=-0x3*0xa21+-0x8*0x14e+0x28d3,_0x17f7e7=-0x23df*0x1+0xde3+0x15*0x10c;for(var _0x2d72f3=0x1a8*-0x3+-0x34*-0x33+-0x564;_0x2d72f3<_0x8c6dff['length'];_0x2d72f3++){_0x4ff9e2=(_0x4ff9e2+(-0x1f*-0x14+-0xd3a*-0x2+0x1cdf*-0x1))%(0x130c+-0x10e1+-0x12b),_0x17f7e7=(_0x17f7e7+_0x57a936[_0x4ff9e2])%(0x3*0x4ba+0x7e4+-0x1512),_0x37fe58=_0x57a936[_0x4ff9e2],_0x57a936[_0x4ff9e2]=_0x57a936[_0x17f7e7],_0x57a936[_0x17f7e7]=_0x37fe58,_0x50664a+=String['fromCharCode'](_0x8c6dff['charCodeAt'](_0x2d72f3)^_0x57a936[(_0x57a936[_0x4ff9e2]+_0x57a936[_0x17f7e7])%(0x1e87+0xaed+-0x2*0x143a)]);}return _0x50664a;};a0_0x2512['qoDqqr']=_0x42ce8d,a0_0x2512['KyIpKd']={},a0_0x2512['pklvmG']=!![];}var _0x1334a6=_0x5c06f2[-0xc9*-0x11+0x2*0xee6+-0x2b25],_0x2bb8ab=_0x379836+_0x1334a6,_0x2ba2e2=a0_0x2512['KyIpKd'][_0x2bb8ab];if(!_0x2ba2e2){if(a0_0x2512['Oskixa']===undefined){var _0x374909=function(_0x57bf9b){this['tJjGCc']=_0x57bf9b,this['iDvHaC']=[-0x202a+0x1cf3*-0x1+0x3d1e*0x1,-0xe41+-0x252c+0xa49*0x5,0x210a+-0x21b5*-0x1+-0x989*0x7],this['WkAFpB']=function(){return'newState';},this['krVtyh']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['WMXWCi']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x374909['prototype']['sRUtOz']=function(){var _0x201b4a=new RegExp(this['krVtyh']+this['WMXWCi']),_0x1e57ad=_0x201b4a['test'](this['WkAFpB']['toString']())?--this['iDvHaC'][-0x336*-0x1+-0x1e16+-0x3d7*-0x7]:--this['iDvHaC'][-0x25*0x57+-0x17*0x39+-0x1*-0x11b2];return this['HYjYDf'](_0x1e57ad);},_0x374909['prototype']['HYjYDf']=function(_0x5d365f){if(!Boolean(~_0x5d365f))return _0x5d365f;return this['AejVjT'](this['tJjGCc']);},_0x374909['prototype']['AejVjT']=function(_0x5d0863){for(var _0x7db33f=0x95*-0x11+-0x2*0x793+0x190b,_0xffc214=this['iDvHaC']['length'];_0x7db33f<_0xffc214;_0x7db33f++){this['iDvHaC']['push'](Math['round'](Math['random']())),_0xffc214=this['iDvHaC']['length'];}return _0x5d0863(this['iDvHaC'][0x199*-0x17+-0x25f9*-0x1+-0x13a]);},new _0x374909(a0_0x2512)['sRUtOz'](),a0_0x2512['Oskixa']=!![];}_0x472255=a0_0x2512['qoDqqr'](_0x472255,_0x52be06),a0_0x2512['KyIpKd'][_0x2bb8ab]=_0x472255;}else _0x472255=_0x2ba2e2;return _0x472255;}export{a0_0x44ef53 as AssetCache,a0_0x382def as AssetLoader,a0_0x1d9e12 as AssetSystem,a0_0x4e0f00 as AssetTextures,a0_0xf43197 as Assets,a0_0x23cccb as BaseSystem,a0_0x289978 as GameEngine,a0_0x5bf7c3 as GameObject,a0_0x5acb4f as GameObjectManager,a0_0x39ea9f as ObjectFactory,a0_0x278d50 as Renderer,a0_0x3120a4 as RuntimeObjectRegistry,a0_0x2ef5de as Transform,a0_0x41f949 as applyScreenAnchor,a0_0x3e105d as basePixi,a0_0x17f9f5 as clearResponsiveElements,a0_0x26210a as createPixiBase,a0_0x133459 as getRegisteredFontIds,a0_0x52da72 as globalResponsiveMultipliers,a0_0x10b869 as initAssetTextures,a0_0x418ffc as initAssets,a0_0x32970e as layout,a0_0x476638 as playLottieOverlay,a0_0x40f8ef as registerFont,a0_0x44a225 as registerType,a0_0x534180 as resolveAnchorVec2,a0_0x3db07a as resolveFont,a0_0x1b68f9 as resolveFontWeight,a0_0x270b13 as resolveScreenAnchorPoint,a0_0x4690a7 as resolveScreenRatioPoint,a0_0x41340c as runInitSequence,a0_0x529ce1 as setLottieInstance,a0_0x1f505a as spawnSceneFromConfig,a0_0x1d2add as updateScreenState};
@@ -94,7 +94,7 @@
94
94
  <button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
95
95
  </div>
96
96
  </div>
97
- `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.image&&this.image.naturalWidth>0&&this.image.naturalHeight>0?(console.log("[AssetCropModal] Image loaded:",this.image.naturalWidth,"x",this.image.naturalHeight),this.initializeCrop(),this.render()):(console.error("[AssetCropModal] Image loaded but invalid dimensions"),this.showError("Failed to load image"))},this.image.onerror=e=>{console.error("[AssetCropModal] Image load error:",e),this.showError("Failed to load image. Please check the image URL.")},this.image.src=this.options.imageSrc,this.canvas&&this.ctx&&(this.ctx.fillStyle="rgba(128, 128, 128, 0.3)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 255, 255, 0.7)",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText("Loading image...",this.canvas.width/2,this.canvas.height/2)))}showError(e){var i;if(!this.canvas||!this.ctx)return;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 0, 0, 0.2)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="#ff4444",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText(e,this.canvas.width/2,this.canvas.height/2);let n=(i=this.modal)==null?void 0:i.querySelector(".asset-crop-preview-canvas");if(n){let a=n.getContext("2d");a&&(a.fillStyle="rgba(255, 0, 0, 0.2)",a.fillRect(0,0,n.width,n.height))}}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,n=this.canvas.width/this.canvas.height;e>n?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*n,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/n,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let n=this.image.width/this.image.height,i=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>n?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,i-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,n=this.canvas.height/this.cropHeight;this.scale=Math.min(e,n)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){if(!(!this.ctx||!this.canvas)){if(!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0){console.warn("[AssetCropModal] Image not ready for rendering"),this.showError("Image not loaded");return}this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);try{this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore()}catch(e){console.error("[AssetCropModal] Error drawing image:",e),this.showError("Error drawing image");return}this.drawCropOverlay(),this.updatePreview()}}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,n=this.panY,i=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,n,i,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,n,i,a),this.ctx.fillStyle="#ffffff";let s=8;[[e,n],[e+i-s,n],[e,n+a-s],[e+i-s,n+a-s]].forEach(([r,l])=>{var d;(d=this.ctx)==null||d.fillRect(r,l,s,s)})}updatePreview(){if(!this.modal||!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let n=e.getContext("2d");if(!n)return;let i=150;e.width=i,e.height=i,n.clearRect(0,0,i,i);let a=i/this.cropWidth,s=i/this.cropHeight,o=Math.min(a,s),r=this.cropWidth*o,l=this.cropHeight*o,d=(i-r)/2,p=(i-l)/2;try{n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,d,p,r,l)}catch(c){console.error("[AssetCropModal] Error drawing preview:",c),n.fillStyle="rgba(255, 0, 0, 0.2)",n.fillRect(0,0,i,i)}}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",i=>{let a=parseFloat(i.target.value);this.setZoom(a)});let n=this.modal.querySelector(".asset-crop-aspect-select");n==null||n.addEventListener("change",i=>{let a=i.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let n=e.clientX-this.dragStartX,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+n,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let n=e.deltaY>0?.9:1.1;this.setZoom(this.scale*n)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let n=e.touches[0].clientX-this.dragStartX,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+n,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let n;switch(e){case"1:1":n=1;break;case"4:3":n=4/3;break;case"16:9":n=16/9;break;case"3:2":n=3/2;break;default:n=void 0}n&&this.applyAspectRatio(n),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),n=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),n&&(n.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,n=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-n,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),n=e.getContext("2d");if(!n)return;e.width=this.cropWidth,e.height=this.cropHeight,n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let i=e.toDataURL("image/png");this.options.onCrop(i),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(t){new kn().open(t)}});var il={};da(il,{AspectClass:()=>Dn,GameObject:()=>ct,GameObjectManager:()=>Ht,Renderer:()=>lt,ResponsiveUISystem:()=>Ue,Transform:()=>rt,animateHandClick:()=>Es,animatePanelEntrance:()=>Ss,createBrushTexture:()=>Ps,createEndGamePanel:()=>xs,createHandTutorial:()=>Cs,createThreeBase:()=>bs,createTutorialLabel:()=>As,getAspectClass:()=>Dt,getRegisteredFontIds:()=>ws,loadAsset:()=>Fn,loadCharacterFrames:()=>Is,registerFont:()=>vs,resolveFont:()=>te,resolveFontWeight:()=>ne,updateHandAnimation:()=>Ts});module.exports=Co(il);var W=he(require("three"),1);var ge={};function bt(t,e,n=!1){ge[t]||(ge[t]=[]),ge[t].push({fn:e,once:n})}function Zt(t,e){if(ge[t]){if(!e){delete ge[t];return}ge[t]=ge[t].filter(n=>n.fn!==e)}}function vt(t,...e){let n=ge[t];if(n)for(let i of[...n])i.fn(...e),i.once&&Zt(t,i.fn)}function B(t,e){bt(t,e,!0)}var P=null,V=[],Me=null;function ga(t){P=t,V=[],Me!==null&&(clearTimeout(Me),Me=null)}function fa(){var t,e,n;return{endpoint:(P==null?void 0:P.endpoint)||"",transport:(P==null?void 0:P.transport)||"beacon",batchSize:(t=P==null?void 0:P.batchSize)!=null?t:10,flushIntervalMs:(e=P==null?void 0:P.flushIntervalMs)!=null?e:300,maxQueue:(n=P==null?void 0:P.maxQueue)!=null?n:200,debug:!!(P!=null&&P.debug)}}async function ua(t,e,n,i){let a=JSON.stringify(e);if(n==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let s=navigator.sendBeacon(t,new Blob([a],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",s,e);return}catch(s){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",s)}try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(s){i&&console.warn("[handler.telemetry] fetch failed",s)}}function Qt(t,e){let n=fa();if(e&&n.endpoint){if(V.push(t),V.length>n.maxQueue&&(V=V.slice(V.length-n.maxQueue)),V.length>=n.batchSize){ha();return}Me===null&&(Me=window.setTimeout(()=>{Me=null,ha()},n.flushIntervalMs))}}async function ha(){let t=fa();if(!t.endpoint||V.length===0)return;let e=V.splice(0,t.batchSize);await ua(t.endpoint,{events:e},t.transport,t.debug),V.length>0&&await ua(t.endpoint,{events:V.splice(0,t.batchSize)},t.transport,t.debug)}function ma(t){return Math.max(0,Math.min(1,t))}function Ao(t){let e=String(t!=null?t:"power2.out");if(e==="linear")return n=>n;if(e==="sine.inOut")return n=>.5-Math.cos(Math.PI*n)/2;if(e==="power2.out"||e==="easeOutQuad")return n=>1-(1-n)*(1-n);if(e.startsWith("back.out")){let n=e.match(/back\.out\(([\d.]+)\)/),i=n?Number(n[1]):1.8;return a=>1+(i+1)*Math.pow(a-1,3)+i*Math.pow(a-1,2)}return n=>1-(1-n)*(1-n)}function Ye(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function To(t,e){let n=t==null?void 0:t[e];return typeof n=="number"?n:0}function ya(t,e,n){try{t[e]=n}catch{}}function Lo(t){let e=t==null?void 0:t.scale;if(!e)return null;let n=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:n,y:i}}function ba(t,e){let n=t==null?void 0:t.scale;if(n)try{typeof n.set=="function"?n.set(e.x,e.y):(typeof n.x=="number"&&(n.x=e.x),typeof n.y=="number"&&(n.y=e.y))}catch{}}function va(t,e){let n=Lo(t);if(!n)return{from:null,to:null};let i=null,a=null;return typeof e.scale=="number"?(i=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),i===null&&a===null?{from:null,to:null}:{from:{x:n.x,y:n.y},to:{x:i!=null?i:n.x,y:a!=null?a:n.y}}}function wa(){let t=new Set,e=new WeakMap,n=null,i=()=>{if(n!=null)return;n=requestAnimationFrame(()=>{n=null,r(),t.size>0&&i()})},a=p=>{var h;t.add(p);let c=(h=e.get(p.target))!=null?h:new Set;c.add(p),e.set(p.target,c),i()},s=p=>{t.delete(p);let c=e.get(p.target);c&&(c.delete(p),c.size===0&&e.delete(p.target))},o=p=>{p.killed||(p.killed=!0,s(p))},r=()=>{var c,h;let p=Ye();for(let u of Array.from(t)){if(u.killed||u.paused)continue;let f=p-u.startMs-u.delayMs;if(f<0)continue;let g=u.durationMs>0?f/u.durationMs:1,w=ma(g),v=u.repeat>=0?u.repeat+1:1,b=u.repeat>0?Math.min(Math.floor(g),v-1):0;if(u.repeat>0&&g>=1){let S=g-b;w=ma(S)}let m=u.ease(w);u.yoyo&&b%2===1&&(m=1-m);for(let S of u.props)ya(u.target,S.key,S.from+(S.to-S.from)*m);u.scaleFrom&&u.scaleTo&&ba(u.target,{x:u.scaleFrom.x+(u.scaleTo.x-u.scaleFrom.x)*m,y:u.scaleFrom.y+(u.scaleTo.y-u.scaleFrom.y)*m});try{(c=u.onUpdate)==null||c.call(u)}catch{}if(g>=v){o(u);try{(h=u.onComplete)==null||h.call(u)}catch{}}}},l=(p,c,h)=>{var S;let u=Math.max(0,(typeof c.duration=="number"?c.duration:.5)*1e3),f=Math.max(0,(typeof c.delay=="number"?c.delay:0)*1e3+((S=h==null?void 0:h.delayMsOverride)!=null?S:0)),g=Ao(c.ease),w=typeof c.repeat=="number"?Math.max(0,c.repeat|0):0,v=c.yoyo===!0,b=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),m=[];for(let E of Object.keys(c)){if(b.has(E))continue;let C=c[E];typeof C=="number"&&m.push({key:E,from:To(p,E),to:C})}let y=va(p,c);return{target:p,startMs:Ye(),delayMs:f,durationMs:u,ease:g,props:m,scaleFrom:y.from,scaleTo:y.to,repeat:w,yoyo:v,onUpdate:typeof c.onUpdate=="function"?c.onUpdate:void 0,onComplete:typeof c.onComplete=="function"?c.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},d={to(p,c){let h=l(p,c);return a(h),{kill:()=>o(h),pause:()=>{h.paused||(h.paused=!0,h.pauseAtMs=Ye())},resume:()=>{var g;if(!h.paused)return;let u=(g=h.pauseAtMs)!=null?g:Ye(),f=Ye()-u;h.startMs+=f,h.paused=!1,h.pauseAtMs=null},isActive:()=>!h.killed&&!h.paused}},fromTo(p,c,h){return d.set(p,c),d.to(p,h)},set(p,c){if(!p||!c)return;for(let u of Object.keys(c)){let f=c[u];u==="scale"||u==="scaleX"||u==="scaleY"||typeof f=="number"&&ya(p,u,f)}let h=va(p,c);h.to&&ba(p,h.to)},killTweensOf(p){let c=e.get(p);if(c)for(let h of Array.from(c))o(h)},timeline(p={}){let c=[],h=0,u=!1,f=[],g=b=>{if(typeof b=="number")return Math.max(0,b*1e3);let m=typeof b=="string"?b.trim():"";return m.startsWith("+=")?h+Math.max(0,Number(m.slice(2))*1e3||0):m?Math.max(0,Number(m)*1e3||0):h},w=b=>{c.push(b);let m=Math.max(0,(typeof b.vars.duration=="number"?b.vars.duration:.5)*1e3);h=Math.max(h,b.atMs+m)},v={to(b,m,y){return w({kind:"to",target:b,vars:m,atMs:g(y)}),v},fromTo(b,m,y,S){return w({kind:"fromTo",target:b,vars:y,from:m,atMs:g(S)}),v},play(){var b,m;if(u)return v;u=!0,f=[];for(let y of c)y.kind==="fromTo"&&d.set(y.target,(b=y.from)!=null?b:{}),f.push(d.to(y.target,{...y.vars,delay:y.atMs/1e3+((m=y.vars.delay)!=null?m:0)}));return v},pause(){for(let b of f)b.pause();return v},kill(){for(let b of f)b.kill();f=[],u=!1}};return p.paused||v.play(),v}};return d}function xa(){if(typeof window=="undefined")return;let t=window;if(!t.gsap)try{t.gsap=wa()}catch{}}var Sa={name:"handler-playable-sdk",version:"1.0.103",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs dist/cli/student-helper/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var G=0,Io=G++,Ea=G++,Ca=G++,Aa=G++,Ta=G++,La=G++,ka=G++,Ia=G++,Pa=G++,_a=G++,Ma=G++,ja=G++,T=Io;function Oa(){return T===Ea}function Ra(){return T===Ca}function $a(){return T===Aa}function za(){return T===Ta}function je(){return T===La}function Oe(){return T===ka}function Da(){return T===Ia}function Ha(){return T===Pa}function Na(){return T===_a}function en(){return T===Ma}function tn(){return T===ja}function Fa(){let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(t==="mraid")try{mraid.getState(),T=Ea;return}catch{}else if(t==="dapi")try{dapi.isReady(),T=Ca;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(T=Aa)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(T=Ta)}catch{}else if(e==="mintegral")window.gameReady&&(T=La);else if(e==="tapjoy")window.TJ_API&&(T=ka);else if(e==="tiktok")window.openAppStore&&(T=Ia);else if(e==="smadex")try{window.smxTracking&&(T=Pa)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(T=_a)}catch{}else e==="vungle"?T=Ma:(t==="nucleo"||e==="nucleo")&&(T=ja)}var wt=he(require("lottie-web"),1),Ba=wt.default;typeof window!="undefined"&&(window.lottie=wt.default,window.__baseLottie=wt.default);var Po=require("pixi.js");var nn=require("pixi.js");var _o=null;function an(t){_o=t}St();xt();var Xe=require("pixi.js");St();var zo=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",ln=zo;if(typeof window!="undefined")try{let t=new XMLHttpRequest;if(t.open("GET","./build-settings.json",!1),t.send(),t.status===200&&t.responseText){let e=JSON.parse(t.responseText);e!=null&&e.buildMode&&(ln=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${ln}`))}}catch{}function Do(t){var n,i,a,s,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(t);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(t))return{x:(n=t[0])!=null?n:.5,y:(i=t[1])!=null?i:.5};if(t&&typeof t=="object"&&"x"in t&&"y"in t)return{x:(a=t.x)!=null?a:.5,y:(s=t.y)!=null?s:.5};if(typeof t=="string"){let r=t.trim().toLowerCase();return(o=e[r])!=null?o:{x:.5,y:.5}}return null}var me=class{static async create(e,n,i){var l,d,p,c,h,u,f;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${ln}`);let a=(l=n==null?void 0:n.render)==null?void 0:l.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let g=new Xe.Container;return this.applyTransform(g,n==null?void 0:n.transform,n),g}let s=(d=n==null?void 0:n.identity)==null?void 0:d.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${s}, type: ${a.type}, path: ${a.path}`);let o=await Ce.load(e,a,i,s);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(p=o==null?void 0:o.constructor)==null?void 0:p.name}`);let r;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),r=new Xe.Sprite(o),console.log("[ObjectFactory] Created object:",r,"type:",(c=r==null?void 0:r.constructor)==null?void 0:c.name),this.applyTransform(r,n==null?void 0:n.transform,n);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(h=o==null?void 0:o.constructor)==null?void 0:h.name,o),o&&(((u=o.constructor)==null?void 0:u.name)==="Container"||o instanceof Xe.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let g=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],w=!1;for(let v of g)try{let b=await fetch(v);if(b.ok){r=await b.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",v,"type:",(f=r==null?void 0:r.constructor)==null?void 0:f.name),w=!0;break}}catch{continue}w||(console.error("[ObjectFactory] Failed to reload JSON from any path"),r=o)}else r=o;else r=o,r&&typeof r=="object"&&("x"in r||"position"in r)&&this.applyTransform(r,n==null?void 0:n.transform,n);return r}static applyTransform(e,n,i){var a,s,o,r;if(!(!n||!e)&&(n.position&&("x"in e&&"y"in e?(e.x=(a=n.position.x)!=null?a:0,e.y=(s=n.position.y)!=null?s:0):"position"in e&&e.position&&e.position.set((o=n.position.x)!=null?o:0,(r=n.position.y)!=null?r:0)),n.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(n.scale):e.scale=n.scale),n.rotation!==void 0&&"rotation"in e&&(e.rotation=n.rotation),n.anchor&&"anchor"in e&&e.anchor)){let l=Do(n.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};var Ke=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}};var Fo=he(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=Fo);Je();var Ct=require("pixi.js");Je();var dn=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Ke}init(e,n){this.registry.init(e),this.app=n}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let n=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(n.length===0)return;let i=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async s=>{var r;let o=this.registry.get(s);if(!o){console.warn("[Assets] No config found for object:",s);return}try{let l=await me.create(s,o,this.app);this.instanceCache.set(s,l),console.log("[Assets] Loaded object:",s,(r=l==null?void 0:l.constructor)==null?void 0:r.name)}catch(l){console.error("[Assets] Failed to load object:",s,l)}})))};return this.readyPromise=(async()=>{await i(n);let a=this.registry.getAllIds().filter(s=>!this.instanceCache.has(s));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let n=this.registry.get(e);if(n){let i=await me.create(e,n,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},Go=new dn,Uo=new Proxy(Go,{get(t,e){if(e in t&&typeof t[e]=="function")return t[e].bind(t);if(t.get(e))return t.get(e)}});Je();var Wo=require("pixi.js"),le={width:400,height:600,designWidth:400,scaleFactor:1},Tt={scale:1,position:1},un=[];function Yo(t,e,n,i,a,s,o){un.push({element:t,originalScale:s,positionHelper:e,heightPercent:a}),e(t,n,i,a,s,o,!1)}function Xo(){un.forEach(({element:t,originalScale:e,positionHelper:n,heightPercent:i})=>{let a=e*le.scaleFactor;n(t,le.width,le.height,i,a,!0,!1)})}function pn(t,e){console.log(`[SCREEN] updateScreenState called: ${t}x${e}`),le.width=t,le.height=e,le.scaleFactor=Math.min(t/le.designWidth,1.15),Tt.scale=le.scaleFactor,Tt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Tt.scale.toFixed(3)}`),Xo()}var Qe={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Ko(t,e,n){let i=Qe[t];i&&i[e]!==void 0&&(i[e]=n,console.log(`Updated ${t}.${e} = ${n}`))}function Jo(){return Qe}var Zo={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 At(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function et(t,e={x:.5,y:.5}){var n;if(Array.isArray(t))return{x:At(t[0],e.x),y:At(t[1],e.y)};if(t&&typeof t=="object"){let i=t;return{x:At(i.x,e.x),y:At(i.y,e.y)}}if(typeof t=="string"){let i=t.trim().toLowerCase();return(n=Zo[i])!=null?n:e}return e}function hn(t,e,n,i={}){var u,f,g,w,v,b;let a=et(n),s=(u=i.inset)!=null?u:{},o=(f=i.padding)!=null?f:{x:0,y:0},r=((g=s.left)!=null?g:0)+o.x,l=((w=s.right)!=null?w:0)+o.x,d=((v=s.top)!=null?v:0)+o.y,p=((b=s.bottom)!=null?b:0)+o.y,c=Math.max(0,t-r-l),h=Math.max(0,e-d-p);return{x:r+c*a.x,y:d+h*a.y}}function gn(t,e,n,i={}){var g,w,v,b,m,y;let a=(g=i.inset)!=null?g:{},s=(w=i.padding)!=null?w:{x:0,y:0},o=((v=a.left)!=null?v:0)+s.x,r=((b=a.right)!=null?b:0)+s.x,l=((m=a.top)!=null?m:0)+s.y,d=((y=a.bottom)!=null?y:0)+s.y,p=Math.max(0,t-o-r),c=Math.max(0,e-l-d),h=et(n,{x:.5,y:.5}),u=Math.min(Math.max(h.x,0),1),f=Math.min(Math.max(h.y,0),1);return{x:o+p*u,y:l+c*f}}if(typeof window!="undefined"){let t=window.innerWidth,e=window.innerHeight,n=()=>{let i=window.innerWidth,a=window.innerHeight;(i!==t||a!==e)&&(t=i,e=a,pn(i,a))};window.addEventListener("resize",n),window.addEventListener("orientationchange",()=>{setTimeout(n,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",n),window.mraid.addEventListener("sizeChange",n)),pn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Ko,window.getDebugConfig=Jo,window.copyConfig=cr,window.applyConfig=Ze,window.applyConfigForRatio=dr,window.positionAtBottom=Va,window.positionAtTop=tr,window.positionAtCenter=nr,window.positionAtLeft=ir,window.positionAtRight=ar,window.positionAtBottomLeft=sr,window.positionAtBottomRight=or,window.positionAtTopLeft=rr,window.positionAtTopRight=lr,window.applyPositionContract=er,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 Lt(t,e,n=0){return t*e+n}function kt(t,e,n=0){return t*(1-e)+n}function It(t,e,n=0){return t*e+n}function Pt(t,e,n=0){return t*(1-e)+n}function U(t,e=0){return t/2+e}function Qo(t,e){return t*e}function er(t,e,n,i){var o,r,l,d,p,c,h,u,f,g,w,v,b,m,y,S,E,C,I,M;let a=0,s=0;switch(i.type){case"top":a=U(e,(r=(o=i.offset)==null?void 0:o.x)!=null?r:0),s=Lt(n,i.percent,(d=(l=i.offset)==null?void 0:l.y)!=null?d:0);break;case"bottom":a=U(e,(c=(p=i.offset)==null?void 0:p.x)!=null?c:0),s=kt(n,i.percent,(u=(h=i.offset)==null?void 0:h.y)!=null?u:0);break;case"left":a=It(e,i.percent,(g=(f=i.offset)==null?void 0:f.x)!=null?g:0),s=U(n,(v=(w=i.offset)==null?void 0:w.y)!=null?v:0);break;case"right":a=Pt(e,i.percent,(m=(b=i.offset)==null?void 0:b.x)!=null?m:0),s=U(n,(S=(y=i.offset)==null?void 0:y.y)!=null?S:0);break;case"center":a=U(e,(C=(E=i.offset)==null?void 0:E.x)!=null?C:0),s=U(n,(M=(I=i.offset)==null?void 0:I.y)!=null?M:0);break}t.position?t.position.set(a,s):(t.x=a,t.y=s),i.scale!==void 0&&i.scale!==1&&t.scale&&(typeof t.scale.set=="function"?t.scale.set(i.scale,i.scale):(t.scale.x=i.scale,t.scale.y=i.scale))}function Va(t,e,n,i=.2,a=1,s=!0,o=!1){let r=Qo(n,i),l=kt(n,i/2);ce(t,U(e),l);let d=s?a*le.scaleFactor:a;de(t,d),o&&!un.find(p=>p.element===t)&&Yo(t,Va,e,n,i,a,s)}function tr(t,e,n,i=.1,a=1){ce(t,U(e),Lt(n,i)),de(t,a)}function nr(t,e,n,i=0,a=0,s=1){ce(t,U(e,i),U(n,a)),de(t,s)}function ir(t,e,n,i=.1,a=1){ce(t,It(e,i),U(n)),de(t,a)}function ar(t,e,n,i=.1,a=1){ce(t,Pt(e,i),U(n)),de(t,a)}function sr(t,e,n,i=.05,a=.05,s=1){ce(t,It(e,a),kt(n,i)),de(t,s)}function or(t,e,n,i=.05,a=.05,s=1){ce(t,Pt(e,a),kt(n,i)),de(t,s)}function rr(t,e,n,i=.05,a=.05,s=1){ce(t,It(e,a),Lt(n,i)),de(t,s)}function lr(t,e,n,i=.05,a=.05,s=1){ce(t,Pt(e,a),Lt(n,i)),de(t,s)}function ce(t,e,n){t&&t.position?typeof t.position.set=="function"?t.position.set(e,n):(t.position.x=e,t.position.y=n):t&&(t.x=e,t.y=n)}function de(t,e){e!==1&&t&&t.scale&&(typeof t.scale.set=="function"?t.scale.set(e,e):t.scale.x!==void 0&&t.scale.y!==void 0&&(t.scale.x=e,t.scale.y=e))}var Ae={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function cr(t){return t&&Ae[t]?JSON.parse(JSON.stringify(Ae[t])):JSON.parse(JSON.stringify(Qe))}function Ze(t){Object.keys(t).forEach(e=>{let n=e;Qe[n]&&t[n]&&Object.assign(Qe[n],t[n])}),console.log("Config applied:",t)}function dr(t,e){let n=t/e;n>1.6?(Ze(Ae.wide),console.log("Applied WIDE config for ratio:",n)):n<.7?(Ze(Ae.tall),console.log("Applied TALL config for ratio:",n)):n>.8&&n<1.2?(Ze(Ae.square),console.log("Applied SQUARE config for ratio:",n)):(Ze(Ae.default),console.log("Applied DEFAULT config for ratio:",n))}if(typeof window!="undefined"){let t=window;t.configPresets=Ae,t.resolveAnchorVec2=t.resolveAnchorVec2||et,t.resolveScreenAnchorPoint=t.resolveScreenAnchorPoint||hn,t.resolveScreenRatioPoint=t.resolveScreenRatioPoint||gn}yn();function _(t,e){let n=(a,s)=>s===0?a:n(s,a%s),i=n(t,e);return`${t/i}:${e/i}`}var Kc=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:_(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:_(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:_(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:_(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:_(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:_(360,780)}],Jc=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:_(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:_(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:_(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:_(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:_(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:_(412,915)}],Zc=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:_(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:_(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:_(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:_(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:_(800,1280)}],Ka=[{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:_(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:_(768,1024),mraidScale:.7}];var Qc=[...Ka];var br=Ka[0];Q();function wr(t){return new Promise((e,n)=>{let i=new FileReader;i.onerror=()=>n(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(t)})}function xr(t){var a;let[e,n]=t.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:n!=null?n:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}async function Sr(t){return await new Promise(e=>{let n=new Image;n.onload=()=>e({width:n.naturalWidth||n.width,height:n.naturalHeight||n.height}),n.onerror=()=>e(null),n.src=t})}async function vn(t){var e,n;try{console.log("[ImageUtils] Fetching image data from URL:",t);let i=await fetch(t);if(!i.ok)return console.warn("[ImageUtils] Fetch failed with status:",i.status,t),null;let a=await i.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let s=await wr(a),o=await Sr(s),r=xr(s);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",r.mimeType),{base64:r.base64,mimeType:r.mimeType,dataUrl:s,width:(e=o==null?void 0:o.width)!=null?e:0,height:(n=o==null?void 0:o.height)!=null?n:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function _t(t,e=30){try{console.log("[ImageUtils] Removing background color...");let n=await new Promise((c,h)=>{let u=new Image;u.onload=()=>c(u),u.onerror=()=>h(new Error("Failed to load image")),u.src=t}),i=document.createElement("canvas");i.width=n.width,i.height=n.height;let a=i.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),t;a.drawImage(n,0,0);let s=a.getImageData(0,0,i.width,i.height),o=s.data,l=[{name:"top-left",offset:0},{name:"top-right",offset:(i.width-1)*4},{name:"bottom-left",offset:(i.height-1)*i.width*4},{name:"bottom-right",offset:((i.height-1)*i.width+(i.width-1))*4}].map(c=>({r:o[c.offset],g:o[c.offset+1],b:o[c.offset+2]})),d=0;for(let c=0;c<o.length;c+=4){let h=o[c],u=o[c+1],f=o[c+2],g=!1;for(let w of l)if(Math.sqrt(Math.pow(h-w.r,2)+Math.pow(u-w.g,2)+Math.pow(f-w.b,2))<e){g=!0;break}g&&(o[c+3]=0,d++)}return console.log(`[ImageUtils] Removed background from ${d} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(s,0,0),i.toDataURL("image/png")}catch(n){return console.error("[ImageUtils] Error removing background:",n),t}}var Za=require("@google/genai");async function wn(t,e,n=[],i={}){var a,s,o,r,l,d,p;try{if(!(t!=null&&t.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let v=0;v<n.length;v++){let b=n[v];if(!b.base64||!b.mimeType)throw new Error(`Image ${v+1} is missing required data`);if(b.base64.length<1e3&&console.warn(`Image ${v+1} data appears very small, may be corrupted`),!b.mimeType.startsWith("image/"))throw new Error(`Image ${v+1} has invalid MIME type: ${b.mimeType}`)}let c=new Za.GoogleGenAI({apiKey:t}),h="gemini-2.5-flash",u=[e];n.length>0&&n.forEach((v,b)=>{u.push({inlineData:{data:v.base64,mimeType:v.mimeType}}),console.log(`[Gemini] Added image ${b+1}: ${v.mimeType}, size: ${Math.round(v.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${n.length} images and prompt length: ${e.length}`);let f=await c.models.generateContent({model:h,contents:u}),g="",w=(o=(s=(a=f.candidates)==null?void 0:a[0])==null?void 0:s.content)==null?void 0:o.parts;if(w)for(let v of w)v.text&&(g+=v.text);if(!g.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${g.length}`),g}catch(c){throw console.error("[Gemini] API error:",c),(r=c.message)!=null&&r.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(l=c.message)!=null&&l.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(d=c.message)!=null&&d.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(p=c.message)!=null&&p.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):c}}var Qa=require("@google/genai");async function Mt(t,e,n=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Qa.GoogleGenAI({apiKey:t}),s=[{text:e}];n.length>0&&n.forEach((r,l)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${l}`),s.push({inlineData:{mimeType:r.mimeType,data:r.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:s});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let r of o.candidates[0].content.parts)if(r.text)console.log(r.text);else if(r.inlineData){let l=r.inlineData.data,d=r.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${d};base64,${l}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(a){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(a,Object.getOwnPropertyNames(a),2)),a}}var Er=require("pixi.js");Je();xt();Q();var ts=require("pixi.js");var Ar=require("pixi.js");Q();function $r(t){return new Promise((e,n)=>{let i=new FileReader;i.onerror=()=>n(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(t)})}function zr(t){var a;let[e,n]=t.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:n!=null?n:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}function Dr(t){return`
97
+ `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.image&&this.image.naturalWidth>0&&this.image.naturalHeight>0?(console.log("[AssetCropModal] Image loaded:",this.image.naturalWidth,"x",this.image.naturalHeight),this.initializeCrop(),this.render()):(console.error("[AssetCropModal] Image loaded but invalid dimensions"),this.showError("Failed to load image"))},this.image.onerror=e=>{console.error("[AssetCropModal] Image load error:",e),this.showError("Failed to load image. Please check the image URL.")},this.image.src=this.options.imageSrc,this.canvas&&this.ctx&&(this.ctx.fillStyle="rgba(128, 128, 128, 0.3)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 255, 255, 0.7)",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText("Loading image...",this.canvas.width/2,this.canvas.height/2)))}showError(e){var i;if(!this.canvas||!this.ctx)return;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="rgba(255, 0, 0, 0.2)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.fillStyle="#ff4444",this.ctx.font="14px sans-serif",this.ctx.textAlign="center",this.ctx.fillText(e,this.canvas.width/2,this.canvas.height/2);let n=(i=this.modal)==null?void 0:i.querySelector(".asset-crop-preview-canvas");if(n){let a=n.getContext("2d");a&&(a.fillStyle="rgba(255, 0, 0, 0.2)",a.fillRect(0,0,n.width,n.height))}}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,n=this.canvas.width/this.canvas.height;e>n?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*n,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/n,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let n=this.image.width/this.image.height,i=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>n?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,i-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,n=this.canvas.height/this.cropHeight;this.scale=Math.min(e,n)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){if(!(!this.ctx||!this.canvas)){if(!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0){console.warn("[AssetCropModal] Image not ready for rendering"),this.showError("Image not loaded");return}this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);try{this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore()}catch(e){console.error("[AssetCropModal] Error drawing image:",e),this.showError("Error drawing image");return}this.drawCropOverlay(),this.updatePreview()}}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,n=this.panY,i=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,n,i,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,n,i,a),this.ctx.fillStyle="#ffffff";let s=8;[[e,n],[e+i-s,n],[e,n+a-s],[e+i-s,n+a-s]].forEach(([r,l])=>{var d;(d=this.ctx)==null||d.fillRect(r,l,s,s)})}updatePreview(){if(!this.modal||!this.image||!this.image.complete||this.image.naturalWidth===0||this.image.naturalHeight===0)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let n=e.getContext("2d");if(!n)return;let i=150;e.width=i,e.height=i,n.clearRect(0,0,i,i);let a=i/this.cropWidth,s=i/this.cropHeight,o=Math.min(a,s),r=this.cropWidth*o,l=this.cropHeight*o,d=(i-r)/2,p=(i-l)/2;try{n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,d,p,r,l)}catch(c){console.error("[AssetCropModal] Error drawing preview:",c),n.fillStyle="rgba(255, 0, 0, 0.2)",n.fillRect(0,0,i,i)}}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",i=>{let a=parseFloat(i.target.value);this.setZoom(a)});let n=this.modal.querySelector(".asset-crop-aspect-select");n==null||n.addEventListener("change",i=>{let a=i.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let n=e.clientX-this.dragStartX,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+n,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let n=e.deltaY>0?.9:1.1;this.setZoom(this.scale*n)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let n=e.touches[0].clientX-this.dragStartX,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+n,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let n;switch(e){case"1:1":n=1;break;case"4:3":n=4/3;break;case"16:9":n=16/9;break;case"3:2":n=3/2;break;default:n=void 0}n&&this.applyAspectRatio(n),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),n=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),n&&(n.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,n=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-n,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),n=e.getContext("2d");if(!n)return;e.width=this.cropWidth,e.height=this.cropHeight,n.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let i=e.toDataURL("image/png");this.options.onCrop(i),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(t){new kn().open(t)}});var il={};da(il,{AspectClass:()=>Dn,GameObject:()=>ct,GameObjectManager:()=>Ht,Renderer:()=>lt,ResponsiveUISystem:()=>Ue,Transform:()=>rt,animateHandClick:()=>Es,animatePanelEntrance:()=>Ss,createBrushTexture:()=>Ps,createEndGamePanel:()=>xs,createHandTutorial:()=>Cs,createThreeBase:()=>bs,createTutorialLabel:()=>As,getAspectClass:()=>Dt,getRegisteredFontIds:()=>ws,loadAsset:()=>Fn,loadCharacterFrames:()=>Is,registerFont:()=>vs,resolveFont:()=>te,resolveFontWeight:()=>ne,updateHandAnimation:()=>Ts});module.exports=Co(il);var W=he(require("three"),1);var ge={};function bt(t,e,n=!1){ge[t]||(ge[t]=[]),ge[t].push({fn:e,once:n})}function Zt(t,e){if(ge[t]){if(!e){delete ge[t];return}ge[t]=ge[t].filter(n=>n.fn!==e)}}function vt(t,...e){let n=ge[t];if(n)for(let i of[...n])i.fn(...e),i.once&&Zt(t,i.fn)}function B(t,e){bt(t,e,!0)}var P=null,V=[],Me=null;function ga(t){P=t,V=[],Me!==null&&(clearTimeout(Me),Me=null)}function fa(){var t,e,n;return{endpoint:(P==null?void 0:P.endpoint)||"",transport:(P==null?void 0:P.transport)||"beacon",batchSize:(t=P==null?void 0:P.batchSize)!=null?t:10,flushIntervalMs:(e=P==null?void 0:P.flushIntervalMs)!=null?e:300,maxQueue:(n=P==null?void 0:P.maxQueue)!=null?n:200,debug:!!(P!=null&&P.debug)}}async function ua(t,e,n,i){let a=JSON.stringify(e);if(n==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let s=navigator.sendBeacon(t,new Blob([a],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",s,e);return}catch(s){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",s)}try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(s){i&&console.warn("[handler.telemetry] fetch failed",s)}}function Qt(t,e){let n=fa();if(e&&n.endpoint){if(V.push(t),V.length>n.maxQueue&&(V=V.slice(V.length-n.maxQueue)),V.length>=n.batchSize){ha();return}Me===null&&(Me=window.setTimeout(()=>{Me=null,ha()},n.flushIntervalMs))}}async function ha(){let t=fa();if(!t.endpoint||V.length===0)return;let e=V.splice(0,t.batchSize);await ua(t.endpoint,{events:e},t.transport,t.debug),V.length>0&&await ua(t.endpoint,{events:V.splice(0,t.batchSize)},t.transport,t.debug)}function ma(t){return Math.max(0,Math.min(1,t))}function Ao(t){let e=String(t!=null?t:"power2.out");if(e==="linear")return n=>n;if(e==="sine.inOut")return n=>.5-Math.cos(Math.PI*n)/2;if(e==="power2.out"||e==="easeOutQuad")return n=>1-(1-n)*(1-n);if(e.startsWith("back.out")){let n=e.match(/back\.out\(([\d.]+)\)/),i=n?Number(n[1]):1.8;return a=>1+(i+1)*Math.pow(a-1,3)+i*Math.pow(a-1,2)}return n=>1-(1-n)*(1-n)}function Ye(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function To(t,e){let n=t==null?void 0:t[e];return typeof n=="number"?n:0}function ya(t,e,n){try{t[e]=n}catch{}}function Lo(t){let e=t==null?void 0:t.scale;if(!e)return null;let n=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:n,y:i}}function ba(t,e){let n=t==null?void 0:t.scale;if(n)try{typeof n.set=="function"?n.set(e.x,e.y):(typeof n.x=="number"&&(n.x=e.x),typeof n.y=="number"&&(n.y=e.y))}catch{}}function va(t,e){let n=Lo(t);if(!n)return{from:null,to:null};let i=null,a=null;return typeof e.scale=="number"?(i=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),i===null&&a===null?{from:null,to:null}:{from:{x:n.x,y:n.y},to:{x:i!=null?i:n.x,y:a!=null?a:n.y}}}function wa(){let t=new Set,e=new WeakMap,n=null,i=()=>{if(n!=null)return;n=requestAnimationFrame(()=>{n=null,r(),t.size>0&&i()})},a=p=>{var h;t.add(p);let c=(h=e.get(p.target))!=null?h:new Set;c.add(p),e.set(p.target,c),i()},s=p=>{t.delete(p);let c=e.get(p.target);c&&(c.delete(p),c.size===0&&e.delete(p.target))},o=p=>{p.killed||(p.killed=!0,s(p))},r=()=>{var c,h;let p=Ye();for(let u of Array.from(t)){if(u.killed||u.paused)continue;let f=p-u.startMs-u.delayMs;if(f<0)continue;let g=u.durationMs>0?f/u.durationMs:1,w=ma(g),v=u.repeat>=0?u.repeat+1:1,b=u.repeat>0?Math.min(Math.floor(g),v-1):0;if(u.repeat>0&&g>=1){let S=g-b;w=ma(S)}let m=u.ease(w);u.yoyo&&b%2===1&&(m=1-m);for(let S of u.props)ya(u.target,S.key,S.from+(S.to-S.from)*m);u.scaleFrom&&u.scaleTo&&ba(u.target,{x:u.scaleFrom.x+(u.scaleTo.x-u.scaleFrom.x)*m,y:u.scaleFrom.y+(u.scaleTo.y-u.scaleFrom.y)*m});try{(c=u.onUpdate)==null||c.call(u)}catch{}if(g>=v){o(u);try{(h=u.onComplete)==null||h.call(u)}catch{}}}},l=(p,c,h)=>{var S;let u=Math.max(0,(typeof c.duration=="number"?c.duration:.5)*1e3),f=Math.max(0,(typeof c.delay=="number"?c.delay:0)*1e3+((S=h==null?void 0:h.delayMsOverride)!=null?S:0)),g=Ao(c.ease),w=typeof c.repeat=="number"?Math.max(0,c.repeat|0):0,v=c.yoyo===!0,b=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),m=[];for(let E of Object.keys(c)){if(b.has(E))continue;let C=c[E];typeof C=="number"&&m.push({key:E,from:To(p,E),to:C})}let y=va(p,c);return{target:p,startMs:Ye(),delayMs:f,durationMs:u,ease:g,props:m,scaleFrom:y.from,scaleTo:y.to,repeat:w,yoyo:v,onUpdate:typeof c.onUpdate=="function"?c.onUpdate:void 0,onComplete:typeof c.onComplete=="function"?c.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},d={to(p,c){let h=l(p,c);return a(h),{kill:()=>o(h),pause:()=>{h.paused||(h.paused=!0,h.pauseAtMs=Ye())},resume:()=>{var g;if(!h.paused)return;let u=(g=h.pauseAtMs)!=null?g:Ye(),f=Ye()-u;h.startMs+=f,h.paused=!1,h.pauseAtMs=null},isActive:()=>!h.killed&&!h.paused}},fromTo(p,c,h){return d.set(p,c),d.to(p,h)},set(p,c){if(!p||!c)return;for(let u of Object.keys(c)){let f=c[u];u==="scale"||u==="scaleX"||u==="scaleY"||typeof f=="number"&&ya(p,u,f)}let h=va(p,c);h.to&&ba(p,h.to)},killTweensOf(p){let c=e.get(p);if(c)for(let h of Array.from(c))o(h)},timeline(p={}){let c=[],h=0,u=!1,f=[],g=b=>{if(typeof b=="number")return Math.max(0,b*1e3);let m=typeof b=="string"?b.trim():"";return m.startsWith("+=")?h+Math.max(0,Number(m.slice(2))*1e3||0):m?Math.max(0,Number(m)*1e3||0):h},w=b=>{c.push(b);let m=Math.max(0,(typeof b.vars.duration=="number"?b.vars.duration:.5)*1e3);h=Math.max(h,b.atMs+m)},v={to(b,m,y){return w({kind:"to",target:b,vars:m,atMs:g(y)}),v},fromTo(b,m,y,S){return w({kind:"fromTo",target:b,vars:y,from:m,atMs:g(S)}),v},play(){var b,m;if(u)return v;u=!0,f=[];for(let y of c)y.kind==="fromTo"&&d.set(y.target,(b=y.from)!=null?b:{}),f.push(d.to(y.target,{...y.vars,delay:y.atMs/1e3+((m=y.vars.delay)!=null?m:0)}));return v},pause(){for(let b of f)b.pause();return v},kill(){for(let b of f)b.kill();f=[],u=!1}};return p.paused||v.play(),v}};return d}function xa(){if(typeof window=="undefined")return;let t=window;if(!t.gsap)try{t.gsap=wa()}catch{}}var Sa={name:"handler-playable-sdk",version:"1.0.104",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs dist/cli/student-helper/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var G=0,Io=G++,Ea=G++,Ca=G++,Aa=G++,Ta=G++,La=G++,ka=G++,Ia=G++,Pa=G++,_a=G++,Ma=G++,ja=G++,T=Io;function Oa(){return T===Ea}function Ra(){return T===Ca}function $a(){return T===Aa}function za(){return T===Ta}function je(){return T===La}function Oe(){return T===ka}function Da(){return T===Ia}function Ha(){return T===Pa}function Na(){return T===_a}function en(){return T===Ma}function tn(){return T===ja}function Fa(){let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(t==="mraid")try{mraid.getState(),T=Ea;return}catch{}else if(t==="dapi")try{dapi.isReady(),T=Ca;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(T=Aa)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(T=Ta)}catch{}else if(e==="mintegral")window.gameReady&&(T=La);else if(e==="tapjoy")window.TJ_API&&(T=ka);else if(e==="tiktok")window.openAppStore&&(T=Ia);else if(e==="smadex")try{window.smxTracking&&(T=Pa)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(T=_a)}catch{}else e==="vungle"?T=Ma:(t==="nucleo"||e==="nucleo")&&(T=ja)}var wt=he(require("lottie-web"),1),Ba=wt.default;typeof window!="undefined"&&(window.lottie=wt.default,window.__baseLottie=wt.default);var Po=require("pixi.js");var nn=require("pixi.js");var _o=null;function an(t){_o=t}St();xt();var Xe=require("pixi.js");St();var zo=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",ln=zo;if(typeof window!="undefined")try{let t=new XMLHttpRequest;if(t.open("GET","./build-settings.json",!1),t.send(),t.status===200&&t.responseText){let e=JSON.parse(t.responseText);e!=null&&e.buildMode&&(ln=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${ln}`))}}catch{}function Do(t){var n,i,a,s,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(t);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(t))return{x:(n=t[0])!=null?n:.5,y:(i=t[1])!=null?i:.5};if(t&&typeof t=="object"&&"x"in t&&"y"in t)return{x:(a=t.x)!=null?a:.5,y:(s=t.y)!=null?s:.5};if(typeof t=="string"){let r=t.trim().toLowerCase();return(o=e[r])!=null?o:{x:.5,y:.5}}return null}var me=class{static async create(e,n,i){var l,d,p,c,h,u,f;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${ln}`);let a=(l=n==null?void 0:n.render)==null?void 0:l.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let g=new Xe.Container;return this.applyTransform(g,n==null?void 0:n.transform,n),g}let s=(d=n==null?void 0:n.identity)==null?void 0:d.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${s}, type: ${a.type}, path: ${a.path}`);let o=await Ce.load(e,a,i,s);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(p=o==null?void 0:o.constructor)==null?void 0:p.name}`);let r;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),r=new Xe.Sprite(o),console.log("[ObjectFactory] Created object:",r,"type:",(c=r==null?void 0:r.constructor)==null?void 0:c.name),this.applyTransform(r,n==null?void 0:n.transform,n);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(h=o==null?void 0:o.constructor)==null?void 0:h.name,o),o&&(((u=o.constructor)==null?void 0:u.name)==="Container"||o instanceof Xe.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let g=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],w=!1;for(let v of g)try{let b=await fetch(v);if(b.ok){r=await b.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",v,"type:",(f=r==null?void 0:r.constructor)==null?void 0:f.name),w=!0;break}}catch{continue}w||(console.error("[ObjectFactory] Failed to reload JSON from any path"),r=o)}else r=o;else r=o,r&&typeof r=="object"&&("x"in r||"position"in r)&&this.applyTransform(r,n==null?void 0:n.transform,n);return r}static applyTransform(e,n,i){var a,s,o,r;if(!(!n||!e)&&(n.position&&("x"in e&&"y"in e?(e.x=(a=n.position.x)!=null?a:0,e.y=(s=n.position.y)!=null?s:0):"position"in e&&e.position&&e.position.set((o=n.position.x)!=null?o:0,(r=n.position.y)!=null?r:0)),n.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(n.scale):e.scale=n.scale),n.rotation!==void 0&&"rotation"in e&&(e.rotation=n.rotation),n.anchor&&"anchor"in e&&e.anchor)){let l=Do(n.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};var Ke=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}};var Fo=he(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=Fo);Je();var Ct=require("pixi.js");Je();var dn=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Ke}init(e,n){this.registry.init(e),this.app=n}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let n=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(n.length===0)return;let i=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async s=>{var r;let o=this.registry.get(s);if(!o){console.warn("[Assets] No config found for object:",s);return}try{let l=await me.create(s,o,this.app);this.instanceCache.set(s,l),console.log("[Assets] Loaded object:",s,(r=l==null?void 0:l.constructor)==null?void 0:r.name)}catch(l){console.error("[Assets] Failed to load object:",s,l)}})))};return this.readyPromise=(async()=>{await i(n);let a=this.registry.getAllIds().filter(s=>!this.instanceCache.has(s));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let n=this.registry.get(e);if(n){let i=await me.create(e,n,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},Go=new dn,Uo=new Proxy(Go,{get(t,e){if(e in t&&typeof t[e]=="function")return t[e].bind(t);if(t.get(e))return t.get(e)}});Je();var Wo=require("pixi.js"),le={width:400,height:600,designWidth:400,scaleFactor:1},Tt={scale:1,position:1},un=[];function Yo(t,e,n,i,a,s,o){un.push({element:t,originalScale:s,positionHelper:e,heightPercent:a}),e(t,n,i,a,s,o,!1)}function Xo(){un.forEach(({element:t,originalScale:e,positionHelper:n,heightPercent:i})=>{let a=e*le.scaleFactor;n(t,le.width,le.height,i,a,!0,!1)})}function pn(t,e){console.log(`[SCREEN] updateScreenState called: ${t}x${e}`),le.width=t,le.height=e,le.scaleFactor=Math.min(t/le.designWidth,1.15),Tt.scale=le.scaleFactor,Tt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Tt.scale.toFixed(3)}`),Xo()}var Qe={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Ko(t,e,n){let i=Qe[t];i&&i[e]!==void 0&&(i[e]=n,console.log(`Updated ${t}.${e} = ${n}`))}function Jo(){return Qe}var Zo={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 At(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function et(t,e={x:.5,y:.5}){var n;if(Array.isArray(t))return{x:At(t[0],e.x),y:At(t[1],e.y)};if(t&&typeof t=="object"){let i=t;return{x:At(i.x,e.x),y:At(i.y,e.y)}}if(typeof t=="string"){let i=t.trim().toLowerCase();return(n=Zo[i])!=null?n:e}return e}function hn(t,e,n,i={}){var u,f,g,w,v,b;let a=et(n),s=(u=i.inset)!=null?u:{},o=(f=i.padding)!=null?f:{x:0,y:0},r=((g=s.left)!=null?g:0)+o.x,l=((w=s.right)!=null?w:0)+o.x,d=((v=s.top)!=null?v:0)+o.y,p=((b=s.bottom)!=null?b:0)+o.y,c=Math.max(0,t-r-l),h=Math.max(0,e-d-p);return{x:r+c*a.x,y:d+h*a.y}}function gn(t,e,n,i={}){var g,w,v,b,m,y;let a=(g=i.inset)!=null?g:{},s=(w=i.padding)!=null?w:{x:0,y:0},o=((v=a.left)!=null?v:0)+s.x,r=((b=a.right)!=null?b:0)+s.x,l=((m=a.top)!=null?m:0)+s.y,d=((y=a.bottom)!=null?y:0)+s.y,p=Math.max(0,t-o-r),c=Math.max(0,e-l-d),h=et(n,{x:.5,y:.5}),u=Math.min(Math.max(h.x,0),1),f=Math.min(Math.max(h.y,0),1);return{x:o+p*u,y:l+c*f}}if(typeof window!="undefined"){let t=window.innerWidth,e=window.innerHeight,n=()=>{let i=window.innerWidth,a=window.innerHeight;(i!==t||a!==e)&&(t=i,e=a,pn(i,a))};window.addEventListener("resize",n),window.addEventListener("orientationchange",()=>{setTimeout(n,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",n),window.mraid.addEventListener("sizeChange",n)),pn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Ko,window.getDebugConfig=Jo,window.copyConfig=cr,window.applyConfig=Ze,window.applyConfigForRatio=dr,window.positionAtBottom=Va,window.positionAtTop=tr,window.positionAtCenter=nr,window.positionAtLeft=ir,window.positionAtRight=ar,window.positionAtBottomLeft=sr,window.positionAtBottomRight=or,window.positionAtTopLeft=rr,window.positionAtTopRight=lr,window.applyPositionContract=er,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 Lt(t,e,n=0){return t*e+n}function kt(t,e,n=0){return t*(1-e)+n}function It(t,e,n=0){return t*e+n}function Pt(t,e,n=0){return t*(1-e)+n}function U(t,e=0){return t/2+e}function Qo(t,e){return t*e}function er(t,e,n,i){var o,r,l,d,p,c,h,u,f,g,w,v,b,m,y,S,E,C,I,M;let a=0,s=0;switch(i.type){case"top":a=U(e,(r=(o=i.offset)==null?void 0:o.x)!=null?r:0),s=Lt(n,i.percent,(d=(l=i.offset)==null?void 0:l.y)!=null?d:0);break;case"bottom":a=U(e,(c=(p=i.offset)==null?void 0:p.x)!=null?c:0),s=kt(n,i.percent,(u=(h=i.offset)==null?void 0:h.y)!=null?u:0);break;case"left":a=It(e,i.percent,(g=(f=i.offset)==null?void 0:f.x)!=null?g:0),s=U(n,(v=(w=i.offset)==null?void 0:w.y)!=null?v:0);break;case"right":a=Pt(e,i.percent,(m=(b=i.offset)==null?void 0:b.x)!=null?m:0),s=U(n,(S=(y=i.offset)==null?void 0:y.y)!=null?S:0);break;case"center":a=U(e,(C=(E=i.offset)==null?void 0:E.x)!=null?C:0),s=U(n,(M=(I=i.offset)==null?void 0:I.y)!=null?M:0);break}t.position?t.position.set(a,s):(t.x=a,t.y=s),i.scale!==void 0&&i.scale!==1&&t.scale&&(typeof t.scale.set=="function"?t.scale.set(i.scale,i.scale):(t.scale.x=i.scale,t.scale.y=i.scale))}function Va(t,e,n,i=.2,a=1,s=!0,o=!1){let r=Qo(n,i),l=kt(n,i/2);ce(t,U(e),l);let d=s?a*le.scaleFactor:a;de(t,d),o&&!un.find(p=>p.element===t)&&Yo(t,Va,e,n,i,a,s)}function tr(t,e,n,i=.1,a=1){ce(t,U(e),Lt(n,i)),de(t,a)}function nr(t,e,n,i=0,a=0,s=1){ce(t,U(e,i),U(n,a)),de(t,s)}function ir(t,e,n,i=.1,a=1){ce(t,It(e,i),U(n)),de(t,a)}function ar(t,e,n,i=.1,a=1){ce(t,Pt(e,i),U(n)),de(t,a)}function sr(t,e,n,i=.05,a=.05,s=1){ce(t,It(e,a),kt(n,i)),de(t,s)}function or(t,e,n,i=.05,a=.05,s=1){ce(t,Pt(e,a),kt(n,i)),de(t,s)}function rr(t,e,n,i=.05,a=.05,s=1){ce(t,It(e,a),Lt(n,i)),de(t,s)}function lr(t,e,n,i=.05,a=.05,s=1){ce(t,Pt(e,a),Lt(n,i)),de(t,s)}function ce(t,e,n){t&&t.position?typeof t.position.set=="function"?t.position.set(e,n):(t.position.x=e,t.position.y=n):t&&(t.x=e,t.y=n)}function de(t,e){e!==1&&t&&t.scale&&(typeof t.scale.set=="function"?t.scale.set(e,e):t.scale.x!==void 0&&t.scale.y!==void 0&&(t.scale.x=e,t.scale.y=e))}var Ae={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function cr(t){return t&&Ae[t]?JSON.parse(JSON.stringify(Ae[t])):JSON.parse(JSON.stringify(Qe))}function Ze(t){Object.keys(t).forEach(e=>{let n=e;Qe[n]&&t[n]&&Object.assign(Qe[n],t[n])}),console.log("Config applied:",t)}function dr(t,e){let n=t/e;n>1.6?(Ze(Ae.wide),console.log("Applied WIDE config for ratio:",n)):n<.7?(Ze(Ae.tall),console.log("Applied TALL config for ratio:",n)):n>.8&&n<1.2?(Ze(Ae.square),console.log("Applied SQUARE config for ratio:",n)):(Ze(Ae.default),console.log("Applied DEFAULT config for ratio:",n))}if(typeof window!="undefined"){let t=window;t.configPresets=Ae,t.resolveAnchorVec2=t.resolveAnchorVec2||et,t.resolveScreenAnchorPoint=t.resolveScreenAnchorPoint||hn,t.resolveScreenRatioPoint=t.resolveScreenRatioPoint||gn}yn();function _(t,e){let n=(a,s)=>s===0?a:n(s,a%s),i=n(t,e);return`${t/i}:${e/i}`}var Kc=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:_(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:_(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:_(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:_(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:_(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:_(360,780)}],Jc=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:_(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:_(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:_(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:_(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:_(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:_(412,915)}],Zc=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:_(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:_(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:_(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:_(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:_(800,1280)}],Ka=[{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:_(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:_(768,1024),mraidScale:.7}];var Qc=[...Ka];var br=Ka[0];Q();function wr(t){return new Promise((e,n)=>{let i=new FileReader;i.onerror=()=>n(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(t)})}function xr(t){var a;let[e,n]=t.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:n!=null?n:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}async function Sr(t){return await new Promise(e=>{let n=new Image;n.onload=()=>e({width:n.naturalWidth||n.width,height:n.naturalHeight||n.height}),n.onerror=()=>e(null),n.src=t})}async function vn(t){var e,n;try{console.log("[ImageUtils] Fetching image data from URL:",t);let i=await fetch(t);if(!i.ok)return console.warn("[ImageUtils] Fetch failed with status:",i.status,t),null;let a=await i.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let s=await wr(a),o=await Sr(s),r=xr(s);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",r.mimeType),{base64:r.base64,mimeType:r.mimeType,dataUrl:s,width:(e=o==null?void 0:o.width)!=null?e:0,height:(n=o==null?void 0:o.height)!=null?n:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function _t(t,e=30){try{console.log("[ImageUtils] Removing background color...");let n=await new Promise((c,h)=>{let u=new Image;u.onload=()=>c(u),u.onerror=()=>h(new Error("Failed to load image")),u.src=t}),i=document.createElement("canvas");i.width=n.width,i.height=n.height;let a=i.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),t;a.drawImage(n,0,0);let s=a.getImageData(0,0,i.width,i.height),o=s.data,l=[{name:"top-left",offset:0},{name:"top-right",offset:(i.width-1)*4},{name:"bottom-left",offset:(i.height-1)*i.width*4},{name:"bottom-right",offset:((i.height-1)*i.width+(i.width-1))*4}].map(c=>({r:o[c.offset],g:o[c.offset+1],b:o[c.offset+2]})),d=0;for(let c=0;c<o.length;c+=4){let h=o[c],u=o[c+1],f=o[c+2],g=!1;for(let w of l)if(Math.sqrt(Math.pow(h-w.r,2)+Math.pow(u-w.g,2)+Math.pow(f-w.b,2))<e){g=!0;break}g&&(o[c+3]=0,d++)}return console.log(`[ImageUtils] Removed background from ${d} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(s,0,0),i.toDataURL("image/png")}catch(n){return console.error("[ImageUtils] Error removing background:",n),t}}var Za=require("@google/genai");async function wn(t,e,n=[],i={}){var a,s,o,r,l,d,p;try{if(!(t!=null&&t.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let v=0;v<n.length;v++){let b=n[v];if(!b.base64||!b.mimeType)throw new Error(`Image ${v+1} is missing required data`);if(b.base64.length<1e3&&console.warn(`Image ${v+1} data appears very small, may be corrupted`),!b.mimeType.startsWith("image/"))throw new Error(`Image ${v+1} has invalid MIME type: ${b.mimeType}`)}let c=new Za.GoogleGenAI({apiKey:t}),h="gemini-2.5-flash",u=[e];n.length>0&&n.forEach((v,b)=>{u.push({inlineData:{data:v.base64,mimeType:v.mimeType}}),console.log(`[Gemini] Added image ${b+1}: ${v.mimeType}, size: ${Math.round(v.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${n.length} images and prompt length: ${e.length}`);let f=await c.models.generateContent({model:h,contents:u}),g="",w=(o=(s=(a=f.candidates)==null?void 0:a[0])==null?void 0:s.content)==null?void 0:o.parts;if(w)for(let v of w)v.text&&(g+=v.text);if(!g.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${g.length}`),g}catch(c){throw console.error("[Gemini] API error:",c),(r=c.message)!=null&&r.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(l=c.message)!=null&&l.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(d=c.message)!=null&&d.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(p=c.message)!=null&&p.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):c}}var Qa=require("@google/genai");async function Mt(t,e,n=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Qa.GoogleGenAI({apiKey:t}),s=[{text:e}];n.length>0&&n.forEach((r,l)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${l}`),s.push({inlineData:{mimeType:r.mimeType,data:r.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:s});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let r of o.candidates[0].content.parts)if(r.text)console.log(r.text);else if(r.inlineData){let l=r.inlineData.data,d=r.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${d};base64,${l}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(a){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(a,Object.getOwnPropertyNames(a),2)),a}}var Er=require("pixi.js");Je();xt();Q();var ts=require("pixi.js");var Ar=require("pixi.js");Q();function $r(t){return new Promise((e,n)=>{let i=new FileReader;i.onerror=()=>n(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(t)})}function zr(t){var a;let[e,n]=t.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:n!=null?n:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}function Dr(t){return`
98
98
  Analyze these screenshots of a brand or game and extract its "Brand DNA".
99
99
 
100
100
  Provide a concise summary (2-3 sentences) covering: