handler-playable-sdk 0.1.18 → 0.2.1

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.
@@ -0,0 +1,17 @@
1
+ var u={};function I(e,t,n=!1){u[e]||(u[e]=[]),u[e].push({fn:t,once:n})}function V(e,t){if(u[e]){if(!t){delete u[e];return}u[e]=u[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=u[e];if(n)for(let i of[...n])i.fn(...t),i.once&&V(e,i.fn)}function a(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.2.1",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var s=0,Se=s++,Z=s++,ee=s++,te=s++,ne=s++,ie=s++,oe=s++,re=s++,ae=s++,se=s++,de=s++,le=s++,r=Se;function ce(){return r===Z}function ue(){return r===ee}function pe(){return r===te}function fe(){return r===ne}function g(){return r===ie}function y(){return r===oe}function me(){return r===re}function ge(){return r===ae}function ye(){return r===se}function H(){return r===de}function F(){return r===le}function we(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=Z;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=ee;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=te)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ne)}catch{}else if(t==="mintegral")window.gameReady&&(r=ie);else if(t==="tapjoy")window.TJ_API&&(r=oe);else if(t==="tiktok")window.openAppStore&&(r=re);else if(t==="smadex")try{window.smxTracking&&(r=ae)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=se)}catch{}else t==="vungle"?r=de:(e==="nucleo"||t==="nucleo")&&(r=le)}var Ee={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ce=Math.random().toString(36).slice(2),w=null,A={...Ee},Ae="web_embed",De={},G=!1,E=!1,T=!1,ke=!1,B=1,W=0,z=!1,d=!1,N="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),K=h>b,l=!1,k=!1,he=!1,be=!1,U=!1,M=null;function _e(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function j(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Te(e,t){return{event_name:e,ts:Date.now(),session_id:Ce,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:Ae==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=j(e),i=Te(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){B=e,o("volume",e)}function v(e){e&&(ke=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&ke||T&&(T=!1,o("resume"),_(B))}function f(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),K=h>b,o("resize",{width:h,height:b})}function Le(){if(ce())try{let e=mraid.getMaxSize();f(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();f(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ie(){if(ue())try{let e=dapi.getScreenSize();f(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();f(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function ve(){let e=()=>{l||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(l=!0,o("boot"),o("view"),o("ready"),d=!0,O(),k&&(k=!1,p.start()))};window.addEventListener("resize",()=>f()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function Pe(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(he=!0),!(he&&t instanceof MouseEvent)&&(W+=1,o("interaction",W))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Re(e){var i,c,x,C,J,D,q,L,$,X,Y,Q;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(c=window.TJ_API)==null?void 0:c.click)==null||x.call(c);else if(pe())(J=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||J.call(C);else if(ye())(q=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||q.call(D);else if(ge())try{($=(L=window.smxTracking)==null?void 0:L.redirect)==null||$.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(fe()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||N||""):e&&window.open(e)}else g()?(X=window.install)==null||X.call(window):me()?(Y=window.openAppStore)==null||Y.call(window):H()?(Q=parent==null?void 0:parent.postMessage)==null||Q.call(parent,"download","*"):e&&window.open(e)}function Me(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;a("view",()=>t(n.mraid_viewable)),a("start",()=>t(n.game_viewable)),a("engagement",()=>t(n.engagement));let i=()=>t(n.complete);a("complete",i),I("engagement",c=>{var x;((x=c==null?void 0:c.payload)==null?void 0:x.count)>3&&i()}),a("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;a("view",()=>t(n.Ad_Load_Start)),a("start",()=>t(n.Ad_Viewable)),a("engagement",()=>t(n.First_Engagement)),a("complete",()=>t(n.Gameplay_Complete)),a("cta_click",()=>t(n.DSP_Click)),a("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function je(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{p.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function xe(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function Ne(){g()&&(window.mintGameStart=()=>{S(!0),f()},window.mintGameClose=()=>{v(!0)})}function ze(){if(!F())return;let e=window.NUC;!e||!e.trigger||(p.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,N)}),p.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var p={init(e={},t){if(Ae=e.profile||"web_embed",De=e.consent||{},A={...Ee,...e.ids||{}},w=e.rootEl||w,N=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,_e(),Ve(w),we(),Le(),Ie(),!z){if(document.readyState==="complete")ve();else if(!be){be=!0;let n=()=>{ve(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Pe(),Me(),je(),Ne(),ze(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),l&&!d&&(o("boot"),o("view"),o("ready"),k&&(k=!1,p.start()),d=!0),d=l},getRoot(){return _e()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return K},get isReady(){return d},get isStarted(){return G},get isPaused(){return T},get isFinished(){return E},get volume(){return B},get interactions(){return W},on(e,t){I(j(e),t)},off(e,t){V(j(e),t)},start(){var e,t;if(!G){if(!l){k=!0;return}if(G=!0,o("start"),f(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:K?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):H()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&xe())},install(e){if(!E){E=!0,y()?(xe(),setTimeout(()=>p.install(e),300)):(o("complete"),setTimeout(()=>p.install(e),0));return}U||(U=!0,setTimeout(()=>U=!1,500),o("cta_click"),o("conversion"),Re(e||N))},emit(e,t){let n=j(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Te(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(F()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){f(e,t)}},Be=p;function Ve(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
2
+ (function(){
3
+ var events = ['touchstart','touchend','mousedown','keydown'];
4
+ function unlock(){
5
+ if(window.AudioContext && AudioContext.prototype.resume){
6
+ if(!window.__handler_audio_ctx){
7
+ window.__handler_audio_ctx = new AudioContext();
8
+ }
9
+ if(window.__handler_audio_ctx.state === 'suspended'){
10
+ window.__handler_audio_ctx.resume();
11
+ }
12
+ }
13
+ events.forEach(function(e){ document.removeEventListener(e, unlock); });
14
+ }
15
+ events.forEach(function(e){ document.addEventListener(e, unlock, false); });
16
+ })();
17
+ `,e.appendChild(t)}export{p as a,Be as b};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var V=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ce(t))!De.call(e,a)&&a!==n&&V(e,a,{get:()=>t[a],enumerable:!(i=Se(t,a))||i.enumerable});return e};var Pe=e=>Ie(V({},"__esModule",{value:!0}),e);var qe={};Le(qe,{Handler:()=>u,default:()=>Be});module.exports=Pe(qe);var p={};function I(e,t,n=!1){p[e]||(p[e]=[]),p[e].push({fn:t,once:n})}function H(e,t){if(p[e]){if(!t){delete p[e];return}p[e]=p[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=p[e];if(n)for(let i of[...n])i.fn(...t),i.once&&H(e,i.fn)}function s(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.1.18",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var d=0,Me=d++,ee=d++,te=d++,ne=d++,ie=d++,oe=d++,re=d++,ae=d++,se=d++,de=d++,le=d++,ce=d++,r=Me;function ue(){return r===ee}function pe(){return r===te}function fe(){return r===ne}function me(){return r===ie}function g(){return r===oe}function y(){return r===re}function ge(){return r===ae}function ye(){return r===se}function we(){return r===de}function F(){return r===le}function G(){return r===ce}function he(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=ee;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=te;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=ne)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ie)}catch{}else if(t==="mintegral")window.gameReady&&(r=oe);else if(t==="tapjoy")window.TJ_API&&(r=re);else if(t==="tiktok")window.openAppStore&&(r=ae);else if(t==="smadex")try{window.smxTracking&&(r=se)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=de)}catch{}else t==="vungle"?r=le:(e==="nucleo"||t==="nucleo")&&(r=ce)}var Ae={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},je=Math.random().toString(36).slice(2),w=null,A={...Ae},ke="web_embed",Ne={},U=!1,E=!1,T=!1,Te=!1,J=1,K=0,z=!1,l=!1,N="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),B=h>b,c=!1,k=!1,be=!1,_e=!1,W=!1,M=null;function ve(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function j(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Oe(e,t){return{event_name:e,ts:Date.now(),session_id:je,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:ke==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=j(e),i=Oe(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){J=e,o("volume",e)}function v(e){e&&(Te=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&Te||T&&(T=!1,o("resume"),_(J))}function f(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),B=h>b,o("resize",{width:h,height:b})}function ze(){if(ue())try{let e=mraid.getMaxSize();f(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();f(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ve(){if(pe())try{let e=dapi.getScreenSize();f(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();f(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function xe(){let e=()=>{c||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(c=!0,o("boot"),o("view"),o("ready"),l=!0,O(),k&&(k=!1,u.start()))};window.addEventListener("resize",()=>f()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function He(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(be=!0),!(be&&t instanceof MouseEvent)&&(K+=1,o("interaction",K))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Fe(e){var i,a,x,C,q,D,$,L,X,Y,Q,Z;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(a=window.TJ_API)==null?void 0:a.click)==null||x.call(a);else if(fe())(q=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||q.call(C);else if(we())($=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||$.call(D);else if(ye())try{(X=(L=window.smxTracking)==null?void 0:L.redirect)==null||X.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(me()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||N||""):e&&window.open(e)}else g()?(Y=window.install)==null||Y.call(window):ge()?(Q=window.openAppStore)==null||Q.call(window):F()?(Z=parent==null?void 0:parent.postMessage)==null||Z.call(parent,"download","*"):e&&window.open(e)}function Ge(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;s("view",()=>t(n.mraid_viewable)),s("start",()=>t(n.game_viewable)),s("engagement",()=>t(n.engagement));let i=()=>t(n.complete);s("complete",i),I("engagement",a=>{var x;((x=a==null?void 0:a.payload)==null?void 0:x.count)>3&&i()}),s("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;s("view",()=>t(n.Ad_Load_Start)),s("start",()=>t(n.Ad_Viewable)),s("engagement",()=>t(n.First_Engagement)),s("complete",()=>t(n.Gameplay_Complete)),s("cta_click",()=>t(n.DSP_Click)),s("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ue(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{u.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Ee(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function We(){g()&&(window.mintGameStart=()=>{S(!0),f()},window.mintGameClose=()=>{v(!0)})}function Ke(){if(!G())return;let e=window.NUC;!e||!e.trigger||(u.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,N)}),u.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var u={init(e={},t){if(ke=e.profile||"web_embed",Ne=e.consent||{},A={...Ae,...e.ids||{}},w=e.rootEl||w,N=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,ve(),Je(w),he(),ze(),Ve(),!z){if(document.readyState==="complete")xe();else if(!_e){_e=!0;let n=()=>{xe(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}He(),Ge(),Ue(),We(),Ke(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),c&&!l&&(o("boot"),o("view"),o("ready"),k&&(k=!1,u.start()),l=!0),l=c},getRoot(){return ve()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return B},get isReady(){return l},get isStarted(){return U},get isPaused(){return T},get isFinished(){return E},get volume(){return J},get interactions(){return K},on(e,t){I(j(e),t)},off(e,t){H(j(e),t)},start(){var e,t;if(!U){if(!c){k=!0;return}if(U=!0,o("start"),f(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:B?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):F()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&Ee())},install(e){if(!E){E=!0,y()?(Ee(),setTimeout(()=>u.install(e),300)):(o("complete"),setTimeout(()=>u.install(e),0));return}W||(W=!0,setTimeout(()=>W=!1,500),o("cta_click"),o("conversion"),Fe(e||N))},emit(e,t){let n=j(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Oe(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(G()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){f(e,t)}},Be=u;function Je(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
1
+ "use strict";var V=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ce(t))!De.call(e,a)&&a!==n&&V(e,a,{get:()=>t[a],enumerable:!(i=Se(t,a))||i.enumerable});return e};var Pe=e=>Ie(V({},"__esModule",{value:!0}),e);var qe={};Le(qe,{Handler:()=>u,default:()=>Be});module.exports=Pe(qe);var p={};function I(e,t,n=!1){p[e]||(p[e]=[]),p[e].push({fn:t,once:n})}function H(e,t){if(p[e]){if(!t){delete p[e];return}p[e]=p[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=p[e];if(n)for(let i of[...n])i.fn(...t),i.once&&H(e,i.fn)}function s(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.2.1",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var d=0,Me=d++,ee=d++,te=d++,ne=d++,ie=d++,oe=d++,re=d++,ae=d++,se=d++,de=d++,le=d++,ce=d++,r=Me;function ue(){return r===ee}function pe(){return r===te}function fe(){return r===ne}function me(){return r===ie}function g(){return r===oe}function y(){return r===re}function ge(){return r===ae}function ye(){return r===se}function we(){return r===de}function F(){return r===le}function G(){return r===ce}function he(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=ee;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=te;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=ne)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ie)}catch{}else if(t==="mintegral")window.gameReady&&(r=oe);else if(t==="tapjoy")window.TJ_API&&(r=re);else if(t==="tiktok")window.openAppStore&&(r=ae);else if(t==="smadex")try{window.smxTracking&&(r=se)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=de)}catch{}else t==="vungle"?r=le:(e==="nucleo"||t==="nucleo")&&(r=ce)}var Ae={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},je=Math.random().toString(36).slice(2),w=null,A={...Ae},ke="web_embed",Ne={},U=!1,E=!1,T=!1,Te=!1,J=1,K=0,z=!1,l=!1,N="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),B=h>b,c=!1,k=!1,be=!1,_e=!1,W=!1,M=null;function ve(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function j(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Oe(e,t){return{event_name:e,ts:Date.now(),session_id:je,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:ke==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=j(e),i=Oe(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){J=e,o("volume",e)}function v(e){e&&(Te=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&Te||T&&(T=!1,o("resume"),_(J))}function f(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),B=h>b,o("resize",{width:h,height:b})}function ze(){if(ue())try{let e=mraid.getMaxSize();f(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();f(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ve(){if(pe())try{let e=dapi.getScreenSize();f(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();f(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function xe(){let e=()=>{c||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(c=!0,o("boot"),o("view"),o("ready"),l=!0,O(),k&&(k=!1,u.start()))};window.addEventListener("resize",()=>f()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function He(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(be=!0),!(be&&t instanceof MouseEvent)&&(K+=1,o("interaction",K))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Fe(e){var i,a,x,C,q,D,$,L,X,Y,Q,Z;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(a=window.TJ_API)==null?void 0:a.click)==null||x.call(a);else if(fe())(q=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||q.call(C);else if(we())($=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||$.call(D);else if(ye())try{(X=(L=window.smxTracking)==null?void 0:L.redirect)==null||X.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(me()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||N||""):e&&window.open(e)}else g()?(Y=window.install)==null||Y.call(window):ge()?(Q=window.openAppStore)==null||Q.call(window):F()?(Z=parent==null?void 0:parent.postMessage)==null||Z.call(parent,"download","*"):e&&window.open(e)}function Ge(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;s("view",()=>t(n.mraid_viewable)),s("start",()=>t(n.game_viewable)),s("engagement",()=>t(n.engagement));let i=()=>t(n.complete);s("complete",i),I("engagement",a=>{var x;((x=a==null?void 0:a.payload)==null?void 0:x.count)>3&&i()}),s("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;s("view",()=>t(n.Ad_Load_Start)),s("start",()=>t(n.Ad_Viewable)),s("engagement",()=>t(n.First_Engagement)),s("complete",()=>t(n.Gameplay_Complete)),s("cta_click",()=>t(n.DSP_Click)),s("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ue(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{u.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Ee(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function We(){g()&&(window.mintGameStart=()=>{S(!0),f()},window.mintGameClose=()=>{v(!0)})}function Ke(){if(!G())return;let e=window.NUC;!e||!e.trigger||(u.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,N)}),u.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var u={init(e={},t){if(ke=e.profile||"web_embed",Ne=e.consent||{},A={...Ae,...e.ids||{}},w=e.rootEl||w,N=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,ve(),Je(w),he(),ze(),Ve(),!z){if(document.readyState==="complete")xe();else if(!_e){_e=!0;let n=()=>{xe(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}He(),Ge(),Ue(),We(),Ke(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),c&&!l&&(o("boot"),o("view"),o("ready"),k&&(k=!1,u.start()),l=!0),l=c},getRoot(){return ve()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return B},get isReady(){return l},get isStarted(){return U},get isPaused(){return T},get isFinished(){return E},get volume(){return J},get interactions(){return K},on(e,t){I(j(e),t)},off(e,t){H(j(e),t)},start(){var e,t;if(!U){if(!c){k=!0;return}if(U=!0,o("start"),f(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:B?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):F()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&Ee())},install(e){if(!E){E=!0,y()?(Ee(),setTimeout(()=>u.install(e),300)):(o("complete"),setTimeout(()=>u.install(e),0));return}W||(W=!0,setTimeout(()=>W=!1,500),o("cta_click"),o("conversion"),Fe(e||N))},emit(e,t){let n=j(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Oe(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(G()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){f(e,t)}},Be=u;function Je(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
2
2
  (function(){
3
3
  var events = ['touchstart','touchend','mousedown','keydown'];
4
4
  function unlock(){
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a,b}from"./chunk-2XLITEWW.mjs";export{a as Handler,b as default};
1
+ import{a,b}from"./chunk-SYQVN25U.mjs";export{a as Handler,b as default};
@@ -1,4 +1,4 @@
1
- "use strict";var Ke=Object.defineProperty;var Ka=Object.getOwnPropertyDescriptor;var $a=Object.getOwnPropertyNames;var Ja=Object.prototype.hasOwnProperty;var Qa=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},Za=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of $a(t))!Ja.call(e,s)&&s!==n&&Ke(e,s,{get:()=>t[s],enumerable:!(a=Ka(t,s))||a.enumerable});return e};var Ua=e=>Za(Ke({},"__esModule",{value:!0}),e);var bi={};Qa(bi,{GameObject:()=>Ae,GameObjectManager:()=>je,Renderer:()=>Ce,Transform:()=>Se,animateHandClick:()=>ia,animatePanelEntrance:()=>aa,createBrushTexture:()=>ca,createEndGamePanel:()=>na,createHandTutorial:()=>sa,createPixiBase:()=>Un,createTutorialLabel:()=>oa,getRegisteredFontIds:()=>ta,loadAsset:()=>at,loadCharacterFrames:()=>la,registerFont:()=>ea,resolveFont:()=>I,resolveFontWeight:()=>G,updateHandAnimation:()=>ra});module.exports=Ua(bi);var Zn=require("pixi.js");var ee={};function Re(e,t,n=!1){ee[e]||(ee[e]=[]),ee[e].push({fn:t,once:n})}function $e(e,t){if(ee[e]){if(!t){delete ee[e];return}ee[e]=ee[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=ee[e];if(n)for(let a of[...n])a.fn(...t),a.once&&$e(e,a.fn)}function W(e,t){Re(e,t,!0)}var He={name:"handler-playable-sdk",version:"0.1.18",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var N=0,ti=N++,Sn=N++,Cn=N++,An=N++,En=N++,kn=N++,Dn=N++,Pn=N++,Mn=N++,Fn=N++,Ln=N++,Rn=N++,_=ti;function zn(){return _===Sn}function Hn(){return _===Cn}function On(){return _===An}function Wn(){return _===En}function de(){return _===kn}function ue(){return _===Dn}function Nn(){return _===Pn}function Yn(){return _===Mn}function Bn(){return _===Fn}function Je(){return _===Ln}function Qe(){return _===Rn}function jn(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),_=Sn;return}catch{}else if(e==="dapi")try{dapi.isReady(),_=Cn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(_=An)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(_=En)}catch{}else if(t==="mintegral")window.gameReady&&(_=kn);else if(t==="tapjoy")window.TJ_API&&(_=Dn);else if(t==="tiktok")window.openAppStore&&(_=Pn);else if(t==="smadex")try{window.smxTracking&&(_=Mn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(_=Fn)}catch{}else t==="vungle"?_=Ln:(e==="nucleo"||t==="nucleo")&&(_=Rn)}var Kn={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},ni=Math.random().toString(36).slice(2),pe=null,be={...Kn},$n="web_embed",ai={},Ze=!1,_e=!1,xe=!1,Jn=!1,nt=1,et=0,Ye=!1,J=!1,Ne="",fe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),tt=fe>me,Q=!1,we=!1,In=!1,Gn=!1,Ue=!1,Oe=null;function Vn(){if(pe)return pe;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),pe=e,e}function We(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Qn(e,t){return{event_name:e,ts:Date.now(),session_id:ni,deployment_id:be.deployment_id,variant_id:be.variant_id,export_profile_id:be.profile_id,instance_id:be.instance_id||"default",env:$n==="mraid"?"mraid":"web",payload:t}}function y(e,t){let n=We(e),a=Qn(n,t);ze(n,a),n!==e&&ze(e,a)}function Te(){Oe&&(Oe(fe,me),Oe=null)}function he(e){nt=e,y("volume",e)}function ye(e){e&&(Jn=!0),!xe&&(xe=!0,y("pause"),he(0))}function ve(e){!e&&Jn||xe&&(xe=!1,y("resume"),he(nt))}function ne(e,t){fe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),tt=fe>me,y("resize",{width:fe,height:me})}function ii(){if(zn())try{let e=mraid.getMaxSize();ne(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ve():ye()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ne(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();he(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&he(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Ye=!0,mraid.isViewable()&&mraid.getState()!=="hidden")Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function si(){if(Hn())try{let e=dapi.getScreenSize();ne(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ve():ye()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();ne(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(he(t?1:0),dapi.addEventListener("audioVolumeChange",n=>he(n?1:0)),Ye=!0,dapi.isViewable())Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function qn(){let e=()=>{Q||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te(),we&&(we=!1,te.start()))};window.addEventListener("resize",()=>ne()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ve(),e()):ye()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ye=!0}function oi(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(In=!0),!(In&&t instanceof MouseEvent)&&(et+=1,y("interaction",et))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function ri(e){var a,s,i,o,r,l,d,p,f,u,c,h;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(a=window.ExitApi)==null||a.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ue())(i=(s=window.TJ_API)==null?void 0:s.click)==null||i.call(s);else if(On())(r=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||r.call(o);else if(Bn())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Yn())try{(f=(p=window.smxTracking)==null?void 0:p.redirect)==null||f.call(p)}catch(m){console.warn("Smadex redirect failed",m)}else if(Wn()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||Ne||""):e&&window.open(e)}else de()?(u=window.install)==null||u.call(window):Nn()?(c=window.openAppStore)==null||c.call(window):Je()?(h=parent==null?void 0:parent.postMessage)==null||h.call(parent,"download","*"):e&&window.open(e)}function li(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let a=new Image;a.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;W("view",()=>t(n.mraid_viewable)),W("start",()=>t(n.game_viewable)),W("engagement",()=>t(n.engagement));let a=()=>t(n.complete);W("complete",a),Re("engagement",s=>{var i;((i=s==null?void 0:s.payload)==null?void 0:i.count)>3&&a()}),W("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;W("view",()=>t(n.Ad_Load_Start)),W("start",()=>t(n.Ad_Viewable)),W("engagement",()=>t(n.First_Engagement)),W("complete",()=>t(n.Gameplay_Complete)),W("cta_click",()=>t(n.DSP_Click)),W("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function ci(){if(!ue())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Xn(){var t,n,a;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(a=e==null?void 0:e.gameplayFinished)==null||a.call(e)}function di(){de()&&(window.mintGameStart=()=>{ve(!0),ne()},window.mintGameClose=()=>{ye(!0)})}function ui(){if(!Qe())return;let e=window.NUC;!e||!e.trigger||(te.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ne)}),te.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var te={init(e={},t){if($n=e.profile||"web_embed",ai=e.consent||{},be={...Kn,...e.ids||{}},pe=e.rootEl||pe,Ne=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),y("init"),document.body.oncontextmenu=()=>!1,Vn(),pi(pe),jn(),ii(),si(),!Ye){if(document.readyState==="complete")qn();else if(!Gn){Gn=!0;let n=()=>{qn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}oi(),li(),ci(),di(),ui(),console.log(`%c @handler/playable-sdk %c v${He.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),Q&&!J&&(y("boot"),y("view"),y("ready"),we&&(we=!1,te.start()),J=!0),J=Q},getRoot(){return Vn()},get version(){return He.version||"0.0.0"},get maxWidth(){return fe},get maxHeight(){return me},get isLandscape(){return tt},get isReady(){return J},get isStarted(){return Ze},get isPaused(){return xe},get isFinished(){return _e},get volume(){return nt},get interactions(){return et},on(e,t){Re(We(e),t)},off(e,t){$e(We(e),t)},start(){var e,t;if(!Ze){if(!Q){we=!0;return}if(Ze=!0,y("start"),ne(),de())ye(),(e=window.gameReady)==null||e.call(window);else if(ue()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:tt?"landscape":"portrait",buildID:He.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,y("complete"),de()?(e=window.gameEnd)==null||e.call(window):Je()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ue()&&Xn())},install(e){if(!_e){_e=!0,ue()?(Xn(),setTimeout(()=>te.install(e),300)):(y("complete"),setTimeout(()=>te.install(e),0));return}Ue||(Ue=!0,setTimeout(()=>Ue=!1,500),y("cta_click"),y("conversion"),ri(e||Ne))},emit(e,t){let n=We(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let a=Qn(n,t);ze(n,a)},retry(){var e,t,n;if(de())(e=window.gameRetry)==null||e.call(window);else if(Qe()){let a=window.NUC;(n=(t=a==null?void 0:a.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}y("engagement",{action:"retry"})},pause(){ye(!0)},resume(){ve(!0)},resize(e,t){ne(e,t)}},Be=te;function pi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
1
+ "use strict";var Ke=Object.defineProperty;var $a=Object.getOwnPropertyDescriptor;var Ja=Object.getOwnPropertyNames;var Qa=Object.prototype.hasOwnProperty;var Za=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},Ua=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ja(t))!Qa.call(e,s)&&s!==n&&Ke(e,s,{get:()=>t[s],enumerable:!(a=$a(t,s))||a.enumerable});return e};var ei=e=>Ua(Ke({},"__esModule",{value:!0}),e);var wi={};Za(wi,{GameObject:()=>Ae,GameObjectManager:()=>Ie,Renderer:()=>Ce,Transform:()=>Se,animateHandClick:()=>ia,animatePanelEntrance:()=>aa,createBrushTexture:()=>da,createEndGamePanel:()=>na,createHandTutorial:()=>sa,createPixiBase:()=>Un,createTutorialLabel:()=>oa,getRegisteredFontIds:()=>ta,loadAsset:()=>at,loadCharacterFrames:()=>ca,registerFont:()=>ea,resolveFont:()=>j,resolveFontWeight:()=>G,updateHandAnimation:()=>ra});module.exports=ei(wi);var Zn=require("pixi.js");var ee={};function Re(e,t,n=!1){ee[e]||(ee[e]=[]),ee[e].push({fn:t,once:n})}function $e(e,t){if(ee[e]){if(!t){delete ee[e];return}ee[e]=ee[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=ee[e];if(n)for(let a of[...n])a.fn(...t),a.once&&$e(e,a.fn)}function W(e,t){Re(e,t,!0)}var He={name:"handler-playable-sdk",version:"0.2.1",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var N=0,ni=N++,Sn=N++,Cn=N++,An=N++,En=N++,kn=N++,Dn=N++,Pn=N++,Fn=N++,Mn=N++,Ln=N++,Rn=N++,_=ni;function zn(){return _===Sn}function Hn(){return _===Cn}function On(){return _===An}function Wn(){return _===En}function de(){return _===kn}function ue(){return _===Dn}function Nn(){return _===Pn}function Yn(){return _===Fn}function Bn(){return _===Mn}function Je(){return _===Ln}function Qe(){return _===Rn}function In(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),_=Sn;return}catch{}else if(e==="dapi")try{dapi.isReady(),_=Cn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(_=An)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(_=En)}catch{}else if(t==="mintegral")window.gameReady&&(_=kn);else if(t==="tapjoy")window.TJ_API&&(_=Dn);else if(t==="tiktok")window.openAppStore&&(_=Pn);else if(t==="smadex")try{window.smxTracking&&(_=Fn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(_=Mn)}catch{}else t==="vungle"?_=Ln:(e==="nucleo"||t==="nucleo")&&(_=Rn)}var Kn={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},ai=Math.random().toString(36).slice(2),pe=null,be={...Kn},$n="web_embed",ii={},Ze=!1,_e=!1,xe=!1,Jn=!1,nt=1,et=0,Ye=!1,J=!1,Ne="",fe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),tt=fe>me,Q=!1,we=!1,jn=!1,Gn=!1,Ue=!1,Oe=null;function Vn(){if(pe)return pe;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),pe=e,e}function We(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Qn(e,t){return{event_name:e,ts:Date.now(),session_id:ai,deployment_id:be.deployment_id,variant_id:be.variant_id,export_profile_id:be.profile_id,instance_id:be.instance_id||"default",env:$n==="mraid"?"mraid":"web",payload:t}}function y(e,t){let n=We(e),a=Qn(n,t);ze(n,a),n!==e&&ze(e,a)}function Te(){Oe&&(Oe(fe,me),Oe=null)}function he(e){nt=e,y("volume",e)}function ye(e){e&&(Jn=!0),!xe&&(xe=!0,y("pause"),he(0))}function ve(e){!e&&Jn||xe&&(xe=!1,y("resume"),he(nt))}function ne(e,t){fe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),tt=fe>me,y("resize",{width:fe,height:me})}function si(){if(zn())try{let e=mraid.getMaxSize();ne(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ve():ye()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ne(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();he(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&he(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Ye=!0,mraid.isViewable()&&mraid.getState()!=="hidden")Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function oi(){if(Hn())try{let e=dapi.getScreenSize();ne(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ve():ye()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();ne(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(he(t?1:0),dapi.addEventListener("audioVolumeChange",n=>he(n?1:0)),Ye=!0,dapi.isViewable())Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function qn(){let e=()=>{Q||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te(),we&&(we=!1,te.start()))};window.addEventListener("resize",()=>ne()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ve(),e()):ye()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ye=!0}function ri(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(jn=!0),!(jn&&t instanceof MouseEvent)&&(et+=1,y("interaction",et))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function li(e){var a,s,i,o,r,l,d,p,f,u,c,h;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(a=window.ExitApi)==null||a.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ue())(i=(s=window.TJ_API)==null?void 0:s.click)==null||i.call(s);else if(On())(r=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||r.call(o);else if(Bn())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Yn())try{(f=(p=window.smxTracking)==null?void 0:p.redirect)==null||f.call(p)}catch(m){console.warn("Smadex redirect failed",m)}else if(Wn()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||Ne||""):e&&window.open(e)}else de()?(u=window.install)==null||u.call(window):Nn()?(c=window.openAppStore)==null||c.call(window):Je()?(h=parent==null?void 0:parent.postMessage)==null||h.call(parent,"download","*"):e&&window.open(e)}function ci(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let a=new Image;a.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;W("view",()=>t(n.mraid_viewable)),W("start",()=>t(n.game_viewable)),W("engagement",()=>t(n.engagement));let a=()=>t(n.complete);W("complete",a),Re("engagement",s=>{var i;((i=s==null?void 0:s.payload)==null?void 0:i.count)>3&&a()}),W("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;W("view",()=>t(n.Ad_Load_Start)),W("start",()=>t(n.Ad_Viewable)),W("engagement",()=>t(n.First_Engagement)),W("complete",()=>t(n.Gameplay_Complete)),W("cta_click",()=>t(n.DSP_Click)),W("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function di(){if(!ue())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Xn(){var t,n,a;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(a=e==null?void 0:e.gameplayFinished)==null||a.call(e)}function ui(){de()&&(window.mintGameStart=()=>{ve(!0),ne()},window.mintGameClose=()=>{ye(!0)})}function pi(){if(!Qe())return;let e=window.NUC;!e||!e.trigger||(te.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ne)}),te.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var te={init(e={},t){if($n=e.profile||"web_embed",ii=e.consent||{},be={...Kn,...e.ids||{}},pe=e.rootEl||pe,Ne=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),y("init"),document.body.oncontextmenu=()=>!1,Vn(),fi(pe),In(),si(),oi(),!Ye){if(document.readyState==="complete")qn();else if(!Gn){Gn=!0;let n=()=>{qn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}ri(),ci(),di(),ui(),pi(),console.log(`%c @handler/playable-sdk %c v${He.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),Q&&!J&&(y("boot"),y("view"),y("ready"),we&&(we=!1,te.start()),J=!0),J=Q},getRoot(){return Vn()},get version(){return He.version||"0.0.0"},get maxWidth(){return fe},get maxHeight(){return me},get isLandscape(){return tt},get isReady(){return J},get isStarted(){return Ze},get isPaused(){return xe},get isFinished(){return _e},get volume(){return nt},get interactions(){return et},on(e,t){Re(We(e),t)},off(e,t){$e(We(e),t)},start(){var e,t;if(!Ze){if(!Q){we=!0;return}if(Ze=!0,y("start"),ne(),de())ye(),(e=window.gameReady)==null||e.call(window);else if(ue()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:tt?"landscape":"portrait",buildID:He.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,y("complete"),de()?(e=window.gameEnd)==null||e.call(window):Je()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ue()&&Xn())},install(e){if(!_e){_e=!0,ue()?(Xn(),setTimeout(()=>te.install(e),300)):(y("complete"),setTimeout(()=>te.install(e),0));return}Ue||(Ue=!0,setTimeout(()=>Ue=!1,500),y("cta_click"),y("conversion"),li(e||Ne))},emit(e,t){let n=We(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let a=Qn(n,t);ze(n,a)},retry(){var e,t,n;if(de())(e=window.gameRetry)==null||e.call(window);else if(Qe()){let a=window.NUC;(n=(t=a==null?void 0:a.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}y("engagement",{action:"retry"})},pause(){ye(!0)},resume(){ve(!0)},resize(e,t){ne(e,t)}},Be=te;function fi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
2
2
  (function(){
3
3
  var events = ['touchstart','touchend','mousedown','keydown'];
4
4
  function unlock(){
@@ -14,4 +14,4 @@
14
14
  }
15
15
  events.forEach(function(e){ document.addEventListener(e, unlock, false); });
16
16
  })();
17
- `,e.appendChild(t)}async function Un(e,t={}){let n=new Zn.Application;await n.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let a=i=>{var l,d,p,f,u,c;let o=(p=(d=(l=i==null?void 0:i.width)!=null?l:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(c=(u=(f=i==null?void 0:i.height)!=null?f:e.clientHeight)!=null?u:window.innerHeight)!=null?c:480;n.renderer.resize(o,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(n.canvas);let s=document.createElement("div");return s.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(s),Be.on("pause",()=>{n.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),Be.on("resume",()=>{n.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),Be.on("resize",({payload:i})=>{a({width:i==null?void 0:i.width,height:i==null?void 0:i.height})}),window.addEventListener("resize",()=>a()),requestAnimationFrame(()=>a()),{app:n,stage:n.stage,overlay:s,applySize:a}}var Se=class{constructor(t){var n,a;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(a=t==null?void 0:t.rotation)!=null?a:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},Ce=class{constructor(t){var n,a,s,i;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(a=t==null?void 0:t.alpha)!=null?a:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(i=t==null?void 0:t.tint)!=null?i:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},Ae=class{constructor(t,n,a,s){this.instanceId=t,this.objectConfig=n,this.pixiObject=a,this._config=s,this.transform=new Se(s.transform),this.renderer=new Ce(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},je=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let a=this.config.objects.get(t);if(!a)throw new Error(`Object config not found: ${t}`);let s=new Ae(t,a.object_config||t,n,a);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,a]of this.objects.entries()){let s=t.objects.get(n);s&&a.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var Ie={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function I(e){let t=Ie[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function G(e){var n;let t=Ie[e];return t&&(n=t.weight)!=null?n:"400"}function ea(e,t){Ie[e]=t}function ta(){return Object.keys(Ie)}var w=require("pixi.js");function na(e,t,n){var ht,yt,gt,_t,bt,wt,xt,Tt,vt,St,Ct,At,Et,kt,Dt,Pt,Mt,Ft,Lt,Rt,zt,Ht,Ot,Wt,Nt,Yt,Bt,jt,It,Gt,Vt,qt,Xt,Kt,$t,Jt,Qt,Zt,Ut,en,tn,nn,an,sn,on,rn,ln,cn,dn,un,pn,fn,mn,hn,yn,gn,_n,bn,wn,xn;let a=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),i=e.objects.get("ui_endgame_title_1"),o=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),l=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),f=e.engine.runtime||{},u=new w.Container;u.alpha=0,u.visible=!1;let c=((ht=a==null?void 0:a.gameplay)==null?void 0:ht.tuning)||{},h=(a==null?void 0:a.render)||{},m=(yt=c.panel_width)!=null?yt:320,g=(gt=c.panel_height)!=null?gt:400,x=(_t=c.panel_padding)!=null?_t:32,T=(bt=c.panel_radius)!=null?bt:24,A=h.background_color||c.panel_bg_color||"#1a0a0a",v=h.background_alpha!==void 0&&h.background_alpha!==null?h.background_alpha:(wt=c.panel_bg_alpha)!=null?wt:.98,E=h.border_color||c.panel_border_color||"#ffffff",k=(xt=c.panel_border_width)!=null?xt:2,S=(Tt=c.panel_border_alpha)!=null?Tt:.3,C=new w.Graphics;C.roundRect(-m/2,-g/2,m,g,T);let b=A.replace("#","");C.fill({color:parseInt(b,16),alpha:v});let D=E.replace("#","");C.stroke({color:parseInt(D,16),width:k,alpha:S});let L=new w.Graphics;L.roundRect(-m/2+2,-g/2+2,m-4,g-4,T-2),L.stroke({color:16777215,width:1,alpha:.1}),C.addChild(L),u.addChild(C);let V=((vt=s==null?void 0:s.gameplay)==null?void 0:vt.tuning)||{},Z=(s==null?void 0:s.transform)||{},Y=(St=V.logo_size)!=null?St:56,q=(Ct=Z.scale)!=null?Ct:1,ae=(Et=(At=Z.offset)==null?void 0:At.y)!=null?Et:-130,da=(kt=V.logo_alpha)!=null?kt:1,M=new w.Sprite(n||w.Texture.EMPTY);M.anchor.set(.5);let se=0,oe=0;if(n&&n!==w.Texture.EMPTY){let F=n.frame,$=n.baseTexture;F&&F.width&&F.height?(se=F.width,oe=F.height):$&&$.width&&$.height?(se=$.width,oe=$.height):n.width&&n.height&&(se=n.width,oe=n.height)}if(se>0&&oe>0){let F=se/oe,$,Xe;F>1?($=Y,Xe=Y/F):(Xe=Y,$=Y*F);let Tn=$/se,vn=Xe/oe;Tn*=q,vn*=q,M.scale.set(Tn,vn)}else{let F=Y/100*q;M.scale.set(F)}M.position.set(0,ae),M.alpha=0,M.visible=!0,M.targetAlpha=da,M.baseScaleX=M.scale.x,M.baseScaleY=M.scale.y,u.addChild(M);let R=i==null?void 0:i.ui,B=((Dt=i==null?void 0:i.gameplay)==null?void 0:Dt.tuning)||{},ua=(R==null?void 0:R.text)||"MISSION ACCOMPLISHED",it=(R==null?void 0:R.font)||"brand.heading",pa=(R==null?void 0:R.fontSize)||24,fa=(Pt=R==null?void 0:R.letterSpacing)!=null?Pt:1,Ee=(Mt=i==null?void 0:i.render)==null?void 0:Mt.tint,ma=typeof Ee=="string"?Ee:Ee?`#${Ee.toString(16).padStart(6,"0")}`:"#00FF88",st=m-x*2-30,ha=B.font_weight_override?B.font_weight_override:G(it),U=new w.Text({text:ua,style:{fontFamily:I(it),fontSize:pa,fontWeight:ha,fill:ma,align:"center",letterSpacing:fa,wordWrap:!1,stroke:{color:B.stroke_color||"#000000",width:(Ft=B.stroke_width)!=null?Ft:2},dropShadow:{color:B.shadow_color||"#000000",alpha:(Lt=B.shadow_alpha)!=null?Lt:.9,angle:(Rt=B.shadow_angle)!=null?Rt:0,blur:(zt=B.shadow_blur)!=null?zt:8,distance:(Ht=B.shadow_distance)!=null?Ht:4}}});if(U.width>st){let F=st/U.width;U.scale.set(F)}U.anchor.set(.5);let ot=(Ot=c.title_offset_y)!=null?Ot:30,ya=ot+((Wt=B.animation_start_y_offset)!=null?Wt:-20);U.position.set(0,ya),U.alpha=0,u.addChild(U);let z=o==null?void 0:o.ui,rt=((Nt=o==null?void 0:o.gameplay)==null?void 0:Nt.tuning)||{},ga=(z==null?void 0:z.text)||"RESCUE COMPLETE",lt=(z==null?void 0:z.font)||"brand.body",_a=(z==null?void 0:z.fontSize)||11,ba=(Yt=z==null?void 0:z.letterSpacing)!=null?Yt:.5,ke=(Bt=o==null?void 0:o.render)==null?void 0:Bt.tint,wa=typeof ke=="string"?ke:ke?`#${ke.toString(16).padStart(6,"0")}`:"#B0B0B0",re=new w.Text({text:ga,style:{fontFamily:I(lt),fontSize:_a,fontWeight:G(lt),fill:wa,align:"center",letterSpacing:ba}});re.anchor.set(.5);let xa=ot+20+((jt=rt.animation_start_y_offset)!=null?jt:-10);re.position.set(0,xa),re.alpha=0,re.animationStartYOffset=(It=rt.animation_start_y_offset)!=null?It:-10,u.addChild(re);let X=r==null?void 0:r.ui,ct=((Gt=r==null?void 0:r.gameplay)==null?void 0:Gt.tuning)||{},Ta=(X==null?void 0:X.text)||((Vt=f.ui)==null?void 0:Vt.cta_hint)||"Continue the adventure!",dt=(X==null?void 0:X.font)||"brand.body",va=(X==null?void 0:X.fontSize)||16,De=(qt=r==null?void 0:r.render)==null?void 0:qt.tint,Sa=typeof De=="string"?De:De?`#${De.toString(16).padStart(6,"0")}`:"#FFFFFF",Ca=(Xt=ct.max_width)!=null?Xt:m-x*2,Aa=(Kt=ct.line_height)!=null?Kt:1.4,le=new w.Text({text:Ta,style:{fontFamily:I(dt),fontSize:va,fontWeight:G(dt),fill:Sa,align:"center",wordWrap:!0,wordWrapWidth:Ca,lineHeight:Aa}});le.anchor.set(.5);let Ea=($t=c.footer_offset_y)!=null?$t:120;le.position.set(0,Ea);let ka=((Jt=r==null?void 0:r.render)==null?void 0:Jt.alpha)!==void 0&&((Qt=r==null?void 0:r.render)==null?void 0:Qt.alpha)!==null?r.render.alpha:1;le.alpha=0,le.targetAlpha=ka,u.addChild(le);let K=((Zt=l==null?void 0:l.gameplay)==null?void 0:Zt.tuning)||{},H=l==null?void 0:l.ui,Pe=(Ut=K.button_width)!=null?Ut:260,Me=(en=K.button_height)!=null?en:56,ut=(tn=K.button_radius)!=null?tn:16,Da=K.button_bg_color||((nn=f.theme)==null?void 0:nn.cta_background)||"#ffb43b",Pa=(an=K.button_bg_alpha)!=null?an:1,Ma=K.button_border_color||"#ffffff",Fa=(sn=K.button_border_width)!=null?sn:2,La=(on=K.button_border_alpha)!=null?on:.2,Fe=(rn=c.cta_offset_y)!=null?rn:160,j=new w.Graphics;j.roundRect(-Pe/2,-Me/2,Pe,Me,ut);let Ra=Da.replace("#","");j.fill({color:parseInt(Ra,16),alpha:Pa});let za=Ma.replace("#","");j.stroke({color:parseInt(za,16),width:Fa,alpha:La});let Ve=new w.Graphics;Ve.roundRect(-Pe/2+2,-Me/2+2,Pe-4,Me-4,ut-2),Ve.stroke({color:0,width:1,alpha:.15}),j.addChild(Ve),j.position.set(0,Fe),j.alpha=0,j.eventMode="static",j.cursor="pointer",u.addChild(j);let Ha=(H==null?void 0:H.text)||((ln=f.ui)==null?void 0:ln.cta_label_end)||"DOWNLOAD",pt=(H==null?void 0:H.font)||"brand.heading",Oa=(H==null?void 0:H.fontSize)||20,Wa=K.button_text_color||((cn=f.theme)==null?void 0:cn.cta_text)||"#1a0a0a",ge=new w.Text({text:Ha,style:{fontFamily:I(pt),fontSize:Oa,fontWeight:G(pt),fill:Wa,align:"center",letterSpacing:(dn=H==null?void 0:H.letterSpacing)!=null?dn:1}});ge.anchor.set(.5),ge.position.set(0,Fe),ge.alpha=0,u.addChild(ge);let O=d==null?void 0:d.ui,ft=((un=d==null?void 0:d.gameplay)==null?void 0:un.tuning)||{},Na=(O==null?void 0:O.text)||"Play the full game",mt=(O==null?void 0:O.font)||"brand.body",Ya=(O==null?void 0:O.fontSize)||11,Ba=(pn=O==null?void 0:O.letterSpacing)!=null?pn:0,Le=(fn=d==null?void 0:d.render)==null?void 0:fn.tint,ja=typeof Le=="string"?Le:Le?`#${Le.toString(16).padStart(6,"0")}`:"#CCCCCC",ce=new w.Text({text:Na,style:{fontFamily:I(mt),fontSize:Ya,fontWeight:G(mt),fill:ja,align:"center",letterSpacing:Ba}});ce.anchor.set(.5);let Ia=Fe+35+((mn=ft.animation_start_y_offset)!=null?mn:5);ce.position.set(0,Ia),ce.alpha=0,ce.animationStartYOffset=(hn=ft.animation_start_y_offset)!=null?hn:5,u.addChild(ce);let qe=((yn=p==null?void 0:p.gameplay)==null?void 0:yn.tuning)||{},Ga=(gn=qe.hand_offset_x)!=null?gn:50,Va=(_n=qe.hand_offset_y)!=null?_n:50,qa=(wn=(bn=p==null?void 0:p.transform)==null?void 0:bn.scale)!=null?wn:.1875,Xa=(xn=qe.hand_scale_multiplier)!=null?xn:2.5,ie=new w.Sprite(t||w.Texture.EMPTY);return ie.anchor.set(.5),ie.scale.set(qa*Xa),ie.position.set(Ga,Fe+Va),ie.alpha=0,ie.visible=!1,u.addChild(ie),{panel:u,logo:M,title:U,subtitle:re,footer:le,ctaButton:j,ctaText:ge,ctaHint:ce,hand:ie}}function aa(e,t,n){var k,S,C,b,D,L,V,Z;let a=t.objects.get("ui_endgame_1"),s=((k=a==null?void 0:a.gameplay)==null?void 0:k.tuning)||{},i=(S=s.animation_duration_ms)!=null?S:800,o=(C=s.fade_in_duration_ms)!=null?C:600,r=(b=s.scale_animation_intensity)!=null?b:.1,l=(D=s.logo_animation_delay_ms)!=null?D:100,d=(L=s.title_animation_delay_ms)!=null?L:200,p=(V=s.footer_animation_delay_ms)!=null?V:300,f=(Z=s.cta_animation_delay_ms)!=null?Z:400,{panel:u,logo:c,title:h,subtitle:m,footer:g,ctaButton:x,ctaText:T,ctaHint:A}=e;u.visible=!0;let v=Date.now(),E=()=>{let Y=Date.now()-v,q=Math.min(Y/o,1),ae=1-Math.pow(1-q,3);u.alpha=ae,u.scale.set(1+r*(1-ae)),q<1?requestAnimationFrame(E):(setTimeout(()=>fi(c,i,t),l),setTimeout(()=>{mi(h,i),setTimeout(()=>hi(m,i),50)},d),setTimeout(()=>yi(g,i),p),setTimeout(()=>{gi(x,T,i),setTimeout(()=>_i(A,i),50),n&&n()},f))};E()}function fi(e,t,n){var u,c,h,m,g;let a=n==null?void 0:n.objects.get("ui_endgame_logo_1"),i=(c=(((u=a==null?void 0:a.gameplay)==null?void 0:u.tuning)||{}).animation_start_scale)!=null?c:1.2,o=Date.now(),r=e.alpha,l=(h=e.targetAlpha)!=null?h:1,d=(m=e.baseScaleX)!=null?m:e.scale.x,p=(g=e.baseScaleY)!=null?g:e.scale.y,f=()=>{let x=Date.now()-o,T=Math.min(x/t,1),A=1-Math.pow(1-T,2);e.alpha=r+(l-r)*A;let v=i+(1-i)*A;e.scale.set(d*v,p*v),T<1&&requestAnimationFrame(f)};f()}function mi(e,t){let n=Date.now(),a=e.alpha,s=e.y,i=()=>{let o=Date.now()-n,r=Math.min(o/t,1),l=1-Math.pow(1-r,2);e.alpha=a+(1-a)*l,e.y=s-20*(1-l),r<1&&requestAnimationFrame(i)};i()}function hi(e,t){var r;let n=Date.now(),a=e.alpha,s=e.position.y,i=s-((r=e.animationStartYOffset)!=null?r:-10),o=()=>{let l=Date.now()-n,d=Math.min(l/t,1),p=1-Math.pow(1-d,2);e.alpha=a+(1-a)*p,e.position.y=s+(i-s)*p,d<1&&requestAnimationFrame(o)};o()}function yi(e,t){var o;let n=Date.now(),a=e.alpha,s=(o=e.targetAlpha)!=null?o:1,i=()=>{let r=Date.now()-n,l=Math.min(r/t,1),d=1-Math.pow(1-l,2);e.alpha=a+(s-a)*d,l<1&&requestAnimationFrame(i)};i()}function gi(e,t,n){let a=Date.now(),s=e.alpha,i=()=>{let o=Date.now()-a,r=Math.min(o/n,1),l=1-Math.pow(1-r,2);e.alpha=s+(1-s)*l,t.alpha=s+(1-s)*l,e.scale.set(1+.1*(1-l)),r<1&&requestAnimationFrame(i)};i()}function _i(e,t){var r;let n=Date.now(),a=e.alpha,s=e.position.y,i=s-((r=e.animationStartYOffset)!=null?r:5),o=()=>{let l=Date.now()-n,d=Math.min(l/t,1),p=1-Math.pow(1-d,2);e.alpha=a+(1-a)*p,e.position.y=s+(i-s)*p,d<1&&requestAnimationFrame(o)};o()}function ia(e,t,n,a){var p,f,u,c;let s=n.objects.get("ui_endgame_hand_1"),i=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},o=(f=i.click_animation_duration_ms)!=null?f:600,r=(u=i.click_delay_ms)!=null?u:2e3,l=(c=i.click_repeat_delay_ms)!=null?c:3e3,d=()=>{var k,S;e.visible=!0,e.alpha=1;let h=e.x,m=e.y,g=(k=i.hand_offset_x)!=null?k:50,x=(S=i.hand_offset_y)!=null?S:50,T=t.x+g,A=t.y+x,v=Date.now(),E=()=>{var Y,q,ae;let C=Date.now()-v,b=Math.min(C/o,1),D=b<.5?2*b*b:1-Math.pow(-2*b+2,2)/2;e.x=h+(T-h)*D,e.y=m+(A-m)*D;let L=(q=(Y=s==null?void 0:s.transform)==null?void 0:Y.scale)!=null?q:.1875,V=(ae=i.hand_scale_multiplier)!=null?ae:2.5,Z=L*V;e.scale.set(Z+Z*.2*Math.sin(b*Math.PI)),b<1?requestAnimationFrame(E):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),a()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=h,e.y=m,d()},l)},500))};E()};setTimeout(d,r)}var Ge=require("pixi.js");function sa(e,t,n){var p,f,u,c;let a=t.objects.get("hand_tutorial_1"),s=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},i=(a==null?void 0:a.render)||{},o=(a==null?void 0:a.transform)||{},r=new Ge.Sprite(e);r.anchor.set(.5),r.alpha=0;let l=(f=s.hand_scale_multiplier)!=null?f:2.5,d=(u=o.scale)!=null?u:.1875;return r.scale.set(d*l),r.zIndex=(c=i.z_index)!=null?c:99999,r}function oa(e){var h,m,g,x,T,A,v,E,k,S;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,a=(t==null?void 0:t.render)||{},s=((h=e.engine.runtime)==null?void 0:h.ui_styles)||{},i=((m=e.engine.runtime)==null?void 0:m.ui)||{},o=(n==null?void 0:n.text)||i.tutorial_label||i.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||s.label_font_size||52,d=(x=n==null?void 0:n.letterSpacing)!=null?x:(g=s.label_letter_spacing)!=null?g:-1,p=(n==null?void 0:n.align)||"center",f=a.tint,u=typeof f=="string"?f:f?`#${f.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",c=new Ge.Text({text:o,style:{fontFamily:I(r),fontSize:l,fontWeight:G(r),fill:u,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(T=s.label_shadow_alpha)!=null?T:.8,angle:(A=s.label_shadow_angle)!=null?A:0,blur:(v=s.label_shadow_blur)!=null?v:4,distance:(E=s.label_shadow_distance)!=null?E:2}}});return c.anchor.set(.5,0),c.alpha=(k=a.alpha)!=null?k:0,c.visible=(S=a.visible)!=null?S:!0,c}function ra(e,t,n,a,s){var l,d,p,f,u,c,h;let i=s.objects.get("hand_tutorial_1"),o=((l=i==null?void 0:i.gameplay)==null?void 0:l.tuning)||{},r=(i==null?void 0:i.transform)||{};if(!a){let m=(d=o.animation_duration)!=null?d:1.5,g=n%m/m,x=g<.5?2*g*g:-1+(4-2*g)*g,T=(p=o.x_offset)!=null?p:0,A=(f=o.y_offset)!=null?f:0,v=(u=o.animation_range)!=null?u:40,E=v*.7,k=v,S=t.x+T+E,C=t.y+A+k,b=S+E,D=C+k;e.x=S+(b-S)*x,e.y=C+(D-C)*x;let L=(c=r.scale)!=null?c:.1875,V=(h=o.hand_scale_multiplier)!=null?h:2.5;e.scale.set(L*V)}}var P=require("pixi.js");async function at(e,t,n=16777215,a=!1){try{let i=(globalThis.INLINE_ASSETS||{})[e];return await P.Assets.load(i||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let i=new P.Graphics;return a?i.roundRect(0,0,60,120,10).fill({color:n}):(i.circle(30,30,30).fill({color:n}),i.rect(25,30,10,40).fill({color:n})),t.renderer.generateTexture(i)}}async function la(e,t,n){var m,g,x,T,A,v,E,k,S,C;let s=(globalThis.INLINE_ASSETS||{})[e]||e,i;try{i=await P.Assets.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(b){let L=(n.gameplay.character_sheet||{}).fallback_color||"#ff00ff";i=await at(e,t,new P.Color(L).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:b})}let o=i.source||i.baseTexture||i;o&&"valid"in o&&o.valid===!1&&typeof o.once=="function"&&await new Promise(b=>o.once("loaded",b));let r=n.gameplay.character_sheet||{},l=(m=r.cols)!=null?m:3,d=(g=r.rows)!=null?g:2,p=(v=(A=(x=o==null?void 0:o.width)!=null?x:o==null?void 0:o.pixelWidth)!=null?A:(T=o==null?void 0:o.baseTexture)==null?void 0:T.width)!=null?v:i.width,f=(C=(S=(E=o==null?void 0:o.height)!=null?E:o==null?void 0:o.pixelHeight)!=null?S:(k=o==null?void 0:o.baseTexture)==null?void 0:k.height)!=null?C:i.height,u=p/l,c=f/d;if(!Number.isFinite(u)||!Number.isFinite(c)||u<=0||c<=0||!o)return[i];let h=[];for(let b=0;b<d;b++)for(let D=0;D<l;D++)h.push(new P.Texture({source:o,frame:new P.Rectangle(D*u,b*c,u,c)}));return h.length>2&&h.push(...h.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:h.length}),h}function ca(e,t){var p,f,u,c;let n=t.gameplay.brush||{},a=new P.Color(t.theme.brush_color||"#ffffff").toNumber(),s=(p=n.radius)!=null?p:20,i=(f=n.inner_radius)!=null?f:15,o=(u=n.alpha)!=null?u:.8,r=(c=n.inner_alpha)!=null?c:.3,l=n.inner_color||"#ffffff",d=new P.Graphics;return d.circle(0,0,s).fill({color:a,alpha:o}),d.circle(0,0,i).fill({color:new P.Color(l).toNumber(),alpha:r}),e.renderer.generateTexture(d)}0&&(module.exports={GameObject,GameObjectManager,Renderer,Transform,animateHandClick,animatePanelEntrance,createBrushTexture,createEndGamePanel,createHandTutorial,createPixiBase,createTutorialLabel,getRegisteredFontIds,loadAsset,loadCharacterFrames,registerFont,resolveFont,resolveFontWeight,updateHandAnimation});
17
+ `,e.appendChild(t)}async function Un(e,t={}){let n=new Zn.Application;await n.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let a=i=>{var l,d,p,f,u,c;let o=(p=(d=(l=i==null?void 0:i.width)!=null?l:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(c=(u=(f=i==null?void 0:i.height)!=null?f:e.clientHeight)!=null?u:window.innerHeight)!=null?c:480;n.renderer.resize(o,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(n.canvas);let s=document.createElement("div");return s.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(s),Be.on("pause",()=>{n.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),Be.on("resume",()=>{n.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),Be.on("resize",({payload:i})=>{a({width:i==null?void 0:i.width,height:i==null?void 0:i.height})}),window.addEventListener("resize",()=>a()),requestAnimationFrame(()=>a()),{app:n,stage:n.stage,overlay:s,applySize:a}}var Se=class{constructor(t){var n,a;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(a=t==null?void 0:t.rotation)!=null?a:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},Ce=class{constructor(t){var n,a,s,i;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(a=t==null?void 0:t.alpha)!=null?a:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(i=t==null?void 0:t.tint)!=null?i:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},Ae=class{constructor(t,n,a,s){this.instanceId=t,this.objectConfig=n,this.pixiObject=a,this._config=s,this.transform=new Se(s.transform),this.renderer=new Ce(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},Ie=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let a=this.config.objects.get(t);if(!a)throw new Error(`Object config not found: ${t}`);let s=new Ae(t,a.object_config||t,n,a);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,a]of this.objects.entries()){let s=t.objects.get(n);s&&a.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var je={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function j(e){let t=je[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function G(e){var n;let t=je[e];return t&&(n=t.weight)!=null?n:"400"}function ea(e,t){je[e]=t}function ta(){return Object.keys(je)}var w=require("pixi.js");function na(e,t,n){var ht,yt,gt,_t,bt,wt,xt,Tt,vt,St,Ct,At,Et,kt,Dt,Pt,Ft,Mt,Lt,Rt,zt,Ht,Ot,Wt,Nt,Yt,Bt,It,jt,Gt,Vt,qt,Xt,Kt,$t,Jt,Qt,Zt,Ut,en,tn,nn,an,sn,on,rn,ln,cn,dn,un,pn,fn,mn,hn,yn,gn,_n,bn,wn,xn;let a=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),i=e.objects.get("ui_endgame_title_1"),o=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),l=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),f=e.engine.runtime||{},u=new w.Container;u.alpha=0,u.visible=!1;let c=((ht=a==null?void 0:a.gameplay)==null?void 0:ht.tuning)||{},h=(a==null?void 0:a.render)||{},m=(yt=c.panel_width)!=null?yt:320,g=(gt=c.panel_height)!=null?gt:400,x=(_t=c.panel_padding)!=null?_t:32,T=(bt=c.panel_radius)!=null?bt:24,A=h.background_color||c.panel_bg_color||"#1a0a0a",v=h.background_alpha!==void 0&&h.background_alpha!==null?h.background_alpha:(wt=c.panel_bg_alpha)!=null?wt:.98,E=h.border_color||c.panel_border_color||"#ffffff",k=(xt=c.panel_border_width)!=null?xt:2,S=(Tt=c.panel_border_alpha)!=null?Tt:.3,C=new w.Graphics;C.roundRect(-m/2,-g/2,m,g,T);let b=A.replace("#","");C.fill({color:parseInt(b,16),alpha:v});let D=E.replace("#","");C.stroke({color:parseInt(D,16),width:k,alpha:S});let L=new w.Graphics;L.roundRect(-m/2+2,-g/2+2,m-4,g-4,T-2),L.stroke({color:16777215,width:1,alpha:.1}),C.addChild(L),u.addChild(C);let V=((vt=s==null?void 0:s.gameplay)==null?void 0:vt.tuning)||{},Z=(s==null?void 0:s.transform)||{},Y=(St=V.logo_size)!=null?St:56,q=(Ct=Z.scale)!=null?Ct:1,ae=(Et=(At=Z.offset)==null?void 0:At.y)!=null?Et:-130,ua=(kt=V.logo_alpha)!=null?kt:1,F=new w.Sprite(n||w.Texture.EMPTY);F.anchor.set(.5);let se=0,oe=0;if(n&&n!==w.Texture.EMPTY){let M=n.frame,$=n.baseTexture;M&&M.width&&M.height?(se=M.width,oe=M.height):$&&$.width&&$.height?(se=$.width,oe=$.height):n.width&&n.height&&(se=n.width,oe=n.height)}if(se>0&&oe>0){let M=se/oe,$,Xe;M>1?($=Y,Xe=Y/M):(Xe=Y,$=Y*M);let Tn=$/se,vn=Xe/oe;Tn*=q,vn*=q,F.scale.set(Tn,vn)}else{let M=Y/100*q;F.scale.set(M)}F.position.set(0,ae),F.alpha=0,F.visible=!0,F.targetAlpha=ua,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,u.addChild(F);let R=i==null?void 0:i.ui,B=((Dt=i==null?void 0:i.gameplay)==null?void 0:Dt.tuning)||{},pa=(R==null?void 0:R.text)||"MISSION ACCOMPLISHED",it=(R==null?void 0:R.font)||"brand.heading",fa=(R==null?void 0:R.fontSize)||24,ma=(Pt=R==null?void 0:R.letterSpacing)!=null?Pt:1,Ee=(Ft=i==null?void 0:i.render)==null?void 0:Ft.tint,ha=typeof Ee=="string"?Ee:Ee?`#${Ee.toString(16).padStart(6,"0")}`:"#00FF88",st=m-x*2-30,ya=B.font_weight_override?B.font_weight_override:G(it),U=new w.Text({text:pa,style:{fontFamily:j(it),fontSize:fa,fontWeight:ya,fill:ha,align:"center",letterSpacing:ma,wordWrap:!1,stroke:{color:B.stroke_color||"#000000",width:(Mt=B.stroke_width)!=null?Mt:2},dropShadow:{color:B.shadow_color||"#000000",alpha:(Lt=B.shadow_alpha)!=null?Lt:.9,angle:(Rt=B.shadow_angle)!=null?Rt:0,blur:(zt=B.shadow_blur)!=null?zt:8,distance:(Ht=B.shadow_distance)!=null?Ht:4}}});if(U.width>st){let M=st/U.width;U.scale.set(M)}U.anchor.set(.5);let ot=(Ot=c.title_offset_y)!=null?Ot:30,ga=ot+((Wt=B.animation_start_y_offset)!=null?Wt:-20);U.position.set(0,ga),U.alpha=0,u.addChild(U);let z=o==null?void 0:o.ui,rt=((Nt=o==null?void 0:o.gameplay)==null?void 0:Nt.tuning)||{},_a=(z==null?void 0:z.text)||"RESCUE COMPLETE",lt=(z==null?void 0:z.font)||"brand.body",ba=(z==null?void 0:z.fontSize)||11,wa=(Yt=z==null?void 0:z.letterSpacing)!=null?Yt:.5,ke=(Bt=o==null?void 0:o.render)==null?void 0:Bt.tint,xa=typeof ke=="string"?ke:ke?`#${ke.toString(16).padStart(6,"0")}`:"#B0B0B0",re=new w.Text({text:_a,style:{fontFamily:j(lt),fontSize:ba,fontWeight:G(lt),fill:xa,align:"center",letterSpacing:wa}});re.anchor.set(.5);let Ta=ot+20+((It=rt.animation_start_y_offset)!=null?It:-10);re.position.set(0,Ta),re.alpha=0,re.animationStartYOffset=(jt=rt.animation_start_y_offset)!=null?jt:-10,u.addChild(re);let X=r==null?void 0:r.ui,ct=((Gt=r==null?void 0:r.gameplay)==null?void 0:Gt.tuning)||{},va=(X==null?void 0:X.text)||((Vt=f.ui)==null?void 0:Vt.cta_hint)||"Continue the adventure!",dt=(X==null?void 0:X.font)||"brand.body",Sa=(X==null?void 0:X.fontSize)||16,De=(qt=r==null?void 0:r.render)==null?void 0:qt.tint,Ca=typeof De=="string"?De:De?`#${De.toString(16).padStart(6,"0")}`:"#FFFFFF",Aa=(Xt=ct.max_width)!=null?Xt:m-x*2,Ea=(Kt=ct.line_height)!=null?Kt:1.4,le=new w.Text({text:va,style:{fontFamily:j(dt),fontSize:Sa,fontWeight:G(dt),fill:Ca,align:"center",wordWrap:!0,wordWrapWidth:Aa,lineHeight:Ea}});le.anchor.set(.5);let ka=($t=c.footer_offset_y)!=null?$t:120;le.position.set(0,ka);let Da=((Jt=r==null?void 0:r.render)==null?void 0:Jt.alpha)!==void 0&&((Qt=r==null?void 0:r.render)==null?void 0:Qt.alpha)!==null?r.render.alpha:1;le.alpha=0,le.targetAlpha=Da,u.addChild(le);let K=((Zt=l==null?void 0:l.gameplay)==null?void 0:Zt.tuning)||{},H=l==null?void 0:l.ui,Pe=(Ut=K.button_width)!=null?Ut:260,Fe=(en=K.button_height)!=null?en:56,ut=(tn=K.button_radius)!=null?tn:16,Pa=K.button_bg_color||((nn=f.theme)==null?void 0:nn.cta_background)||"#ffb43b",Fa=(an=K.button_bg_alpha)!=null?an:1,Ma=K.button_border_color||"#ffffff",La=(sn=K.button_border_width)!=null?sn:2,Ra=(on=K.button_border_alpha)!=null?on:.2,Me=(rn=c.cta_offset_y)!=null?rn:160,I=new w.Graphics;I.roundRect(-Pe/2,-Fe/2,Pe,Fe,ut);let za=Pa.replace("#","");I.fill({color:parseInt(za,16),alpha:Fa});let Ha=Ma.replace("#","");I.stroke({color:parseInt(Ha,16),width:La,alpha:Ra});let Ve=new w.Graphics;Ve.roundRect(-Pe/2+2,-Fe/2+2,Pe-4,Fe-4,ut-2),Ve.stroke({color:0,width:1,alpha:.15}),I.addChild(Ve),I.position.set(0,Me),I.alpha=0,I.eventMode="static",I.cursor="pointer",u.addChild(I);let Oa=(H==null?void 0:H.text)||((ln=f.ui)==null?void 0:ln.cta_label_end)||"DOWNLOAD",pt=(H==null?void 0:H.font)||"brand.heading",Wa=(H==null?void 0:H.fontSize)||20,Na=K.button_text_color||((cn=f.theme)==null?void 0:cn.cta_text)||"#1a0a0a",ge=new w.Text({text:Oa,style:{fontFamily:j(pt),fontSize:Wa,fontWeight:G(pt),fill:Na,align:"center",letterSpacing:(dn=H==null?void 0:H.letterSpacing)!=null?dn:1}});ge.anchor.set(.5),ge.position.set(0,Me),ge.alpha=0,u.addChild(ge);let O=d==null?void 0:d.ui,ft=((un=d==null?void 0:d.gameplay)==null?void 0:un.tuning)||{},Ya=(O==null?void 0:O.text)||"Play the full game",mt=(O==null?void 0:O.font)||"brand.body",Ba=(O==null?void 0:O.fontSize)||11,Ia=(pn=O==null?void 0:O.letterSpacing)!=null?pn:0,Le=(fn=d==null?void 0:d.render)==null?void 0:fn.tint,ja=typeof Le=="string"?Le:Le?`#${Le.toString(16).padStart(6,"0")}`:"#CCCCCC",ce=new w.Text({text:Ya,style:{fontFamily:j(mt),fontSize:Ba,fontWeight:G(mt),fill:ja,align:"center",letterSpacing:Ia}});ce.anchor.set(.5);let Ga=Me+35+((mn=ft.animation_start_y_offset)!=null?mn:5);ce.position.set(0,Ga),ce.alpha=0,ce.animationStartYOffset=(hn=ft.animation_start_y_offset)!=null?hn:5,u.addChild(ce);let qe=((yn=p==null?void 0:p.gameplay)==null?void 0:yn.tuning)||{},Va=(gn=qe.hand_offset_x)!=null?gn:50,qa=(_n=qe.hand_offset_y)!=null?_n:50,Xa=(wn=(bn=p==null?void 0:p.transform)==null?void 0:bn.scale)!=null?wn:.1875,Ka=(xn=qe.hand_scale_multiplier)!=null?xn:2.5,ie=new w.Sprite(t||w.Texture.EMPTY);return ie.anchor.set(.5),ie.scale.set(Xa*Ka),ie.position.set(Va,Me+qa),ie.alpha=0,ie.visible=!1,u.addChild(ie),{panel:u,logo:F,title:U,subtitle:re,footer:le,ctaButton:I,ctaText:ge,ctaHint:ce,hand:ie}}function aa(e,t,n){var k,S,C,b,D,L,V,Z;let a=t.objects.get("ui_endgame_1"),s=((k=a==null?void 0:a.gameplay)==null?void 0:k.tuning)||{},i=(S=s.animation_duration_ms)!=null?S:800,o=(C=s.fade_in_duration_ms)!=null?C:600,r=(b=s.scale_animation_intensity)!=null?b:.1,l=(D=s.logo_animation_delay_ms)!=null?D:100,d=(L=s.title_animation_delay_ms)!=null?L:200,p=(V=s.footer_animation_delay_ms)!=null?V:300,f=(Z=s.cta_animation_delay_ms)!=null?Z:400,{panel:u,logo:c,title:h,subtitle:m,footer:g,ctaButton:x,ctaText:T,ctaHint:A}=e;u.visible=!0;let v=Date.now(),E=()=>{let Y=Date.now()-v,q=Math.min(Y/o,1),ae=1-Math.pow(1-q,3);u.alpha=ae,u.scale.set(1+r*(1-ae)),q<1?requestAnimationFrame(E):(setTimeout(()=>mi(c,i,t),l),setTimeout(()=>{hi(h,i),setTimeout(()=>yi(m,i),50)},d),setTimeout(()=>gi(g,i),p),setTimeout(()=>{_i(x,T,i),setTimeout(()=>bi(A,i),50),n&&n()},f))};E()}function mi(e,t,n){var u,c,h,m,g;let a=n==null?void 0:n.objects.get("ui_endgame_logo_1"),i=(c=(((u=a==null?void 0:a.gameplay)==null?void 0:u.tuning)||{}).animation_start_scale)!=null?c:1.2,o=Date.now(),r=e.alpha,l=(h=e.targetAlpha)!=null?h:1,d=(m=e.baseScaleX)!=null?m:e.scale.x,p=(g=e.baseScaleY)!=null?g:e.scale.y,f=()=>{let x=Date.now()-o,T=Math.min(x/t,1),A=1-Math.pow(1-T,2);e.alpha=r+(l-r)*A;let v=i+(1-i)*A;e.scale.set(d*v,p*v),T<1&&requestAnimationFrame(f)};f()}function hi(e,t){let n=Date.now(),a=e.alpha,s=e.y,i=()=>{let o=Date.now()-n,r=Math.min(o/t,1),l=1-Math.pow(1-r,2);e.alpha=a+(1-a)*l,e.y=s-20*(1-l),r<1&&requestAnimationFrame(i)};i()}function yi(e,t){var r;let n=Date.now(),a=e.alpha,s=e.position.y,i=s-((r=e.animationStartYOffset)!=null?r:-10),o=()=>{let l=Date.now()-n,d=Math.min(l/t,1),p=1-Math.pow(1-d,2);e.alpha=a+(1-a)*p,e.position.y=s+(i-s)*p,d<1&&requestAnimationFrame(o)};o()}function gi(e,t){var o;let n=Date.now(),a=e.alpha,s=(o=e.targetAlpha)!=null?o:1,i=()=>{let r=Date.now()-n,l=Math.min(r/t,1),d=1-Math.pow(1-l,2);e.alpha=a+(s-a)*d,l<1&&requestAnimationFrame(i)};i()}function _i(e,t,n){let a=Date.now(),s=e.alpha,i=()=>{let o=Date.now()-a,r=Math.min(o/n,1),l=1-Math.pow(1-r,2);e.alpha=s+(1-s)*l,t.alpha=s+(1-s)*l,e.scale.set(1+.1*(1-l)),r<1&&requestAnimationFrame(i)};i()}function bi(e,t){var r;let n=Date.now(),a=e.alpha,s=e.position.y,i=s-((r=e.animationStartYOffset)!=null?r:5),o=()=>{let l=Date.now()-n,d=Math.min(l/t,1),p=1-Math.pow(1-d,2);e.alpha=a+(1-a)*p,e.position.y=s+(i-s)*p,d<1&&requestAnimationFrame(o)};o()}function ia(e,t,n,a){var p,f,u,c;let s=n.objects.get("ui_endgame_hand_1"),i=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},o=(f=i.click_animation_duration_ms)!=null?f:600,r=(u=i.click_delay_ms)!=null?u:2e3,l=(c=i.click_repeat_delay_ms)!=null?c:3e3,d=()=>{var k,S;e.visible=!0,e.alpha=1;let h=e.x,m=e.y,g=(k=i.hand_offset_x)!=null?k:50,x=(S=i.hand_offset_y)!=null?S:50,T=t.x+g,A=t.y+x,v=Date.now(),E=()=>{var Y,q,ae;let C=Date.now()-v,b=Math.min(C/o,1),D=b<.5?2*b*b:1-Math.pow(-2*b+2,2)/2;e.x=h+(T-h)*D,e.y=m+(A-m)*D;let L=(q=(Y=s==null?void 0:s.transform)==null?void 0:Y.scale)!=null?q:.1875,V=(ae=i.hand_scale_multiplier)!=null?ae:2.5,Z=L*V;e.scale.set(Z+Z*.2*Math.sin(b*Math.PI)),b<1?requestAnimationFrame(E):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),a()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=h,e.y=m,d()},l)},500))};E()};setTimeout(d,r)}var Ge=require("pixi.js");function sa(e,t,n){var p,f,u,c;let a=t.objects.get("hand_tutorial_1"),s=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},i=(a==null?void 0:a.render)||{},o=(a==null?void 0:a.transform)||{},r=new Ge.Sprite(e);r.anchor.set(.5),r.alpha=0;let l=(f=s.hand_scale_multiplier)!=null?f:2.5,d=(u=o.scale)!=null?u:.1875;return r.scale.set(d*l),r.zIndex=(c=i.z_index)!=null?c:99999,r}function oa(e){var h,m,g,x,T,A,v,E,k,S;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,a=(t==null?void 0:t.render)||{},s=((h=e.engine.runtime)==null?void 0:h.ui_styles)||{},i=((m=e.engine.runtime)==null?void 0:m.ui)||{},o=(n==null?void 0:n.text)||i.tutorial_label||i.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||s.label_font_size||52,d=(x=n==null?void 0:n.letterSpacing)!=null?x:(g=s.label_letter_spacing)!=null?g:-1,p=(n==null?void 0:n.align)||"center",f=a.tint,u=typeof f=="string"?f:f?`#${f.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",c=new Ge.Text({text:o,style:{fontFamily:j(r),fontSize:l,fontWeight:G(r),fill:u,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(T=s.label_shadow_alpha)!=null?T:.8,angle:(A=s.label_shadow_angle)!=null?A:0,blur:(v=s.label_shadow_blur)!=null?v:4,distance:(E=s.label_shadow_distance)!=null?E:2}}});return c.anchor.set(.5,0),c.alpha=(k=a.alpha)!=null?k:0,c.visible=(S=a.visible)!=null?S:!0,c}function ra(e,t,n,a,s){var l,d,p,f,u,c,h;let i=s.objects.get("hand_tutorial_1"),o=((l=i==null?void 0:i.gameplay)==null?void 0:l.tuning)||{},r=(i==null?void 0:i.transform)||{};if(!a){let m=(d=o.animation_duration)!=null?d:1.5,g=n%m/m,x=g<.5?2*g*g:-1+(4-2*g)*g,T=(p=o.x_offset)!=null?p:0,A=(f=o.y_offset)!=null?f:0,v=(u=o.animation_range)!=null?u:40,E=v*.7,k=v,S=t.x+T+E,C=t.y+A+k,b=S+E,D=C+k;e.x=S+(b-S)*x,e.y=C+(D-C)*x;let L=(c=r.scale)!=null?c:.1875,V=(h=o.hand_scale_multiplier)!=null?h:2.5;e.scale.set(L*V)}}var P=require("pixi.js");function la(e,t){if(!e)return;let n=t[e];if(n)return n;let a=e.split("?")[0].split("#")[0];if(a!==e&&t[a])return t[a];let s=a.split("/").pop();if(s&&t[s])return t[s];let i=a.replace(/^\.?\/*/,"");if(i!==a&&t[i])return t[i]}async function at(e,t,n=16777215,a=!1){try{let s=globalThis.INLINE_ASSETS||{},i=la(e,s)||e;return await P.Assets.load(i)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let i=new P.Graphics;return a?i.roundRect(0,0,60,120,10).fill({color:n}):(i.circle(30,30,30).fill({color:n}),i.rect(25,30,10,40).fill({color:n})),t.renderer.generateTexture(i)}}async function ca(e,t,n){var m,g,x,T,A,v,E,k,S,C;let a=globalThis.INLINE_ASSETS||{},s=la(e,a)||e,i;try{i=await P.Assets.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(b){let L=(n.gameplay.character_sheet||{}).fallback_color||"#ff00ff";i=await at(e,t,new P.Color(L).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:b})}let o=i.source||i.baseTexture||i;o&&"valid"in o&&o.valid===!1&&typeof o.once=="function"&&await new Promise(b=>o.once("loaded",b));let r=n.gameplay.character_sheet||{},l=(m=r.cols)!=null?m:3,d=(g=r.rows)!=null?g:2,p=(v=(A=(x=o==null?void 0:o.width)!=null?x:o==null?void 0:o.pixelWidth)!=null?A:(T=o==null?void 0:o.baseTexture)==null?void 0:T.width)!=null?v:i.width,f=(C=(S=(E=o==null?void 0:o.height)!=null?E:o==null?void 0:o.pixelHeight)!=null?S:(k=o==null?void 0:o.baseTexture)==null?void 0:k.height)!=null?C:i.height,u=p/l,c=f/d;if(!Number.isFinite(u)||!Number.isFinite(c)||u<=0||c<=0||!o)return[i];let h=[];for(let b=0;b<d;b++)for(let D=0;D<l;D++)h.push(new P.Texture({source:o,frame:new P.Rectangle(D*u,b*c,u,c)}));return h.length>2&&h.push(...h.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:h.length}),h}function da(e,t){var p,f,u,c;let n=t.gameplay.brush||{},a=new P.Color(t.theme.brush_color||"#ffffff").toNumber(),s=(p=n.radius)!=null?p:20,i=(f=n.inner_radius)!=null?f:15,o=(u=n.alpha)!=null?u:.8,r=(c=n.inner_alpha)!=null?c:.3,l=n.inner_color||"#ffffff",d=new P.Graphics;return d.circle(0,0,s).fill({color:a,alpha:o}),d.circle(0,0,i).fill({color:new P.Color(l).toNumber(),alpha:r}),e.renderer.generateTexture(d)}0&&(module.exports={GameObject,GameObjectManager,Renderer,Transform,animateHandClick,animatePanelEntrance,createBrushTexture,createEndGamePanel,createHandTutorial,createPixiBase,createTutorialLabel,getRegisteredFontIds,loadAsset,loadCharacterFrames,registerFont,resolveFont,resolveFontWeight,updateHandAnimation});
@@ -1 +1 @@
1
- import{b as lt}from"../chunk-2XLITEWW.mjs";import{Application as Pn}from"pixi.js";async function Mn(e,t={}){let a=new Pn;await a.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let o=n=>{var c,d,p,u,h,l;let i=(p=(d=(c=n==null?void 0:n.width)!=null?c:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(l=(h=(u=n==null?void 0:n.height)!=null?u:e.clientHeight)!=null?h:window.innerHeight)!=null?l:480;a.renderer.resize(i,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(a.canvas);let s=document.createElement("div");return s.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(s),lt.on("pause",()=>{a.ticker.stop(),document.querySelectorAll("audio").forEach(i=>i.pause())}),lt.on("resume",()=>{a.ticker.start(),document.querySelectorAll("audio").forEach(i=>{i.currentTime>0&&!i.ended&&i.play().catch(()=>{})})}),lt.on("resize",({payload:n})=>{o({width:n==null?void 0:n.width,height:n==null?void 0:n.height})}),window.addEventListener("resize",()=>o()),requestAnimationFrame(()=>o()),{app:a,stage:a.stage,overlay:s,applySize:o}}var ct=class{constructor(t){var a,o;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(a=t==null?void 0:t.scale)!=null?a:1,this.rotation=(o=t==null?void 0:t.rotation)!=null?o:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},dt=class{constructor(t){var a,o,s,n;this.z_index=(a=t==null?void 0:t.z_index)!=null?a:0,this.alpha=(o=t==null?void 0:t.alpha)!=null?o:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(n=t==null?void 0:t.tint)!=null?n:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},ht=class{constructor(t,a,o,s){this.instanceId=t,this.objectConfig=a,this.pixiObject=o,this._config=s,this.transform=new ct(s.transform),this.renderer=new dt(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,a){this.transform.position={x:t,y:a},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},gt=class{constructor(t){this.objects=new Map;this.config=t}create(t,a){let o=this.config.objects.get(t);if(!o)throw new Error(`Object config not found: ${t}`);let s=new ht(t,o.object_config||t,a,o);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[a,o]of this.objects.entries()){let s=t.objects.get(a);s&&o.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var pt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function X(e){let t=pt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var a;let t=pt[e];return t&&(a=t.weight)!=null?a:"400"}function En(e,t){pt[e]=t}function Dn(){return Object.keys(pt)}import{Container as Yn,Graphics as ut,Text as tt,Sprite as Le,Texture as _t}from"pixi.js";function kn(e,t,a){var Dt,Yt,kt,zt,Ht,Wt,Bt,Rt,Lt,Gt,Nt,Xt,qt,$t,Vt,jt,Jt,Kt,Qt,Zt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,de,he,pe,ue,me,fe,ye,ge,_e,be,xe,we,Te,Ce,Se,ve,Ae,Fe,Pe,Me,Ee,De,Ye,ke,ze,He,We;let o=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),n=e.objects.get("ui_endgame_title_1"),i=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),c=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),u=e.engine.runtime||{},h=new Yn;h.alpha=0,h.visible=!1;let l=((Dt=o==null?void 0:o.gameplay)==null?void 0:Dt.tuning)||{},m=(o==null?void 0:o.render)||{},f=(Yt=l.panel_width)!=null?Yt:320,y=(kt=l.panel_height)!=null?kt:400,_=(zt=l.panel_padding)!=null?zt:32,b=(Ht=l.panel_radius)!=null?Ht:24,C=m.background_color||l.panel_bg_color||"#1a0a0a",x=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(Wt=l.panel_bg_alpha)!=null?Wt:.98,S=m.border_color||l.panel_border_color||"#ffffff",v=(Bt=l.panel_border_width)!=null?Bt:2,w=(Rt=l.panel_border_alpha)!=null?Rt:.3,T=new ut;T.roundRect(-f/2,-y/2,f,y,b);let g=C.replace("#","");T.fill({color:parseInt(g,16),alpha:x});let A=S.replace("#","");T.stroke({color:parseInt(A,16),width:v,alpha:w});let M=new ut;M.roundRect(-f/2+2,-y/2+2,f-4,y-4,b-2),M.stroke({color:16777215,width:1,alpha:.1}),T.addChild(M),h.addChild(T);let B=((Lt=s==null?void 0:s.gameplay)==null?void 0:Lt.tuning)||{},$=(s==null?void 0:s.transform)||{},z=(Gt=B.logo_size)!=null?Gt:56,R=(Nt=$.scale)!=null?Nt:1,j=(qt=(Xt=$.offset)==null?void 0:Xt.y)!=null?qt:-130,qe=($t=B.logo_alpha)!=null?$t:1,F=new Le(a||_t.EMPTY);F.anchor.set(.5);let K=0,Q=0;if(a&&a!==_t.EMPTY){let P=a.frame,N=a.baseTexture;P&&P.width&&P.height?(K=P.width,Q=P.height):N&&N.width&&N.height?(K=N.width,Q=N.height):a.width&&a.height&&(K=a.width,Q=a.height)}if(K>0&&Q>0){let P=K/Q,N,yt;P>1?(N=z,yt=z/P):(yt=z,N=z*P);let Be=N/K,Re=yt/Q;Be*=R,Re*=R,F.scale.set(Be,Re)}else{let P=z/100*R;F.scale.set(P)}F.position.set(0,j),F.alpha=0,F.visible=!0,F.targetAlpha=qe,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,h.addChild(F);let E=n==null?void 0:n.ui,H=((Vt=n==null?void 0:n.gameplay)==null?void 0:Vt.tuning)||{},$e=(E==null?void 0:E.text)||"MISSION ACCOMPLISHED",xt=(E==null?void 0:E.font)||"brand.heading",Ve=(E==null?void 0:E.fontSize)||24,je=(jt=E==null?void 0:E.letterSpacing)!=null?jt:1,et=(Jt=n==null?void 0:n.render)==null?void 0:Jt.tint,Je=typeof et=="string"?et:et?`#${et.toString(16).padStart(6,"0")}`:"#00FF88",wt=f-_*2-30,Ke=H.font_weight_override?H.font_weight_override:q(xt),V=new tt({text:$e,style:{fontFamily:X(xt),fontSize:Ve,fontWeight:Ke,fill:Je,align:"center",letterSpacing:je,wordWrap:!1,stroke:{color:H.stroke_color||"#000000",width:(Kt=H.stroke_width)!=null?Kt:2},dropShadow:{color:H.shadow_color||"#000000",alpha:(Qt=H.shadow_alpha)!=null?Qt:.9,angle:(Zt=H.shadow_angle)!=null?Zt:0,blur:(Ot=H.shadow_blur)!=null?Ot:8,distance:(It=H.shadow_distance)!=null?It:4}}});if(V.width>wt){let P=wt/V.width;V.scale.set(P)}V.anchor.set(.5);let Tt=(Ut=l.title_offset_y)!=null?Ut:30,Qe=Tt+((te=H.animation_start_y_offset)!=null?te:-20);V.position.set(0,Qe),V.alpha=0,h.addChild(V);let D=i==null?void 0:i.ui,Ct=((ee=i==null?void 0:i.gameplay)==null?void 0:ee.tuning)||{},Ze=(D==null?void 0:D.text)||"RESCUE COMPLETE",St=(D==null?void 0:D.font)||"brand.body",Oe=(D==null?void 0:D.fontSize)||11,Ie=(ne=D==null?void 0:D.letterSpacing)!=null?ne:.5,nt=(ae=i==null?void 0:i.render)==null?void 0:ae.tint,Ue=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=new tt({text:Ze,style:{fontFamily:X(St),fontSize:Oe,fontWeight:q(St),fill:Ue,align:"center",letterSpacing:Ie}});Z.anchor.set(.5);let tn=Tt+20+((se=Ct.animation_start_y_offset)!=null?se:-10);Z.position.set(0,tn),Z.alpha=0,Z.animationStartYOffset=(ie=Ct.animation_start_y_offset)!=null?ie:-10,h.addChild(Z);let L=r==null?void 0:r.ui,vt=((oe=r==null?void 0:r.gameplay)==null?void 0:oe.tuning)||{},en=(L==null?void 0:L.text)||((re=u.ui)==null?void 0:re.cta_hint)||"Continue the adventure!",At=(L==null?void 0:L.font)||"brand.body",nn=(L==null?void 0:L.fontSize)||16,at=(le=r==null?void 0:r.render)==null?void 0:le.tint,an=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#FFFFFF",sn=(ce=vt.max_width)!=null?ce:f-_*2,on=(de=vt.line_height)!=null?de:1.4,O=new tt({text:en,style:{fontFamily:X(At),fontSize:nn,fontWeight:q(At),fill:an,align:"center",wordWrap:!0,wordWrapWidth:sn,lineHeight:on}});O.anchor.set(.5);let rn=(he=l.footer_offset_y)!=null?he:120;O.position.set(0,rn);let ln=((pe=r==null?void 0:r.render)==null?void 0:pe.alpha)!==void 0&&((ue=r==null?void 0:r.render)==null?void 0:ue.alpha)!==null?r.render.alpha:1;O.alpha=0,O.targetAlpha=ln,h.addChild(O);let G=((me=c==null?void 0:c.gameplay)==null?void 0:me.tuning)||{},Y=c==null?void 0:c.ui,st=(fe=G.button_width)!=null?fe:260,it=(ye=G.button_height)!=null?ye:56,Ft=(ge=G.button_radius)!=null?ge:16,cn=G.button_bg_color||((_e=u.theme)==null?void 0:_e.cta_background)||"#ffb43b",dn=(be=G.button_bg_alpha)!=null?be:1,hn=G.button_border_color||"#ffffff",pn=(xe=G.button_border_width)!=null?xe:2,un=(we=G.button_border_alpha)!=null?we:.2,ot=(Te=l.cta_offset_y)!=null?Te:160,W=new ut;W.roundRect(-st/2,-it/2,st,it,Ft);let mn=cn.replace("#","");W.fill({color:parseInt(mn,16),alpha:dn});let fn=hn.replace("#","");W.stroke({color:parseInt(fn,16),width:pn,alpha:un});let mt=new ut;mt.roundRect(-st/2+2,-it/2+2,st-4,it-4,Ft-2),mt.stroke({color:0,width:1,alpha:.15}),W.addChild(mt),W.position.set(0,ot),W.alpha=0,W.eventMode="static",W.cursor="pointer",h.addChild(W);let yn=(Y==null?void 0:Y.text)||((Ce=u.ui)==null?void 0:Ce.cta_label_end)||"DOWNLOAD",Pt=(Y==null?void 0:Y.font)||"brand.heading",gn=(Y==null?void 0:Y.fontSize)||20,_n=G.button_text_color||((Se=u.theme)==null?void 0:Se.cta_text)||"#1a0a0a",U=new tt({text:yn,style:{fontFamily:X(Pt),fontSize:gn,fontWeight:q(Pt),fill:_n,align:"center",letterSpacing:(ve=Y==null?void 0:Y.letterSpacing)!=null?ve:1}});U.anchor.set(.5),U.position.set(0,ot),U.alpha=0,h.addChild(U);let k=d==null?void 0:d.ui,Mt=((Ae=d==null?void 0:d.gameplay)==null?void 0:Ae.tuning)||{},bn=(k==null?void 0:k.text)||"Play the full game",Et=(k==null?void 0:k.font)||"brand.body",xn=(k==null?void 0:k.fontSize)||11,wn=(Fe=k==null?void 0:k.letterSpacing)!=null?Fe:0,rt=(Pe=d==null?void 0:d.render)==null?void 0:Pe.tint,Tn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",I=new tt({text:bn,style:{fontFamily:X(Et),fontSize:xn,fontWeight:q(Et),fill:Tn,align:"center",letterSpacing:wn}});I.anchor.set(.5);let Cn=ot+35+((Me=Mt.animation_start_y_offset)!=null?Me:5);I.position.set(0,Cn),I.alpha=0,I.animationStartYOffset=(Ee=Mt.animation_start_y_offset)!=null?Ee:5,h.addChild(I);let ft=((De=p==null?void 0:p.gameplay)==null?void 0:De.tuning)||{},Sn=(Ye=ft.hand_offset_x)!=null?Ye:50,vn=(ke=ft.hand_offset_y)!=null?ke:50,An=(He=(ze=p==null?void 0:p.transform)==null?void 0:ze.scale)!=null?He:.1875,Fn=(We=ft.hand_scale_multiplier)!=null?We:2.5,J=new Le(t||_t.EMPTY);return J.anchor.set(.5),J.scale.set(An*Fn),J.position.set(Sn,ot+vn),J.alpha=0,J.visible=!1,h.addChild(J),{panel:h,logo:F,title:V,subtitle:Z,footer:O,ctaButton:W,ctaText:U,ctaHint:I,hand:J}}function zn(e,t,a){var v,w,T,g,A,M,B,$;let o=t.objects.get("ui_endgame_1"),s=((v=o==null?void 0:o.gameplay)==null?void 0:v.tuning)||{},n=(w=s.animation_duration_ms)!=null?w:800,i=(T=s.fade_in_duration_ms)!=null?T:600,r=(g=s.scale_animation_intensity)!=null?g:.1,c=(A=s.logo_animation_delay_ms)!=null?A:100,d=(M=s.title_animation_delay_ms)!=null?M:200,p=(B=s.footer_animation_delay_ms)!=null?B:300,u=($=s.cta_animation_delay_ms)!=null?$:400,{panel:h,logo:l,title:m,subtitle:f,footer:y,ctaButton:_,ctaText:b,ctaHint:C}=e;h.visible=!0;let x=Date.now(),S=()=>{let z=Date.now()-x,R=Math.min(z/i,1),j=1-Math.pow(1-R,3);h.alpha=j,h.scale.set(1+r*(1-j)),R<1?requestAnimationFrame(S):(setTimeout(()=>Hn(l,n,t),c),setTimeout(()=>{Wn(m,n),setTimeout(()=>Bn(f,n),50)},d),setTimeout(()=>Rn(y,n),p),setTimeout(()=>{Ln(_,b,n),setTimeout(()=>Gn(C,n),50),a&&a()},u))};S()}function Hn(e,t,a){var h,l,m,f,y;let o=a==null?void 0:a.objects.get("ui_endgame_logo_1"),n=(l=(((h=o==null?void 0:o.gameplay)==null?void 0:h.tuning)||{}).animation_start_scale)!=null?l:1.2,i=Date.now(),r=e.alpha,c=(m=e.targetAlpha)!=null?m:1,d=(f=e.baseScaleX)!=null?f:e.scale.x,p=(y=e.baseScaleY)!=null?y:e.scale.y,u=()=>{let _=Date.now()-i,b=Math.min(_/t,1),C=1-Math.pow(1-b,2);e.alpha=r+(c-r)*C;let x=n+(1-n)*C;e.scale.set(d*x,p*x),b<1&&requestAnimationFrame(u)};u()}function Wn(e,t){let a=Date.now(),o=e.alpha,s=e.y,n=()=>{let i=Date.now()-a,r=Math.min(i/t,1),c=1-Math.pow(1-r,2);e.alpha=o+(1-o)*c,e.y=s-20*(1-c),r<1&&requestAnimationFrame(n)};n()}function Bn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:-10),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Rn(e,t){var i;let a=Date.now(),o=e.alpha,s=(i=e.targetAlpha)!=null?i:1,n=()=>{let r=Date.now()-a,c=Math.min(r/t,1),d=1-Math.pow(1-c,2);e.alpha=o+(s-o)*d,c<1&&requestAnimationFrame(n)};n()}function Ln(e,t,a){let o=Date.now(),s=e.alpha,n=()=>{let i=Date.now()-o,r=Math.min(i/a,1),c=1-Math.pow(1-r,2);e.alpha=s+(1-s)*c,t.alpha=s+(1-s)*c,e.scale.set(1+.1*(1-c)),r<1&&requestAnimationFrame(n)};n()}function Gn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:5),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Nn(e,t,a,o){var p,u,h,l;let s=a.objects.get("ui_endgame_hand_1"),n=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},i=(u=n.click_animation_duration_ms)!=null?u:600,r=(h=n.click_delay_ms)!=null?h:2e3,c=(l=n.click_repeat_delay_ms)!=null?l:3e3,d=()=>{var v,w;e.visible=!0,e.alpha=1;let m=e.x,f=e.y,y=(v=n.hand_offset_x)!=null?v:50,_=(w=n.hand_offset_y)!=null?w:50,b=t.x+y,C=t.y+_,x=Date.now(),S=()=>{var z,R,j;let T=Date.now()-x,g=Math.min(T/i,1),A=g<.5?2*g*g:1-Math.pow(-2*g+2,2)/2;e.x=m+(b-m)*A,e.y=f+(C-f)*A;let M=(R=(z=s==null?void 0:s.transform)==null?void 0:z.scale)!=null?R:.1875,B=(j=n.hand_scale_multiplier)!=null?j:2.5,$=M*B;e.scale.set($+$*.2*Math.sin(g*Math.PI)),g<1?requestAnimationFrame(S):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),o()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=m,e.y=f,d()},c)},500))};S()};setTimeout(d,r)}import{Sprite as Xn,Text as qn}from"pixi.js";function $n(e,t,a){var p,u,h,l;let o=t.objects.get("hand_tutorial_1"),s=((p=o==null?void 0:o.gameplay)==null?void 0:p.tuning)||{},n=(o==null?void 0:o.render)||{},i=(o==null?void 0:o.transform)||{},r=new Xn(e);r.anchor.set(.5),r.alpha=0;let c=(u=s.hand_scale_multiplier)!=null?u:2.5,d=(h=i.scale)!=null?h:.1875;return r.scale.set(d*c),r.zIndex=(l=n.z_index)!=null?l:99999,r}function Vn(e){var m,f,y,_,b,C,x,S,v,w;let t=e.objects.get("ui_tutorial_1"),a=t==null?void 0:t.ui,o=(t==null?void 0:t.render)||{},s=((m=e.engine.runtime)==null?void 0:m.ui_styles)||{},n=((f=e.engine.runtime)==null?void 0:f.ui)||{},i=(a==null?void 0:a.text)||n.tutorial_label||n.label_text||"CLEAN!",r=(a==null?void 0:a.font)||"brand.warning",c=(a==null?void 0:a.fontSize)||s.label_font_size||52,d=(_=a==null?void 0:a.letterSpacing)!=null?_:(y=s.label_letter_spacing)!=null?y:-1,p=(a==null?void 0:a.align)||"center",u=o.tint,h=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",l=new qn({text:i,style:{fontFamily:X(r),fontSize:c,fontWeight:q(r),fill:h,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(b=s.label_shadow_alpha)!=null?b:.8,angle:(C=s.label_shadow_angle)!=null?C:0,blur:(x=s.label_shadow_blur)!=null?x:4,distance:(S=s.label_shadow_distance)!=null?S:2}}});return l.anchor.set(.5,0),l.alpha=(v=o.alpha)!=null?v:0,l.visible=(w=o.visible)!=null?w:!0,l}function jn(e,t,a,o,s){var c,d,p,u,h,l,m;let n=s.objects.get("hand_tutorial_1"),i=((c=n==null?void 0:n.gameplay)==null?void 0:c.tuning)||{},r=(n==null?void 0:n.transform)||{};if(!o){let f=(d=i.animation_duration)!=null?d:1.5,y=a%f/f,_=y<.5?2*y*y:-1+(4-2*y)*y,b=(p=i.x_offset)!=null?p:0,C=(u=i.y_offset)!=null?u:0,x=(h=i.animation_range)!=null?h:40,S=x*.7,v=x,w=t.x+b+S,T=t.y+C+v,g=w+S,A=T+v;e.x=w+(g-w)*_,e.y=T+(A-T)*_;let M=(l=r.scale)!=null?l:.1875,B=(m=i.hand_scale_multiplier)!=null?m:2.5;e.scale.set(M*B)}}import{Graphics as Ge,Assets as Ne,Texture as Jn,Rectangle as Kn,Color as bt}from"pixi.js";async function Xe(e,t,a=16777215,o=!1){try{let n=(globalThis.INLINE_ASSETS||{})[e];return await Ne.load(n||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let n=new Ge;return o?n.roundRect(0,0,60,120,10).fill({color:a}):(n.circle(30,30,30).fill({color:a}),n.rect(25,30,10,40).fill({color:a})),t.renderer.generateTexture(n)}}async function Qn(e,t,a){var f,y,_,b,C,x,S,v,w,T;let s=(globalThis.INLINE_ASSETS||{})[e]||e,n;try{n=await Ne.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(g){let M=(a.gameplay.character_sheet||{}).fallback_color||"#ff00ff";n=await Xe(e,t,new bt(M).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:g})}let i=n.source||n.baseTexture||n;i&&"valid"in i&&i.valid===!1&&typeof i.once=="function"&&await new Promise(g=>i.once("loaded",g));let r=a.gameplay.character_sheet||{},c=(f=r.cols)!=null?f:3,d=(y=r.rows)!=null?y:2,p=(x=(C=(_=i==null?void 0:i.width)!=null?_:i==null?void 0:i.pixelWidth)!=null?C:(b=i==null?void 0:i.baseTexture)==null?void 0:b.width)!=null?x:n.width,u=(T=(w=(S=i==null?void 0:i.height)!=null?S:i==null?void 0:i.pixelHeight)!=null?w:(v=i==null?void 0:i.baseTexture)==null?void 0:v.height)!=null?T:n.height,h=p/c,l=u/d;if(!Number.isFinite(h)||!Number.isFinite(l)||h<=0||l<=0||!i)return[n];let m=[];for(let g=0;g<d;g++)for(let A=0;A<c;A++)m.push(new Jn({source:i,frame:new Kn(A*h,g*l,h,l)}));return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function Zn(e,t){var p,u,h,l;let a=t.gameplay.brush||{},o=new bt(t.theme.brush_color||"#ffffff").toNumber(),s=(p=a.radius)!=null?p:20,n=(u=a.inner_radius)!=null?u:15,i=(h=a.alpha)!=null?h:.8,r=(l=a.inner_alpha)!=null?l:.3,c=a.inner_color||"#ffffff",d=new Ge;return d.circle(0,0,s).fill({color:o,alpha:i}),d.circle(0,0,n).fill({color:new bt(c).toNumber(),alpha:r}),e.renderer.generateTexture(d)}export{ht as GameObject,gt as GameObjectManager,dt as Renderer,ct as Transform,Nn as animateHandClick,zn as animatePanelEntrance,Zn as createBrushTexture,kn as createEndGamePanel,$n as createHandTutorial,Mn as createPixiBase,Vn as createTutorialLabel,Dn as getRegisteredFontIds,Xe as loadAsset,Qn as loadCharacterFrames,En as registerFont,X as resolveFont,q as resolveFontWeight,jn as updateHandAnimation};
1
+ import{b as lt}from"../chunk-SYQVN25U.mjs";import{Application as En}from"pixi.js";async function Dn(e,t={}){let a=new En;await a.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let i=n=>{var c,d,p,u,h,l;let o=(p=(d=(c=n==null?void 0:n.width)!=null?c:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(l=(h=(u=n==null?void 0:n.height)!=null?u:e.clientHeight)!=null?h:window.innerHeight)!=null?l:480;a.renderer.resize(o,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(a.canvas);let s=document.createElement("div");return s.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(s),lt.on("pause",()=>{a.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),lt.on("resume",()=>{a.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),lt.on("resize",({payload:n})=>{i({width:n==null?void 0:n.width,height:n==null?void 0:n.height})}),window.addEventListener("resize",()=>i()),requestAnimationFrame(()=>i()),{app:a,stage:a.stage,overlay:s,applySize:i}}var ct=class{constructor(t){var a,i;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(a=t==null?void 0:t.scale)!=null?a:1,this.rotation=(i=t==null?void 0:t.rotation)!=null?i:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},dt=class{constructor(t){var a,i,s,n;this.z_index=(a=t==null?void 0:t.z_index)!=null?a:0,this.alpha=(i=t==null?void 0:t.alpha)!=null?i:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(n=t==null?void 0:t.tint)!=null?n:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},ht=class{constructor(t,a,i,s){this.instanceId=t,this.objectConfig=a,this.pixiObject=i,this._config=s,this.transform=new ct(s.transform),this.renderer=new dt(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,a){this.transform.position={x:t,y:a},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},gt=class{constructor(t){this.objects=new Map;this.config=t}create(t,a){let i=this.config.objects.get(t);if(!i)throw new Error(`Object config not found: ${t}`);let s=new ht(t,i.object_config||t,a,i);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[a,i]of this.objects.entries()){let s=t.objects.get(a);s&&i.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var pt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function X(e){let t=pt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var a;let t=pt[e];return t&&(a=t.weight)!=null?a:"400"}function Yn(e,t){pt[e]=t}function kn(){return Object.keys(pt)}import{Container as zn,Graphics as ut,Text as tt,Sprite as Le,Texture as _t}from"pixi.js";function Mn(e,t,a){var Yt,kt,zt,Mt,Ht,Wt,Bt,Rt,Lt,Gt,Nt,Xt,qt,$t,Vt,jt,Jt,Kt,Qt,Zt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,de,he,pe,ue,me,fe,ye,ge,_e,be,xe,we,Te,Ce,Se,ve,Ae,Fe,Pe,Ee,De,Ye,ke,ze,Me,He,We;let i=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),n=e.objects.get("ui_endgame_title_1"),o=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),c=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),u=e.engine.runtime||{},h=new zn;h.alpha=0,h.visible=!1;let l=((Yt=i==null?void 0:i.gameplay)==null?void 0:Yt.tuning)||{},m=(i==null?void 0:i.render)||{},f=(kt=l.panel_width)!=null?kt:320,y=(zt=l.panel_height)!=null?zt:400,_=(Mt=l.panel_padding)!=null?Mt:32,b=(Ht=l.panel_radius)!=null?Ht:24,C=m.background_color||l.panel_bg_color||"#1a0a0a",x=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(Wt=l.panel_bg_alpha)!=null?Wt:.98,S=m.border_color||l.panel_border_color||"#ffffff",v=(Bt=l.panel_border_width)!=null?Bt:2,w=(Rt=l.panel_border_alpha)!=null?Rt:.3,T=new ut;T.roundRect(-f/2,-y/2,f,y,b);let g=C.replace("#","");T.fill({color:parseInt(g,16),alpha:x});let A=S.replace("#","");T.stroke({color:parseInt(A,16),width:v,alpha:w});let E=new ut;E.roundRect(-f/2+2,-y/2+2,f-4,y-4,b-2),E.stroke({color:16777215,width:1,alpha:.1}),T.addChild(E),h.addChild(T);let B=((Lt=s==null?void 0:s.gameplay)==null?void 0:Lt.tuning)||{},$=(s==null?void 0:s.transform)||{},M=(Gt=B.logo_size)!=null?Gt:56,R=(Nt=$.scale)!=null?Nt:1,j=(qt=(Xt=$.offset)==null?void 0:Xt.y)!=null?qt:-130,$e=($t=B.logo_alpha)!=null?$t:1,F=new Le(a||_t.EMPTY);F.anchor.set(.5);let K=0,Q=0;if(a&&a!==_t.EMPTY){let P=a.frame,N=a.baseTexture;P&&P.width&&P.height?(K=P.width,Q=P.height):N&&N.width&&N.height?(K=N.width,Q=N.height):a.width&&a.height&&(K=a.width,Q=a.height)}if(K>0&&Q>0){let P=K/Q,N,yt;P>1?(N=M,yt=M/P):(yt=M,N=M*P);let Be=N/K,Re=yt/Q;Be*=R,Re*=R,F.scale.set(Be,Re)}else{let P=M/100*R;F.scale.set(P)}F.position.set(0,j),F.alpha=0,F.visible=!0,F.targetAlpha=$e,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,h.addChild(F);let D=n==null?void 0:n.ui,H=((Vt=n==null?void 0:n.gameplay)==null?void 0:Vt.tuning)||{},Ve=(D==null?void 0:D.text)||"MISSION ACCOMPLISHED",xt=(D==null?void 0:D.font)||"brand.heading",je=(D==null?void 0:D.fontSize)||24,Je=(jt=D==null?void 0:D.letterSpacing)!=null?jt:1,et=(Jt=n==null?void 0:n.render)==null?void 0:Jt.tint,Ke=typeof et=="string"?et:et?`#${et.toString(16).padStart(6,"0")}`:"#00FF88",wt=f-_*2-30,Qe=H.font_weight_override?H.font_weight_override:q(xt),V=new tt({text:Ve,style:{fontFamily:X(xt),fontSize:je,fontWeight:Qe,fill:Ke,align:"center",letterSpacing:Je,wordWrap:!1,stroke:{color:H.stroke_color||"#000000",width:(Kt=H.stroke_width)!=null?Kt:2},dropShadow:{color:H.shadow_color||"#000000",alpha:(Qt=H.shadow_alpha)!=null?Qt:.9,angle:(Zt=H.shadow_angle)!=null?Zt:0,blur:(Ot=H.shadow_blur)!=null?Ot:8,distance:(It=H.shadow_distance)!=null?It:4}}});if(V.width>wt){let P=wt/V.width;V.scale.set(P)}V.anchor.set(.5);let Tt=(Ut=l.title_offset_y)!=null?Ut:30,Ze=Tt+((te=H.animation_start_y_offset)!=null?te:-20);V.position.set(0,Ze),V.alpha=0,h.addChild(V);let Y=o==null?void 0:o.ui,Ct=((ee=o==null?void 0:o.gameplay)==null?void 0:ee.tuning)||{},Oe=(Y==null?void 0:Y.text)||"RESCUE COMPLETE",St=(Y==null?void 0:Y.font)||"brand.body",Ie=(Y==null?void 0:Y.fontSize)||11,Ue=(ne=Y==null?void 0:Y.letterSpacing)!=null?ne:.5,nt=(ae=o==null?void 0:o.render)==null?void 0:ae.tint,tn=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=new tt({text:Oe,style:{fontFamily:X(St),fontSize:Ie,fontWeight:q(St),fill:tn,align:"center",letterSpacing:Ue}});Z.anchor.set(.5);let en=Tt+20+((se=Ct.animation_start_y_offset)!=null?se:-10);Z.position.set(0,en),Z.alpha=0,Z.animationStartYOffset=(ie=Ct.animation_start_y_offset)!=null?ie:-10,h.addChild(Z);let L=r==null?void 0:r.ui,vt=((oe=r==null?void 0:r.gameplay)==null?void 0:oe.tuning)||{},nn=(L==null?void 0:L.text)||((re=u.ui)==null?void 0:re.cta_hint)||"Continue the adventure!",At=(L==null?void 0:L.font)||"brand.body",an=(L==null?void 0:L.fontSize)||16,at=(le=r==null?void 0:r.render)==null?void 0:le.tint,sn=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#FFFFFF",on=(ce=vt.max_width)!=null?ce:f-_*2,rn=(de=vt.line_height)!=null?de:1.4,O=new tt({text:nn,style:{fontFamily:X(At),fontSize:an,fontWeight:q(At),fill:sn,align:"center",wordWrap:!0,wordWrapWidth:on,lineHeight:rn}});O.anchor.set(.5);let ln=(he=l.footer_offset_y)!=null?he:120;O.position.set(0,ln);let cn=((pe=r==null?void 0:r.render)==null?void 0:pe.alpha)!==void 0&&((ue=r==null?void 0:r.render)==null?void 0:ue.alpha)!==null?r.render.alpha:1;O.alpha=0,O.targetAlpha=cn,h.addChild(O);let G=((me=c==null?void 0:c.gameplay)==null?void 0:me.tuning)||{},k=c==null?void 0:c.ui,st=(fe=G.button_width)!=null?fe:260,it=(ye=G.button_height)!=null?ye:56,Ft=(ge=G.button_radius)!=null?ge:16,dn=G.button_bg_color||((_e=u.theme)==null?void 0:_e.cta_background)||"#ffb43b",hn=(be=G.button_bg_alpha)!=null?be:1,pn=G.button_border_color||"#ffffff",un=(xe=G.button_border_width)!=null?xe:2,mn=(we=G.button_border_alpha)!=null?we:.2,ot=(Te=l.cta_offset_y)!=null?Te:160,W=new ut;W.roundRect(-st/2,-it/2,st,it,Ft);let fn=dn.replace("#","");W.fill({color:parseInt(fn,16),alpha:hn});let yn=pn.replace("#","");W.stroke({color:parseInt(yn,16),width:un,alpha:mn});let mt=new ut;mt.roundRect(-st/2+2,-it/2+2,st-4,it-4,Ft-2),mt.stroke({color:0,width:1,alpha:.15}),W.addChild(mt),W.position.set(0,ot),W.alpha=0,W.eventMode="static",W.cursor="pointer",h.addChild(W);let gn=(k==null?void 0:k.text)||((Ce=u.ui)==null?void 0:Ce.cta_label_end)||"DOWNLOAD",Pt=(k==null?void 0:k.font)||"brand.heading",_n=(k==null?void 0:k.fontSize)||20,bn=G.button_text_color||((Se=u.theme)==null?void 0:Se.cta_text)||"#1a0a0a",U=new tt({text:gn,style:{fontFamily:X(Pt),fontSize:_n,fontWeight:q(Pt),fill:bn,align:"center",letterSpacing:(ve=k==null?void 0:k.letterSpacing)!=null?ve:1}});U.anchor.set(.5),U.position.set(0,ot),U.alpha=0,h.addChild(U);let z=d==null?void 0:d.ui,Et=((Ae=d==null?void 0:d.gameplay)==null?void 0:Ae.tuning)||{},xn=(z==null?void 0:z.text)||"Play the full game",Dt=(z==null?void 0:z.font)||"brand.body",wn=(z==null?void 0:z.fontSize)||11,Tn=(Fe=z==null?void 0:z.letterSpacing)!=null?Fe:0,rt=(Pe=d==null?void 0:d.render)==null?void 0:Pe.tint,Cn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",I=new tt({text:xn,style:{fontFamily:X(Dt),fontSize:wn,fontWeight:q(Dt),fill:Cn,align:"center",letterSpacing:Tn}});I.anchor.set(.5);let Sn=ot+35+((Ee=Et.animation_start_y_offset)!=null?Ee:5);I.position.set(0,Sn),I.alpha=0,I.animationStartYOffset=(De=Et.animation_start_y_offset)!=null?De:5,h.addChild(I);let ft=((Ye=p==null?void 0:p.gameplay)==null?void 0:Ye.tuning)||{},vn=(ke=ft.hand_offset_x)!=null?ke:50,An=(ze=ft.hand_offset_y)!=null?ze:50,Fn=(He=(Me=p==null?void 0:p.transform)==null?void 0:Me.scale)!=null?He:.1875,Pn=(We=ft.hand_scale_multiplier)!=null?We:2.5,J=new Le(t||_t.EMPTY);return J.anchor.set(.5),J.scale.set(Fn*Pn),J.position.set(vn,ot+An),J.alpha=0,J.visible=!1,h.addChild(J),{panel:h,logo:F,title:V,subtitle:Z,footer:O,ctaButton:W,ctaText:U,ctaHint:I,hand:J}}function Hn(e,t,a){var v,w,T,g,A,E,B,$;let i=t.objects.get("ui_endgame_1"),s=((v=i==null?void 0:i.gameplay)==null?void 0:v.tuning)||{},n=(w=s.animation_duration_ms)!=null?w:800,o=(T=s.fade_in_duration_ms)!=null?T:600,r=(g=s.scale_animation_intensity)!=null?g:.1,c=(A=s.logo_animation_delay_ms)!=null?A:100,d=(E=s.title_animation_delay_ms)!=null?E:200,p=(B=s.footer_animation_delay_ms)!=null?B:300,u=($=s.cta_animation_delay_ms)!=null?$:400,{panel:h,logo:l,title:m,subtitle:f,footer:y,ctaButton:_,ctaText:b,ctaHint:C}=e;h.visible=!0;let x=Date.now(),S=()=>{let M=Date.now()-x,R=Math.min(M/o,1),j=1-Math.pow(1-R,3);h.alpha=j,h.scale.set(1+r*(1-j)),R<1?requestAnimationFrame(S):(setTimeout(()=>Wn(l,n,t),c),setTimeout(()=>{Bn(m,n),setTimeout(()=>Rn(f,n),50)},d),setTimeout(()=>Ln(y,n),p),setTimeout(()=>{Gn(_,b,n),setTimeout(()=>Nn(C,n),50),a&&a()},u))};S()}function Wn(e,t,a){var h,l,m,f,y;let i=a==null?void 0:a.objects.get("ui_endgame_logo_1"),n=(l=(((h=i==null?void 0:i.gameplay)==null?void 0:h.tuning)||{}).animation_start_scale)!=null?l:1.2,o=Date.now(),r=e.alpha,c=(m=e.targetAlpha)!=null?m:1,d=(f=e.baseScaleX)!=null?f:e.scale.x,p=(y=e.baseScaleY)!=null?y:e.scale.y,u=()=>{let _=Date.now()-o,b=Math.min(_/t,1),C=1-Math.pow(1-b,2);e.alpha=r+(c-r)*C;let x=n+(1-n)*C;e.scale.set(d*x,p*x),b<1&&requestAnimationFrame(u)};u()}function Bn(e,t){let a=Date.now(),i=e.alpha,s=e.y,n=()=>{let o=Date.now()-a,r=Math.min(o/t,1),c=1-Math.pow(1-r,2);e.alpha=i+(1-i)*c,e.y=s-20*(1-c),r<1&&requestAnimationFrame(n)};n()}function Rn(e,t){var r;let a=Date.now(),i=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:-10),o=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=i+(1-i)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(o)};o()}function Ln(e,t){var o;let a=Date.now(),i=e.alpha,s=(o=e.targetAlpha)!=null?o:1,n=()=>{let r=Date.now()-a,c=Math.min(r/t,1),d=1-Math.pow(1-c,2);e.alpha=i+(s-i)*d,c<1&&requestAnimationFrame(n)};n()}function Gn(e,t,a){let i=Date.now(),s=e.alpha,n=()=>{let o=Date.now()-i,r=Math.min(o/a,1),c=1-Math.pow(1-r,2);e.alpha=s+(1-s)*c,t.alpha=s+(1-s)*c,e.scale.set(1+.1*(1-c)),r<1&&requestAnimationFrame(n)};n()}function Nn(e,t){var r;let a=Date.now(),i=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:5),o=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=i+(1-i)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(o)};o()}function Xn(e,t,a,i){var p,u,h,l;let s=a.objects.get("ui_endgame_hand_1"),n=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},o=(u=n.click_animation_duration_ms)!=null?u:600,r=(h=n.click_delay_ms)!=null?h:2e3,c=(l=n.click_repeat_delay_ms)!=null?l:3e3,d=()=>{var v,w;e.visible=!0,e.alpha=1;let m=e.x,f=e.y,y=(v=n.hand_offset_x)!=null?v:50,_=(w=n.hand_offset_y)!=null?w:50,b=t.x+y,C=t.y+_,x=Date.now(),S=()=>{var M,R,j;let T=Date.now()-x,g=Math.min(T/o,1),A=g<.5?2*g*g:1-Math.pow(-2*g+2,2)/2;e.x=m+(b-m)*A,e.y=f+(C-f)*A;let E=(R=(M=s==null?void 0:s.transform)==null?void 0:M.scale)!=null?R:.1875,B=(j=n.hand_scale_multiplier)!=null?j:2.5,$=E*B;e.scale.set($+$*.2*Math.sin(g*Math.PI)),g<1?requestAnimationFrame(S):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),i()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=m,e.y=f,d()},c)},500))};S()};setTimeout(d,r)}import{Sprite as qn,Text as $n}from"pixi.js";function Vn(e,t,a){var p,u,h,l;let i=t.objects.get("hand_tutorial_1"),s=((p=i==null?void 0:i.gameplay)==null?void 0:p.tuning)||{},n=(i==null?void 0:i.render)||{},o=(i==null?void 0:i.transform)||{},r=new qn(e);r.anchor.set(.5),r.alpha=0;let c=(u=s.hand_scale_multiplier)!=null?u:2.5,d=(h=o.scale)!=null?h:.1875;return r.scale.set(d*c),r.zIndex=(l=n.z_index)!=null?l:99999,r}function jn(e){var m,f,y,_,b,C,x,S,v,w;let t=e.objects.get("ui_tutorial_1"),a=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},s=((m=e.engine.runtime)==null?void 0:m.ui_styles)||{},n=((f=e.engine.runtime)==null?void 0:f.ui)||{},o=(a==null?void 0:a.text)||n.tutorial_label||n.label_text||"CLEAN!",r=(a==null?void 0:a.font)||"brand.warning",c=(a==null?void 0:a.fontSize)||s.label_font_size||52,d=(_=a==null?void 0:a.letterSpacing)!=null?_:(y=s.label_letter_spacing)!=null?y:-1,p=(a==null?void 0:a.align)||"center",u=i.tint,h=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",l=new $n({text:o,style:{fontFamily:X(r),fontSize:c,fontWeight:q(r),fill:h,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(b=s.label_shadow_alpha)!=null?b:.8,angle:(C=s.label_shadow_angle)!=null?C:0,blur:(x=s.label_shadow_blur)!=null?x:4,distance:(S=s.label_shadow_distance)!=null?S:2}}});return l.anchor.set(.5,0),l.alpha=(v=i.alpha)!=null?v:0,l.visible=(w=i.visible)!=null?w:!0,l}function Jn(e,t,a,i,s){var c,d,p,u,h,l,m;let n=s.objects.get("hand_tutorial_1"),o=((c=n==null?void 0:n.gameplay)==null?void 0:c.tuning)||{},r=(n==null?void 0:n.transform)||{};if(!i){let f=(d=o.animation_duration)!=null?d:1.5,y=a%f/f,_=y<.5?2*y*y:-1+(4-2*y)*y,b=(p=o.x_offset)!=null?p:0,C=(u=o.y_offset)!=null?u:0,x=(h=o.animation_range)!=null?h:40,S=x*.7,v=x,w=t.x+b+S,T=t.y+C+v,g=w+S,A=T+v;e.x=w+(g-w)*_,e.y=T+(A-T)*_;let E=(l=r.scale)!=null?l:.1875,B=(m=o.hand_scale_multiplier)!=null?m:2.5;e.scale.set(E*B)}}import{Graphics as Ge,Assets as Ne,Texture as Kn,Rectangle as Qn,Color as bt}from"pixi.js";function Xe(e,t){if(!e)return;let a=t[e];if(a)return a;let i=e.split("?")[0].split("#")[0];if(i!==e&&t[i])return t[i];let s=i.split("/").pop();if(s&&t[s])return t[s];let n=i.replace(/^\.?\/*/,"");if(n!==i&&t[n])return t[n]}async function qe(e,t,a=16777215,i=!1){try{let s=globalThis.INLINE_ASSETS||{},n=Xe(e,s)||e;return await Ne.load(n)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let n=new Ge;return i?n.roundRect(0,0,60,120,10).fill({color:a}):(n.circle(30,30,30).fill({color:a}),n.rect(25,30,10,40).fill({color:a})),t.renderer.generateTexture(n)}}async function Zn(e,t,a){var f,y,_,b,C,x,S,v,w,T;let i=globalThis.INLINE_ASSETS||{},s=Xe(e,i)||e,n;try{n=await Ne.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(g){let E=(a.gameplay.character_sheet||{}).fallback_color||"#ff00ff";n=await qe(e,t,new bt(E).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:g})}let o=n.source||n.baseTexture||n;o&&"valid"in o&&o.valid===!1&&typeof o.once=="function"&&await new Promise(g=>o.once("loaded",g));let r=a.gameplay.character_sheet||{},c=(f=r.cols)!=null?f:3,d=(y=r.rows)!=null?y:2,p=(x=(C=(_=o==null?void 0:o.width)!=null?_:o==null?void 0:o.pixelWidth)!=null?C:(b=o==null?void 0:o.baseTexture)==null?void 0:b.width)!=null?x:n.width,u=(T=(w=(S=o==null?void 0:o.height)!=null?S:o==null?void 0:o.pixelHeight)!=null?w:(v=o==null?void 0:o.baseTexture)==null?void 0:v.height)!=null?T:n.height,h=p/c,l=u/d;if(!Number.isFinite(h)||!Number.isFinite(l)||h<=0||l<=0||!o)return[n];let m=[];for(let g=0;g<d;g++)for(let A=0;A<c;A++)m.push(new Kn({source:o,frame:new Qn(A*h,g*l,h,l)}));return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function On(e,t){var p,u,h,l;let a=t.gameplay.brush||{},i=new bt(t.theme.brush_color||"#ffffff").toNumber(),s=(p=a.radius)!=null?p:20,n=(u=a.inner_radius)!=null?u:15,o=(h=a.alpha)!=null?h:.8,r=(l=a.inner_alpha)!=null?l:.3,c=a.inner_color||"#ffffff",d=new Ge;return d.circle(0,0,s).fill({color:i,alpha:o}),d.circle(0,0,n).fill({color:new bt(c).toNumber(),alpha:r}),e.renderer.generateTexture(d)}export{ht as GameObject,gt as GameObjectManager,dt as Renderer,ct as Transform,Xn as animateHandClick,Hn as animatePanelEntrance,On as createBrushTexture,Mn as createEndGamePanel,Vn as createHandTutorial,Dn as createPixiBase,jn as createTutorialLabel,kn as getRegisteredFontIds,qe as loadAsset,Zn as loadCharacterFrames,Yn as registerFont,X as resolveFont,q as resolveFontWeight,Jn as updateHandAnimation};
@@ -1,4 +1,4 @@
1
- "use strict";var ha=Object.create;var Pe=Object.defineProperty;var fa=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var ga=Object.getPrototypeOf,ba=Object.prototype.hasOwnProperty;var wa=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},On=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ya(t))!ba.call(e,a)&&a!==n&&Pe(e,a,{get:()=>t[a],enumerable:!(i=fa(t,a))||i.enumerable});return e};var we=(e,t,n)=>(n=e!=null?ha(ga(e)):{},On(t||!e||!e.__esModule?Pe(n,"default",{value:e,enumerable:!0}):n,e)),Ea=e=>On(Pe({},"__esModule",{value:!0}),e);var Oa={};wa(Oa,{AspectClass:()=>ut,GameObject:()=>He,GameObjectManager:()=>Ve,Renderer:()=>Ae,ResponsiveUISystem:()=>fe,Transform:()=>Re,animateHandClick:()=>Ei,animatePanelEntrance:()=>wi,createBrushTexture:()=>Ri,createEndGamePanel:()=>bi,createHandTutorial:()=>xi,createThreeBase:()=>fi,createTutorialLabel:()=>_i,getAspectClass:()=>je,getRegisteredFontIds:()=>gi,loadAsset:()=>ht,loadCharacterFrames:()=>Si,registerFont:()=>yi,resolveFont:()=>G,resolveFontWeight:()=>j,updateHandAnimation:()=>Ti});module.exports=Ea(Oa);var N=we(require("three"));var Z={};function We(e,t,n=!1){Z[e]||(Z[e]=[]),Z[e].push({fn:t,once:n})}function st(e,t){if(Z[e]){if(!t){delete Z[e];return}Z[e]=Z[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=Z[e];if(n)for(let i of[...n])i.fn(...t),i.once&&st(e,i.fn)}function z(e,t){We(e,t,!0)}var Be={name:"handler-playable-sdk",version:"0.1.18",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var B=0,_a=B++,Nn=B++,Yn=B++,In=B++,Gn=B++,jn=B++,Vn=B++,qn=B++,Xn=B++,Kn=B++,Jn=B++,Zn=B++,T=_a;function Qn(){return T===Nn}function Un(){return T===Yn}function ei(){return T===In}function ti(){return T===Gn}function le(){return T===jn}function ce(){return T===Vn}function ni(){return T===qn}function ii(){return T===Xn}function ai(){return T===Kn}function ot(){return T===Jn}function rt(){return T===Zn}function si(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),T=Nn;return}catch{}else if(e==="dapi")try{dapi.isReady(),T=Yn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(T=In)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(T=Gn)}catch{}else if(t==="mintegral")window.gameReady&&(T=jn);else if(t==="tapjoy")window.TJ_API&&(T=Vn);else if(t==="tiktok")window.openAppStore&&(T=qn);else if(t==="smadex")try{window.smxTracking&&(T=Xn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(T=Kn)}catch{}else t==="vungle"?T=Jn:(e==="nucleo"||t==="nucleo")&&(T=Zn)}var pi={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ta=Math.random().toString(36).slice(2),de=null,xe={...pi},mi="web_embed",va={},lt=!1,Ee=!1,Te=!1,ui=!1,mt=1,dt=0,Ie=!1,K=!1,Ye="",pe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),pt=pe>me,J=!1,_e=!1,oi=!1,ri=!1,ct=!1,Oe=null;function li(){if(de)return de;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),de=e,e}function Ne(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function hi(e,t){return{event_name:e,ts:Date.now(),session_id:Ta,deployment_id:xe.deployment_id,variant_id:xe.variant_id,export_profile_id:xe.profile_id,instance_id:xe.instance_id||"default",env:mi==="mraid"?"mraid":"web",payload:t}}function w(e,t){let n=Ne(e),i=hi(n,t);ze(n,i),n!==e&&ze(e,i)}function ve(){Oe&&(Oe(pe,me),Oe=null)}function ue(e){mt=e,w("volume",e)}function he(e){e&&(ui=!0),!Te&&(Te=!0,w("pause"),ue(0))}function Se(e){!e&&ui||Te&&(Te=!1,w("resume"),ue(mt))}function U(e,t){pe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),pt=pe>me,w("resize",{width:pe,height:me})}function Sa(){if(Qn())try{let e=mraid.getMaxSize();U(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?Se():he()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();U(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();ue(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&ue(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),Ie=!0,mraid.isViewable()&&mraid.getState()!=="hidden")J=!0,w("boot"),w("view"),w("ready"),K=!0,ve();else{let n=()=>{J=!0,w("boot"),w("view"),w("ready"),K=!0,ve()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ra(){if(Un())try{let e=dapi.getScreenSize();U(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?Se():he()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();U(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(ue(t?1:0),dapi.addEventListener("audioVolumeChange",n=>ue(n?1:0)),Ie=!0,dapi.isViewable())J=!0,w("boot"),w("view"),w("ready"),K=!0,ve();else{let n=()=>{J=!0,w("boot"),w("view"),w("ready"),K=!0,ve()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function ci(){let e=()=>{J||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(J=!0,w("boot"),w("view"),w("ready"),K=!0,ve(),_e&&(_e=!1,Q.start()))};window.addEventListener("resize",()=>U()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(Se(),e()):he()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ie=!0}function Aa(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(oi=!0),!(oi&&t instanceof MouseEvent)&&(dt+=1,w("interaction",dt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Ha(e){var i,a,s,r,m,l,h,p,y,f,u,g;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ce())(s=(a=window.TJ_API)==null?void 0:a.click)==null||s.call(a);else if(ei())(m=(r=window.FbPlayableAd)==null?void 0:r.onCTAClick)==null||m.call(r);else if(ai())(h=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||h.call(l);else if(ii())try{(y=(p=window.smxTracking)==null?void 0:p.redirect)==null||y.call(p)}catch(o){console.warn("Smadex redirect failed",o)}else if(ti()){let o=window.ExitApi;o&&typeof o.exit=="function"?o.exit(e||Ye||""):e&&window.open(e)}else le()?(f=window.install)==null||f.call(window):ni()?(u=window.openAppStore)==null||u.call(window):ot()?(g=parent==null?void 0:parent.postMessage)==null||g.call(parent,"download","*"):e&&window.open(e)}function Ca(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;z("view",()=>t(n.mraid_viewable)),z("start",()=>t(n.game_viewable)),z("engagement",()=>t(n.engagement));let i=()=>t(n.complete);z("complete",i),We("engagement",a=>{var s;((s=a==null?void 0:a.payload)==null?void 0:s.count)>3&&i()}),z("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;z("view",()=>t(n.Ad_Load_Start)),z("start",()=>t(n.Ad_Viewable)),z("engagement",()=>t(n.First_Engagement)),z("complete",()=>t(n.Gameplay_Complete)),z("cta_click",()=>t(n.DSP_Click)),z("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ma(){if(!ce())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{Q.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function di(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function La(){le()&&(window.mintGameStart=()=>{Se(!0),U()},window.mintGameClose=()=>{he(!0)})}function ka(){if(!rt())return;let e=window.NUC;!e||!e.trigger||(Q.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ye)}),Q.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var Q={init(e={},t){if(mi=e.profile||"web_embed",va=e.consent||{},xe={...pi,...e.ids||{}},de=e.rootEl||de,Ye=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),w("init"),document.body.oncontextmenu=()=>!1,li(),Fa(de),si(),Sa(),Ra(),!Ie){if(document.readyState==="complete")ci();else if(!ri){ri=!0;let n=()=>{ci(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Aa(),Ca(),Ma(),La(),ka(),console.log(`%c @handler/playable-sdk %c v${Be.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),J&&!K&&(w("boot"),w("view"),w("ready"),_e&&(_e=!1,Q.start()),K=!0),K=J},getRoot(){return li()},get version(){return Be.version||"0.0.0"},get maxWidth(){return pe},get maxHeight(){return me},get isLandscape(){return pt},get isReady(){return K},get isStarted(){return lt},get isPaused(){return Te},get isFinished(){return Ee},get volume(){return mt},get interactions(){return dt},on(e,t){We(Ne(e),t)},off(e,t){st(Ne(e),t)},start(){var e,t;if(!lt){if(!J){_e=!0;return}if(lt=!0,w("start"),U(),le())he(),(e=window.gameReady)==null||e.call(window);else if(ce()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:pt?"landscape":"portrait",buildID:Be.version||"dev"})}}},finish(){var e,t;Ee||(Ee=!0,w("complete"),le()?(e=window.gameEnd)==null||e.call(window):ot()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ce()&&di())},install(e){if(!Ee){Ee=!0,ce()?(di(),setTimeout(()=>Q.install(e),300)):(w("complete"),setTimeout(()=>Q.install(e),0));return}ct||(ct=!0,setTimeout(()=>ct=!1,500),w("cta_click"),w("conversion"),Ha(e||Ye))},emit(e,t){let n=Ne(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=hi(n,t);ze(n,i)},retry(){var e,t,n;if(le())(e=window.gameRetry)==null||e.call(window);else if(rt()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}w("engagement",{action:"retry"})},pause(){he(!0)},resume(){Se(!0)},resize(e,t){U(e,t)}},Ge=Q;function Fa(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
1
+ "use strict";var ha=Object.create;var Pe=Object.defineProperty;var fa=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var ga=Object.getPrototypeOf,ba=Object.prototype.hasOwnProperty;var wa=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},On=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ya(t))!ba.call(e,a)&&a!==n&&Pe(e,a,{get:()=>t[a],enumerable:!(i=fa(t,a))||i.enumerable});return e};var we=(e,t,n)=>(n=e!=null?ha(ga(e)):{},On(t||!e||!e.__esModule?Pe(n,"default",{value:e,enumerable:!0}):n,e)),Ea=e=>On(Pe({},"__esModule",{value:!0}),e);var Oa={};wa(Oa,{AspectClass:()=>ut,GameObject:()=>He,GameObjectManager:()=>Ve,Renderer:()=>Ae,ResponsiveUISystem:()=>fe,Transform:()=>Re,animateHandClick:()=>Ei,animatePanelEntrance:()=>wi,createBrushTexture:()=>Ri,createEndGamePanel:()=>bi,createHandTutorial:()=>xi,createThreeBase:()=>fi,createTutorialLabel:()=>_i,getAspectClass:()=>je,getRegisteredFontIds:()=>gi,loadAsset:()=>ht,loadCharacterFrames:()=>Si,registerFont:()=>yi,resolveFont:()=>G,resolveFontWeight:()=>j,updateHandAnimation:()=>Ti});module.exports=Ea(Oa);var N=we(require("three"));var Z={};function We(e,t,n=!1){Z[e]||(Z[e]=[]),Z[e].push({fn:t,once:n})}function st(e,t){if(Z[e]){if(!t){delete Z[e];return}Z[e]=Z[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=Z[e];if(n)for(let i of[...n])i.fn(...t),i.once&&st(e,i.fn)}function z(e,t){We(e,t,!0)}var Be={name:"handler-playable-sdk",version:"0.2.1",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var B=0,_a=B++,Nn=B++,Yn=B++,In=B++,Gn=B++,jn=B++,Vn=B++,qn=B++,Xn=B++,Kn=B++,Jn=B++,Zn=B++,v=_a;function Qn(){return v===Nn}function Un(){return v===Yn}function ei(){return v===In}function ti(){return v===Gn}function le(){return v===jn}function ce(){return v===Vn}function ni(){return v===qn}function ii(){return v===Xn}function ai(){return v===Kn}function ot(){return v===Jn}function rt(){return v===Zn}function si(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),v=Nn;return}catch{}else if(e==="dapi")try{dapi.isReady(),v=Yn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(v=In)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(v=Gn)}catch{}else if(t==="mintegral")window.gameReady&&(v=jn);else if(t==="tapjoy")window.TJ_API&&(v=Vn);else if(t==="tiktok")window.openAppStore&&(v=qn);else if(t==="smadex")try{window.smxTracking&&(v=Xn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(v=Kn)}catch{}else t==="vungle"?v=Jn:(e==="nucleo"||t==="nucleo")&&(v=Zn)}var pi={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ta=Math.random().toString(36).slice(2),de=null,xe={...pi},mi="web_embed",va={},lt=!1,Ee=!1,Te=!1,ui=!1,mt=1,dt=0,Ie=!1,K=!1,Ye="",pe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),pt=pe>me,J=!1,_e=!1,oi=!1,ri=!1,ct=!1,Oe=null;function li(){if(de)return de;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),de=e,e}function Ne(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function hi(e,t){return{event_name:e,ts:Date.now(),session_id:Ta,deployment_id:xe.deployment_id,variant_id:xe.variant_id,export_profile_id:xe.profile_id,instance_id:xe.instance_id||"default",env:mi==="mraid"?"mraid":"web",payload:t}}function w(e,t){let n=Ne(e),i=hi(n,t);ze(n,i),n!==e&&ze(e,i)}function ve(){Oe&&(Oe(pe,me),Oe=null)}function ue(e){mt=e,w("volume",e)}function he(e){e&&(ui=!0),!Te&&(Te=!0,w("pause"),ue(0))}function Se(e){!e&&ui||Te&&(Te=!1,w("resume"),ue(mt))}function U(e,t){pe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),pt=pe>me,w("resize",{width:pe,height:me})}function Sa(){if(Qn())try{let e=mraid.getMaxSize();U(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?Se():he()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();U(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();ue(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&ue(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),Ie=!0,mraid.isViewable()&&mraid.getState()!=="hidden")J=!0,w("boot"),w("view"),w("ready"),K=!0,ve();else{let n=()=>{J=!0,w("boot"),w("view"),w("ready"),K=!0,ve()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ra(){if(Un())try{let e=dapi.getScreenSize();U(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?Se():he()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();U(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(ue(t?1:0),dapi.addEventListener("audioVolumeChange",n=>ue(n?1:0)),Ie=!0,dapi.isViewable())J=!0,w("boot"),w("view"),w("ready"),K=!0,ve();else{let n=()=>{J=!0,w("boot"),w("view"),w("ready"),K=!0,ve()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function ci(){let e=()=>{J||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(J=!0,w("boot"),w("view"),w("ready"),K=!0,ve(),_e&&(_e=!1,Q.start()))};window.addEventListener("resize",()=>U()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(Se(),e()):he()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ie=!0}function Aa(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(oi=!0),!(oi&&t instanceof MouseEvent)&&(dt+=1,w("interaction",dt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Ha(e){var i,a,s,r,u,l,m,p,y,f,h,g;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ce())(s=(a=window.TJ_API)==null?void 0:a.click)==null||s.call(a);else if(ei())(u=(r=window.FbPlayableAd)==null?void 0:r.onCTAClick)==null||u.call(r);else if(ai())(m=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||m.call(l);else if(ii())try{(y=(p=window.smxTracking)==null?void 0:p.redirect)==null||y.call(p)}catch(o){console.warn("Smadex redirect failed",o)}else if(ti()){let o=window.ExitApi;o&&typeof o.exit=="function"?o.exit(e||Ye||""):e&&window.open(e)}else le()?(f=window.install)==null||f.call(window):ni()?(h=window.openAppStore)==null||h.call(window):ot()?(g=parent==null?void 0:parent.postMessage)==null||g.call(parent,"download","*"):e&&window.open(e)}function Ca(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;z("view",()=>t(n.mraid_viewable)),z("start",()=>t(n.game_viewable)),z("engagement",()=>t(n.engagement));let i=()=>t(n.complete);z("complete",i),We("engagement",a=>{var s;((s=a==null?void 0:a.payload)==null?void 0:s.count)>3&&i()}),z("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;z("view",()=>t(n.Ad_Load_Start)),z("start",()=>t(n.Ad_Viewable)),z("engagement",()=>t(n.First_Engagement)),z("complete",()=>t(n.Gameplay_Complete)),z("cta_click",()=>t(n.DSP_Click)),z("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ma(){if(!ce())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{Q.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function di(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function La(){le()&&(window.mintGameStart=()=>{Se(!0),U()},window.mintGameClose=()=>{he(!0)})}function ka(){if(!rt())return;let e=window.NUC;!e||!e.trigger||(Q.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ye)}),Q.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var Q={init(e={},t){if(mi=e.profile||"web_embed",va=e.consent||{},xe={...pi,...e.ids||{}},de=e.rootEl||de,Ye=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),w("init"),document.body.oncontextmenu=()=>!1,li(),Fa(de),si(),Sa(),Ra(),!Ie){if(document.readyState==="complete")ci();else if(!ri){ri=!0;let n=()=>{ci(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Aa(),Ca(),Ma(),La(),ka(),console.log(`%c @handler/playable-sdk %c v${Be.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),J&&!K&&(w("boot"),w("view"),w("ready"),_e&&(_e=!1,Q.start()),K=!0),K=J},getRoot(){return li()},get version(){return Be.version||"0.0.0"},get maxWidth(){return pe},get maxHeight(){return me},get isLandscape(){return pt},get isReady(){return K},get isStarted(){return lt},get isPaused(){return Te},get isFinished(){return Ee},get volume(){return mt},get interactions(){return dt},on(e,t){We(Ne(e),t)},off(e,t){st(Ne(e),t)},start(){var e,t;if(!lt){if(!J){_e=!0;return}if(lt=!0,w("start"),U(),le())he(),(e=window.gameReady)==null||e.call(window);else if(ce()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:pt?"landscape":"portrait",buildID:Be.version||"dev"})}}},finish(){var e,t;Ee||(Ee=!0,w("complete"),le()?(e=window.gameEnd)==null||e.call(window):ot()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ce()&&di())},install(e){if(!Ee){Ee=!0,ce()?(di(),setTimeout(()=>Q.install(e),300)):(w("complete"),setTimeout(()=>Q.install(e),0));return}ct||(ct=!0,setTimeout(()=>ct=!1,500),w("cta_click"),w("conversion"),Ha(e||Ye))},emit(e,t){let n=Ne(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=hi(n,t);ze(n,i)},retry(){var e,t,n;if(le())(e=window.gameRetry)==null||e.call(window);else if(rt()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}w("engagement",{action:"retry"})},pause(){he(!0)},resume(){Se(!0)},resize(e,t){U(e,t)}},Ge=Q;function Fa(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
2
2
  (function(){
3
3
  var events = ['touchstart','touchend','mousedown','keydown'];
4
4
  function unlock(){
@@ -35,16 +35,16 @@
35
35
  padding: 0 !important;
36
36
  border: none !important;
37
37
  overflow: hidden !important;
38
- `,e.appendChild(r);let m=document.createElement("div");m.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","min-width:100%","min-height:100%","max-width:100%","max-height:100%","pointer-events:auto","box-sizing:border-box","margin:0","padding:0","overflow:hidden"].join(";")),r.appendChild(m);let l=new N.Scene,{width:h,height:p}=n(),y=new N.AmbientLight(16777215,.6);l.add(y);let f=new N.DirectionalLight(16777215,.8);f.position.set(5,5,5),f.castShadow=!1,l.add(f);let u=new N.DirectionalLight(16777215,.3);u.position.set(-5,0,5),l.add(u);let g=new N.PerspectiveCamera(55,h/p,.1,100);g.position.set(0,0,3.2),g.lookAt(0,0,0),g.updateMatrixWorld();let o=new N.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});o.setPixelRatio(window.devicePixelRatio||1),o.setSize(h,p),o.setClearColor(0,0),o.domElement.style.position="absolute",o.domElement.style.top="0",o.domElement.style.left="0",o.domElement.style.right="0",o.domElement.style.bottom="0",o.domElement.style.width="100%",o.domElement.style.height="100%",o.domElement.style.minWidth="100%",o.domElement.style.minHeight="100%",o.domElement.style.maxWidth="100%",o.domElement.style.maxHeight="100%",o.domElement.style.display="block",o.domElement.style.pointerEvents="auto",o.domElement.style.margin="0",o.domElement.style.padding="0",o.domElement.style.boxSizing="border-box",m.appendChild(o.domElement);let E=d=>{var R;let c=e.getBoundingClientRect(),b=window.getComputedStyle(e);console.log("[THREE-BASE] applySize called:",{providedSize:d,rootRect:{width:c.width,height:c.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleSize:{width:e.style.width,height:e.style.height},computedStyle:{width:b.width,height:b.height,transform:b.transform,scale:b.scale},rendererCurrentSize:{width:o.domElement.width,height:o.domElement.height},rendererStyleSize:{width:o.domElement.style.width,height:o.domElement.style.height},stackTrace:(R=new Error().stack)==null?void 0:R.split(`
38
+ `,e.appendChild(r);let u=document.createElement("div");u.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","min-width:100%","min-height:100%","max-width:100%","max-height:100%","pointer-events:auto","box-sizing:border-box","margin:0","padding:0","overflow:hidden"].join(";")),r.appendChild(u);let l=new N.Scene,{width:m,height:p}=n(),y=new N.AmbientLight(16777215,.6);l.add(y);let f=new N.DirectionalLight(16777215,.8);f.position.set(5,5,5),f.castShadow=!1,l.add(f);let h=new N.DirectionalLight(16777215,.3);h.position.set(-5,0,5),l.add(h);let g=new N.PerspectiveCamera(55,m/p,.1,100);g.position.set(0,0,3.2),g.lookAt(0,0,0),g.updateMatrixWorld();let o=new N.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});o.setPixelRatio(window.devicePixelRatio||1),o.setSize(m,p),o.setClearColor(0,0),o.domElement.style.position="absolute",o.domElement.style.top="0",o.domElement.style.left="0",o.domElement.style.right="0",o.domElement.style.bottom="0",o.domElement.style.width="100%",o.domElement.style.height="100%",o.domElement.style.minWidth="100%",o.domElement.style.minHeight="100%",o.domElement.style.maxWidth="100%",o.domElement.style.maxHeight="100%",o.domElement.style.display="block",o.domElement.style.pointerEvents="auto",o.domElement.style.margin="0",o.domElement.style.padding="0",o.domElement.style.boxSizing="border-box",u.appendChild(o.domElement);let E=d=>{var A;let c=e.getBoundingClientRect(),b=window.getComputedStyle(e);console.log("[THREE-BASE] applySize called:",{providedSize:d,rootRect:{width:c.width,height:c.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleSize:{width:e.style.width,height:e.style.height},computedStyle:{width:b.width,height:b.height,transform:b.transform,scale:b.scale},rendererCurrentSize:{width:o.domElement.width,height:o.domElement.height},rendererStyleSize:{width:o.domElement.style.width,height:o.domElement.style.height},stackTrace:(A=new Error().stack)==null?void 0:A.split(`
39
39
  `).slice(1,4).join(`
40
- `)});let _=c.width,v=c.height;if((_<=0||!isFinite(_))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:c.width,clientWidth:e.clientWidth}),_=e.clientWidth||window.innerWidth||320),(v<=0||!isFinite(v))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:c.height,clientHeight:e.clientHeight}),v=e.clientHeight||window.innerHeight||480),typeof(d==null?void 0:d.width)=="number"&&d.width>0){let L=Math.abs(d.width-c.width),C=c.width*.1;L>C?console.warn("[THREE-BASE] Provided width ignored (too different from container):",{provided:d.width,container:c.width,difference:L,tolerance:C,willUse:"container size (boundingRect)"}):(_=d.width,console.log("[THREE-BASE] Using provided width (within tolerance):",{provided:d.width,container:c.width}))}if(typeof(d==null?void 0:d.height)=="number"&&d.height>0){let L=Math.abs(d.height-c.height),C=c.height*.1;L>C?console.warn("[THREE-BASE] Provided height ignored (too different from container):",{provided:d.height,container:c.height,difference:L,tolerance:C,willUse:"container size (boundingRect)"}):(v=d.height,console.log("[THREE-BASE] Using provided height (within tolerance):",{provided:d.height,container:c.height}))}(_<=0||v<=0||!isFinite(_)||!isFinite(v))&&(console.warn("[THREE-BASE] Invalid size in applySize, using fallback",{newWidth:_,newHeight:v,size:d,rootRect:c}),_=c.width||e.clientWidth||320,v=c.height||e.clientHeight||480);let H=Math.floor(_),F=Math.floor(v);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:H,finalHeight:F,aspectRatio:H/F,beforeRendererSize:{width:o.domElement.width,height:o.domElement.height},beforeRendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height}}),o.setSize(H,F),o.setPixelRatio(window.devicePixelRatio||1),g.aspect=H/F,g.updateProjectionMatrix();let S=e.getBoundingClientRect();console.log("[THREE-BASE] applySize after setting:",{rendererSize:{width:o.domElement.width,height:o.domElement.height},rendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height},containerRect:{width:S.width,height:S.height},cameraAspect:g.aspect,matches:{width:Math.abs(o.domElement.width-S.width)<1,height:Math.abs(o.domElement.height-S.height)<1},sizeDifference:{width:o.domElement.width-S.width,height:o.domElement.height-S.height}})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{E()})});let A=!1;Ge.on("pause",()=>{A=!0,document.querySelectorAll("audio").forEach(c=>c.pause())}),Ge.on("resume",()=>{A=!1,document.querySelectorAll("audio").forEach(c=>{c.currentTime>0&&!c.ended&&c.play().catch(()=>{})})});let x=new fe(e,r);return Ge.on("resize",({payload:d})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:d,timestamp:Date.now(),rootRect:e.getBoundingClientRect()}),E({width:d==null?void 0:d.width,height:d==null?void 0:d.height}),x.updateLayout()}),window.addEventListener("resize",()=>{console.log("[THREE-BASE] Window resize event received:",{timestamp:Date.now(),windowSize:{width:window.innerWidth,height:window.innerHeight},rootRect:e.getBoundingClientRect()}),E(),x.updateLayout()}),{scene:l,camera:g,renderer:o,uiSystem:x,applySize:E}}var k=we(require("three")),Re=class{constructor(t){var n,i;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(i=t==null?void 0:t.rotation)!=null?i:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToThree(t){let n=t.position.z,i=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,i),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},Ae=class{constructor(t){var n,i,a,s;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(i=t==null?void 0:t.alpha)!=null?i:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(s=t==null?void 0:t.tint)!=null?s:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof k.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof k.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof k.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof k.Mesh&&t.material){let n=typeof this.tint=="string"?new k.Color(this.tint):new k.Color(this.tint);Array.isArray(t.material)?t.material.forEach(i=>{(i instanceof k.MeshBasicMaterial||i instanceof k.MeshStandardMaterial)&&i.color.copy(n)}):(t.material instanceof k.MeshBasicMaterial||t.material instanceof k.MeshStandardMaterial)&&t.material.color.copy(n)}}},He=class{constructor(t,n,i,a){this.instanceId=t,this.objectConfig=n,this.threeObject=i,this._config=a,this.transform=new Re(a.transform),this.renderer=new Ae(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToThree(this.threeObject)}},Ve=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let i=this.config.objects.get(t);if(!i)throw new Error(`Object config not found: ${t}`);let a=new He(t,i.object_config||t,n,i);return this.objects.set(t,a),a}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,i]of this.objects.entries()){let a=t.objects.get(n);a&&i.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var qe={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function G(e){let t=qe[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function j(e){var n;let t=qe[e];return t&&(n=t.weight)!=null?n:"400"}function yi(e,t){qe[e]=t}function gi(){return Object.keys(qe)}var ye=we(require("three"));function se(e){return{element:e,get alpha(){return parseFloat(e.style.opacity||"1")},set alpha(t){e.style.opacity=t.toString()},get visible(){return e.style.display!=="none"},set visible(t){e.style.display=t?"":"none"},position:{set(t,n){e.style.left=`${t}px`,e.style.top=`${n}px`},get x(){return parseFloat(e.style.left||"0")},get y(){return parseFloat(e.style.top||"0")}},scale:{set(t,n){e.style.transform=`scale(${t})`},get x(){let t=e.style.transform.match(/scale\(([^)]+)\)/);return t?parseFloat(t[1]):1}}}}function bi(e,t,n,i){var Mt,Lt,kt,Ft,Dt,$t,Pt,Wt,zt,Bt,Ot,Nt,Yt,It,Gt,jt,Vt,qt,Xt,Kt,Jt,Zt,Qt,Ut,en,tn,nn,an,sn,on,rn,ln,cn,dn,pn,mn,un,hn,fn,yn,gn,bn,wn,En,xn,_n,Tn,vn,Sn,Rn,An,Hn,Cn,Mn,Ln,kn,Fn,Dn,$n,Pn,Wn,zn,Bn;let a=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),r=e.objects.get("ui_endgame_title_1"),m=e.objects.get("ui_endgame_subtitle_1"),l=e.objects.get("ui_endgame_footer_1"),h=e.objects.get("ui_endgame_cta_1"),p=e.objects.get("ui_endgame_cta_hint_1"),y=e.objects.get("ui_endgame_hand_1"),f=e.engine.runtime||{},u=((Mt=a==null?void 0:a.gameplay)==null?void 0:Mt.tuning)||{},g=(a==null?void 0:a.render)||{},o=i.getBoundingClientRect(),E=o.width>0?o.width*.9:320,A=o.height>0?o.height*.85:400,x=Math.min((Lt=u.panel_width)!=null?Lt:320,E),d=Math.min((kt=u.panel_height)!=null?kt:400,A),c=(Ft=u.panel_padding)!=null?Ft:32,b=(Dt=u.panel_radius)!=null?Dt:24,_=g.background_color||u.panel_bg_color||"#1a0a0a",v=g.background_alpha!==void 0&&g.background_alpha!==null?g.background_alpha:($t=u.panel_bg_alpha)!=null?$t:.98,H=g.border_color||u.panel_border_color||"#ffffff",F=(Pt=u.panel_border_width)!=null?Pt:2,S=(Wt=u.panel_border_alpha)!=null?Wt:.3,R=document.createElement("div");R.style.cssText=`
40
+ `)});let _=c.width,S=c.height;if((_<=0||!isFinite(_))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:c.width,clientWidth:e.clientWidth}),_=e.clientWidth||window.innerWidth||320),(S<=0||!isFinite(S))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:c.height,clientHeight:e.clientHeight}),S=e.clientHeight||window.innerHeight||480),typeof(d==null?void 0:d.width)=="number"&&d.width>0){let L=Math.abs(d.width-c.width),C=c.width*.1;L>C?console.warn("[THREE-BASE] Provided width ignored (too different from container):",{provided:d.width,container:c.width,difference:L,tolerance:C,willUse:"container size (boundingRect)"}):(_=d.width,console.log("[THREE-BASE] Using provided width (within tolerance):",{provided:d.width,container:c.width}))}if(typeof(d==null?void 0:d.height)=="number"&&d.height>0){let L=Math.abs(d.height-c.height),C=c.height*.1;L>C?console.warn("[THREE-BASE] Provided height ignored (too different from container):",{provided:d.height,container:c.height,difference:L,tolerance:C,willUse:"container size (boundingRect)"}):(S=d.height,console.log("[THREE-BASE] Using provided height (within tolerance):",{provided:d.height,container:c.height}))}(_<=0||S<=0||!isFinite(_)||!isFinite(S))&&(console.warn("[THREE-BASE] Invalid size in applySize, using fallback",{newWidth:_,newHeight:S,size:d,rootRect:c}),_=c.width||e.clientWidth||320,S=c.height||e.clientHeight||480);let H=Math.floor(_),F=Math.floor(S);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:H,finalHeight:F,aspectRatio:H/F,beforeRendererSize:{width:o.domElement.width,height:o.domElement.height},beforeRendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height}}),o.setSize(H,F),o.setPixelRatio(window.devicePixelRatio||1),g.aspect=H/F,g.updateProjectionMatrix();let R=e.getBoundingClientRect();console.log("[THREE-BASE] applySize after setting:",{rendererSize:{width:o.domElement.width,height:o.domElement.height},rendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height},containerRect:{width:R.width,height:R.height},cameraAspect:g.aspect,matches:{width:Math.abs(o.domElement.width-R.width)<1,height:Math.abs(o.domElement.height-R.height)<1},sizeDifference:{width:o.domElement.width-R.width,height:o.domElement.height-R.height}})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{E()})});let T=!1;Ge.on("pause",()=>{T=!0,document.querySelectorAll("audio").forEach(c=>c.pause())}),Ge.on("resume",()=>{T=!1,document.querySelectorAll("audio").forEach(c=>{c.currentTime>0&&!c.ended&&c.play().catch(()=>{})})});let x=new fe(e,r);return Ge.on("resize",({payload:d})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:d,timestamp:Date.now(),rootRect:e.getBoundingClientRect()}),E({width:d==null?void 0:d.width,height:d==null?void 0:d.height}),x.updateLayout()}),window.addEventListener("resize",()=>{console.log("[THREE-BASE] Window resize event received:",{timestamp:Date.now(),windowSize:{width:window.innerWidth,height:window.innerHeight},rootRect:e.getBoundingClientRect()}),E(),x.updateLayout()}),{scene:l,camera:g,renderer:o,uiSystem:x,applySize:E}}var k=we(require("three")),Re=class{constructor(t){var n,i;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(i=t==null?void 0:t.rotation)!=null?i:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToThree(t){let n=t.position.z,i=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,i),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},Ae=class{constructor(t){var n,i,a,s;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(i=t==null?void 0:t.alpha)!=null?i:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(s=t==null?void 0:t.tint)!=null?s:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof k.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof k.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof k.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof k.Mesh&&t.material){let n=typeof this.tint=="string"?new k.Color(this.tint):new k.Color(this.tint);Array.isArray(t.material)?t.material.forEach(i=>{(i instanceof k.MeshBasicMaterial||i instanceof k.MeshStandardMaterial)&&i.color.copy(n)}):(t.material instanceof k.MeshBasicMaterial||t.material instanceof k.MeshStandardMaterial)&&t.material.color.copy(n)}}},He=class{constructor(t,n,i,a){this.instanceId=t,this.objectConfig=n,this.threeObject=i,this._config=a,this.transform=new Re(a.transform),this.renderer=new Ae(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToThree(this.threeObject)}},Ve=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let i=this.config.objects.get(t);if(!i)throw new Error(`Object config not found: ${t}`);let a=new He(t,i.object_config||t,n,i);return this.objects.set(t,a),a}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,i]of this.objects.entries()){let a=t.objects.get(n);a&&i.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var qe={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function G(e){let t=qe[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function j(e){var n;let t=qe[e];return t&&(n=t.weight)!=null?n:"400"}function yi(e,t){qe[e]=t}function gi(){return Object.keys(qe)}var ye=we(require("three"));function se(e){return{element:e,get alpha(){return parseFloat(e.style.opacity||"1")},set alpha(t){e.style.opacity=t.toString()},get visible(){return e.style.display!=="none"},set visible(t){e.style.display=t?"":"none"},position:{set(t,n){e.style.left=`${t}px`,e.style.top=`${n}px`},get x(){return parseFloat(e.style.left||"0")},get y(){return parseFloat(e.style.top||"0")}},scale:{set(t,n){e.style.transform=`scale(${t})`},get x(){let t=e.style.transform.match(/scale\(([^)]+)\)/);return t?parseFloat(t[1]):1}}}}function bi(e,t,n,i){var Mt,Lt,kt,Ft,Dt,$t,Pt,Wt,zt,Bt,Ot,Nt,Yt,It,Gt,jt,Vt,qt,Xt,Kt,Jt,Zt,Qt,Ut,en,tn,nn,an,sn,on,rn,ln,cn,dn,pn,mn,un,hn,fn,yn,gn,bn,wn,En,xn,_n,Tn,vn,Sn,Rn,An,Hn,Cn,Mn,Ln,kn,Fn,Dn,$n,Pn,Wn,zn,Bn;let a=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),r=e.objects.get("ui_endgame_title_1"),u=e.objects.get("ui_endgame_subtitle_1"),l=e.objects.get("ui_endgame_footer_1"),m=e.objects.get("ui_endgame_cta_1"),p=e.objects.get("ui_endgame_cta_hint_1"),y=e.objects.get("ui_endgame_hand_1"),f=e.engine.runtime||{},h=((Mt=a==null?void 0:a.gameplay)==null?void 0:Mt.tuning)||{},g=(a==null?void 0:a.render)||{},o=i.getBoundingClientRect(),E=o.width>0?o.width*.9:320,T=o.height>0?o.height*.85:400,x=Math.min((Lt=h.panel_width)!=null?Lt:320,E),d=Math.min((kt=h.panel_height)!=null?kt:400,T),c=(Ft=h.panel_padding)!=null?Ft:32,b=(Dt=h.panel_radius)!=null?Dt:24,_=g.background_color||h.panel_bg_color||"#1a0a0a",S=g.background_alpha!==void 0&&g.background_alpha!==null?g.background_alpha:($t=h.panel_bg_alpha)!=null?$t:.98,H=g.border_color||h.panel_border_color||"#ffffff",F=(Pt=h.panel_border_width)!=null?Pt:2,R=(Wt=h.panel_border_alpha)!=null?Wt:.3,A=document.createElement("div");A.style.cssText=`
41
41
  position: absolute;
42
42
  width: ${x}px;
43
43
  height: ${d}px;
44
44
  background: ${_};
45
- opacity: ${v};
45
+ opacity: ${S};
46
46
  border: ${F}px solid ${H};
47
- border-opacity: ${S};
47
+ border-opacity: ${R};
48
48
  border-radius: ${b}px;
49
49
  display: block;
50
50
  transform: translate(-50%, -50%);
@@ -56,7 +56,7 @@
56
56
  z-index: 1000;
57
57
  box-sizing: border-box;
58
58
  padding: ${c}px;
59
- `,i.appendChild(R);let L=se(R);L.element=R;let C=((zt=s==null?void 0:s.gameplay)==null?void 0:zt.tuning)||{},ee=(s==null?void 0:s.transform)||{},O=(Bt=C.logo_size)!=null?Bt:56,Y=(Ot=ee.scale)!=null?Ot:1,oe=(Yt=(Nt=ee.offset)==null?void 0:Nt.y)!=null?Yt:-130,Ce=(It=C.logo_alpha)!=null?It:1,Ai=new ye.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),I=new ye.Sprite(Ai);I.position.set(0,oe,0),I.material.opacity=0;let Me=0,Le=0;if(n&&(Me=((Gt=n.image)==null?void 0:Gt.width)||100,Le=((jt=n.image)==null?void 0:jt.height)||100),Me>0&&Le>0){let re=Me/Le,it,at;re>1?(it=O,at=O/re):(at=O,it=O*re);let ma=it/Me*Y,ua=at/Le*Y;I.scale.set(ma,ua,1)}else{let re=O/100*Y;I.scale.set(re,re,1)}I.targetAlpha=Ce,I.baseScaleX=I.scale.x,I.baseScaleY=I.scale.y;let D=r==null?void 0:r.ui,V=((Vt=r==null?void 0:r.gameplay)==null?void 0:Vt.tuning)||{},Hi=(D==null?void 0:D.text)||"MISSION ACCOMPLISHED",ft=(D==null?void 0:D.font)||"brand.heading",Ke=(D==null?void 0:D.fontSize)||24,Ci=(qt=D==null?void 0:D.letterSpacing)!=null?qt:1,ke=(Xt=r==null?void 0:r.render)==null?void 0:Xt.tint,Mi=typeof ke=="string"?ke:ke?`#${ke.toString(16).padStart(6,"0")}`:"#00FF88",Li=x-c*2-30,ki=V.font_weight_override?V.font_weight_override:j(ft),te=document.createElement("div");te.textContent=Hi,te.style.cssText=`
59
+ `,i.appendChild(A);let L=se(A);L.element=A;let C=((zt=s==null?void 0:s.gameplay)==null?void 0:zt.tuning)||{},ee=(s==null?void 0:s.transform)||{},O=(Bt=C.logo_size)!=null?Bt:56,Y=(Ot=ee.scale)!=null?Ot:1,oe=(Yt=(Nt=ee.offset)==null?void 0:Nt.y)!=null?Yt:-130,Ce=(It=C.logo_alpha)!=null?It:1,Ai=new ye.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),I=new ye.Sprite(Ai);I.position.set(0,oe,0),I.material.opacity=0;let Me=0,Le=0;if(n&&(Me=((Gt=n.image)==null?void 0:Gt.width)||100,Le=((jt=n.image)==null?void 0:jt.height)||100),Me>0&&Le>0){let re=Me/Le,it,at;re>1?(it=O,at=O/re):(at=O,it=O*re);let ma=it/Me*Y,ua=at/Le*Y;I.scale.set(ma,ua,1)}else{let re=O/100*Y;I.scale.set(re,re,1)}I.targetAlpha=Ce,I.baseScaleX=I.scale.x,I.baseScaleY=I.scale.y;let D=r==null?void 0:r.ui,V=((Vt=r==null?void 0:r.gameplay)==null?void 0:Vt.tuning)||{},Hi=(D==null?void 0:D.text)||"MISSION ACCOMPLISHED",ft=(D==null?void 0:D.font)||"brand.heading",Ke=(D==null?void 0:D.fontSize)||24,Ci=(qt=D==null?void 0:D.letterSpacing)!=null?qt:1,ke=(Xt=r==null?void 0:r.render)==null?void 0:Xt.tint,Mi=typeof ke=="string"?ke:ke?`#${ke.toString(16).padStart(6,"0")}`:"#00FF88",Li=x-c*2-30,ki=V.font_weight_override?V.font_weight_override:j(ft),te=document.createElement("div");te.textContent=Hi,te.style.cssText=`
60
60
  font-family: ${G(ft)};
61
61
  font-size: ${Ke}px;
62
62
  font-weight: ${ki};
@@ -70,7 +70,7 @@
70
70
  transform: translate(-50%, -50%);
71
71
  white-space: nowrap;
72
72
  max-width: ${Li}px;
73
- `;let yt=c+30,Fi=((en=u.title_offset_y)!=null?en:yt+Ke/2)+((tn=V.animation_start_y_offset)!=null?tn:-20);te.style.top=`${Fi}px`,te.style.left="50%";let gt=se(te);gt.element=te,R.appendChild(te);let $=m==null?void 0:m.ui,bt=((nn=m==null?void 0:m.gameplay)==null?void 0:nn.tuning)||{},Di=($==null?void 0:$.text)||"RESCUE COMPLETE",wt=($==null?void 0:$.font)||"brand.body",Je=($==null?void 0:$.fontSize)||11,$i=(an=$==null?void 0:$.letterSpacing)!=null?an:.5,Fe=(sn=m==null?void 0:m.render)==null?void 0:sn.tint,Pi=typeof Fe=="string"?Fe:Fe?`#${Fe.toString(16).padStart(6,"0")}`:"#B0B0B0",ne=document.createElement("div");ne.textContent=Di,ne.style.cssText=`
73
+ `;let yt=c+30,Fi=((en=h.title_offset_y)!=null?en:yt+Ke/2)+((tn=V.animation_start_y_offset)!=null?tn:-20);te.style.top=`${Fi}px`,te.style.left="50%";let gt=se(te);gt.element=te,A.appendChild(te);let $=u==null?void 0:u.ui,bt=((nn=u==null?void 0:u.gameplay)==null?void 0:nn.tuning)||{},Di=($==null?void 0:$.text)||"RESCUE COMPLETE",wt=($==null?void 0:$.font)||"brand.body",Je=($==null?void 0:$.fontSize)||11,$i=(an=$==null?void 0:$.letterSpacing)!=null?an:.5,Fe=(sn=u==null?void 0:u.render)==null?void 0:sn.tint,Pi=typeof Fe=="string"?Fe:Fe?`#${Fe.toString(16).padStart(6,"0")}`:"#B0B0B0",ne=document.createElement("div");ne.textContent=Di,ne.style.cssText=`
74
74
  font-family: ${G(wt)};
75
75
  font-size: ${Je}px;
76
76
  font-weight: ${j(wt)};
@@ -81,7 +81,7 @@
81
81
  position: absolute;
82
82
  transform: translate(-50%, -50%);
83
83
  white-space: nowrap;
84
- `;let Et=yt+Ke+15,Wi=((on=u.subtitle_offset_y)!=null?on:Et+Je/2)+((rn=bt.animation_start_y_offset)!=null?rn:-10);ne.style.top=`${Wi}px`,ne.style.left="50%";let Ze=se(ne);Ze.element=ne,Ze.animationStartYOffset=(ln=bt.animation_start_y_offset)!=null?ln:-10,R.appendChild(ne);let q=l==null?void 0:l.ui,xt=((cn=l==null?void 0:l.gameplay)==null?void 0:cn.tuning)||{},zi=(q==null?void 0:q.text)||((dn=f.ui)==null?void 0:dn.cta_hint)||"Continue the adventure!",_t=(q==null?void 0:q.font)||"brand.body",Tt=(q==null?void 0:q.fontSize)||16,De=(pn=l==null?void 0:l.render)==null?void 0:pn.tint,Bi=typeof De=="string"?De:De?`#${De.toString(16).padStart(6,"0")}`:"#FFFFFF",Oi=(mn=xt.max_width)!=null?mn:x-c*2,Ni=(un=xt.line_height)!=null?un:1.4,ie=document.createElement("div");ie.textContent=zi,ie.style.cssText=`
84
+ `;let Et=yt+Ke+15,Wi=((on=h.subtitle_offset_y)!=null?on:Et+Je/2)+((rn=bt.animation_start_y_offset)!=null?rn:-10);ne.style.top=`${Wi}px`,ne.style.left="50%";let Ze=se(ne);Ze.element=ne,Ze.animationStartYOffset=(ln=bt.animation_start_y_offset)!=null?ln:-10,A.appendChild(ne);let q=l==null?void 0:l.ui,xt=((cn=l==null?void 0:l.gameplay)==null?void 0:cn.tuning)||{},zi=(q==null?void 0:q.text)||((dn=f.ui)==null?void 0:dn.cta_hint)||"Continue the adventure!",_t=(q==null?void 0:q.font)||"brand.body",Tt=(q==null?void 0:q.fontSize)||16,De=(pn=l==null?void 0:l.render)==null?void 0:pn.tint,Bi=typeof De=="string"?De:De?`#${De.toString(16).padStart(6,"0")}`:"#FFFFFF",Oi=(mn=xt.max_width)!=null?mn:x-c*2,Ni=(un=xt.line_height)!=null?un:1.4,ie=document.createElement("div");ie.textContent=zi,ie.style.cssText=`
85
85
  font-family: ${G(_t)};
86
86
  font-size: ${Tt}px;
87
87
  font-weight: ${j(_t)};
@@ -93,7 +93,7 @@
93
93
  max-width: ${Oi}px;
94
94
  line-height: ${Ni};
95
95
  word-wrap: break-word;
96
- `;let Yi=Et+Je+30,Ii=(hn=u.footer_offset_y)!=null?hn:Yi+Tt/2;ie.style.top=`${Ii}px`,ie.style.left="50%";let Qe=se(ie);Qe.element=ie;let Gi=((fn=l==null?void 0:l.render)==null?void 0:fn.alpha)!==void 0&&((yn=l==null?void 0:l.render)==null?void 0:yn.alpha)!==null?l.render.alpha:1;Qe.targetAlpha=Gi,R.appendChild(ie);let X=((gn=h==null?void 0:h.gameplay)==null?void 0:gn.tuning)||{},P=h==null?void 0:h.ui,ji=(bn=X.button_width)!=null?bn:260,vt=(wn=X.button_height)!=null?wn:56,Vi=(En=X.button_radius)!=null?En:16,qi=X.button_bg_color||((xn=f.theme)==null?void 0:xn.cta_background)||"#ffb43b",Xi=(_n=X.button_bg_alpha)!=null?_n:1,Ki=X.button_border_color||"#ffffff",Ji=(Tn=X.button_border_width)!=null?Tn:2,Ia=(vn=X.button_border_alpha)!=null?vn:.2,Ue=(Sn=u.cta_offset_y)!=null?Sn:d*.7,M=document.createElement("button");M.style.cssText=`
96
+ `;let Yi=Et+Je+30,Ii=(hn=h.footer_offset_y)!=null?hn:Yi+Tt/2;ie.style.top=`${Ii}px`,ie.style.left="50%";let Qe=se(ie);Qe.element=ie;let Gi=((fn=l==null?void 0:l.render)==null?void 0:fn.alpha)!==void 0&&((yn=l==null?void 0:l.render)==null?void 0:yn.alpha)!==null?l.render.alpha:1;Qe.targetAlpha=Gi,A.appendChild(ie);let X=((gn=m==null?void 0:m.gameplay)==null?void 0:gn.tuning)||{},P=m==null?void 0:m.ui,ji=(bn=X.button_width)!=null?bn:260,vt=(wn=X.button_height)!=null?wn:56,Vi=(En=X.button_radius)!=null?En:16,qi=X.button_bg_color||((xn=f.theme)==null?void 0:xn.cta_background)||"#ffb43b",Xi=(_n=X.button_bg_alpha)!=null?_n:1,Ki=X.button_border_color||"#ffffff",Ji=(Tn=X.button_border_width)!=null?Tn:2,Ia=(vn=X.button_border_alpha)!=null?vn:.2,Ue=(Sn=h.cta_offset_y)!=null?Sn:d*.7,M=document.createElement("button");M.style.cssText=`
97
97
  width: ${ji}px;
98
98
  height: ${vt}px;
99
99
  background: ${qi};
@@ -105,7 +105,7 @@
105
105
  position: absolute;
106
106
  transform: translate(-50%, -50%);
107
107
  box-shadow: inset 0 0 1px rgba(0,0,0,0.15);
108
- `,M.style.top=`${Ue}px`,M.style.left="50%";let et=se(M);et.element=M,et.addEventListener=M.addEventListener.bind(M),R.appendChild(M);let Zi=(P==null?void 0:P.text)||((Rn=f.ui)==null?void 0:Rn.cta_label_end)||"DOWNLOAD",St=(P==null?void 0:P.font)||"brand.heading",Qi=(P==null?void 0:P.fontSize)||20,Ui=X.button_text_color||((An=f.theme)==null?void 0:An.cta_text)||"#1a0a0a";M.textContent=Zi,M.style.fontFamily=G(St),M.style.fontSize=`${Qi}px`,M.style.fontWeight=String(j(St)),M.style.color=Ui,M.style.letterSpacing=`${(Hn=P==null?void 0:P.letterSpacing)!=null?Hn:1}px`;let Rt=se(M);Rt.element=M;let W=p==null?void 0:p.ui,At=((Cn=p==null?void 0:p.gameplay)==null?void 0:Cn.tuning)||{},ea=(W==null?void 0:W.text)||"Play the full game",Ht=(W==null?void 0:W.font)||"brand.body",ta=(W==null?void 0:W.fontSize)||11,na=(Mn=W==null?void 0:W.letterSpacing)!=null?Mn:0,$e=(Ln=p==null?void 0:p.render)==null?void 0:Ln.tint,ia=typeof $e=="string"?$e:$e?`#${$e.toString(16).padStart(6,"0")}`:"#CCCCCC",ae=document.createElement("div");ae.textContent=ea,ae.style.cssText=`
108
+ `,M.style.top=`${Ue}px`,M.style.left="50%";let et=se(M);et.element=M,et.addEventListener=M.addEventListener.bind(M),A.appendChild(M);let Zi=(P==null?void 0:P.text)||((Rn=f.ui)==null?void 0:Rn.cta_label_end)||"DOWNLOAD",St=(P==null?void 0:P.font)||"brand.heading",Qi=(P==null?void 0:P.fontSize)||20,Ui=X.button_text_color||((An=f.theme)==null?void 0:An.cta_text)||"#1a0a0a";M.textContent=Zi,M.style.fontFamily=G(St),M.style.fontSize=`${Qi}px`,M.style.fontWeight=String(j(St)),M.style.color=Ui,M.style.letterSpacing=`${(Hn=P==null?void 0:P.letterSpacing)!=null?Hn:1}px`;let Rt=se(M);Rt.element=M;let W=p==null?void 0:p.ui,At=((Cn=p==null?void 0:p.gameplay)==null?void 0:Cn.tuning)||{},ea=(W==null?void 0:W.text)||"Play the full game",Ht=(W==null?void 0:W.font)||"brand.body",ta=(W==null?void 0:W.fontSize)||11,na=(Mn=W==null?void 0:W.letterSpacing)!=null?Mn:0,$e=(Ln=p==null?void 0:p.render)==null?void 0:Ln.tint,ia=typeof $e=="string"?$e:$e?`#${$e.toString(16).padStart(6,"0")}`:"#CCCCCC",ae=document.createElement("div");ae.textContent=ea,ae.style.cssText=`
109
109
  font-family: ${G(Ht)};
110
110
  font-size: ${ta}px;
111
111
  font-weight: ${j(Ht)};
@@ -116,13 +116,13 @@
116
116
  position: absolute;
117
117
  transform: translate(-50%, -50%);
118
118
  white-space: nowrap;
119
- `;let aa=Ue+vt/2+20,sa=d-c-10,oa=Math.min(aa+((kn=At.animation_start_y_offset)!=null?kn:5),sa);ae.style.top=`${oa}px`,ae.style.left="50%";let tt=se(ae);tt.element=ae,tt.animationStartYOffset=(Fn=At.animation_start_y_offset)!=null?Fn:5,R.appendChild(ae);let nt=((Dn=y==null?void 0:y.gameplay)==null?void 0:Dn.tuning)||{},ra=($n=nt.hand_offset_x)!=null?$n:50,la=(Pn=nt.hand_offset_y)!=null?Pn:50,ca=(zn=(Wn=y==null?void 0:y.transform)==null?void 0:Wn.scale)!=null?zn:.1875,da=(Bn=nt.hand_scale_multiplier)!=null?Bn:2.5,pa=new ye.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),be=new ye.Sprite(pa),Ct=ca*da*100;return be.scale.set(Ct,Ct,1),be.position.set(ra,Ue+la,0),be.material.opacity=0,be.visible=!1,{panel:L,logo:I,title:gt,subtitle:Ze,footer:Qe,ctaButton:et,ctaText:Rt,ctaHint:tt,hand:be}}function wi(e,t,n){var _,v,H,F,S,R,L,C;let i=t.objects.get("ui_endgame_1"),a=((_=i==null?void 0:i.gameplay)==null?void 0:_.tuning)||{},s=(v=a.animation_duration_ms)!=null?v:800,r=(H=a.fade_in_duration_ms)!=null?H:600,m=(F=a.scale_animation_intensity)!=null?F:.1,l=(S=a.logo_animation_delay_ms)!=null?S:100,h=(R=a.title_animation_delay_ms)!=null?R:200,p=(L=a.footer_animation_delay_ms)!=null?L:300,y=(C=a.cta_animation_delay_ms)!=null?C:400,{panel:f,logo:u,title:g,subtitle:o,footer:E,ctaButton:A,ctaText:x,ctaHint:d}=e;f.visible=!0,f.element.style.visibility="visible";let c=Date.now(),b=()=>{let ee=Date.now()-c,O=Math.min(ee/r,1),Y=1-Math.pow(1-O,3);f.alpha=Y,f.element.style.opacity=Y.toString();let oe=1+m*(1-Y);f.element.style.transform=`translate(-50%, -50%) scale(${oe})`,O<1?requestAnimationFrame(b):(setTimeout(()=>Da(u,s,t),l),setTimeout(()=>{$a(g,s),setTimeout(()=>Pa(o,s),50)},h),setTimeout(()=>Wa(E,s),p),setTimeout(()=>{za(A,x,s),setTimeout(()=>Ba(d,s),50),n&&n()},y))};b()}function Da(e,t,n){var f,u,g,o,E;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(u=(((f=i==null?void 0:i.gameplay)==null?void 0:f.tuning)||{}).animation_start_scale)!=null?u:1.2,r=Date.now(),m=e.material.opacity,l=(g=e.targetAlpha)!=null?g:1,h=(o=e.baseScaleX)!=null?o:e.scale.x,p=(E=e.baseScaleY)!=null?E:e.scale.y,y=()=>{let A=Date.now()-r,x=Math.min(A/t,1),d=1-Math.pow(1-x,2);e.material.opacity=m+(l-m)*d;let c=s+(1-s)*d;e.scale.set(h*c,p*c,1),x<1&&requestAnimationFrame(y)};y()}function $a(e,t){let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=()=>{let r=Date.now()-n,m=Math.min(r/t,1),l=1-Math.pow(1-m,2);e.element.style.opacity=(i+(1-i)*l).toString(),e.element.style.top=`${a-20*(1-l)}px`,m<1&&requestAnimationFrame(s)};s()}function Pa(e,t){var m;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((m=e.animationStartYOffset)!=null?m:-10),r=()=>{let l=Date.now()-n,h=Math.min(l/t,1),p=1-Math.pow(1-h,2);e.element.style.opacity=(i+(1-i)*p).toString(),e.element.style.top=`${a+(s-a)*p}px`,h<1&&requestAnimationFrame(r)};r()}function Wa(e,t){var r;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=(r=e.targetAlpha)!=null?r:1,s=()=>{let m=Date.now()-n,l=Math.min(m/t,1),h=1-Math.pow(1-l,2);e.element.style.opacity=(i+(a-i)*h).toString(),l<1&&requestAnimationFrame(s)};s()}function za(e,t,n){let i=Date.now(),a=parseFloat(e.element.style.opacity||"0"),s=()=>{let r=Date.now()-i,m=Math.min(r/n,1),l=1-Math.pow(1-m,2);e.element.style.opacity=(a+(1-a)*l).toString(),t.element.style.opacity=(a+(1-a)*l).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-l)})`,m<1&&requestAnimationFrame(s)};s()}function Ba(e,t){var m;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((m=e.animationStartYOffset)!=null?m:5),r=()=>{let l=Date.now()-n,h=Math.min(l/t,1),p=1-Math.pow(1-h,2);e.element.style.opacity=(i+(1-i)*p).toString(),e.element.style.top=`${a+(s-a)*p}px`,h<1&&requestAnimationFrame(r)};r()}function Ei(e,t,n,i){var p,y,f,u;let a=n.objects.get("ui_endgame_hand_1"),s=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},r=(y=s.click_animation_duration_ms)!=null?y:600,m=(f=s.click_delay_ms)!=null?f:2e3,l=(u=s.click_repeat_delay_ms)!=null?u:3e3,h=()=>{var v,H;e.visible=!0,e.material.opacity=1;let g=e.position.x,o=e.position.y,E=(v=s.hand_offset_x)!=null?v:50,A=(H=s.hand_offset_y)!=null?H:50,x=t.element.getBoundingClientRect(),d=E,c=A,b=Date.now(),_=()=>{var Y,oe,Ce;let F=Date.now()-b,S=Math.min(F/r,1),R=S<.5?2*S*S:1-Math.pow(-2*S+2,2)/2;e.position.set(g+(d-g)*R,o+(c-o)*R,0);let L=(oe=(Y=a==null?void 0:a.transform)==null?void 0:Y.scale)!=null?oe:.1875,C=(Ce=s.hand_scale_multiplier)!=null?Ce:2.5,ee=L*C*100,O=ee+ee*.2*Math.sin(S*Math.PI);e.scale.set(O,O,1),S<1?requestAnimationFrame(_):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",i()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(g,o,0),h()},l)},500))};_()};setTimeout(h,m)}var Xe=we(require("three"));function xi(e,t,n){var y,f,u,g;let i=t.objects.get("hand_tutorial_1"),a=((y=i==null?void 0:i.gameplay)==null?void 0:y.tuning)||{},s=(i==null?void 0:i.render)||{},r=(i==null?void 0:i.transform)||{},m=new Xe.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),l=new Xe.Sprite(m);l.position.set(n.x,n.y,0),l.material.opacity=0;let h=(f=a.hand_scale_multiplier)!=null?f:2.5,p=(u=r.scale)!=null?u:.1875;return l.scale.set(p*h*100,p*h*100,1),l.renderOrder=(g=s.z_index)!=null?g:99999,l}function _i(e){var g,o,E,A,x,d,c,b,_;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},a=((g=e.engine.runtime)==null?void 0:g.ui_styles)||{},s=((o=e.engine.runtime)==null?void 0:o.ui)||{},r=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",m=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||a.label_font_size||52,h=(A=n==null?void 0:n.letterSpacing)!=null?A:(E=a.label_letter_spacing)!=null?E:-1,p=(n==null?void 0:n.align)||"center",y=i.tint,f=typeof y=="string"?y:y?`#${y.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",u=document.createElement("div");return u.textContent=r,u.style.cssText=`
120
- font-family: ${G(m)};
119
+ `;let aa=Ue+vt/2+20,sa=d-c-10,oa=Math.min(aa+((kn=At.animation_start_y_offset)!=null?kn:5),sa);ae.style.top=`${oa}px`,ae.style.left="50%";let tt=se(ae);tt.element=ae,tt.animationStartYOffset=(Fn=At.animation_start_y_offset)!=null?Fn:5,A.appendChild(ae);let nt=((Dn=y==null?void 0:y.gameplay)==null?void 0:Dn.tuning)||{},ra=($n=nt.hand_offset_x)!=null?$n:50,la=(Pn=nt.hand_offset_y)!=null?Pn:50,ca=(zn=(Wn=y==null?void 0:y.transform)==null?void 0:Wn.scale)!=null?zn:.1875,da=(Bn=nt.hand_scale_multiplier)!=null?Bn:2.5,pa=new ye.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),be=new ye.Sprite(pa),Ct=ca*da*100;return be.scale.set(Ct,Ct,1),be.position.set(ra,Ue+la,0),be.material.opacity=0,be.visible=!1,{panel:L,logo:I,title:gt,subtitle:Ze,footer:Qe,ctaButton:et,ctaText:Rt,ctaHint:tt,hand:be}}function wi(e,t,n){var _,S,H,F,R,A,L,C;let i=t.objects.get("ui_endgame_1"),a=((_=i==null?void 0:i.gameplay)==null?void 0:_.tuning)||{},s=(S=a.animation_duration_ms)!=null?S:800,r=(H=a.fade_in_duration_ms)!=null?H:600,u=(F=a.scale_animation_intensity)!=null?F:.1,l=(R=a.logo_animation_delay_ms)!=null?R:100,m=(A=a.title_animation_delay_ms)!=null?A:200,p=(L=a.footer_animation_delay_ms)!=null?L:300,y=(C=a.cta_animation_delay_ms)!=null?C:400,{panel:f,logo:h,title:g,subtitle:o,footer:E,ctaButton:T,ctaText:x,ctaHint:d}=e;f.visible=!0,f.element.style.visibility="visible";let c=Date.now(),b=()=>{let ee=Date.now()-c,O=Math.min(ee/r,1),Y=1-Math.pow(1-O,3);f.alpha=Y,f.element.style.opacity=Y.toString();let oe=1+u*(1-Y);f.element.style.transform=`translate(-50%, -50%) scale(${oe})`,O<1?requestAnimationFrame(b):(setTimeout(()=>Da(h,s,t),l),setTimeout(()=>{$a(g,s),setTimeout(()=>Pa(o,s),50)},m),setTimeout(()=>Wa(E,s),p),setTimeout(()=>{za(T,x,s),setTimeout(()=>Ba(d,s),50),n&&n()},y))};b()}function Da(e,t,n){var f,h,g,o,E;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(h=(((f=i==null?void 0:i.gameplay)==null?void 0:f.tuning)||{}).animation_start_scale)!=null?h:1.2,r=Date.now(),u=e.material.opacity,l=(g=e.targetAlpha)!=null?g:1,m=(o=e.baseScaleX)!=null?o:e.scale.x,p=(E=e.baseScaleY)!=null?E:e.scale.y,y=()=>{let T=Date.now()-r,x=Math.min(T/t,1),d=1-Math.pow(1-x,2);e.material.opacity=u+(l-u)*d;let c=s+(1-s)*d;e.scale.set(m*c,p*c,1),x<1&&requestAnimationFrame(y)};y()}function $a(e,t){let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=()=>{let r=Date.now()-n,u=Math.min(r/t,1),l=1-Math.pow(1-u,2);e.element.style.opacity=(i+(1-i)*l).toString(),e.element.style.top=`${a-20*(1-l)}px`,u<1&&requestAnimationFrame(s)};s()}function Pa(e,t){var u;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((u=e.animationStartYOffset)!=null?u:-10),r=()=>{let l=Date.now()-n,m=Math.min(l/t,1),p=1-Math.pow(1-m,2);e.element.style.opacity=(i+(1-i)*p).toString(),e.element.style.top=`${a+(s-a)*p}px`,m<1&&requestAnimationFrame(r)};r()}function Wa(e,t){var r;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=(r=e.targetAlpha)!=null?r:1,s=()=>{let u=Date.now()-n,l=Math.min(u/t,1),m=1-Math.pow(1-l,2);e.element.style.opacity=(i+(a-i)*m).toString(),l<1&&requestAnimationFrame(s)};s()}function za(e,t,n){let i=Date.now(),a=parseFloat(e.element.style.opacity||"0"),s=()=>{let r=Date.now()-i,u=Math.min(r/n,1),l=1-Math.pow(1-u,2);e.element.style.opacity=(a+(1-a)*l).toString(),t.element.style.opacity=(a+(1-a)*l).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-l)})`,u<1&&requestAnimationFrame(s)};s()}function Ba(e,t){var u;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((u=e.animationStartYOffset)!=null?u:5),r=()=>{let l=Date.now()-n,m=Math.min(l/t,1),p=1-Math.pow(1-m,2);e.element.style.opacity=(i+(1-i)*p).toString(),e.element.style.top=`${a+(s-a)*p}px`,m<1&&requestAnimationFrame(r)};r()}function Ei(e,t,n,i){var p,y,f,h;let a=n.objects.get("ui_endgame_hand_1"),s=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},r=(y=s.click_animation_duration_ms)!=null?y:600,u=(f=s.click_delay_ms)!=null?f:2e3,l=(h=s.click_repeat_delay_ms)!=null?h:3e3,m=()=>{var S,H;e.visible=!0,e.material.opacity=1;let g=e.position.x,o=e.position.y,E=(S=s.hand_offset_x)!=null?S:50,T=(H=s.hand_offset_y)!=null?H:50,x=t.element.getBoundingClientRect(),d=E,c=T,b=Date.now(),_=()=>{var Y,oe,Ce;let F=Date.now()-b,R=Math.min(F/r,1),A=R<.5?2*R*R:1-Math.pow(-2*R+2,2)/2;e.position.set(g+(d-g)*A,o+(c-o)*A,0);let L=(oe=(Y=a==null?void 0:a.transform)==null?void 0:Y.scale)!=null?oe:.1875,C=(Ce=s.hand_scale_multiplier)!=null?Ce:2.5,ee=L*C*100,O=ee+ee*.2*Math.sin(R*Math.PI);e.scale.set(O,O,1),R<1?requestAnimationFrame(_):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",i()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(g,o,0),m()},l)},500))};_()};setTimeout(m,u)}var Xe=we(require("three"));function xi(e,t,n){var h,g,o,E,T,x,d;let i=t.objects.get("hand_tutorial_1"),a=((h=i==null?void 0:i.gameplay)==null?void 0:h.tuning)||{},s=(i==null?void 0:i.render)||{},r=(i==null?void 0:i.transform)||{},u=new Xe.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),l=new Xe.Sprite(u),m=r.position||{},p=(g=m==null?void 0:m.z)!=null?g:0;l.position.set(n.x+((o=m==null?void 0:m.x)!=null?o:0),n.y+((E=m==null?void 0:m.y)!=null?E:0),p),l.material.opacity=s.alpha!==void 0&&s.alpha!==null?s.alpha:0,l.visible=s.visible!==void 0&&s.visible!==null?s.visible:!1;let y=(T=a.hand_scale_multiplier)!=null?T:2.5,f=(x=r.scale)!=null?x:.1875;return l.scale.set(f*y*100,f*y*100,1),l.renderOrder=(d=s.z_index)!=null?d:99999,l}function _i(e){var g,o,E,T,x,d,c,b,_;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},a=((g=e.engine.runtime)==null?void 0:g.ui_styles)||{},s=((o=e.engine.runtime)==null?void 0:o.ui)||{},r=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",u=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||a.label_font_size||52,m=(T=n==null?void 0:n.letterSpacing)!=null?T:(E=a.label_letter_spacing)!=null?E:-1,p=(n==null?void 0:n.align)||"center",y=i.tint,f=typeof y=="string"?y:y?`#${y.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",h=document.createElement("div");return h.textContent=r,h.style.cssText=`
120
+ font-family: ${G(u)};
121
121
  font-size: ${l}px;
122
- font-weight: ${j(m)};
122
+ font-weight: ${j(u)};
123
123
  color: ${f};
124
124
  text-align: ${p};
125
- letter-spacing: ${h}px;
125
+ letter-spacing: ${m}px;
126
126
  text-shadow: ${(x=a.label_shadow_distance)!=null?x:2}px ${(d=a.label_shadow_distance)!=null?d:2}px ${(c=a.label_shadow_blur)!=null?c:4}px rgba(0,0,0,${(b=a.label_shadow_alpha)!=null?b:.8});
127
127
  -webkit-text-stroke: ${a.label_stroke||"#8B0000"} 2px;
128
128
  opacity: ${(_=i.alpha)!=null?_:0};
@@ -131,4 +131,4 @@
131
131
  position: absolute;
132
132
  transform: translate(-50%, -50%);
133
133
  white-space: nowrap;
134
- `,u}function Ti(e,t,n,i,a){var l,h,p,y,f,u,g;let s=a.objects.get("hand_tutorial_1"),r=((l=s==null?void 0:s.gameplay)==null?void 0:l.tuning)||{},m=(s==null?void 0:s.transform)||{};if(!i){let o=(h=r.animation_duration)!=null?h:1.5,E=n%o/o,A=E<.5?2*E*E:-1+(4-2*E)*E,x=(p=r.x_offset)!=null?p:0,d=(y=r.y_offset)!=null?y:0,c=(f=r.animation_range)!=null?f:40,b=c*.7,_=c,v=t.x+x+b,H=t.y+d+_,F=v+b,S=H+_;e.position.set(v+(F-v)*A,H+(S-H)*A,0);let R=(u=m.scale)!=null?u:.1875,L=(g=r.hand_scale_multiplier)!=null?g:2.5,C=R*L*100;e.scale.set(C,C,1)}}var ge=we(require("three")),vi=new ge.TextureLoader;async function ht(e,t,n=16777215,i=!1){try{let s=(globalThis.INLINE_ASSETS||{})[e];return await vi.loadAsync(s||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let s=document.createElement("canvas");s.width=64,s.height=64;let r=s.getContext("2d");return r&&(r.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?r.fillRect(0,0,30,60):(r.beginPath(),r.arc(32,32,30,0,Math.PI*2),r.fill(),r.fillRect(27,32,10,40))),new ge.CanvasTexture(s)}}async function Si(e,t,n){var g,o,E,A;let a=(globalThis.INLINE_ASSETS||{})[e]||e,s;try{s=await vi.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(x){let b=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");s=await ht(e,t,parseInt(b,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:x})}if(!s)return[];let r=n.gameplay.character_sheet||{},m=(g=r.cols)!=null?g:3,l=(o=r.rows)!=null?o:2,h=((E=s.image)==null?void 0:E.width)||0,p=((A=s.image)==null?void 0:A.height)||0,y=h/m,f=p/l;if(!Number.isFinite(y)||!Number.isFinite(f)||y<=0||f<=0)return[s];let u=[];for(let x=0;x<l;x++)for(let d=0;d<m;d++){let c=document.createElement("canvas");c.width=y,c.height=f;let b=c.getContext("2d");b&&s.image&&b.drawImage(s.image,d*y,x*f,y,f,0,0,y,f),u.push(new ge.CanvasTexture(c))}return u.length>2&&u.push(...u.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:u.length}),u}function Ri(e,t){var y,f,u,g;let n=t.gameplay.brush||{},i=t.theme.brush_color||"#ffffff",a=(y=n.radius)!=null?y:20,s=(f=n.inner_radius)!=null?f:15,r=(u=n.alpha)!=null?u:.8,m=(g=n.inner_alpha)!=null?g:.3,l=n.inner_color||"#ffffff",h=document.createElement("canvas");h.width=a*2,h.height=a*2;let p=h.getContext("2d");return p&&(p.clearRect(0,0,h.width,h.height),p.beginPath(),p.arc(a,a,a,0,Math.PI*2),p.fillStyle=i,p.globalAlpha=r,p.fill(),p.beginPath(),p.arc(a,a,s,0,Math.PI*2),p.fillStyle=l,p.globalAlpha=m,p.fill()),new ge.CanvasTexture(h)}0&&(module.exports={AspectClass,GameObject,GameObjectManager,Renderer,ResponsiveUISystem,Transform,animateHandClick,animatePanelEntrance,createBrushTexture,createEndGamePanel,createHandTutorial,createThreeBase,createTutorialLabel,getAspectClass,getRegisteredFontIds,loadAsset,loadCharacterFrames,registerFont,resolveFont,resolveFontWeight,updateHandAnimation});
134
+ `,h}function Ti(e,t,n,i,a){var l,m,p,y,f,h,g;let s=a.objects.get("hand_tutorial_1"),r=((l=s==null?void 0:s.gameplay)==null?void 0:l.tuning)||{},u=(s==null?void 0:s.transform)||{};if(!i){let o=(m=r.animation_duration)!=null?m:1.5,E=n%o/o,T=E<.5?2*E*E:-1+(4-2*E)*E,x=(p=r.x_offset)!=null?p:0,d=(y=r.y_offset)!=null?y:0,c=(f=r.animation_range)!=null?f:40,b=c*.7,_=c,S=t.x+x+b,H=t.y+d+_,F=S+b,R=H+_;e.position.set(S+(F-S)*T,H+(R-H)*T,0);let A=(h=u.scale)!=null?h:.1875,L=(g=r.hand_scale_multiplier)!=null?g:2.5,C=A*L*100;e.scale.set(C,C,1)}}var ge=we(require("three")),vi=new ge.TextureLoader;async function ht(e,t,n=16777215,i=!1){try{let s=(globalThis.INLINE_ASSETS||{})[e];return await vi.loadAsync(s||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let s=document.createElement("canvas");s.width=64,s.height=64;let r=s.getContext("2d");return r&&(r.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?r.fillRect(0,0,30,60):(r.beginPath(),r.arc(32,32,30,0,Math.PI*2),r.fill(),r.fillRect(27,32,10,40))),new ge.CanvasTexture(s)}}async function Si(e,t,n){var g,o,E,T;let a=(globalThis.INLINE_ASSETS||{})[e]||e,s;try{s=await vi.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(x){let b=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");s=await ht(e,t,parseInt(b,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:x})}if(!s)return[];let r=n.gameplay.character_sheet||{},u=(g=r.cols)!=null?g:3,l=(o=r.rows)!=null?o:2,m=((E=s.image)==null?void 0:E.width)||0,p=((T=s.image)==null?void 0:T.height)||0,y=m/u,f=p/l;if(!Number.isFinite(y)||!Number.isFinite(f)||y<=0||f<=0)return[s];let h=[];for(let x=0;x<l;x++)for(let d=0;d<u;d++){let c=document.createElement("canvas");c.width=y,c.height=f;let b=c.getContext("2d");b&&s.image&&b.drawImage(s.image,d*y,x*f,y,f,0,0,y,f),h.push(new ge.CanvasTexture(c))}return h.length>2&&h.push(...h.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:h.length}),h}function Ri(e,t){var y,f,h,g;let n=t.gameplay.brush||{},i=t.theme.brush_color||"#ffffff",a=(y=n.radius)!=null?y:20,s=(f=n.inner_radius)!=null?f:15,r=(h=n.alpha)!=null?h:.8,u=(g=n.inner_alpha)!=null?g:.3,l=n.inner_color||"#ffffff",m=document.createElement("canvas");m.width=a*2,m.height=a*2;let p=m.getContext("2d");return p&&(p.clearRect(0,0,m.width,m.height),p.beginPath(),p.arc(a,a,a,0,Math.PI*2),p.fillStyle=i,p.globalAlpha=r,p.fill(),p.beginPath(),p.arc(a,a,s,0,Math.PI*2),p.fillStyle=l,p.globalAlpha=u,p.fill()),new ge.CanvasTexture(m)}0&&(module.exports={AspectClass,GameObject,GameObjectManager,Renderer,ResponsiveUISystem,Transform,animateHandClick,animatePanelEntrance,createBrushTexture,createEndGamePanel,createHandTutorial,createThreeBase,createTutorialLabel,getAspectClass,getRegisteredFontIds,loadAsset,loadCharacterFrames,registerFont,resolveFont,resolveFontWeight,updateHandAnimation});
@@ -1,4 +1,4 @@
1
- import{b as dt}from"../chunk-2XLITEWW.mjs";import*as k from"three";var Oe=(i=>(i[i.PHONE_TALL=0]="PHONE_TALL",i[i.TABLET=1]="TABLET",i[i.LANDSCAPE=2]="LANDSCAPE",i))(Oe||{});function Rt(e,t){let n=e/t;return n<=.62?0:n<=.85?1:2}var nt=class{constructor(t,n){this.root=t,this.stage=n,this.uiFrame=document.createElement("div"),this.uiFrame.style.position="absolute",this.uiFrame.style.top="0",this.uiFrame.style.bottom="0",this.uiFrame.style.left="50%",this.uiFrame.style.transform="translateX(-50%)",this.uiFrame.style.width="100%",this.uiFrame.style.maxWidth="420px",this.uiFrame.style.pointerEvents="none",this.stage.appendChild(this.uiFrame),this.uiContainer=document.createElement("div"),this.uiContainer.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","justify-content:flex-start","gap:12px","pointer-events:none","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),this.uiFrame.appendChild(this.uiContainer),this.updateLayout()}getUIFrame(){return this.uiFrame}getUIContainer(){return this.uiContainer}updateLayout(){let t=this.stage.getBoundingClientRect(),n=Rt(t.width,t.height);n===0?this.uiFrame.style.maxWidth="420px":n===1?this.uiFrame.style.maxWidth="520px":this.uiFrame.style.maxWidth="640px"}getAspectClass(){let t=this.stage.getBoundingClientRect();return Rt(t.width,t.height)}};async function Xn(e,t={}){let n=()=>{let d=e.getBoundingClientRect(),r=Math.floor(d.width),E=Math.floor(d.height);return(r<=0||!isFinite(r)||r!==r)&&(r=e.clientWidth||window.innerWidth||320),(E<=0||!isFinite(E)||E!==E)&&(E=e.clientHeight||window.innerHeight||480),(r<=0||!isFinite(r)||r!==r)&&(r=320),(E<=0||!isFinite(E)||E!==E)&&(E=480),console.log("[THREE-BASE] getSize result:",{width:r,height:E,boundingRect:{width:d.width,height:d.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleWidth:e.style.width,styleHeight:e.style.height,note:"Using boundingRect as primary source (actual rendered size)"}),{width:r,height:E}},i=e.style.width&&!e.style.width.includes("%"),a=e.style.height&&!e.style.height.includes("%");e.style.position||(e.style.position="relative"),e.style.display||(e.style.display="block"),e.style.width=e.style.width||"100%",e.style.height=e.style.height||"100%",e.style.minWidth="100%",e.style.minHeight="100%",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",e.style.margin="0",e.style.padding="0",e.style.border="none";let s=t.background||"linear-gradient(160deg, #0d1020, #0f1c2f)";e.style.setProperty("background",s,"important"),e.style.setProperty("background-size","cover","important"),e.style.setProperty("background-position","center","important"),e.style.setProperty("background-repeat","no-repeat","important");let l=document.createElement("div");l.style.cssText=`
1
+ import{b as dt}from"../chunk-SYQVN25U.mjs";import*as k from"three";var Oe=(s=>(s[s.PHONE_TALL=0]="PHONE_TALL",s[s.TABLET=1]="TABLET",s[s.LANDSCAPE=2]="LANDSCAPE",s))(Oe||{});function Rt(e,t){let n=e/t;return n<=.62?0:n<=.85?1:2}var nt=class{constructor(t,n){this.root=t,this.stage=n,this.uiFrame=document.createElement("div"),this.uiFrame.style.position="absolute",this.uiFrame.style.top="0",this.uiFrame.style.bottom="0",this.uiFrame.style.left="50%",this.uiFrame.style.transform="translateX(-50%)",this.uiFrame.style.width="100%",this.uiFrame.style.maxWidth="420px",this.uiFrame.style.pointerEvents="none",this.stage.appendChild(this.uiFrame),this.uiContainer=document.createElement("div"),this.uiContainer.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","justify-content:flex-start","gap:12px","pointer-events:none","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),this.uiFrame.appendChild(this.uiContainer),this.updateLayout()}getUIFrame(){return this.uiFrame}getUIContainer(){return this.uiContainer}updateLayout(){let t=this.stage.getBoundingClientRect(),n=Rt(t.width,t.height);n===0?this.uiFrame.style.maxWidth="420px":n===1?this.uiFrame.style.maxWidth="520px":this.uiFrame.style.maxWidth="640px"}getAspectClass(){let t=this.stage.getBoundingClientRect();return Rt(t.width,t.height)}};async function Xn(e,t={}){let n=()=>{let d=e.getBoundingClientRect(),r=Math.floor(d.width),E=Math.floor(d.height);return(r<=0||!isFinite(r)||r!==r)&&(r=e.clientWidth||window.innerWidth||320),(E<=0||!isFinite(E)||E!==E)&&(E=e.clientHeight||window.innerHeight||480),(r<=0||!isFinite(r)||r!==r)&&(r=320),(E<=0||!isFinite(E)||E!==E)&&(E=480),console.log("[THREE-BASE] getSize result:",{width:r,height:E,boundingRect:{width:d.width,height:d.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleWidth:e.style.width,styleHeight:e.style.height,note:"Using boundingRect as primary source (actual rendered size)"}),{width:r,height:E}},s=e.style.width&&!e.style.width.includes("%"),a=e.style.height&&!e.style.height.includes("%");e.style.position||(e.style.position="relative"),e.style.display||(e.style.display="block"),e.style.width=e.style.width||"100%",e.style.height=e.style.height||"100%",e.style.minWidth="100%",e.style.minHeight="100%",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",e.style.margin="0",e.style.padding="0",e.style.border="none";let i=t.background||"linear-gradient(160deg, #0d1020, #0f1c2f)";e.style.setProperty("background",i,"important"),e.style.setProperty("background-size","cover","important"),e.style.setProperty("background-position","center","important"),e.style.setProperty("background-repeat","no-repeat","important");let l=document.createElement("div");l.style.cssText=`
2
2
  position: absolute !important;
3
3
  inset: 0 !important;
4
4
  width: 100% !important;
@@ -8,7 +8,7 @@ import{b as dt}from"../chunk-2XLITEWW.mjs";import*as k from"three";var Oe=(i=>(i
8
8
  max-width: 100% !important;
9
9
  max-height: 100% !important;
10
10
  display: block !important;
11
- background: ${s} !important;
11
+ background: ${i} !important;
12
12
  background-size: cover !important;
13
13
  background-position: center !important;
14
14
  background-repeat: no-repeat !important;
@@ -19,16 +19,16 @@ import{b as dt}from"../chunk-2XLITEWW.mjs";import*as k from"three";var Oe=(i=>(i
19
19
  padding: 0 !important;
20
20
  border: none !important;
21
21
  overflow: hidden !important;
22
- `,e.appendChild(l);let p=document.createElement("div");p.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","min-width:100%","min-height:100%","max-width:100%","max-height:100%","pointer-events:auto","box-sizing:border-box","margin:0","padding:0","overflow:hidden"].join(";")),l.appendChild(p);let c=new k.Scene,{width:u,height:h}=n(),g=new k.AmbientLight(16777215,.6);c.add(g);let y=new k.DirectionalLight(16777215,.8);y.position.set(5,5,5),y.castShadow=!1,c.add(y);let m=new k.DirectionalLight(16777215,.3);m.position.set(-5,0,5),c.add(m);let f=new k.PerspectiveCamera(55,u/h,.1,100);f.position.set(0,0,3.2),f.lookAt(0,0,0),f.updateMatrixWorld();let o=new k.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});o.setPixelRatio(window.devicePixelRatio||1),o.setSize(u,h),o.setClearColor(0,0),o.domElement.style.position="absolute",o.domElement.style.top="0",o.domElement.style.left="0",o.domElement.style.right="0",o.domElement.style.bottom="0",o.domElement.style.width="100%",o.domElement.style.height="100%",o.domElement.style.minWidth="100%",o.domElement.style.minHeight="100%",o.domElement.style.maxWidth="100%",o.domElement.style.maxHeight="100%",o.domElement.style.display="block",o.domElement.style.pointerEvents="auto",o.domElement.style.margin="0",o.domElement.style.padding="0",o.domElement.style.boxSizing="border-box",p.appendChild(o.domElement);let b=d=>{var S;let r=e.getBoundingClientRect(),E=window.getComputedStyle(e);console.log("[THREE-BASE] applySize called:",{providedSize:d,rootRect:{width:r.width,height:r.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleSize:{width:e.style.width,height:e.style.height},computedStyle:{width:E.width,height:E.height,transform:E.transform,scale:E.scale},rendererCurrentSize:{width:o.domElement.width,height:o.domElement.height},rendererStyleSize:{width:o.domElement.style.width,height:o.domElement.style.height},stackTrace:(S=new Error().stack)==null?void 0:S.split(`
22
+ `,e.appendChild(l);let m=document.createElement("div");m.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","min-width:100%","min-height:100%","max-width:100%","max-height:100%","pointer-events:auto","box-sizing:border-box","margin:0","padding:0","overflow:hidden"].join(";")),l.appendChild(m);let c=new k.Scene,{width:h,height:p}=n(),g=new k.AmbientLight(16777215,.6);c.add(g);let y=new k.DirectionalLight(16777215,.8);y.position.set(5,5,5),y.castShadow=!1,c.add(y);let u=new k.DirectionalLight(16777215,.3);u.position.set(-5,0,5),c.add(u);let f=new k.PerspectiveCamera(55,h/p,.1,100);f.position.set(0,0,3.2),f.lookAt(0,0,0),f.updateMatrixWorld();let o=new k.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});o.setPixelRatio(window.devicePixelRatio||1),o.setSize(h,p),o.setClearColor(0,0),o.domElement.style.position="absolute",o.domElement.style.top="0",o.domElement.style.left="0",o.domElement.style.right="0",o.domElement.style.bottom="0",o.domElement.style.width="100%",o.domElement.style.height="100%",o.domElement.style.minWidth="100%",o.domElement.style.minHeight="100%",o.domElement.style.maxWidth="100%",o.domElement.style.maxHeight="100%",o.domElement.style.display="block",o.domElement.style.pointerEvents="auto",o.domElement.style.margin="0",o.domElement.style.padding="0",o.domElement.style.boxSizing="border-box",m.appendChild(o.domElement);let b=d=>{var H;let r=e.getBoundingClientRect(),E=window.getComputedStyle(e);console.log("[THREE-BASE] applySize called:",{providedSize:d,rootRect:{width:r.width,height:r.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleSize:{width:e.style.width,height:e.style.height},computedStyle:{width:E.width,height:E.height,transform:E.transform,scale:E.scale},rendererCurrentSize:{width:o.domElement.width,height:o.domElement.height},rendererStyleSize:{width:o.domElement.style.width,height:o.domElement.style.height},stackTrace:(H=new Error().stack)==null?void 0:H.split(`
23
23
  `).slice(1,4).join(`
24
- `)});let x=r.width,w=r.height;if((x<=0||!isFinite(x))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:r.width,clientWidth:e.clientWidth}),x=e.clientWidth||window.innerWidth||320),(w<=0||!isFinite(w))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:r.height,clientHeight:e.clientHeight}),w=e.clientHeight||window.innerHeight||480),typeof(d==null?void 0:d.width)=="number"&&d.width>0){let M=Math.abs(d.width-r.width),v=r.width*.1;M>v?console.warn("[THREE-BASE] Provided width ignored (too different from container):",{provided:d.width,container:r.width,difference:M,tolerance:v,willUse:"container size (boundingRect)"}):(x=d.width,console.log("[THREE-BASE] Using provided width (within tolerance):",{provided:d.width,container:r.width}))}if(typeof(d==null?void 0:d.height)=="number"&&d.height>0){let M=Math.abs(d.height-r.height),v=r.height*.1;M>v?console.warn("[THREE-BASE] Provided height ignored (too different from container):",{provided:d.height,container:r.height,difference:M,tolerance:v,willUse:"container size (boundingRect)"}):(w=d.height,console.log("[THREE-BASE] Using provided height (within tolerance):",{provided:d.height,container:r.height}))}(x<=0||w<=0||!isFinite(x)||!isFinite(w))&&(console.warn("[THREE-BASE] Invalid size in applySize, using fallback",{newWidth:x,newHeight:w,size:d,rootRect:r}),x=r.width||e.clientWidth||320,w=r.height||e.clientHeight||480);let R=Math.floor(x),F=Math.floor(w);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:R,finalHeight:F,aspectRatio:R/F,beforeRendererSize:{width:o.domElement.width,height:o.domElement.height},beforeRendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height}}),o.setSize(R,F),o.setPixelRatio(window.devicePixelRatio||1),f.aspect=R/F,f.updateProjectionMatrix();let _=e.getBoundingClientRect();console.log("[THREE-BASE] applySize after setting:",{rendererSize:{width:o.domElement.width,height:o.domElement.height},rendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height},containerRect:{width:_.width,height:_.height},cameraAspect:f.aspect,matches:{width:Math.abs(o.domElement.width-_.width)<1,height:Math.abs(o.domElement.height-_.height)<1},sizeDifference:{width:o.domElement.width-_.width,height:o.domElement.height-_.height}})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{b()})});let H=!1;dt.on("pause",()=>{H=!0,document.querySelectorAll("audio").forEach(r=>r.pause())}),dt.on("resume",()=>{H=!1,document.querySelectorAll("audio").forEach(r=>{r.currentTime>0&&!r.ended&&r.play().catch(()=>{})})});let T=new nt(e,l);return dt.on("resize",({payload:d})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:d,timestamp:Date.now(),rootRect:e.getBoundingClientRect()}),b({width:d==null?void 0:d.width,height:d==null?void 0:d.height}),T.updateLayout()}),window.addEventListener("resize",()=>{console.log("[THREE-BASE] Window resize event received:",{timestamp:Date.now(),windowSize:{width:window.innerWidth,height:window.innerHeight},rootRect:e.getBoundingClientRect()}),b(),T.updateLayout()}),{scene:c,camera:f,renderer:o,uiSystem:T,applySize:b}}import*as A from"three";var ht=class{constructor(t){var n,i;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(i=t==null?void 0:t.rotation)!=null?i:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToThree(t){let n=t.position.z,i=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,i),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},pt=class{constructor(t){var n,i,a,s;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(i=t==null?void 0:t.alpha)!=null?i:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(s=t==null?void 0:t.tint)!=null?s:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof A.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof A.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof A.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof A.Mesh&&t.material){let n=typeof this.tint=="string"?new A.Color(this.tint):new A.Color(this.tint);Array.isArray(t.material)?t.material.forEach(i=>{(i instanceof A.MeshBasicMaterial||i instanceof A.MeshStandardMaterial)&&i.color.copy(n)}):(t.material instanceof A.MeshBasicMaterial||t.material instanceof A.MeshStandardMaterial)&&t.material.color.copy(n)}}},mt=class{constructor(t,n,i,a){this.instanceId=t,this.objectConfig=n,this.threeObject=i,this._config=a,this.transform=new ht(a.transform),this.renderer=new pt(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToThree(this.threeObject)}},vt=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let i=this.config.objects.get(t);if(!i)throw new Error(`Object config not found: ${t}`);let a=new mt(t,i.object_config||t,n,i);return this.objects.set(t,a),a}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,i]of this.objects.entries()){let a=t.objects.get(n);a&&i.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var ut={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function X(e){let t=ut[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var n;let t=ut[e];return t&&(n=t.weight)!=null?n:"400"}function qn(e,t){ut[e]=t}function Vn(){return Object.keys(ut)}import*as U from"three";function j(e){return{element:e,get alpha(){return parseFloat(e.style.opacity||"1")},set alpha(t){e.style.opacity=t.toString()},get visible(){return e.style.display!=="none"},set visible(t){e.style.display=t?"":"none"},position:{set(t,n){e.style.left=`${t}px`,e.style.top=`${n}px`},get x(){return parseFloat(e.style.left||"0")},get y(){return parseFloat(e.style.top||"0")}},scale:{set(t,n){e.style.transform=`scale(${t})`},get x(){let t=e.style.transform.match(/scale\(([^)]+)\)/);return t?parseFloat(t[1]):1}}}}function Zn(e,t,n,i){var Xt,qt,Vt,Zt,Jt,Kt,Qt,jt,It,Ot,Ut,te,ee,ne,ae,ie,se,oe,re,le,ce,de,he,pe,me,ue,ye,ge,fe,Ee,be,Te,xe,we,_e,Se,He,Re,ve,Ce,Me,Ae,Fe,$e,Le,We,Be,De,ke,ze,Pe,Ye,Ne,Ge,Xe,qe,Ve,Ze,Je,Ke,Qe,je,Ie;let a=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),l=e.objects.get("ui_endgame_title_1"),p=e.objects.get("ui_endgame_subtitle_1"),c=e.objects.get("ui_endgame_footer_1"),u=e.objects.get("ui_endgame_cta_1"),h=e.objects.get("ui_endgame_cta_hint_1"),g=e.objects.get("ui_endgame_hand_1"),y=e.engine.runtime||{},m=((Xt=a==null?void 0:a.gameplay)==null?void 0:Xt.tuning)||{},f=(a==null?void 0:a.render)||{},o=i.getBoundingClientRect(),b=o.width>0?o.width*.9:320,H=o.height>0?o.height*.85:400,T=Math.min((qt=m.panel_width)!=null?qt:320,b),d=Math.min((Vt=m.panel_height)!=null?Vt:400,H),r=(Zt=m.panel_padding)!=null?Zt:32,E=(Jt=m.panel_radius)!=null?Jt:24,x=f.background_color||m.panel_bg_color||"#1a0a0a",w=f.background_alpha!==void 0&&f.background_alpha!==null?f.background_alpha:(Kt=m.panel_bg_alpha)!=null?Kt:.98,R=f.border_color||m.panel_border_color||"#ffffff",F=(Qt=m.panel_border_width)!=null?Qt:2,_=(jt=m.panel_border_alpha)!=null?jt:.3,S=document.createElement("div");S.style.cssText=`
24
+ `)});let x=r.width,_=r.height;if((x<=0||!isFinite(x))&&(console.warn("[THREE-BASE] Invalid boundingRect.width, using clientWidth fallback",{boundingRectWidth:r.width,clientWidth:e.clientWidth}),x=e.clientWidth||window.innerWidth||320),(_<=0||!isFinite(_))&&(console.warn("[THREE-BASE] Invalid boundingRect.height, using clientHeight fallback",{boundingRectHeight:r.height,clientHeight:e.clientHeight}),_=e.clientHeight||window.innerHeight||480),typeof(d==null?void 0:d.width)=="number"&&d.width>0){let M=Math.abs(d.width-r.width),v=r.width*.1;M>v?console.warn("[THREE-BASE] Provided width ignored (too different from container):",{provided:d.width,container:r.width,difference:M,tolerance:v,willUse:"container size (boundingRect)"}):(x=d.width,console.log("[THREE-BASE] Using provided width (within tolerance):",{provided:d.width,container:r.width}))}if(typeof(d==null?void 0:d.height)=="number"&&d.height>0){let M=Math.abs(d.height-r.height),v=r.height*.1;M>v?console.warn("[THREE-BASE] Provided height ignored (too different from container):",{provided:d.height,container:r.height,difference:M,tolerance:v,willUse:"container size (boundingRect)"}):(_=d.height,console.log("[THREE-BASE] Using provided height (within tolerance):",{provided:d.height,container:r.height}))}(x<=0||_<=0||!isFinite(x)||!isFinite(_))&&(console.warn("[THREE-BASE] Invalid size in applySize, using fallback",{newWidth:x,newHeight:_,size:d,rootRect:r}),x=r.width||e.clientWidth||320,_=r.height||e.clientHeight||480);let R=Math.floor(x),F=Math.floor(_);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:R,finalHeight:F,aspectRatio:R/F,beforeRendererSize:{width:o.domElement.width,height:o.domElement.height},beforeRendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height}}),o.setSize(R,F),o.setPixelRatio(window.devicePixelRatio||1),f.aspect=R/F,f.updateProjectionMatrix();let S=e.getBoundingClientRect();console.log("[THREE-BASE] applySize after setting:",{rendererSize:{width:o.domElement.width,height:o.domElement.height},rendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height},containerRect:{width:S.width,height:S.height},cameraAspect:f.aspect,matches:{width:Math.abs(o.domElement.width-S.width)<1,height:Math.abs(o.domElement.height-S.height)<1},sizeDifference:{width:o.domElement.width-S.width,height:o.domElement.height-S.height}})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{b()})});let w=!1;dt.on("pause",()=>{w=!0,document.querySelectorAll("audio").forEach(r=>r.pause())}),dt.on("resume",()=>{w=!1,document.querySelectorAll("audio").forEach(r=>{r.currentTime>0&&!r.ended&&r.play().catch(()=>{})})});let T=new nt(e,l);return dt.on("resize",({payload:d})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:d,timestamp:Date.now(),rootRect:e.getBoundingClientRect()}),b({width:d==null?void 0:d.width,height:d==null?void 0:d.height}),T.updateLayout()}),window.addEventListener("resize",()=>{console.log("[THREE-BASE] Window resize event received:",{timestamp:Date.now(),windowSize:{width:window.innerWidth,height:window.innerHeight},rootRect:e.getBoundingClientRect()}),b(),T.updateLayout()}),{scene:c,camera:f,renderer:o,uiSystem:T,applySize:b}}import*as A from"three";var ht=class{constructor(t){var n,s;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(s=t==null?void 0:t.rotation)!=null?s:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToThree(t){let n=t.position.z,s=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,s),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},pt=class{constructor(t){var n,s,a,i;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(s=t==null?void 0:t.alpha)!=null?s:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(i=t==null?void 0:t.tint)!=null?i:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof A.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof A.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof A.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof A.Mesh&&t.material){let n=typeof this.tint=="string"?new A.Color(this.tint):new A.Color(this.tint);Array.isArray(t.material)?t.material.forEach(s=>{(s instanceof A.MeshBasicMaterial||s instanceof A.MeshStandardMaterial)&&s.color.copy(n)}):(t.material instanceof A.MeshBasicMaterial||t.material instanceof A.MeshStandardMaterial)&&t.material.color.copy(n)}}},mt=class{constructor(t,n,s,a){this.instanceId=t,this.objectConfig=n,this.threeObject=s,this._config=a,this.transform=new ht(a.transform),this.renderer=new pt(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToThree(this.threeObject)}},vt=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let s=this.config.objects.get(t);if(!s)throw new Error(`Object config not found: ${t}`);let a=new mt(t,s.object_config||t,n,s);return this.objects.set(t,a),a}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,s]of this.objects.entries()){let a=t.objects.get(n);a&&s.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var ut={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function X(e){let t=ut[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var n;let t=ut[e];return t&&(n=t.weight)!=null?n:"400"}function qn(e,t){ut[e]=t}function Zn(){return Object.keys(ut)}import*as U from"three";function j(e){return{element:e,get alpha(){return parseFloat(e.style.opacity||"1")},set alpha(t){e.style.opacity=t.toString()},get visible(){return e.style.display!=="none"},set visible(t){e.style.display=t?"":"none"},position:{set(t,n){e.style.left=`${t}px`,e.style.top=`${n}px`},get x(){return parseFloat(e.style.left||"0")},get y(){return parseFloat(e.style.top||"0")}},scale:{set(t,n){e.style.transform=`scale(${t})`},get x(){let t=e.style.transform.match(/scale\(([^)]+)\)/);return t?parseFloat(t[1]):1}}}}function Vn(e,t,n,s){var Xt,qt,Zt,Vt,Jt,Kt,Qt,jt,It,Ot,Ut,te,ee,ne,ae,ie,se,oe,re,le,ce,de,he,pe,me,ue,ye,ge,fe,Ee,be,Te,xe,we,_e,Se,He,Re,ve,Ce,Me,Ae,Fe,$e,Le,We,Be,De,ke,ze,Pe,Ye,Ne,Ge,Xe,qe,Ze,Ve,Je,Ke,Qe,je,Ie;let a=e.objects.get("ui_endgame_1"),i=e.objects.get("ui_endgame_logo_1"),l=e.objects.get("ui_endgame_title_1"),m=e.objects.get("ui_endgame_subtitle_1"),c=e.objects.get("ui_endgame_footer_1"),h=e.objects.get("ui_endgame_cta_1"),p=e.objects.get("ui_endgame_cta_hint_1"),g=e.objects.get("ui_endgame_hand_1"),y=e.engine.runtime||{},u=((Xt=a==null?void 0:a.gameplay)==null?void 0:Xt.tuning)||{},f=(a==null?void 0:a.render)||{},o=s.getBoundingClientRect(),b=o.width>0?o.width*.9:320,w=o.height>0?o.height*.85:400,T=Math.min((qt=u.panel_width)!=null?qt:320,b),d=Math.min((Zt=u.panel_height)!=null?Zt:400,w),r=(Vt=u.panel_padding)!=null?Vt:32,E=(Jt=u.panel_radius)!=null?Jt:24,x=f.background_color||u.panel_bg_color||"#1a0a0a",_=f.background_alpha!==void 0&&f.background_alpha!==null?f.background_alpha:(Kt=u.panel_bg_alpha)!=null?Kt:.98,R=f.border_color||u.panel_border_color||"#ffffff",F=(Qt=u.panel_border_width)!=null?Qt:2,S=(jt=u.panel_border_alpha)!=null?jt:.3,H=document.createElement("div");H.style.cssText=`
25
25
  position: absolute;
26
26
  width: ${T}px;
27
27
  height: ${d}px;
28
28
  background: ${x};
29
- opacity: ${w};
29
+ opacity: ${_};
30
30
  border: ${F}px solid ${R};
31
- border-opacity: ${_};
31
+ border-opacity: ${S};
32
32
  border-radius: ${E}px;
33
33
  display: block;
34
34
  transform: translate(-50%, -50%);
@@ -40,7 +40,7 @@ import{b as dt}from"../chunk-2XLITEWW.mjs";import*as k from"three";var Oe=(i=>(i
40
40
  z-index: 1000;
41
41
  box-sizing: border-box;
42
42
  padding: ${r}px;
43
- `,i.appendChild(S);let M=j(S);M.element=S;let v=((It=s==null?void 0:s.gameplay)==null?void 0:It.tuning)||{},V=(s==null?void 0:s.transform)||{},D=(Ot=v.logo_size)!=null?Ot:56,z=(Ut=V.scale)!=null?Ut:1,I=(ee=(te=V.offset)==null?void 0:te.y)!=null?ee:-130,at=(ne=v.logo_alpha)!=null?ne:1,en=new U.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),P=new U.Sprite(en);P.position.set(0,I,0),P.material.opacity=0;let it=0,st=0;if(n&&(it=((ae=n.image)==null?void 0:ae.width)||100,st=((ie=n.image)==null?void 0:ie.height)||100),it>0&&st>0){let O=it/st,St,Ht;O>1?(St=D,Ht=D/O):(Ht=D,St=D*O);let Nn=St/it*z,Gn=Ht/st*z;P.scale.set(Nn,Gn,1)}else{let O=D/100*z;P.scale.set(O,O,1)}P.targetAlpha=at,P.baseScaleX=P.scale.x,P.baseScaleY=P.scale.y;let $=l==null?void 0:l.ui,Y=((se=l==null?void 0:l.gameplay)==null?void 0:se.tuning)||{},nn=($==null?void 0:$.text)||"MISSION ACCOMPLISHED",Ct=($==null?void 0:$.font)||"brand.heading",gt=($==null?void 0:$.fontSize)||24,an=(oe=$==null?void 0:$.letterSpacing)!=null?oe:1,ot=(re=l==null?void 0:l.render)==null?void 0:re.tint,sn=typeof ot=="string"?ot:ot?`#${ot.toString(16).padStart(6,"0")}`:"#00FF88",on=T-r*2-30,rn=Y.font_weight_override?Y.font_weight_override:q(Ct),Z=document.createElement("div");Z.textContent=nn,Z.style.cssText=`
43
+ `,s.appendChild(H);let M=j(H);M.element=H;let v=((It=i==null?void 0:i.gameplay)==null?void 0:It.tuning)||{},Z=(i==null?void 0:i.transform)||{},D=(Ot=v.logo_size)!=null?Ot:56,z=(Ut=Z.scale)!=null?Ut:1,I=(ee=(te=Z.offset)==null?void 0:te.y)!=null?ee:-130,at=(ne=v.logo_alpha)!=null?ne:1,en=new U.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),P=new U.Sprite(en);P.position.set(0,I,0),P.material.opacity=0;let it=0,st=0;if(n&&(it=((ae=n.image)==null?void 0:ae.width)||100,st=((ie=n.image)==null?void 0:ie.height)||100),it>0&&st>0){let O=it/st,St,Ht;O>1?(St=D,Ht=D/O):(Ht=D,St=D*O);let Nn=St/it*z,Gn=Ht/st*z;P.scale.set(Nn,Gn,1)}else{let O=D/100*z;P.scale.set(O,O,1)}P.targetAlpha=at,P.baseScaleX=P.scale.x,P.baseScaleY=P.scale.y;let $=l==null?void 0:l.ui,Y=((se=l==null?void 0:l.gameplay)==null?void 0:se.tuning)||{},nn=($==null?void 0:$.text)||"MISSION ACCOMPLISHED",Ct=($==null?void 0:$.font)||"brand.heading",gt=($==null?void 0:$.fontSize)||24,an=(oe=$==null?void 0:$.letterSpacing)!=null?oe:1,ot=(re=l==null?void 0:l.render)==null?void 0:re.tint,sn=typeof ot=="string"?ot:ot?`#${ot.toString(16).padStart(6,"0")}`:"#00FF88",on=T-r*2-30,rn=Y.font_weight_override?Y.font_weight_override:q(Ct),V=document.createElement("div");V.textContent=nn,V.style.cssText=`
44
44
  font-family: ${X(Ct)};
45
45
  font-size: ${gt}px;
46
46
  font-weight: ${rn};
@@ -54,7 +54,7 @@ import{b as dt}from"../chunk-2XLITEWW.mjs";import*as k from"three";var Oe=(i=>(i
54
54
  transform: translate(-50%, -50%);
55
55
  white-space: nowrap;
56
56
  max-width: ${on}px;
57
- `;let Mt=r+30,ln=((me=m.title_offset_y)!=null?me:Mt+gt/2)+((ue=Y.animation_start_y_offset)!=null?ue:-20);Z.style.top=`${ln}px`,Z.style.left="50%";let At=j(Z);At.element=Z,S.appendChild(Z);let L=p==null?void 0:p.ui,Ft=((ye=p==null?void 0:p.gameplay)==null?void 0:ye.tuning)||{},cn=(L==null?void 0:L.text)||"RESCUE COMPLETE",$t=(L==null?void 0:L.font)||"brand.body",ft=(L==null?void 0:L.fontSize)||11,dn=(ge=L==null?void 0:L.letterSpacing)!=null?ge:.5,rt=(fe=p==null?void 0:p.render)==null?void 0:fe.tint,hn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#B0B0B0",J=document.createElement("div");J.textContent=cn,J.style.cssText=`
57
+ `;let Mt=r+30,ln=((me=u.title_offset_y)!=null?me:Mt+gt/2)+((ue=Y.animation_start_y_offset)!=null?ue:-20);V.style.top=`${ln}px`,V.style.left="50%";let At=j(V);At.element=V,H.appendChild(V);let L=m==null?void 0:m.ui,Ft=((ye=m==null?void 0:m.gameplay)==null?void 0:ye.tuning)||{},cn=(L==null?void 0:L.text)||"RESCUE COMPLETE",$t=(L==null?void 0:L.font)||"brand.body",ft=(L==null?void 0:L.fontSize)||11,dn=(ge=L==null?void 0:L.letterSpacing)!=null?ge:.5,rt=(fe=m==null?void 0:m.render)==null?void 0:fe.tint,hn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#B0B0B0",J=document.createElement("div");J.textContent=cn,J.style.cssText=`
58
58
  font-family: ${X($t)};
59
59
  font-size: ${ft}px;
60
60
  font-weight: ${q($t)};
@@ -65,7 +65,7 @@ import{b as dt}from"../chunk-2XLITEWW.mjs";import*as k from"three";var Oe=(i=>(i
65
65
  position: absolute;
66
66
  transform: translate(-50%, -50%);
67
67
  white-space: nowrap;
68
- `;let Lt=Mt+gt+15,pn=((Ee=m.subtitle_offset_y)!=null?Ee:Lt+ft/2)+((be=Ft.animation_start_y_offset)!=null?be:-10);J.style.top=`${pn}px`,J.style.left="50%";let Et=j(J);Et.element=J,Et.animationStartYOffset=(Te=Ft.animation_start_y_offset)!=null?Te:-10,S.appendChild(J);let N=c==null?void 0:c.ui,Wt=((xe=c==null?void 0:c.gameplay)==null?void 0:xe.tuning)||{},mn=(N==null?void 0:N.text)||((we=y.ui)==null?void 0:we.cta_hint)||"Continue the adventure!",Bt=(N==null?void 0:N.font)||"brand.body",Dt=(N==null?void 0:N.fontSize)||16,lt=(_e=c==null?void 0:c.render)==null?void 0:_e.tint,un=typeof lt=="string"?lt:lt?`#${lt.toString(16).padStart(6,"0")}`:"#FFFFFF",yn=(Se=Wt.max_width)!=null?Se:T-r*2,gn=(He=Wt.line_height)!=null?He:1.4,K=document.createElement("div");K.textContent=mn,K.style.cssText=`
68
+ `;let Lt=Mt+gt+15,pn=((Ee=u.subtitle_offset_y)!=null?Ee:Lt+ft/2)+((be=Ft.animation_start_y_offset)!=null?be:-10);J.style.top=`${pn}px`,J.style.left="50%";let Et=j(J);Et.element=J,Et.animationStartYOffset=(Te=Ft.animation_start_y_offset)!=null?Te:-10,H.appendChild(J);let N=c==null?void 0:c.ui,Wt=((xe=c==null?void 0:c.gameplay)==null?void 0:xe.tuning)||{},mn=(N==null?void 0:N.text)||((we=y.ui)==null?void 0:we.cta_hint)||"Continue the adventure!",Bt=(N==null?void 0:N.font)||"brand.body",Dt=(N==null?void 0:N.fontSize)||16,lt=(_e=c==null?void 0:c.render)==null?void 0:_e.tint,un=typeof lt=="string"?lt:lt?`#${lt.toString(16).padStart(6,"0")}`:"#FFFFFF",yn=(Se=Wt.max_width)!=null?Se:T-r*2,gn=(He=Wt.line_height)!=null?He:1.4,K=document.createElement("div");K.textContent=mn,K.style.cssText=`
69
69
  font-family: ${X(Bt)};
70
70
  font-size: ${Dt}px;
71
71
  font-weight: ${q(Bt)};
@@ -77,7 +77,7 @@ import{b as dt}from"../chunk-2XLITEWW.mjs";import*as k from"three";var Oe=(i=>(i
77
77
  max-width: ${yn}px;
78
78
  line-height: ${gn};
79
79
  word-wrap: break-word;
80
- `;let fn=Lt+ft+30,En=(Re=m.footer_offset_y)!=null?Re:fn+Dt/2;K.style.top=`${En}px`,K.style.left="50%";let bt=j(K);bt.element=K;let bn=((ve=c==null?void 0:c.render)==null?void 0:ve.alpha)!==void 0&&((Ce=c==null?void 0:c.render)==null?void 0:Ce.alpha)!==null?c.render.alpha:1;bt.targetAlpha=bn,S.appendChild(K);let G=((Me=u==null?void 0:u.gameplay)==null?void 0:Me.tuning)||{},W=u==null?void 0:u.ui,Tn=(Ae=G.button_width)!=null?Ae:260,kt=(Fe=G.button_height)!=null?Fe:56,xn=($e=G.button_radius)!=null?$e:16,wn=G.button_bg_color||((Le=y.theme)==null?void 0:Le.cta_background)||"#ffb43b",_n=(We=G.button_bg_alpha)!=null?We:1,Sn=G.button_border_color||"#ffffff",Hn=(Be=G.button_border_width)!=null?Be:2,la=(De=G.button_border_alpha)!=null?De:.2,Tt=(ke=m.cta_offset_y)!=null?ke:d*.7,C=document.createElement("button");C.style.cssText=`
80
+ `;let fn=Lt+ft+30,En=(Re=u.footer_offset_y)!=null?Re:fn+Dt/2;K.style.top=`${En}px`,K.style.left="50%";let bt=j(K);bt.element=K;let bn=((ve=c==null?void 0:c.render)==null?void 0:ve.alpha)!==void 0&&((Ce=c==null?void 0:c.render)==null?void 0:Ce.alpha)!==null?c.render.alpha:1;bt.targetAlpha=bn,H.appendChild(K);let G=((Me=h==null?void 0:h.gameplay)==null?void 0:Me.tuning)||{},W=h==null?void 0:h.ui,Tn=(Ae=G.button_width)!=null?Ae:260,kt=(Fe=G.button_height)!=null?Fe:56,xn=($e=G.button_radius)!=null?$e:16,wn=G.button_bg_color||((Le=y.theme)==null?void 0:Le.cta_background)||"#ffb43b",_n=(We=G.button_bg_alpha)!=null?We:1,Sn=G.button_border_color||"#ffffff",Hn=(Be=G.button_border_width)!=null?Be:2,la=(De=G.button_border_alpha)!=null?De:.2,Tt=(ke=u.cta_offset_y)!=null?ke:d*.7,C=document.createElement("button");C.style.cssText=`
81
81
  width: ${Tn}px;
82
82
  height: ${kt}px;
83
83
  background: ${wn};
@@ -89,7 +89,7 @@ import{b as dt}from"../chunk-2XLITEWW.mjs";import*as k from"three";var Oe=(i=>(i
89
89
  position: absolute;
90
90
  transform: translate(-50%, -50%);
91
91
  box-shadow: inset 0 0 1px rgba(0,0,0,0.15);
92
- `,C.style.top=`${Tt}px`,C.style.left="50%";let xt=j(C);xt.element=C,xt.addEventListener=C.addEventListener.bind(C),S.appendChild(C);let Rn=(W==null?void 0:W.text)||((ze=y.ui)==null?void 0:ze.cta_label_end)||"DOWNLOAD",zt=(W==null?void 0:W.font)||"brand.heading",vn=(W==null?void 0:W.fontSize)||20,Cn=G.button_text_color||((Pe=y.theme)==null?void 0:Pe.cta_text)||"#1a0a0a";C.textContent=Rn,C.style.fontFamily=X(zt),C.style.fontSize=`${vn}px`,C.style.fontWeight=String(q(zt)),C.style.color=Cn,C.style.letterSpacing=`${(Ye=W==null?void 0:W.letterSpacing)!=null?Ye:1}px`;let Pt=j(C);Pt.element=C;let B=h==null?void 0:h.ui,Yt=((Ne=h==null?void 0:h.gameplay)==null?void 0:Ne.tuning)||{},Mn=(B==null?void 0:B.text)||"Play the full game",Nt=(B==null?void 0:B.font)||"brand.body",An=(B==null?void 0:B.fontSize)||11,Fn=(Ge=B==null?void 0:B.letterSpacing)!=null?Ge:0,ct=(Xe=h==null?void 0:h.render)==null?void 0:Xe.tint,$n=typeof ct=="string"?ct:ct?`#${ct.toString(16).padStart(6,"0")}`:"#CCCCCC",Q=document.createElement("div");Q.textContent=Mn,Q.style.cssText=`
92
+ `,C.style.top=`${Tt}px`,C.style.left="50%";let xt=j(C);xt.element=C,xt.addEventListener=C.addEventListener.bind(C),H.appendChild(C);let Rn=(W==null?void 0:W.text)||((ze=y.ui)==null?void 0:ze.cta_label_end)||"DOWNLOAD",zt=(W==null?void 0:W.font)||"brand.heading",vn=(W==null?void 0:W.fontSize)||20,Cn=G.button_text_color||((Pe=y.theme)==null?void 0:Pe.cta_text)||"#1a0a0a";C.textContent=Rn,C.style.fontFamily=X(zt),C.style.fontSize=`${vn}px`,C.style.fontWeight=String(q(zt)),C.style.color=Cn,C.style.letterSpacing=`${(Ye=W==null?void 0:W.letterSpacing)!=null?Ye:1}px`;let Pt=j(C);Pt.element=C;let B=p==null?void 0:p.ui,Yt=((Ne=p==null?void 0:p.gameplay)==null?void 0:Ne.tuning)||{},Mn=(B==null?void 0:B.text)||"Play the full game",Nt=(B==null?void 0:B.font)||"brand.body",An=(B==null?void 0:B.fontSize)||11,Fn=(Ge=B==null?void 0:B.letterSpacing)!=null?Ge:0,ct=(Xe=p==null?void 0:p.render)==null?void 0:Xe.tint,$n=typeof ct=="string"?ct:ct?`#${ct.toString(16).padStart(6,"0")}`:"#CCCCCC",Q=document.createElement("div");Q.textContent=Mn,Q.style.cssText=`
93
93
  font-family: ${X(Nt)};
94
94
  font-size: ${An}px;
95
95
  font-weight: ${q(Nt)};
@@ -100,19 +100,19 @@ import{b as dt}from"../chunk-2XLITEWW.mjs";import*as k from"three";var Oe=(i=>(i
100
100
  position: absolute;
101
101
  transform: translate(-50%, -50%);
102
102
  white-space: nowrap;
103
- `;let Ln=Tt+kt/2+20,Wn=d-r-10,Bn=Math.min(Ln+((qe=Yt.animation_start_y_offset)!=null?qe:5),Wn);Q.style.top=`${Bn}px`,Q.style.left="50%";let wt=j(Q);wt.element=Q,wt.animationStartYOffset=(Ve=Yt.animation_start_y_offset)!=null?Ve:5,S.appendChild(Q);let _t=((Ze=g==null?void 0:g.gameplay)==null?void 0:Ze.tuning)||{},Dn=(Je=_t.hand_offset_x)!=null?Je:50,kn=(Ke=_t.hand_offset_y)!=null?Ke:50,zn=(je=(Qe=g==null?void 0:g.transform)==null?void 0:Qe.scale)!=null?je:.1875,Pn=(Ie=_t.hand_scale_multiplier)!=null?Ie:2.5,Yn=new U.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),et=new U.Sprite(Yn),Gt=zn*Pn*100;return et.scale.set(Gt,Gt,1),et.position.set(Dn,Tt+kn,0),et.material.opacity=0,et.visible=!1,{panel:M,logo:P,title:At,subtitle:Et,footer:bt,ctaButton:xt,ctaText:Pt,ctaHint:wt,hand:et}}function Jn(e,t,n){var x,w,R,F,_,S,M,v;let i=t.objects.get("ui_endgame_1"),a=((x=i==null?void 0:i.gameplay)==null?void 0:x.tuning)||{},s=(w=a.animation_duration_ms)!=null?w:800,l=(R=a.fade_in_duration_ms)!=null?R:600,p=(F=a.scale_animation_intensity)!=null?F:.1,c=(_=a.logo_animation_delay_ms)!=null?_:100,u=(S=a.title_animation_delay_ms)!=null?S:200,h=(M=a.footer_animation_delay_ms)!=null?M:300,g=(v=a.cta_animation_delay_ms)!=null?v:400,{panel:y,logo:m,title:f,subtitle:o,footer:b,ctaButton:H,ctaText:T,ctaHint:d}=e;y.visible=!0,y.element.style.visibility="visible";let r=Date.now(),E=()=>{let V=Date.now()-r,D=Math.min(V/l,1),z=1-Math.pow(1-D,3);y.alpha=z,y.element.style.opacity=z.toString();let I=1+p*(1-z);y.element.style.transform=`translate(-50%, -50%) scale(${I})`,D<1?requestAnimationFrame(E):(setTimeout(()=>Kn(m,s,t),c),setTimeout(()=>{Qn(f,s),setTimeout(()=>jn(o,s),50)},u),setTimeout(()=>In(b,s),h),setTimeout(()=>{On(H,T,s),setTimeout(()=>Un(d,s),50),n&&n()},g))};E()}function Kn(e,t,n){var y,m,f,o,b;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(m=(((y=i==null?void 0:i.gameplay)==null?void 0:y.tuning)||{}).animation_start_scale)!=null?m:1.2,l=Date.now(),p=e.material.opacity,c=(f=e.targetAlpha)!=null?f:1,u=(o=e.baseScaleX)!=null?o:e.scale.x,h=(b=e.baseScaleY)!=null?b:e.scale.y,g=()=>{let H=Date.now()-l,T=Math.min(H/t,1),d=1-Math.pow(1-T,2);e.material.opacity=p+(c-p)*d;let r=s+(1-s)*d;e.scale.set(u*r,h*r,1),T<1&&requestAnimationFrame(g)};g()}function Qn(e,t){let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=()=>{let l=Date.now()-n,p=Math.min(l/t,1),c=1-Math.pow(1-p,2);e.element.style.opacity=(i+(1-i)*c).toString(),e.element.style.top=`${a-20*(1-c)}px`,p<1&&requestAnimationFrame(s)};s()}function jn(e,t){var p;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((p=e.animationStartYOffset)!=null?p:-10),l=()=>{let c=Date.now()-n,u=Math.min(c/t,1),h=1-Math.pow(1-u,2);e.element.style.opacity=(i+(1-i)*h).toString(),e.element.style.top=`${a+(s-a)*h}px`,u<1&&requestAnimationFrame(l)};l()}function In(e,t){var l;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=(l=e.targetAlpha)!=null?l:1,s=()=>{let p=Date.now()-n,c=Math.min(p/t,1),u=1-Math.pow(1-c,2);e.element.style.opacity=(i+(a-i)*u).toString(),c<1&&requestAnimationFrame(s)};s()}function On(e,t,n){let i=Date.now(),a=parseFloat(e.element.style.opacity||"0"),s=()=>{let l=Date.now()-i,p=Math.min(l/n,1),c=1-Math.pow(1-p,2);e.element.style.opacity=(a+(1-a)*c).toString(),t.element.style.opacity=(a+(1-a)*c).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-c)})`,p<1&&requestAnimationFrame(s)};s()}function Un(e,t){var p;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((p=e.animationStartYOffset)!=null?p:5),l=()=>{let c=Date.now()-n,u=Math.min(c/t,1),h=1-Math.pow(1-u,2);e.element.style.opacity=(i+(1-i)*h).toString(),e.element.style.top=`${a+(s-a)*h}px`,u<1&&requestAnimationFrame(l)};l()}function ta(e,t,n,i){var h,g,y,m;let a=n.objects.get("ui_endgame_hand_1"),s=((h=a==null?void 0:a.gameplay)==null?void 0:h.tuning)||{},l=(g=s.click_animation_duration_ms)!=null?g:600,p=(y=s.click_delay_ms)!=null?y:2e3,c=(m=s.click_repeat_delay_ms)!=null?m:3e3,u=()=>{var w,R;e.visible=!0,e.material.opacity=1;let f=e.position.x,o=e.position.y,b=(w=s.hand_offset_x)!=null?w:50,H=(R=s.hand_offset_y)!=null?R:50,T=t.element.getBoundingClientRect(),d=b,r=H,E=Date.now(),x=()=>{var z,I,at;let F=Date.now()-E,_=Math.min(F/l,1),S=_<.5?2*_*_:1-Math.pow(-2*_+2,2)/2;e.position.set(f+(d-f)*S,o+(r-o)*S,0);let M=(I=(z=a==null?void 0:a.transform)==null?void 0:z.scale)!=null?I:.1875,v=(at=s.hand_scale_multiplier)!=null?at:2.5,V=M*v*100,D=V+V*.2*Math.sin(_*Math.PI);e.scale.set(D,D,1),_<1?requestAnimationFrame(x):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",i()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(f,o,0),u()},c)},500))};x()};setTimeout(u,p)}import*as yt from"three";function ea(e,t,n){var g,y,m,f;let i=t.objects.get("hand_tutorial_1"),a=((g=i==null?void 0:i.gameplay)==null?void 0:g.tuning)||{},s=(i==null?void 0:i.render)||{},l=(i==null?void 0:i.transform)||{},p=new yt.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),c=new yt.Sprite(p);c.position.set(n.x,n.y,0),c.material.opacity=0;let u=(y=a.hand_scale_multiplier)!=null?y:2.5,h=(m=l.scale)!=null?m:.1875;return c.scale.set(h*u*100,h*u*100,1),c.renderOrder=(f=s.z_index)!=null?f:99999,c}function na(e){var f,o,b,H,T,d,r,E,x;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},a=((f=e.engine.runtime)==null?void 0:f.ui_styles)||{},s=((o=e.engine.runtime)==null?void 0:o.ui)||{},l=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",p=(n==null?void 0:n.font)||"brand.warning",c=(n==null?void 0:n.fontSize)||a.label_font_size||52,u=(H=n==null?void 0:n.letterSpacing)!=null?H:(b=a.label_letter_spacing)!=null?b:-1,h=(n==null?void 0:n.align)||"center",g=i.tint,y=typeof g=="string"?g:g?`#${g.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",m=document.createElement("div");return m.textContent=l,m.style.cssText=`
104
- font-family: ${X(p)};
103
+ `;let Ln=Tt+kt/2+20,Wn=d-r-10,Bn=Math.min(Ln+((qe=Yt.animation_start_y_offset)!=null?qe:5),Wn);Q.style.top=`${Bn}px`,Q.style.left="50%";let wt=j(Q);wt.element=Q,wt.animationStartYOffset=(Ze=Yt.animation_start_y_offset)!=null?Ze:5,H.appendChild(Q);let _t=((Ve=g==null?void 0:g.gameplay)==null?void 0:Ve.tuning)||{},Dn=(Je=_t.hand_offset_x)!=null?Je:50,kn=(Ke=_t.hand_offset_y)!=null?Ke:50,zn=(je=(Qe=g==null?void 0:g.transform)==null?void 0:Qe.scale)!=null?je:.1875,Pn=(Ie=_t.hand_scale_multiplier)!=null?Ie:2.5,Yn=new U.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),et=new U.Sprite(Yn),Gt=zn*Pn*100;return et.scale.set(Gt,Gt,1),et.position.set(Dn,Tt+kn,0),et.material.opacity=0,et.visible=!1,{panel:M,logo:P,title:At,subtitle:Et,footer:bt,ctaButton:xt,ctaText:Pt,ctaHint:wt,hand:et}}function Jn(e,t,n){var x,_,R,F,S,H,M,v;let s=t.objects.get("ui_endgame_1"),a=((x=s==null?void 0:s.gameplay)==null?void 0:x.tuning)||{},i=(_=a.animation_duration_ms)!=null?_:800,l=(R=a.fade_in_duration_ms)!=null?R:600,m=(F=a.scale_animation_intensity)!=null?F:.1,c=(S=a.logo_animation_delay_ms)!=null?S:100,h=(H=a.title_animation_delay_ms)!=null?H:200,p=(M=a.footer_animation_delay_ms)!=null?M:300,g=(v=a.cta_animation_delay_ms)!=null?v:400,{panel:y,logo:u,title:f,subtitle:o,footer:b,ctaButton:w,ctaText:T,ctaHint:d}=e;y.visible=!0,y.element.style.visibility="visible";let r=Date.now(),E=()=>{let Z=Date.now()-r,D=Math.min(Z/l,1),z=1-Math.pow(1-D,3);y.alpha=z,y.element.style.opacity=z.toString();let I=1+m*(1-z);y.element.style.transform=`translate(-50%, -50%) scale(${I})`,D<1?requestAnimationFrame(E):(setTimeout(()=>Kn(u,i,t),c),setTimeout(()=>{Qn(f,i),setTimeout(()=>jn(o,i),50)},h),setTimeout(()=>In(b,i),p),setTimeout(()=>{On(w,T,i),setTimeout(()=>Un(d,i),50),n&&n()},g))};E()}function Kn(e,t,n){var y,u,f,o,b;let s=n==null?void 0:n.objects.get("ui_endgame_logo_1"),i=(u=(((y=s==null?void 0:s.gameplay)==null?void 0:y.tuning)||{}).animation_start_scale)!=null?u:1.2,l=Date.now(),m=e.material.opacity,c=(f=e.targetAlpha)!=null?f:1,h=(o=e.baseScaleX)!=null?o:e.scale.x,p=(b=e.baseScaleY)!=null?b:e.scale.y,g=()=>{let w=Date.now()-l,T=Math.min(w/t,1),d=1-Math.pow(1-T,2);e.material.opacity=m+(c-m)*d;let r=i+(1-i)*d;e.scale.set(h*r,p*r,1),T<1&&requestAnimationFrame(g)};g()}function Qn(e,t){let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=()=>{let l=Date.now()-n,m=Math.min(l/t,1),c=1-Math.pow(1-m,2);e.element.style.opacity=(s+(1-s)*c).toString(),e.element.style.top=`${a-20*(1-c)}px`,m<1&&requestAnimationFrame(i)};i()}function jn(e,t){var m;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=a-((m=e.animationStartYOffset)!=null?m:-10),l=()=>{let c=Date.now()-n,h=Math.min(c/t,1),p=1-Math.pow(1-h,2);e.element.style.opacity=(s+(1-s)*p).toString(),e.element.style.top=`${a+(i-a)*p}px`,h<1&&requestAnimationFrame(l)};l()}function In(e,t){var l;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=(l=e.targetAlpha)!=null?l:1,i=()=>{let m=Date.now()-n,c=Math.min(m/t,1),h=1-Math.pow(1-c,2);e.element.style.opacity=(s+(a-s)*h).toString(),c<1&&requestAnimationFrame(i)};i()}function On(e,t,n){let s=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=()=>{let l=Date.now()-s,m=Math.min(l/n,1),c=1-Math.pow(1-m,2);e.element.style.opacity=(a+(1-a)*c).toString(),t.element.style.opacity=(a+(1-a)*c).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-c)})`,m<1&&requestAnimationFrame(i)};i()}function Un(e,t){var m;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=a-((m=e.animationStartYOffset)!=null?m:5),l=()=>{let c=Date.now()-n,h=Math.min(c/t,1),p=1-Math.pow(1-h,2);e.element.style.opacity=(s+(1-s)*p).toString(),e.element.style.top=`${a+(i-a)*p}px`,h<1&&requestAnimationFrame(l)};l()}function ta(e,t,n,s){var p,g,y,u;let a=n.objects.get("ui_endgame_hand_1"),i=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},l=(g=i.click_animation_duration_ms)!=null?g:600,m=(y=i.click_delay_ms)!=null?y:2e3,c=(u=i.click_repeat_delay_ms)!=null?u:3e3,h=()=>{var _,R;e.visible=!0,e.material.opacity=1;let f=e.position.x,o=e.position.y,b=(_=i.hand_offset_x)!=null?_:50,w=(R=i.hand_offset_y)!=null?R:50,T=t.element.getBoundingClientRect(),d=b,r=w,E=Date.now(),x=()=>{var z,I,at;let F=Date.now()-E,S=Math.min(F/l,1),H=S<.5?2*S*S:1-Math.pow(-2*S+2,2)/2;e.position.set(f+(d-f)*H,o+(r-o)*H,0);let M=(I=(z=a==null?void 0:a.transform)==null?void 0:z.scale)!=null?I:.1875,v=(at=i.hand_scale_multiplier)!=null?at:2.5,Z=M*v*100,D=Z+Z*.2*Math.sin(S*Math.PI);e.scale.set(D,D,1),S<1?requestAnimationFrame(x):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",s()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(f,o,0),h()},c)},500))};x()};setTimeout(h,m)}import*as yt from"three";function ea(e,t,n){var u,f,o,b,w,T,d;let s=t.objects.get("hand_tutorial_1"),a=((u=s==null?void 0:s.gameplay)==null?void 0:u.tuning)||{},i=(s==null?void 0:s.render)||{},l=(s==null?void 0:s.transform)||{},m=new yt.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),c=new yt.Sprite(m),h=l.position||{},p=(f=h==null?void 0:h.z)!=null?f:0;c.position.set(n.x+((o=h==null?void 0:h.x)!=null?o:0),n.y+((b=h==null?void 0:h.y)!=null?b:0),p),c.material.opacity=i.alpha!==void 0&&i.alpha!==null?i.alpha:0,c.visible=i.visible!==void 0&&i.visible!==null?i.visible:!1;let g=(w=a.hand_scale_multiplier)!=null?w:2.5,y=(T=l.scale)!=null?T:.1875;return c.scale.set(y*g*100,y*g*100,1),c.renderOrder=(d=i.z_index)!=null?d:99999,c}function na(e){var f,o,b,w,T,d,r,E,x;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,s=(t==null?void 0:t.render)||{},a=((f=e.engine.runtime)==null?void 0:f.ui_styles)||{},i=((o=e.engine.runtime)==null?void 0:o.ui)||{},l=(n==null?void 0:n.text)||i.tutorial_label||i.label_text||"CLEAN!",m=(n==null?void 0:n.font)||"brand.warning",c=(n==null?void 0:n.fontSize)||a.label_font_size||52,h=(w=n==null?void 0:n.letterSpacing)!=null?w:(b=a.label_letter_spacing)!=null?b:-1,p=(n==null?void 0:n.align)||"center",g=s.tint,y=typeof g=="string"?g:g?`#${g.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",u=document.createElement("div");return u.textContent=l,u.style.cssText=`
104
+ font-family: ${X(m)};
105
105
  font-size: ${c}px;
106
- font-weight: ${q(p)};
106
+ font-weight: ${q(m)};
107
107
  color: ${y};
108
- text-align: ${h};
109
- letter-spacing: ${u}px;
108
+ text-align: ${p};
109
+ letter-spacing: ${h}px;
110
110
  text-shadow: ${(T=a.label_shadow_distance)!=null?T:2}px ${(d=a.label_shadow_distance)!=null?d:2}px ${(r=a.label_shadow_blur)!=null?r:4}px rgba(0,0,0,${(E=a.label_shadow_alpha)!=null?E:.8});
111
111
  -webkit-text-stroke: ${a.label_stroke||"#8B0000"} 2px;
112
- opacity: ${(x=i.alpha)!=null?x:0};
113
- visibility: ${i.visible!==!1?"visible":"hidden"};
112
+ opacity: ${(x=s.alpha)!=null?x:0};
113
+ visibility: ${s.visible!==!1?"visible":"hidden"};
114
114
  pointer-events: none;
115
115
  position: absolute;
116
116
  transform: translate(-50%, -50%);
117
117
  white-space: nowrap;
118
- `,m}function aa(e,t,n,i,a){var c,u,h,g,y,m,f;let s=a.objects.get("hand_tutorial_1"),l=((c=s==null?void 0:s.gameplay)==null?void 0:c.tuning)||{},p=(s==null?void 0:s.transform)||{};if(!i){let o=(u=l.animation_duration)!=null?u:1.5,b=n%o/o,H=b<.5?2*b*b:-1+(4-2*b)*b,T=(h=l.x_offset)!=null?h:0,d=(g=l.y_offset)!=null?g:0,r=(y=l.animation_range)!=null?y:40,E=r*.7,x=r,w=t.x+T+E,R=t.y+d+x,F=w+E,_=R+x;e.position.set(w+(F-w)*H,R+(_-R)*H,0);let S=(m=p.scale)!=null?m:.1875,M=(f=l.hand_scale_multiplier)!=null?f:2.5,v=S*M*100;e.scale.set(v,v,1)}}import*as tt from"three";var Ue=new tt.TextureLoader;async function tn(e,t,n=16777215,i=!1){try{let s=(globalThis.INLINE_ASSETS||{})[e];return await Ue.loadAsync(s||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let s=document.createElement("canvas");s.width=64,s.height=64;let l=s.getContext("2d");return l&&(l.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?l.fillRect(0,0,30,60):(l.beginPath(),l.arc(32,32,30,0,Math.PI*2),l.fill(),l.fillRect(27,32,10,40))),new tt.CanvasTexture(s)}}async function ia(e,t,n){var f,o,b,H;let a=(globalThis.INLINE_ASSETS||{})[e]||e,s;try{s=await Ue.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(T){let E=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");s=await tn(e,t,parseInt(E,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:T})}if(!s)return[];let l=n.gameplay.character_sheet||{},p=(f=l.cols)!=null?f:3,c=(o=l.rows)!=null?o:2,u=((b=s.image)==null?void 0:b.width)||0,h=((H=s.image)==null?void 0:H.height)||0,g=u/p,y=h/c;if(!Number.isFinite(g)||!Number.isFinite(y)||g<=0||y<=0)return[s];let m=[];for(let T=0;T<c;T++)for(let d=0;d<p;d++){let r=document.createElement("canvas");r.width=g,r.height=y;let E=r.getContext("2d");E&&s.image&&E.drawImage(s.image,d*g,T*y,g,y,0,0,g,y),m.push(new tt.CanvasTexture(r))}return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function sa(e,t){var g,y,m,f;let n=t.gameplay.brush||{},i=t.theme.brush_color||"#ffffff",a=(g=n.radius)!=null?g:20,s=(y=n.inner_radius)!=null?y:15,l=(m=n.alpha)!=null?m:.8,p=(f=n.inner_alpha)!=null?f:.3,c=n.inner_color||"#ffffff",u=document.createElement("canvas");u.width=a*2,u.height=a*2;let h=u.getContext("2d");return h&&(h.clearRect(0,0,u.width,u.height),h.beginPath(),h.arc(a,a,a,0,Math.PI*2),h.fillStyle=i,h.globalAlpha=l,h.fill(),h.beginPath(),h.arc(a,a,s,0,Math.PI*2),h.fillStyle=c,h.globalAlpha=p,h.fill()),new tt.CanvasTexture(u)}export{Oe as AspectClass,mt as GameObject,vt as GameObjectManager,pt as Renderer,nt as ResponsiveUISystem,ht as Transform,ta as animateHandClick,Jn as animatePanelEntrance,sa as createBrushTexture,Zn as createEndGamePanel,ea as createHandTutorial,Xn as createThreeBase,na as createTutorialLabel,Rt as getAspectClass,Vn as getRegisteredFontIds,tn as loadAsset,ia as loadCharacterFrames,qn as registerFont,X as resolveFont,q as resolveFontWeight,aa as updateHandAnimation};
118
+ `,u}function aa(e,t,n,s,a){var c,h,p,g,y,u,f;let i=a.objects.get("hand_tutorial_1"),l=((c=i==null?void 0:i.gameplay)==null?void 0:c.tuning)||{},m=(i==null?void 0:i.transform)||{};if(!s){let o=(h=l.animation_duration)!=null?h:1.5,b=n%o/o,w=b<.5?2*b*b:-1+(4-2*b)*b,T=(p=l.x_offset)!=null?p:0,d=(g=l.y_offset)!=null?g:0,r=(y=l.animation_range)!=null?y:40,E=r*.7,x=r,_=t.x+T+E,R=t.y+d+x,F=_+E,S=R+x;e.position.set(_+(F-_)*w,R+(S-R)*w,0);let H=(u=m.scale)!=null?u:.1875,M=(f=l.hand_scale_multiplier)!=null?f:2.5,v=H*M*100;e.scale.set(v,v,1)}}import*as tt from"three";var Ue=new tt.TextureLoader;async function tn(e,t,n=16777215,s=!1){try{let i=(globalThis.INLINE_ASSETS||{})[e];return await Ue.loadAsync(i||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let i=document.createElement("canvas");i.width=64,i.height=64;let l=i.getContext("2d");return l&&(l.fillStyle=`#${n.toString(16).padStart(6,"0")}`,s?l.fillRect(0,0,30,60):(l.beginPath(),l.arc(32,32,30,0,Math.PI*2),l.fill(),l.fillRect(27,32,10,40))),new tt.CanvasTexture(i)}}async function ia(e,t,n){var f,o,b,w;let a=(globalThis.INLINE_ASSETS||{})[e]||e,i;try{i=await Ue.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(T){let E=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");i=await tn(e,t,parseInt(E,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:T})}if(!i)return[];let l=n.gameplay.character_sheet||{},m=(f=l.cols)!=null?f:3,c=(o=l.rows)!=null?o:2,h=((b=i.image)==null?void 0:b.width)||0,p=((w=i.image)==null?void 0:w.height)||0,g=h/m,y=p/c;if(!Number.isFinite(g)||!Number.isFinite(y)||g<=0||y<=0)return[i];let u=[];for(let T=0;T<c;T++)for(let d=0;d<m;d++){let r=document.createElement("canvas");r.width=g,r.height=y;let E=r.getContext("2d");E&&i.image&&E.drawImage(i.image,d*g,T*y,g,y,0,0,g,y),u.push(new tt.CanvasTexture(r))}return u.length>2&&u.push(...u.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:u.length}),u}function sa(e,t){var g,y,u,f;let n=t.gameplay.brush||{},s=t.theme.brush_color||"#ffffff",a=(g=n.radius)!=null?g:20,i=(y=n.inner_radius)!=null?y:15,l=(u=n.alpha)!=null?u:.8,m=(f=n.inner_alpha)!=null?f:.3,c=n.inner_color||"#ffffff",h=document.createElement("canvas");h.width=a*2,h.height=a*2;let p=h.getContext("2d");return p&&(p.clearRect(0,0,h.width,h.height),p.beginPath(),p.arc(a,a,a,0,Math.PI*2),p.fillStyle=s,p.globalAlpha=l,p.fill(),p.beginPath(),p.arc(a,a,i,0,Math.PI*2),p.fillStyle=c,p.globalAlpha=m,p.fill()),new tt.CanvasTexture(h)}export{Oe as AspectClass,mt as GameObject,vt as GameObjectManager,pt as Renderer,nt as ResponsiveUISystem,ht as Transform,ta as animateHandClick,Jn as animatePanelEntrance,sa as createBrushTexture,Vn as createEndGamePanel,ea as createHandTutorial,Xn as createThreeBase,na as createTutorialLabel,Rt as getAspectClass,Zn as getRegisteredFontIds,tn as loadAsset,ia as loadCharacterFrames,qn as registerFont,X as resolveFont,q as resolveFontWeight,aa as updateHandAnimation};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handler-playable-sdk",
3
- "version": "0.1.18",
3
+ "version": "0.2.1",
4
4
  "description": "Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,17 +0,0 @@
1
- var u={};function I(e,t,n=!1){u[e]||(u[e]=[]),u[e].push({fn:t,once:n})}function V(e,t){if(u[e]){if(!t){delete u[e];return}u[e]=u[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=u[e];if(n)for(let i of[...n])i.fn(...t),i.once&&V(e,i.fn)}function a(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.1.18",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var s=0,Se=s++,Z=s++,ee=s++,te=s++,ne=s++,ie=s++,oe=s++,re=s++,ae=s++,se=s++,de=s++,le=s++,r=Se;function ce(){return r===Z}function ue(){return r===ee}function pe(){return r===te}function fe(){return r===ne}function g(){return r===ie}function y(){return r===oe}function me(){return r===re}function ge(){return r===ae}function ye(){return r===se}function H(){return r===de}function F(){return r===le}function we(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=Z;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=ee;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=te)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ne)}catch{}else if(t==="mintegral")window.gameReady&&(r=ie);else if(t==="tapjoy")window.TJ_API&&(r=oe);else if(t==="tiktok")window.openAppStore&&(r=re);else if(t==="smadex")try{window.smxTracking&&(r=ae)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=se)}catch{}else t==="vungle"?r=de:(e==="nucleo"||t==="nucleo")&&(r=le)}var Ee={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ce=Math.random().toString(36).slice(2),w=null,A={...Ee},Ae="web_embed",De={},G=!1,E=!1,T=!1,ke=!1,B=1,W=0,z=!1,d=!1,N="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),K=h>b,l=!1,k=!1,he=!1,be=!1,U=!1,M=null;function _e(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function j(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Te(e,t){return{event_name:e,ts:Date.now(),session_id:Ce,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:Ae==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=j(e),i=Te(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){B=e,o("volume",e)}function v(e){e&&(ke=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&ke||T&&(T=!1,o("resume"),_(B))}function f(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),K=h>b,o("resize",{width:h,height:b})}function Le(){if(ce())try{let e=mraid.getMaxSize();f(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();f(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ie(){if(ue())try{let e=dapi.getScreenSize();f(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();f(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function ve(){let e=()=>{l||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(l=!0,o("boot"),o("view"),o("ready"),d=!0,O(),k&&(k=!1,p.start()))};window.addEventListener("resize",()=>f()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function Pe(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(he=!0),!(he&&t instanceof MouseEvent)&&(W+=1,o("interaction",W))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Re(e){var i,c,x,C,J,D,q,L,$,X,Y,Q;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(c=window.TJ_API)==null?void 0:c.click)==null||x.call(c);else if(pe())(J=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||J.call(C);else if(ye())(q=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||q.call(D);else if(ge())try{($=(L=window.smxTracking)==null?void 0:L.redirect)==null||$.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(fe()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||N||""):e&&window.open(e)}else g()?(X=window.install)==null||X.call(window):me()?(Y=window.openAppStore)==null||Y.call(window):H()?(Q=parent==null?void 0:parent.postMessage)==null||Q.call(parent,"download","*"):e&&window.open(e)}function Me(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;a("view",()=>t(n.mraid_viewable)),a("start",()=>t(n.game_viewable)),a("engagement",()=>t(n.engagement));let i=()=>t(n.complete);a("complete",i),I("engagement",c=>{var x;((x=c==null?void 0:c.payload)==null?void 0:x.count)>3&&i()}),a("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;a("view",()=>t(n.Ad_Load_Start)),a("start",()=>t(n.Ad_Viewable)),a("engagement",()=>t(n.First_Engagement)),a("complete",()=>t(n.Gameplay_Complete)),a("cta_click",()=>t(n.DSP_Click)),a("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function je(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{p.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function xe(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function Ne(){g()&&(window.mintGameStart=()=>{S(!0),f()},window.mintGameClose=()=>{v(!0)})}function ze(){if(!F())return;let e=window.NUC;!e||!e.trigger||(p.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,N)}),p.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var p={init(e={},t){if(Ae=e.profile||"web_embed",De=e.consent||{},A={...Ee,...e.ids||{}},w=e.rootEl||w,N=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,_e(),Ve(w),we(),Le(),Ie(),!z){if(document.readyState==="complete")ve();else if(!be){be=!0;let n=()=>{ve(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Pe(),Me(),je(),Ne(),ze(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),l&&!d&&(o("boot"),o("view"),o("ready"),k&&(k=!1,p.start()),d=!0),d=l},getRoot(){return _e()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return K},get isReady(){return d},get isStarted(){return G},get isPaused(){return T},get isFinished(){return E},get volume(){return B},get interactions(){return W},on(e,t){I(j(e),t)},off(e,t){V(j(e),t)},start(){var e,t;if(!G){if(!l){k=!0;return}if(G=!0,o("start"),f(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:K?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):H()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&xe())},install(e){if(!E){E=!0,y()?(xe(),setTimeout(()=>p.install(e),300)):(o("complete"),setTimeout(()=>p.install(e),0));return}U||(U=!0,setTimeout(()=>U=!1,500),o("cta_click"),o("conversion"),Re(e||N))},emit(e,t){let n=j(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Te(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(F()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){f(e,t)}},Be=p;function Ve(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
2
- (function(){
3
- var events = ['touchstart','touchend','mousedown','keydown'];
4
- function unlock(){
5
- if(window.AudioContext && AudioContext.prototype.resume){
6
- if(!window.__handler_audio_ctx){
7
- window.__handler_audio_ctx = new AudioContext();
8
- }
9
- if(window.__handler_audio_ctx.state === 'suspended'){
10
- window.__handler_audio_ctx.resume();
11
- }
12
- }
13
- events.forEach(function(e){ document.removeEventListener(e, unlock); });
14
- }
15
- events.forEach(function(e){ document.addEventListener(e, unlock, false); });
16
- })();
17
- `,e.appendChild(t)}export{p as a,Be as b};