handler-playable-sdk 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-6MYM2EUT.mjs → chunk-AOCUS265.mjs} +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/pixi/index.d.mts +1 -1
- package/dist/pixi/index.d.ts +1 -1
- package/dist/pixi/index.js +2 -2
- package/dist/pixi/index.mjs +1 -1
- package/dist/three/index.js +24 -24
- package/dist/three/index.mjs +26 -26
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
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.3",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=`
|
|
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.5",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
2
|
(function(){
|
|
3
3
|
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
4
4
|
function unlock(){
|
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.2.3",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.5",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-
|
|
1
|
+
import{a,b}from"./chunk-AOCUS265.mjs";export{a as Handler,b as default};
|
package/dist/pixi/index.d.mts
CHANGED
|
@@ -440,7 +440,7 @@ declare function loadAsset(path: string, app: any, fallbackColor?: number, isCha
|
|
|
440
440
|
* @param app - PixiJS application instance
|
|
441
441
|
* @param config - Object-centric configuration
|
|
442
442
|
*/
|
|
443
|
-
declare function loadCharacterFrames(path: string, app: any, config: ObjectCentricConfig): Promise<Texture[]>;
|
|
443
|
+
declare function loadCharacterFrames(path: string, app: any, config: ObjectCentricConfig | any): Promise<Texture[]>;
|
|
444
444
|
/**
|
|
445
445
|
* Create brush texture
|
|
446
446
|
* Uses config.theme.brush_color for color
|
package/dist/pixi/index.d.ts
CHANGED
|
@@ -440,7 +440,7 @@ declare function loadAsset(path: string, app: any, fallbackColor?: number, isCha
|
|
|
440
440
|
* @param app - PixiJS application instance
|
|
441
441
|
* @param config - Object-centric configuration
|
|
442
442
|
*/
|
|
443
|
-
declare function loadCharacterFrames(path: string, app: any, config: ObjectCentricConfig): Promise<Texture[]>;
|
|
443
|
+
declare function loadCharacterFrames(path: string, app: any, config: ObjectCentricConfig | any): Promise<Texture[]>;
|
|
444
444
|
/**
|
|
445
445
|
* Create brush texture
|
|
446
446
|
* Uses config.theme.brush_color for color
|
package/dist/pixi/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var $e=Object.defineProperty;var Za=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var ei=Object.prototype.hasOwnProperty;var ti=(e,t)=>{for(var n in t)$e(e,n,{get:t[n],enumerable:!0})},ni=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ua(t))!ei.call(e,i)&&i!==n&&$e(e,i,{get:()=>t[i],enumerable:!(a=Za(t,i))||a.enumerable});return e};var ai=e=>ni($e({},"__esModule",{value:!0}),e);var Ci={};ti(Ci,{GameObject:()=>Se,GameObjectManager:()=>Ie,Renderer:()=>Ae,Transform:()=>Ce,animateHandClick:()=>sa,animatePanelEntrance:()=>ia,createBrushTexture:()=>fa,createEndGamePanel:()=>aa,createHandTutorial:()=>oa,createPixiBase:()=>ea,createTutorialLabel:()=>ra,getRegisteredFontIds:()=>na,loadAsset:()=>ua,loadCharacterFrames:()=>pa,registerFont:()=>ta,resolveFont:()=>j,resolveFontWeight:()=>G,updateHandAnimation:()=>la});module.exports=ai(Ci);var Un=require("pixi.js");var ee={};function Le(e,t,n=!1){ee[e]||(ee[e]=[]),ee[e].push({fn:t,once:n})}function Ke(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&&Ke(e,a.fn)}function O(e,t){Le(e,t,!0)}var Oe={name:"handler-playable-sdk",version:"0.2.3",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 H=0,si=H++,An=H++,Sn=H++,En=H++,kn=H++,Pn=H++,Dn=H++,Fn=H++,Mn=H++,Rn=H++,Ln=H++,zn=H++,b=si;function On(){return b===An}function Hn(){return b===Sn}function Wn(){return b===En}function Yn(){return b===kn}function de(){return b===Pn}function ue(){return b===Dn}function Nn(){return b===Fn}function Bn(){return b===Mn}function In(){return b===Rn}function Je(){return b===Ln}function Qe(){return b===zn}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(),b=An;return}catch{}else if(e==="dapi")try{dapi.isReady(),b=Sn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(b=En)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(b=kn)}catch{}else if(t==="mintegral")window.gameReady&&(b=Pn);else if(t==="tapjoy")window.TJ_API&&(b=Dn);else if(t==="tiktok")window.openAppStore&&(b=Fn);else if(t==="smadex")try{window.smxTracking&&(b=Mn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(b=Rn)}catch{}else t==="vungle"?b=Ln:(e==="nucleo"||t==="nucleo")&&(b=zn)}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"},oi=Math.random().toString(36).slice(2),pe=null,_e={...Kn},Jn="web_embed",ri={},Ze=!1,be=!1,xe=!1,Qn=!1,nt=1,et=0,Ne=!1,J=!1,Ye="",fe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),tt=fe>me,Q=!1,we=!1,Gn=!1,Vn=!1,Ue=!1,He=null;function qn(){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 Zn(e,t){return{event_name:e,ts:Date.now(),session_id:oi,deployment_id:_e.deployment_id,variant_id:_e.variant_id,export_profile_id:_e.profile_id,instance_id:_e.instance_id||"default",env:Jn==="mraid"?"mraid":"web",payload:t}}function y(e,t){let n=We(e),a=Zn(n,t);ze(n,a),n!==e&&ze(e,a)}function Te(){He&&(He(fe,me),He=null)}function he(e){nt=e,y("volume",e)}function ye(e){e&&(Qn=!0),!xe&&(xe=!0,y("pause"),he(0))}function ve(e){!e&&Qn||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 li(){if(On())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)}),Ne=!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 ci(){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)),Ne=!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 Xn(){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),Ne=!0}function di(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(Gn=!0),!(Gn&&t instanceof MouseEvent)&&(et+=1,y("interaction",et))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function ui(e){var a,i,s,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())(s=(i=window.TJ_API)==null?void 0:i.click)==null||s.call(i);else if(Wn())(r=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||r.call(o);else if(In())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Bn())try{(f=(p=window.smxTracking)==null?void 0:p.redirect)==null||f.call(p)}catch(m){console.warn("Smadex redirect failed",m)}else if(Yn()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||Ye||""):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 pi(){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;O("view",()=>t(n.mraid_viewable)),O("start",()=>t(n.game_viewable)),O("engagement",()=>t(n.engagement));let a=()=>t(n.complete);O("complete",a),Le("engagement",i=>{var s;((s=i==null?void 0:i.payload)==null?void 0:s.count)>3&&a()}),O("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;O("view",()=>t(n.Ad_Load_Start)),O("start",()=>t(n.Ad_Viewable)),O("engagement",()=>t(n.First_Engagement)),O("complete",()=>t(n.Gameplay_Complete)),O("cta_click",()=>t(n.DSP_Click)),O("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function fi(){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 $n(){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 mi(){de()&&(window.mintGameStart=()=>{ve(!0),ne()},window.mintGameClose=()=>{ye(!0)})}function hi(){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,Ye)}),te.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var te={init(e={},t){if(Jn=e.profile||"web_embed",ri=e.consent||{},_e={...Kn,...e.ids||{}},pe=e.rootEl||pe,Ye=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(He=t),y("init"),document.body.oncontextmenu=()=>!1,qn(),yi(pe),jn(),li(),ci(),!Ne){if(document.readyState==="complete")Xn();else if(!Vn){Vn=!0;let n=()=>{Xn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}di(),pi(),fi(),mi(),hi(),console.log(`%c @handler/playable-sdk %c v${Oe.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 qn()},get version(){return Oe.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 be},get volume(){return nt},get interactions(){return et},on(e,t){Le(We(e),t)},off(e,t){Ke(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:Oe.version||"dev"})}}},finish(){var e,t;be||(be=!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()&&$n())},install(e){if(!be){be=!0,ue()?($n(),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"),ui(e||Ye))},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=Zn(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 yi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
1
|
+
"use strict";var $e=Object.defineProperty;var Za=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var ei=Object.prototype.hasOwnProperty;var ti=(e,t)=>{for(var n in t)$e(e,n,{get:t[n],enumerable:!0})},ni=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ua(t))!ei.call(e,i)&&i!==n&&$e(e,i,{get:()=>t[i],enumerable:!(a=Za(t,i))||a.enumerable});return e};var ai=e=>ni($e({},"__esModule",{value:!0}),e);var Ai={};ti(Ai,{GameObject:()=>Ee,GameObjectManager:()=>Be,Renderer:()=>Ce,Transform:()=>Se,animateHandClick:()=>oa,animatePanelEntrance:()=>sa,createBrushTexture:()=>ma,createEndGamePanel:()=>ia,createHandTutorial:()=>ra,createPixiBase:()=>ta,createTutorialLabel:()=>la,getRegisteredFontIds:()=>aa,loadAsset:()=>pa,loadCharacterFrames:()=>fa,registerFont:()=>na,resolveFont:()=>K,resolveFontWeight:()=>X,updateHandAnimation:()=>ca});module.exports=ai(Ai);var ea=require("pixi.js");var ne={};function ze(e,t,n=!1){ne[e]||(ne[e]=[]),ne[e].push({fn:t,once:n})}function Je(e,t){if(ne[e]){if(!t){delete ne[e];return}ne[e]=ne[e].filter(n=>n.fn!==t)}}function Oe(e,...t){let n=ne[e];if(n)for(let a of[...n])a.fn(...t),a.once&&Je(e,a.fn)}function N(e,t){ze(e,t,!0)}var He={name:"handler-playable-sdk",version:"0.2.5",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 Y=0,si=Y++,Cn=Y++,En=Y++,kn=Y++,Pn=Y++,Dn=Y++,Fn=Y++,Mn=Y++,Ln=Y++,Rn=Y++,zn=Y++,On=Y++,_=si;function Hn(){return _===Cn}function Wn(){return _===En}function In(){return _===kn}function Nn(){return _===Pn}function ue(){return _===Dn}function pe(){return _===Fn}function Yn(){return _===Mn}function jn(){return _===Ln}function Bn(){return _===Rn}function Qe(){return _===zn}function Ze(){return _===On}function Gn(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),_=Cn;return}catch{}else if(e==="dapi")try{dapi.isReady(),_=En;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(_=kn)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(_=Pn)}catch{}else if(t==="mintegral")window.gameReady&&(_=Dn);else if(t==="tapjoy")window.TJ_API&&(_=Fn);else if(t==="tiktok")window.openAppStore&&(_=Mn);else if(t==="smadex")try{window.smxTracking&&(_=Ln)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(_=Rn)}catch{}else t==="vungle"?_=zn:(e==="nucleo"||t==="nucleo")&&(_=On)}var Jn={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"},oi=Math.random().toString(36).slice(2),fe=null,we={...Jn},Qn="web_embed",ri={},Ue=!1,be=!1,ve=!1,Zn=!1,at=1,tt=0,Ye=!1,Z=!1,Ne="",me=Math.floor(window.innerWidth),he=Math.floor(window.innerHeight),nt=me>he,U=!1,xe=!1,Vn=!1,qn=!1,et=!1,We=null;function Kn(){if(fe)return fe;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),fe=e,e}function Ie(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Un(e,t){return{event_name:e,ts:Date.now(),session_id:oi,deployment_id:we.deployment_id,variant_id:we.variant_id,export_profile_id:we.profile_id,instance_id:we.instance_id||"default",env:Qn==="mraid"?"mraid":"web",payload:t}}function y(e,t){let n=Ie(e),a=Un(n,t);Oe(n,a),n!==e&&Oe(e,a)}function Te(){We&&(We(me,he),We=null)}function ye(e){at=e,y("volume",e)}function ge(e){e&&(Zn=!0),!ve&&(ve=!0,y("pause"),ye(0))}function Ae(e){!e&&Zn||ve&&(ve=!1,y("resume"),ye(at))}function ie(e,t){me=Math.floor(e||window.innerWidth),he=Math.floor(t||window.innerHeight),nt=me>he,y("resize",{width:me,height:he})}function li(){if(Hn())try{let e=mraid.getMaxSize();ie(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?Ae():ge()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ie(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();ye(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&ye(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Ye=!0,mraid.isViewable()&&mraid.getState()!=="hidden")U=!0,y("boot"),y("view"),y("ready"),Z=!0,Te();else{let n=()=>{U=!0,y("boot"),y("view"),y("ready"),Z=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function ci(){if(Wn())try{let e=dapi.getScreenSize();ie(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?Ae():ge()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();ie(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(ye(t?1:0),dapi.addEventListener("audioVolumeChange",n=>ye(n?1:0)),Ye=!0,dapi.isViewable())U=!0,y("boot"),y("view"),y("ready"),Z=!0,Te();else{let n=()=>{U=!0,y("boot"),y("view"),y("ready"),Z=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function Xn(){let e=()=>{U||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(U=!0,y("boot"),y("view"),y("ready"),Z=!0,Te(),xe&&(xe=!1,ae.start()))};window.addEventListener("resize",()=>ie()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(Ae(),e()):ge()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ye=!0}function di(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(Vn=!0),!(Vn&&t instanceof MouseEvent)&&(tt+=1,y("interaction",tt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function ui(e){var a,i,s,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(pe())(s=(i=window.TJ_API)==null?void 0:i.click)==null||s.call(i);else if(In())(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(jn())try{(f=(p=window.smxTracking)==null?void 0:p.redirect)==null||f.call(p)}catch(m){console.warn("Smadex redirect failed",m)}else if(Nn()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||Ne||""):e&&window.open(e)}else ue()?(u=window.install)==null||u.call(window):Yn()?(c=window.openAppStore)==null||c.call(window):Qe()?(h=parent==null?void 0:parent.postMessage)==null||h.call(parent,"download","*"):e&&window.open(e)}function pi(){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;N("view",()=>t(n.mraid_viewable)),N("start",()=>t(n.game_viewable)),N("engagement",()=>t(n.engagement));let a=()=>t(n.complete);N("complete",a),ze("engagement",i=>{var s;((s=i==null?void 0:i.payload)==null?void 0:s.count)>3&&a()}),N("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;N("view",()=>t(n.Ad_Load_Start)),N("start",()=>t(n.Ad_Viewable)),N("engagement",()=>t(n.First_Engagement)),N("complete",()=>t(n.Gameplay_Complete)),N("cta_click",()=>t(n.DSP_Click)),N("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function fi(){if(!pe())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{ae.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function $n(){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 mi(){ue()&&(window.mintGameStart=()=>{Ae(!0),ie()},window.mintGameClose=()=>{ge(!0)})}function hi(){if(!Ze())return;let e=window.NUC;!e||!e.trigger||(ae.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ne)}),ae.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var ae={init(e={},t){if(Qn=e.profile||"web_embed",ri=e.consent||{},we={...Jn,...e.ids||{}},fe=e.rootEl||fe,Ne=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(We=t),y("init"),document.body.oncontextmenu=()=>!1,Kn(),yi(fe),Gn(),li(),ci(),!Ye){if(document.readyState==="complete")Xn();else if(!qn){qn=!0;let n=()=>{Xn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}di(),pi(),fi(),mi(),hi(),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;"),U&&!Z&&(y("boot"),y("view"),y("ready"),xe&&(xe=!1,ae.start()),Z=!0),Z=U},getRoot(){return Kn()},get version(){return He.version||"0.0.0"},get maxWidth(){return me},get maxHeight(){return he},get isLandscape(){return nt},get isReady(){return Z},get isStarted(){return Ue},get isPaused(){return ve},get isFinished(){return be},get volume(){return at},get interactions(){return tt},on(e,t){ze(Ie(e),t)},off(e,t){Je(Ie(e),t)},start(){var e,t;if(!Ue){if(!U){xe=!0;return}if(Ue=!0,y("start"),ie(),ue())ge(),(e=window.gameReady)==null||e.call(window);else if(pe()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:nt?"landscape":"portrait",buildID:He.version||"dev"})}}},finish(){var e,t;be||(be=!0,y("complete"),ue()?(e=window.gameEnd)==null||e.call(window):Qe()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):pe()&&$n())},install(e){if(!be){be=!0,pe()?($n(),setTimeout(()=>ae.install(e),300)):(y("complete"),setTimeout(()=>ae.install(e),0));return}et||(et=!0,setTimeout(()=>et=!1,500),y("cta_click"),y("conversion"),ui(e||Ne))},emit(e,t){let n=Ie(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=Un(n,t);Oe(n,a)},retry(){var e,t,n;if(ue())(e=window.gameRetry)==null||e.call(window);else if(Ze()){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(){ge(!0)},resume(){Ae(!0)},resize(e,t){ie(e,t)}},je=ae;function yi(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 ea(e,t={}){let n=new Un.Application;await n.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let a=s=>{var l,d,p,f,u,c;let o=(p=(d=(l=s==null?void 0:s.width)!=null?l:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(c=(u=(f=s==null?void 0:s.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 i=document.createElement("div");return i.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(i),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:s})=>{a({width:s==null?void 0:s.width,height:s==null?void 0:s.height})}),window.addEventListener("resize",()=>a()),requestAnimationFrame(()=>a()),{app:n,stage:n.stage,overlay:i,applySize:a}}var Ce=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}},Ae=class{constructor(t){var n,a,i,s;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=(i=t==null?void 0:t.visible)!=null?i:!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)}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)}},Se=class{constructor(t,n,a,i){this.instanceId=t,this.objectConfig=n,this.pixiObject=a,this._config=i,this.transform=new Ce(i.transform),this.renderer=new Ae(i.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 i=new Se(t,a.object_config||t,n,a);return this.objects.set(t,i),i}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,a]of this.objects.entries()){let i=t.objects.get(n);i&&a.updateConfig(i)}}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 ta(e,t){je[e]=t}function na(){return Object.keys(je)}var w=require("pixi.js");function aa(e,t,n){var yt,gt,bt,_t,wt,xt,Tt,vt,Ct,At,St,Et,kt,Pt,Dt,Ft,Mt,Rt,Lt,zt,Ot,Ht,Wt,Yt,Nt,Bt,It,jt,Gt,Vt,qt,Xt,$t,Kt,Jt,Qt,Zt,Ut,en,tn,nn,an,sn,on,rn,ln,cn,dn,un,pn,fn,mn,hn,yn,gn,bn,_n,wn,xn,Tn;let a=e.objects.get("ui_endgame_1"),i=e.objects.get("ui_endgame_logo_1"),s=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=((yt=a==null?void 0:a.gameplay)==null?void 0:yt.tuning)||{},h=(a==null?void 0:a.render)||{},m=(gt=c.panel_width)!=null?gt:320,g=(bt=c.panel_height)!=null?bt:400,x=(_t=c.panel_padding)!=null?_t:32,T=(wt=c.panel_radius)!=null?wt:24,S=h.background_color||c.panel_bg_color||"#1a0a0a",v=h.background_alpha!==void 0&&h.background_alpha!==null?h.background_alpha:(xt=c.panel_bg_alpha)!=null?xt:.98,E=h.border_color||c.panel_border_color||"#ffffff",k=(Tt=c.panel_border_width)!=null?Tt:2,C=(vt=c.panel_border_alpha)!=null?vt:.3,A=new w.Graphics;A.roundRect(-m/2,-g/2,m,g,T);let _=S.replace("#","");A.fill({color:parseInt(_,16),alpha:v});let P=E.replace("#","");A.stroke({color:parseInt(P,16),width:k,alpha:C});let Y=new w.Graphics;Y.roundRect(-m/2+2,-g/2+2,m-4,g-4,T-2),Y.stroke({color:16777215,width:1,alpha:.1}),A.addChild(Y),u.addChild(A);let V=((Ct=i==null?void 0:i.gameplay)==null?void 0:Ct.tuning)||{},Z=(i==null?void 0:i.transform)||{},N=(At=V.logo_size)!=null?At:56,q=(St=Z.scale)!=null?St:1,ae=(kt=(Et=Z.offset)==null?void 0:Et.y)!=null?kt:-130,ma=(Pt=V.logo_alpha)!=null?Pt:1,D=new w.Sprite(n||w.Texture.EMPTY);D.anchor.set(.5);let se=0,oe=0;if(n&&n!==w.Texture.EMPTY){let F=n.frame,K=n.baseTexture;F&&F.width&&F.height?(se=F.width,oe=F.height):K&&K.width&&K.height?(se=K.width,oe=K.height):n.width&&n.height&&(se=n.width,oe=n.height)}if(se>0&&oe>0){let F=se/oe,K,Xe;F>1?(K=N,Xe=N/F):(Xe=N,K=N*F);let vn=K/se,Cn=Xe/oe;vn*=q,Cn*=q,D.scale.set(vn,Cn)}else{let F=N/100*q;D.scale.set(F)}D.position.set(0,ae),D.alpha=0,D.visible=!0,D.targetAlpha=ma,D.baseScaleX=D.scale.x,D.baseScaleY=D.scale.y,u.addChild(D);let M=s==null?void 0:s.ui,B=((Dt=s==null?void 0:s.gameplay)==null?void 0:Dt.tuning)||{},ha=(M==null?void 0:M.text)||"MISSION ACCOMPLISHED",st=(M==null?void 0:M.font)||"brand.heading",ya=(M==null?void 0:M.fontSize)||24,ga=(Ft=M==null?void 0:M.letterSpacing)!=null?Ft:1,Ee=(Mt=s==null?void 0:s.render)==null?void 0:Mt.tint,ba=typeof Ee=="string"?Ee:Ee?`#${Ee.toString(16).padStart(6,"0")}`:"#00FF88",ot=m-x*2-30,_a=B.font_weight_override?B.font_weight_override:G(st),U=new w.Text({text:ha,style:{fontFamily:j(st),fontSize:ya,fontWeight:_a,fill:ba,align:"center",letterSpacing:ga,wordWrap:!1,stroke:{color:B.stroke_color||"#000000",width:(Rt=B.stroke_width)!=null?Rt:2},dropShadow:{color:B.shadow_color||"#000000",alpha:(Lt=B.shadow_alpha)!=null?Lt:.9,angle:(zt=B.shadow_angle)!=null?zt:0,blur:(Ot=B.shadow_blur)!=null?Ot:8,distance:(Ht=B.shadow_distance)!=null?Ht:4}}});if(U.width>ot){let F=ot/U.width;U.scale.set(F)}U.anchor.set(.5);let rt=(Wt=c.title_offset_y)!=null?Wt:30,wa=rt+((Yt=B.animation_start_y_offset)!=null?Yt:-20);U.position.set(0,wa),U.alpha=0,u.addChild(U);let R=o==null?void 0:o.ui,lt=((Nt=o==null?void 0:o.gameplay)==null?void 0:Nt.tuning)||{},xa=(R==null?void 0:R.text)||"RESCUE COMPLETE",ct=(R==null?void 0:R.font)||"brand.body",Ta=(R==null?void 0:R.fontSize)||11,va=(Bt=R==null?void 0:R.letterSpacing)!=null?Bt:.5,ke=(It=o==null?void 0:o.render)==null?void 0:It.tint,Ca=typeof ke=="string"?ke:ke?`#${ke.toString(16).padStart(6,"0")}`:"#B0B0B0",re=new w.Text({text:xa,style:{fontFamily:j(ct),fontSize:Ta,fontWeight:G(ct),fill:Ca,align:"center",letterSpacing:va}});re.anchor.set(.5);let Aa=rt+20+((jt=lt.animation_start_y_offset)!=null?jt:-10);re.position.set(0,Aa),re.alpha=0,re.animationStartYOffset=(Gt=lt.animation_start_y_offset)!=null?Gt:-10,u.addChild(re);let X=r==null?void 0:r.ui,dt=((Vt=r==null?void 0:r.gameplay)==null?void 0:Vt.tuning)||{},Sa=(X==null?void 0:X.text)||((qt=f.ui)==null?void 0:qt.cta_hint)||"Continue the adventure!",ut=(X==null?void 0:X.font)||"brand.body",Ea=(X==null?void 0:X.fontSize)||16,Pe=(Xt=r==null?void 0:r.render)==null?void 0:Xt.tint,ka=typeof Pe=="string"?Pe:Pe?`#${Pe.toString(16).padStart(6,"0")}`:"#FFFFFF",Pa=($t=dt.max_width)!=null?$t:m-x*2,Da=(Kt=dt.line_height)!=null?Kt:1.4,le=new w.Text({text:Sa,style:{fontFamily:j(ut),fontSize:Ea,fontWeight:G(ut),fill:ka,align:"center",wordWrap:!0,wordWrapWidth:Pa,lineHeight:Da}});le.anchor.set(.5);let Fa=(Jt=c.footer_offset_y)!=null?Jt:120;le.position.set(0,Fa);let Ma=((Qt=r==null?void 0:r.render)==null?void 0:Qt.alpha)!==void 0&&((Zt=r==null?void 0:r.render)==null?void 0:Zt.alpha)!==null?r.render.alpha:1;le.alpha=0,le.targetAlpha=Ma,u.addChild(le);let $=((Ut=l==null?void 0:l.gameplay)==null?void 0:Ut.tuning)||{},L=l==null?void 0:l.ui,De=(en=$.button_width)!=null?en:260,Fe=(tn=$.button_height)!=null?tn:56,pt=(nn=$.button_radius)!=null?nn:16,Ra=$.button_bg_color||((an=f.theme)==null?void 0:an.cta_background)||"#ffb43b",La=(sn=$.button_bg_alpha)!=null?sn:1,za=$.button_border_color||"#ffffff",Oa=(on=$.button_border_width)!=null?on:2,Ha=(rn=$.button_border_alpha)!=null?rn:.2,Me=(ln=c.cta_offset_y)!=null?ln:160,I=new w.Graphics;I.roundRect(-De/2,-Fe/2,De,Fe,pt);let Wa=Ra.replace("#","");I.fill({color:parseInt(Wa,16),alpha:La});let Ya=za.replace("#","");I.stroke({color:parseInt(Ya,16),width:Oa,alpha:Ha});let Ve=new w.Graphics;Ve.roundRect(-De/2+2,-Fe/2+2,De-4,Fe-4,pt-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 Na=(L==null?void 0:L.text)||((cn=f.ui)==null?void 0:cn.cta_label_end)||"DOWNLOAD",ft=(L==null?void 0:L.font)||"brand.heading",Ba=(L==null?void 0:L.fontSize)||20,Ia=$.button_text_color||((dn=f.theme)==null?void 0:dn.cta_text)||"#1a0a0a",ge=new w.Text({text:Na,style:{fontFamily:j(ft),fontSize:Ba,fontWeight:G(ft),fill:Ia,align:"center",letterSpacing:(un=L==null?void 0:L.letterSpacing)!=null?un:1}});ge.anchor.set(.5),ge.position.set(0,Me),ge.alpha=0,u.addChild(ge);let z=d==null?void 0:d.ui,mt=((pn=d==null?void 0:d.gameplay)==null?void 0:pn.tuning)||{},ja=(z==null?void 0:z.text)||"Play the full game",ht=(z==null?void 0:z.font)||"brand.body",Ga=(z==null?void 0:z.fontSize)||11,Va=(fn=z==null?void 0:z.letterSpacing)!=null?fn:0,Re=(mn=d==null?void 0:d.render)==null?void 0:mn.tint,qa=typeof Re=="string"?Re:Re?`#${Re.toString(16).padStart(6,"0")}`:"#CCCCCC",ce=new w.Text({text:ja,style:{fontFamily:j(ht),fontSize:Ga,fontWeight:G(ht),fill:qa,align:"center",letterSpacing:Va}});ce.anchor.set(.5);let Xa=Me+35+((hn=mt.animation_start_y_offset)!=null?hn:5);ce.position.set(0,Xa),ce.alpha=0,ce.animationStartYOffset=(yn=mt.animation_start_y_offset)!=null?yn:5,u.addChild(ce);let qe=((gn=p==null?void 0:p.gameplay)==null?void 0:gn.tuning)||{},$a=(bn=qe.hand_offset_x)!=null?bn:50,Ka=(_n=qe.hand_offset_y)!=null?_n:50,Ja=(xn=(wn=p==null?void 0:p.transform)==null?void 0:wn.scale)!=null?xn:.1875,Qa=(Tn=qe.hand_scale_multiplier)!=null?Tn:2.5,ie=new w.Sprite(t||w.Texture.EMPTY);return ie.anchor.set(.5),ie.scale.set(Ja*Qa),ie.position.set($a,Me+Ka),ie.alpha=0,ie.visible=!1,u.addChild(ie),{panel:u,logo:D,title:U,subtitle:re,footer:le,ctaButton:I,ctaText:ge,ctaHint:ce,hand:ie}}function ia(e,t,n){var k,C,A,_,P,Y,V,Z;let a=t.objects.get("ui_endgame_1"),i=((k=a==null?void 0:a.gameplay)==null?void 0:k.tuning)||{},s=(C=i.animation_duration_ms)!=null?C:800,o=(A=i.fade_in_duration_ms)!=null?A:600,r=(_=i.scale_animation_intensity)!=null?_:.1,l=(P=i.logo_animation_delay_ms)!=null?P:100,d=(Y=i.title_animation_delay_ms)!=null?Y:200,p=(V=i.footer_animation_delay_ms)!=null?V:300,f=(Z=i.cta_animation_delay_ms)!=null?Z:400,{panel:u,logo:c,title:h,subtitle:m,footer:g,ctaButton:x,ctaText:T,ctaHint:S}=e;u.visible=!0;let v=Date.now(),E=()=>{let N=Date.now()-v,q=Math.min(N/o,1),ae=1-Math.pow(1-q,3);u.alpha=ae,u.scale.set(1+r*(1-ae)),q<1?requestAnimationFrame(E):(setTimeout(()=>gi(c,s,t),l),setTimeout(()=>{bi(h,s),setTimeout(()=>_i(m,s),50)},d),setTimeout(()=>wi(g,s),p),setTimeout(()=>{xi(x,T,s),setTimeout(()=>Ti(S,s),50),n&&n()},f))};E()}function gi(e,t,n){var u,c,h,m,g;let a=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(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),S=1-Math.pow(1-T,2);e.alpha=r+(l-r)*S;let v=s+(1-s)*S;e.scale.set(d*v,p*v),T<1&&requestAnimationFrame(f)};f()}function bi(e,t){let n=Date.now(),a=e.alpha,i=e.y,s=()=>{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=i-20*(1-l),r<1&&requestAnimationFrame(s)};s()}function _i(e,t){var r;let n=Date.now(),a=e.alpha,i=e.position.y,s=i-((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=i+(s-i)*p,d<1&&requestAnimationFrame(o)};o()}function wi(e,t){var o;let n=Date.now(),a=e.alpha,i=(o=e.targetAlpha)!=null?o:1,s=()=>{let r=Date.now()-n,l=Math.min(r/t,1),d=1-Math.pow(1-l,2);e.alpha=a+(i-a)*d,l<1&&requestAnimationFrame(s)};s()}function xi(e,t,n){let a=Date.now(),i=e.alpha,s=()=>{let o=Date.now()-a,r=Math.min(o/n,1),l=1-Math.pow(1-r,2);e.alpha=i+(1-i)*l,t.alpha=i+(1-i)*l,e.scale.set(1+.1*(1-l)),r<1&&requestAnimationFrame(s)};s()}function Ti(e,t){var r;let n=Date.now(),a=e.alpha,i=e.position.y,s=i-((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=i+(s-i)*p,d<1&&requestAnimationFrame(o)};o()}function sa(e,t,n,a){var p,f,u,c;let i=n.objects.get("ui_endgame_hand_1"),s=((p=i==null?void 0:i.gameplay)==null?void 0:p.tuning)||{},o=(f=s.click_animation_duration_ms)!=null?f:600,r=(u=s.click_delay_ms)!=null?u:2e3,l=(c=s.click_repeat_delay_ms)!=null?c:3e3,d=()=>{var k,C;e.visible=!0,e.alpha=1;let h=e.x,m=e.y,g=(k=s.hand_offset_x)!=null?k:50,x=(C=s.hand_offset_y)!=null?C:50,T=t.x+g,S=t.y+x,v=Date.now(),E=()=>{var N,q,ae;let A=Date.now()-v,_=Math.min(A/o,1),P=_<.5?2*_*_:1-Math.pow(-2*_+2,2)/2;e.x=h+(T-h)*P,e.y=m+(S-m)*P;let Y=(q=(N=i==null?void 0:i.transform)==null?void 0:N.scale)!=null?q:.1875,V=(ae=s.hand_scale_multiplier)!=null?ae:2.5,Z=Y*V;e.scale.set(Z+Z*.2*Math.sin(_*Math.PI)),_<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 oa(e,t,n){var p,f,u,c;let a=t.objects.get("hand_tutorial_1"),i=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},s=(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=i.hand_scale_multiplier)!=null?f:2.5,d=(u=o.scale)!=null?u:.1875;return r.scale.set(d*l),r.zIndex=(c=s.z_index)!=null?c:99999,r}function ra(e){var h,m,g,x,T,S,v,E,k,C;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,a=(t==null?void 0:t.render)||{},i=((h=e.engine.runtime)==null?void 0:h.ui_styles)||{},s=((m=e.engine.runtime)==null?void 0:m.ui)||{},o=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||i.label_font_size||52,d=(x=n==null?void 0:n.letterSpacing)!=null?x:(g=i.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")}`:i.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:i.label_stroke||"#8B0000",width:2},dropShadow:{color:i.label_shadow_color||"#000000",alpha:(T=i.label_shadow_alpha)!=null?T:.8,angle:(S=i.label_shadow_angle)!=null?S:0,blur:(v=i.label_shadow_blur)!=null?v:4,distance:(E=i.label_shadow_distance)!=null?E:2}}});return c.anchor.set(.5,0),c.alpha=(k=a.alpha)!=null?k:0,c.visible=(C=a.visible)!=null?C:!0,c}function la(e,t,n,a,i){var l,d,p,f,u,c,h;let s=i.objects.get("hand_tutorial_1"),o=((l=s==null?void 0:s.gameplay)==null?void 0:l.tuning)||{},r=(s==null?void 0:s.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,S=(f=o.y_offset)!=null?f:0,v=(u=o.animation_range)!=null?u:40,E=v*.7,k=v,C=t.x+T+E,A=t.y+S+k,_=C+E,P=A+k;e.x=C+(_-C)*x,e.y=A+(P-A)*x;let Y=(c=r.scale)!=null?c:.1875,V=(h=o.hand_scale_multiplier)!=null?h:2.5;e.scale.set(Y*V)}}var W=require("pixi.js"),at=null,it=null;async function ca(){if(at)return at;if(!it){let t=typeof window!="undefined"?window.location.pathname:"",n=t.substring(0,t.lastIndexOf("/")+1),o="./"+"inline-assets"+".js";it=new Function("path","return import(path)")(o).then(r=>r.INLINE_ASSETS||{}).catch(()=>({}))}let e=await it;return at=e||{},e||{}}function vi(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 i=a.split("/").pop();if(i&&t[i])return t[i];let s=a.replace(/^\.?\/*/,"");if(s!==a&&t[s])return t[s]}function da(e,t){let n=vi(e,t);if(!n)throw new Error(`[assets] inline asset not found: ${e}`);return n}async function ua(e,t,n=16777215,a=!1){let i=await ca(),s=da(e,i);try{return await W.Assets.load(s)}catch{throw new Error(`[assets] inline asset failed to load: ${e}`)}}async function pa(e,t,n){var m,g,x,T,S,v,E,k,C,A;let a=await ca(),i=da(e,a),s;try{s=await W.Assets.load(i),console.log("[character] loaded sheet",{path:e,sourceUsed:i})}catch{throw new Error(`[assets] inline character sheet failed to load: ${e}`)}let o=s.source||s.baseTexture||s;o&&"valid"in o&&o.valid===!1&&typeof o.once=="function"&&await new Promise(_=>o.once("loaded",_));let r=n.gameplay.character_sheet||{},l=(m=r.cols)!=null?m:3,d=(g=r.rows)!=null?g:2,p=(v=(S=(x=o==null?void 0:o.width)!=null?x:o==null?void 0:o.pixelWidth)!=null?S:(T=o==null?void 0:o.baseTexture)==null?void 0:T.width)!=null?v:s.width,f=(A=(C=(E=o==null?void 0:o.height)!=null?E:o==null?void 0:o.pixelHeight)!=null?C:(k=o==null?void 0:o.baseTexture)==null?void 0:k.height)!=null?A:s.height,u=p/l,c=f/d;if(!Number.isFinite(u)||!Number.isFinite(c)||u<=0||c<=0||!o)return[s];let h=[];for(let _=0;_<d;_++)for(let P=0;P<l;P++)h.push(new W.Texture({source:o,frame:new W.Rectangle(P*u,_*c,u,c)}));return h.length>2&&h.push(...h.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:h.length}),h}function fa(e,t){var p,f,u,c;let n=t.gameplay.brush||{},a=new W.Color(t.theme.brush_color||"#ffffff").toNumber(),i=(p=n.radius)!=null?p:20,s=(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 W.Graphics;return d.circle(0,0,i).fill({color:a,alpha:o}),d.circle(0,0,s).fill({color:new W.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 ta(e,t={}){let n=new ea.Application;await n.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let a=s=>{var l,d,p,f,u,c;let o=(p=(d=(l=s==null?void 0:s.width)!=null?l:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(c=(u=(f=s==null?void 0:s.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 i=document.createElement("div");return i.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(i),je.on("pause",()=>{n.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),je.on("resume",()=>{n.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),je.on("resize",({payload:s})=>{a({width:s==null?void 0:s.width,height:s==null?void 0:s.height})}),window.addEventListener("resize",()=>a()),requestAnimationFrame(()=>a()),{app:n,stage:n.stage,overlay:i,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,i,s;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=(i=t==null?void 0:t.visible)!=null?i:!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)}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)}},Ee=class{constructor(t,n,a,i){this.instanceId=t,this.objectConfig=n,this.pixiObject=a,this._config=i,this.transform=new Se(i.transform),this.renderer=new Ce(i.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)}},Be=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 i=new Ee(t,a.object_config||t,n,a);return this.objects.set(t,i),i}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,a]of this.objects.entries()){let i=t.objects.get(n);i&&a.updateConfig(i)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var Ge={"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 K(e){let t=Ge[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function X(e){var n;let t=Ge[e];return t&&(n=t.weight)!=null?n:"400"}function na(e,t){Ge[e]=t}function aa(){return Object.keys(Ge)}var b=require("pixi.js");function ia(e,t,n){var gt,_t,bt,wt,xt,vt,Tt,At,St,Ct,Et,kt,Pt,Dt,Ft,Mt,Lt,Rt,zt,Ot,Ht,Wt,It,Nt,Yt,jt,Bt,Gt,Vt,qt,Kt,Xt,$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,vn,Tn;let a=e.objects.get("ui_endgame_1"),i=e.objects.get("ui_endgame_logo_1"),s=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 b.Container;u.alpha=0,u.visible=!1;let c=((gt=a==null?void 0:a.gameplay)==null?void 0:gt.tuning)||{},h=(a==null?void 0:a.render)||{},m=(_t=c.panel_width)!=null?_t:320,g=(bt=c.panel_height)!=null?bt:400,x=(wt=c.panel_padding)!=null?wt:32,v=(xt=c.panel_radius)!=null?xt:24,w=h.background_color||c.panel_bg_color||"#1a0a0a",T=h.background_alpha!==void 0&&h.background_alpha!==null?h.background_alpha:(vt=c.panel_bg_alpha)!=null?vt:.98,E=h.border_color||c.panel_border_color||"#ffffff",k=(Tt=c.panel_border_width)!=null?Tt:2,A=(At=c.panel_border_alpha)!=null?At:.3,S=new b.Graphics;S.roundRect(-m/2,-g/2,m,g,v);let P=w.replace("#","");S.fill({color:parseInt(P,16),alpha:T});let L=E.replace("#","");S.stroke({color:parseInt(L,16),width:k,alpha:A});let D=new b.Graphics;D.roundRect(-m/2+2,-g/2+2,m-4,g-4,v-2),D.stroke({color:16777215,width:1,alpha:.1}),S.addChild(D),u.addChild(S);let R=((St=i==null?void 0:i.gameplay)==null?void 0:St.tuning)||{},B=(i==null?void 0:i.transform)||{},F=(Ct=R.logo_size)!=null?Ct:56,z=(Et=B.scale)!=null?Et:1,G=(Pt=(kt=B.offset)==null?void 0:kt.y)!=null?Pt:-130,ee=(Dt=R.logo_alpha)!=null?Dt:1,C=new b.Sprite(n||b.Texture.EMPTY);C.anchor.set(.5);let oe=0,re=0;if(n&&n!==b.Texture.EMPTY){let M=n.frame,Q=n.baseTexture;M&&M.width&&M.height?(oe=M.width,re=M.height):Q&&Q.width&&Q.height?(oe=Q.width,re=Q.height):n.width&&n.height&&(oe=n.width,re=n.height)}if(oe>0&&re>0){let M=oe/re,Q,Xe;M>1?(Q=F,Xe=F/M):(Xe=F,Q=F*M);let An=Q/oe,Sn=Xe/re;An*=z,Sn*=z,C.scale.set(An,Sn)}else{let M=F/100*z;C.scale.set(M)}C.position.set(0,G),C.alpha=0,C.visible=!0,C.targetAlpha=ee,C.baseScaleX=C.scale.x,C.baseScaleY=C.scale.y,u.addChild(C);let O=s==null?void 0:s.ui,V=((Ft=s==null?void 0:s.gameplay)==null?void 0:Ft.tuning)||{},ha=(O==null?void 0:O.text)||"MISSION ACCOMPLISHED",ot=(O==null?void 0:O.font)||"brand.heading",ya=(O==null?void 0:O.fontSize)||24,ga=(Mt=O==null?void 0:O.letterSpacing)!=null?Mt:1,ke=(Lt=s==null?void 0:s.render)==null?void 0:Lt.tint,_a=typeof ke=="string"?ke:ke?`#${ke.toString(16).padStart(6,"0")}`:"#00FF88",rt=m-x*2-30,ba=V.font_weight_override?V.font_weight_override:X(ot),te=new b.Text({text:ha,style:{fontFamily:K(ot),fontSize:ya,fontWeight:ba,fill:_a,align:"center",letterSpacing:ga,wordWrap:!1,stroke:{color:V.stroke_color||"#000000",width:(Rt=V.stroke_width)!=null?Rt:2},dropShadow:{color:V.shadow_color||"#000000",alpha:(zt=V.shadow_alpha)!=null?zt:.9,angle:(Ot=V.shadow_angle)!=null?Ot:0,blur:(Ht=V.shadow_blur)!=null?Ht:8,distance:(Wt=V.shadow_distance)!=null?Wt:4}}});if(te.width>rt){let M=rt/te.width;te.scale.set(M)}te.anchor.set(.5);let lt=(It=c.title_offset_y)!=null?It:30,wa=lt+((Nt=V.animation_start_y_offset)!=null?Nt:-20);te.position.set(0,wa),te.alpha=0,u.addChild(te);let H=o==null?void 0:o.ui,ct=((Yt=o==null?void 0:o.gameplay)==null?void 0:Yt.tuning)||{},xa=(H==null?void 0:H.text)||"RESCUE COMPLETE",dt=(H==null?void 0:H.font)||"brand.body",va=(H==null?void 0:H.fontSize)||11,Ta=(jt=H==null?void 0:H.letterSpacing)!=null?jt:.5,Pe=(Bt=o==null?void 0:o.render)==null?void 0:Bt.tint,Aa=typeof Pe=="string"?Pe:Pe?`#${Pe.toString(16).padStart(6,"0")}`:"#B0B0B0",le=new b.Text({text:xa,style:{fontFamily:K(dt),fontSize:va,fontWeight:X(dt),fill:Aa,align:"center",letterSpacing:Ta}});le.anchor.set(.5);let Sa=lt+20+((Gt=ct.animation_start_y_offset)!=null?Gt:-10);le.position.set(0,Sa),le.alpha=0,le.animationStartYOffset=(Vt=ct.animation_start_y_offset)!=null?Vt:-10,u.addChild(le);let $=r==null?void 0:r.ui,ut=((qt=r==null?void 0:r.gameplay)==null?void 0:qt.tuning)||{},Ca=($==null?void 0:$.text)||((Kt=f.ui)==null?void 0:Kt.cta_hint)||"Continue the adventure!",pt=($==null?void 0:$.font)||"brand.body",Ea=($==null?void 0:$.fontSize)||16,De=(Xt=r==null?void 0:r.render)==null?void 0:Xt.tint,ka=typeof De=="string"?De:De?`#${De.toString(16).padStart(6,"0")}`:"#FFFFFF",Pa=($t=ut.max_width)!=null?$t:m-x*2,Da=(Jt=ut.line_height)!=null?Jt:1.4,ce=new b.Text({text:Ca,style:{fontFamily:K(pt),fontSize:Ea,fontWeight:X(pt),fill:ka,align:"center",wordWrap:!0,wordWrapWidth:Pa,lineHeight:Da}});ce.anchor.set(.5);let Fa=(Qt=c.footer_offset_y)!=null?Qt:120;ce.position.set(0,Fa);let Ma=((Zt=r==null?void 0:r.render)==null?void 0:Zt.alpha)!==void 0&&((Ut=r==null?void 0:r.render)==null?void 0:Ut.alpha)!==null?r.render.alpha:1;ce.alpha=0,ce.targetAlpha=Ma,u.addChild(ce);let J=((en=l==null?void 0:l.gameplay)==null?void 0:en.tuning)||{},W=l==null?void 0:l.ui,Fe=(tn=J.button_width)!=null?tn:260,Me=(nn=J.button_height)!=null?nn:56,ft=(an=J.button_radius)!=null?an:16,La=J.button_bg_color||((sn=f.theme)==null?void 0:sn.cta_background)||"#ffb43b",Ra=(on=J.button_bg_alpha)!=null?on:1,za=J.button_border_color||"#ffffff",Oa=(rn=J.button_border_width)!=null?rn:2,Ha=(ln=J.button_border_alpha)!=null?ln:.2,Le=(cn=c.cta_offset_y)!=null?cn:160,q=new b.Graphics;q.roundRect(-Fe/2,-Me/2,Fe,Me,ft);let Wa=La.replace("#","");q.fill({color:parseInt(Wa,16),alpha:Ra});let Ia=za.replace("#","");q.stroke({color:parseInt(Ia,16),width:Oa,alpha:Ha});let qe=new b.Graphics;qe.roundRect(-Fe/2+2,-Me/2+2,Fe-4,Me-4,ft-2),qe.stroke({color:0,width:1,alpha:.15}),q.addChild(qe),q.position.set(0,Le),q.alpha=0,q.eventMode="static",q.cursor="pointer",u.addChild(q);let Na=(W==null?void 0:W.text)||((dn=f.ui)==null?void 0:dn.cta_label_end)||"DOWNLOAD",mt=(W==null?void 0:W.font)||"brand.heading",Ya=(W==null?void 0:W.fontSize)||20,ja=J.button_text_color||((un=f.theme)==null?void 0:un.cta_text)||"#1a0a0a",_e=new b.Text({text:Na,style:{fontFamily:K(mt),fontSize:Ya,fontWeight:X(mt),fill:ja,align:"center",letterSpacing:(pn=W==null?void 0:W.letterSpacing)!=null?pn:1}});_e.anchor.set(.5),_e.position.set(0,Le),_e.alpha=0,u.addChild(_e);let I=d==null?void 0:d.ui,ht=((fn=d==null?void 0:d.gameplay)==null?void 0:fn.tuning)||{},Ba=(I==null?void 0:I.text)||"Play the full game",yt=(I==null?void 0:I.font)||"brand.body",Ga=(I==null?void 0:I.fontSize)||11,Va=(mn=I==null?void 0:I.letterSpacing)!=null?mn:0,Re=(hn=d==null?void 0:d.render)==null?void 0:hn.tint,qa=typeof Re=="string"?Re:Re?`#${Re.toString(16).padStart(6,"0")}`:"#CCCCCC",de=new b.Text({text:Ba,style:{fontFamily:K(yt),fontSize:Ga,fontWeight:X(yt),fill:qa,align:"center",letterSpacing:Va}});de.anchor.set(.5);let Ka=Le+35+((yn=ht.animation_start_y_offset)!=null?yn:5);de.position.set(0,Ka),de.alpha=0,de.animationStartYOffset=(gn=ht.animation_start_y_offset)!=null?gn:5,u.addChild(de);let Ke=((_n=p==null?void 0:p.gameplay)==null?void 0:_n.tuning)||{},Xa=(bn=Ke.hand_offset_x)!=null?bn:50,$a=(wn=Ke.hand_offset_y)!=null?wn:50,Ja=(vn=(xn=p==null?void 0:p.transform)==null?void 0:xn.scale)!=null?vn:.1875,Qa=(Tn=Ke.hand_scale_multiplier)!=null?Tn:2.5,se=new b.Sprite(t||b.Texture.EMPTY);return se.anchor.set(.5),se.scale.set(Ja*Qa),se.position.set(Xa,Le+$a),se.alpha=0,se.visible=!1,u.addChild(se),{panel:u,logo:C,title:te,subtitle:le,footer:ce,ctaButton:q,ctaText:_e,ctaHint:de,hand:se}}function sa(e,t,n){var k,A,S,P,L,D,R,B;let a=t.objects.get("ui_endgame_1"),i=((k=a==null?void 0:a.gameplay)==null?void 0:k.tuning)||{},s=(A=i.animation_duration_ms)!=null?A:800,o=(S=i.fade_in_duration_ms)!=null?S:600,r=(P=i.scale_animation_intensity)!=null?P:.1,l=(L=i.logo_animation_delay_ms)!=null?L:100,d=(D=i.title_animation_delay_ms)!=null?D:200,p=(R=i.footer_animation_delay_ms)!=null?R:300,f=(B=i.cta_animation_delay_ms)!=null?B:400,{panel:u,logo:c,title:h,subtitle:m,footer:g,ctaButton:x,ctaText:v,ctaHint:w}=e;u.visible=!0;let T=Date.now(),E=()=>{let F=Date.now()-T,z=Math.min(F/o,1),G=1-Math.pow(1-z,3);u.alpha=G,u.scale.set(1+r*(1-G)),z<1?requestAnimationFrame(E):(setTimeout(()=>gi(c,s,t),l),setTimeout(()=>{_i(h,s),setTimeout(()=>bi(m,s),50)},d),setTimeout(()=>wi(g,s),p),setTimeout(()=>{xi(x,v,s),setTimeout(()=>vi(w,s),50),n&&n()},f))};E()}function gi(e,t,n){var u,c,h,m,g;let a=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(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,v=Math.min(x/t,1),w=1-Math.pow(1-v,2);e.alpha=r+(l-r)*w;let T=s+(1-s)*w;e.scale.set(d*T,p*T),v<1&&requestAnimationFrame(f)};f()}function _i(e,t){let n=Date.now(),a=e.alpha,i=e.y,s=()=>{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=i-20*(1-l),r<1&&requestAnimationFrame(s)};s()}function bi(e,t){var r;let n=Date.now(),a=e.alpha,i=e.position.y,s=i-((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=i+(s-i)*p,d<1&&requestAnimationFrame(o)};o()}function wi(e,t){var o;let n=Date.now(),a=e.alpha,i=(o=e.targetAlpha)!=null?o:1,s=()=>{let r=Date.now()-n,l=Math.min(r/t,1),d=1-Math.pow(1-l,2);e.alpha=a+(i-a)*d,l<1&&requestAnimationFrame(s)};s()}function xi(e,t,n){let a=Date.now(),i=e.alpha,s=()=>{let o=Date.now()-a,r=Math.min(o/n,1),l=1-Math.pow(1-r,2);e.alpha=i+(1-i)*l,t.alpha=i+(1-i)*l,e.scale.set(1+.1*(1-l)),r<1&&requestAnimationFrame(s)};s()}function vi(e,t){var r;let n=Date.now(),a=e.alpha,i=e.position.y,s=i-((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=i+(s-i)*p,d<1&&requestAnimationFrame(o)};o()}function oa(e,t,n,a){var p,f,u,c;let i=n.objects.get("ui_endgame_hand_1"),s=((p=i==null?void 0:i.gameplay)==null?void 0:p.tuning)||{},o=(f=s.click_animation_duration_ms)!=null?f:600,r=(u=s.click_delay_ms)!=null?u:2e3,l=(c=s.click_repeat_delay_ms)!=null?c:3e3,d=()=>{var k,A;e.visible=!0,e.alpha=1;let h=e.x,m=e.y,g=(k=s.hand_offset_x)!=null?k:50,x=(A=s.hand_offset_y)!=null?A:50,v=t.x+g,w=t.y+x,T=Date.now(),E=()=>{var F,z,G;let S=Date.now()-T,P=Math.min(S/o,1),L=P<.5?2*P*P:1-Math.pow(-2*P+2,2)/2;e.x=h+(v-h)*L,e.y=m+(w-m)*L;let D=(z=(F=i==null?void 0:i.transform)==null?void 0:F.scale)!=null?z:.1875,R=(G=s.hand_scale_multiplier)!=null?G:2.5,B=D*R;e.scale.set(B+B*.2*Math.sin(P*Math.PI)),P<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 Ve=require("pixi.js");function ra(e,t,n){var p,f,u,c;let a=t.objects.get("hand_tutorial_1"),i=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},s=(a==null?void 0:a.render)||{},o=(a==null?void 0:a.transform)||{},r=new Ve.Sprite(e);r.anchor.set(.5),r.alpha=0;let l=(f=i.hand_scale_multiplier)!=null?f:2.5,d=(u=o.scale)!=null?u:.1875;return r.scale.set(d*l),r.zIndex=(c=s.z_index)!=null?c:99999,r}function la(e){var h,m,g,x,v,w,T,E,k,A;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,a=(t==null?void 0:t.render)||{},i=((h=e.engine.runtime)==null?void 0:h.ui_styles)||{},s=((m=e.engine.runtime)==null?void 0:m.ui)||{},o=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||i.label_font_size||52,d=(x=n==null?void 0:n.letterSpacing)!=null?x:(g=i.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")}`:i.label_fill||"#FFF1C1",c=new Ve.Text({text:o,style:{fontFamily:K(r),fontSize:l,fontWeight:X(r),fill:u,align:p,letterSpacing:d,stroke:{color:i.label_stroke||"#8B0000",width:2},dropShadow:{color:i.label_shadow_color||"#000000",alpha:(v=i.label_shadow_alpha)!=null?v:.8,angle:(w=i.label_shadow_angle)!=null?w:0,blur:(T=i.label_shadow_blur)!=null?T:4,distance:(E=i.label_shadow_distance)!=null?E:2}}});return c.anchor.set(.5,0),c.alpha=(k=a.alpha)!=null?k:0,c.visible=(A=a.visible)!=null?A:!0,c}function ca(e,t,n,a,i){var l,d,p,f,u,c,h;let s=i.objects.get("hand_tutorial_1"),o=((l=s==null?void 0:s.gameplay)==null?void 0:l.tuning)||{},r=(s==null?void 0:s.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,v=(p=o.x_offset)!=null?p:0,w=(f=o.y_offset)!=null?f:0,T=(u=o.animation_range)!=null?u:40,E=T*.7,k=T,A=t.x+v+E,S=t.y+w+k,P=A+E,L=S+k;e.x=A+(P-A)*x,e.y=S+(L-S)*x;let D=(c=r.scale)!=null?c:.1875,R=(h=o.hand_scale_multiplier)!=null?h:2.5;e.scale.set(D*R)}}var j=require("pixi.js"),it=null,st=null;async function da(){if(it)return it;if(!st){let n=(()=>{if(typeof window!="undefined")try{return new URL("inline-assets.js",window.location.href).href}catch{return"./inline-assets.js"}return"./inline-assets.js"})();st=new Function("path","return import(path)")(n).then(a=>a?a.INLINE_ASSETS?a.INLINE_ASSETS:(console.warn("[assets] Module does not have INLINE_ASSETS export. Module keys:",Object.keys(a)),{}):(console.warn("[assets] Module import returned undefined"),{})).catch(a=>(console.warn("[assets] Failed to load inline-assets.js:",a),{}))}let e=await st;return it=e||{},e||{}}function Ti(e,t){if(!e)return;let n=t[e];if(n)return console.log("[assets] resolveInlineAsset: direct match",{path:e}),n;let a=e.split("?")[0].split("#")[0];if(a!==e&&t[a])return console.log("[assets] resolveInlineAsset: trimmed match",{path:e,trimmed:a}),t[a];let i=a.split("/").pop();if(i&&t[i])return console.log("[assets] resolveInlineAsset: filename match",{path:e,filename:i}),t[i];let s=a.replace(/^\.?\/*/,"");if(s!==a&&t[s])return console.log("[assets] resolveInlineAsset: normalized match",{path:e,normalized:s}),t[s];console.warn("[assets] resolveInlineAsset: no match found",{path:e,trimmed:a,filename:i,normalized:s,availableKeys:Object.keys(t).slice(0,10)})}function ua(e,t){let n=Ti(e,t);if(!n)throw new Error(`[assets] inline asset not found: ${e}`);return n}async function pa(e,t,n=16777215,a=!1){let i=await da(),s=ua(e,i);console.log("[assets] loadAsset",{path:e,resolvedSource:(s==null?void 0:s.substring(0,50))+"...",hasInlineMap:!!i,inlineMapKeys:Object.keys(i).length});try{let o=await j.Assets.load(s);return console.log("[assets] loadAsset success",{path:e,textureWidth:o.width,textureHeight:o.height}),o}catch(o){throw console.error("[assets] loadAsset failed",{path:e,source:s,error:o}),new Error(`[assets] inline asset failed to load: ${e}`)}}async function fa(e,t,n){var m,g,x,v,w,T,E,k,A,S,P,L,D,R,B,F,z,G;let a=await da(),i=ua(e,a),s;try{s=await j.Assets.load(i),console.log("[character] loaded sheet",{path:e,sourceUsed:i})}catch{throw new Error(`[assets] inline character sheet failed to load: ${e}`)}let o=s.source||s.baseTexture||s;o&&"valid"in o&&o.valid===!1&&typeof o.once=="function"&&await new Promise(ee=>o.once("loaded",ee));let r=((m=n==null?void 0:n.gameplay)==null?void 0:m.character_sheet)||((v=(x=(g=n==null?void 0:n.engine)==null?void 0:g.runtime)==null?void 0:x.gameplay)==null?void 0:v.character_sheet)||((k=(E=(T=(w=n==null?void 0:n.objects)==null?void 0:w.get)==null?void 0:T.call(w,"character_1"))==null?void 0:E.gameplay)==null?void 0:k.character_sheet)||{},l=(A=r.cols)!=null?A:3,d=(S=r.rows)!=null?S:2,p=(R=(D=(P=o==null?void 0:o.width)!=null?P:o==null?void 0:o.pixelWidth)!=null?D:(L=o==null?void 0:o.baseTexture)==null?void 0:L.width)!=null?R:s.width,f=(G=(z=(B=o==null?void 0:o.height)!=null?B:o==null?void 0:o.pixelHeight)!=null?z:(F=o==null?void 0:o.baseTexture)==null?void 0:F.height)!=null?G:s.height,u=p/l,c=f/d;if(!Number.isFinite(u)||!Number.isFinite(c)||u<=0||c<=0||!o)return[s];let h=[];for(let ee=0;ee<d;ee++)for(let C=0;C<l;C++)h.push(new j.Texture({source:o,frame:new j.Rectangle(C*u,ee*c,u,c)}));return h.length>2&&h.push(...h.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:h.length}),h}function ma(e,t){var p,f,u,c;let n=t.gameplay.brush||{},a=new j.Color(t.theme.brush_color||"#ffffff").toNumber(),i=(p=n.radius)!=null?p:20,s=(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 j.Graphics;return d.circle(0,0,i).fill({color:a,alpha:o}),d.circle(0,0,s).fill({color:new j.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});
|
package/dist/pixi/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as lt}from"../chunk-6MYM2EUT.mjs";import{Application as Dn}from"pixi.js";async function Yn(e,t={}){let n=new Dn;await n.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let i=a=>{var c,d,p,u,h,l;let o=(p=(d=(c=a==null?void 0:a.width)!=null?c:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(l=(h=(u=a==null?void 0:a.height)!=null?u:e.clientHeight)!=null?h:window.innerHeight)!=null?l: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),lt.on("pause",()=>{n.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),lt.on("resume",()=>{n.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),lt.on("resize",({payload:a})=>{i({width:a==null?void 0:a.width,height:a==null?void 0:a.height})}),window.addEventListener("resize",()=>i()),requestAnimationFrame(()=>i()),{app:n,stage:n.stage,overlay:s,applySize:i}}var ct=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)}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 n,i,s,a;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=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(a=t==null?void 0:t.tint)!=null?a: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,n,i,s){this.instanceId=t,this.objectConfig=n,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,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)}},gt=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 s=new ht(t,i.object_config||t,n,i);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,i]of this.objects.entries()){let s=t.objects.get(n);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 N(e){var n;let t=pt[e];return t&&(n=t.weight)!=null?n:"400"}function kn(e,t){pt[e]=t}function zn(){return Object.keys(pt)}import{Container as Mn,Graphics as ut,Text as tt,Sprite as Ge,Texture as _t}from"pixi.js";function Hn(e,t,n){var kt,zt,Mt,Ht,Wt,Rt,Bt,Lt,Gt,qt,Xt,Nt,$t,jt,Vt,Jt,Kt,Qt,Zt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,de,he,pe,ue,fe,me,ye,ge,_e,be,xe,we,Te,Ce,Se,Ae,ve,Fe,Pe,Ee,De,Ye,ke,ze,Me,He,We,Re;let i=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),a=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 Mn;h.alpha=0,h.visible=!1;let l=((kt=i==null?void 0:i.gameplay)==null?void 0:kt.tuning)||{},f=(i==null?void 0:i.render)||{},m=(zt=l.panel_width)!=null?zt:320,y=(Mt=l.panel_height)!=null?Mt:400,_=(Ht=l.panel_padding)!=null?Ht:32,b=(Wt=l.panel_radius)!=null?Wt:24,C=f.background_color||l.panel_bg_color||"#1a0a0a",x=f.background_alpha!==void 0&&f.background_alpha!==null?f.background_alpha:(Rt=l.panel_bg_alpha)!=null?Rt:.98,S=f.border_color||l.panel_border_color||"#ffffff",A=(Bt=l.panel_border_width)!=null?Bt:2,w=(Lt=l.panel_border_alpha)!=null?Lt:.3,T=new ut;T.roundRect(-m/2,-y/2,m,y,b);let g=C.replace("#","");T.fill({color:parseInt(g,16),alpha:x});let v=S.replace("#","");T.stroke({color:parseInt(v,16),width:A,alpha:w});let z=new ut;z.roundRect(-m/2+2,-y/2+2,m-4,y-4,b-2),z.stroke({color:16777215,width:1,alpha:.1}),T.addChild(z),h.addChild(T);let R=((Gt=s==null?void 0:s.gameplay)==null?void 0:Gt.tuning)||{},$=(s==null?void 0:s.transform)||{},M=(qt=R.logo_size)!=null?qt:56,B=(Xt=$.scale)!=null?Xt:1,V=($t=(Nt=$.offset)==null?void 0:Nt.y)!=null?$t:-130,je=(jt=R.logo_alpha)!=null?jt:1,F=new Ge(n||_t.EMPTY);F.anchor.set(.5);let K=0,Q=0;if(n&&n!==_t.EMPTY){let P=n.frame,q=n.baseTexture;P&&P.width&&P.height?(K=P.width,Q=P.height):q&&q.width&&q.height?(K=q.width,Q=q.height):n.width&&n.height&&(K=n.width,Q=n.height)}if(K>0&&Q>0){let P=K/Q,q,yt;P>1?(q=M,yt=M/P):(yt=M,q=M*P);let Be=q/K,Le=yt/Q;Be*=B,Le*=B,F.scale.set(Be,Le)}else{let P=M/100*B;F.scale.set(P)}F.position.set(0,V),F.alpha=0,F.visible=!0,F.targetAlpha=je,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,h.addChild(F);let E=a==null?void 0:a.ui,H=((Vt=a==null?void 0:a.gameplay)==null?void 0:Vt.tuning)||{},Ve=(E==null?void 0:E.text)||"MISSION ACCOMPLISHED",wt=(E==null?void 0:E.font)||"brand.heading",Je=(E==null?void 0:E.fontSize)||24,Ke=(Jt=E==null?void 0:E.letterSpacing)!=null?Jt:1,et=(Kt=a==null?void 0:a.render)==null?void 0:Kt.tint,Qe=typeof et=="string"?et:et?`#${et.toString(16).padStart(6,"0")}`:"#00FF88",Tt=m-_*2-30,Ze=H.font_weight_override?H.font_weight_override:N(wt),j=new tt({text:Ve,style:{fontFamily:X(wt),fontSize:Je,fontWeight:Ze,fill:Qe,align:"center",letterSpacing:Ke,wordWrap:!1,stroke:{color:H.stroke_color||"#000000",width:(Qt=H.stroke_width)!=null?Qt:2},dropShadow:{color:H.shadow_color||"#000000",alpha:(Zt=H.shadow_alpha)!=null?Zt:.9,angle:(Ot=H.shadow_angle)!=null?Ot:0,blur:(It=H.shadow_blur)!=null?It:8,distance:(Ut=H.shadow_distance)!=null?Ut:4}}});if(j.width>Tt){let P=Tt/j.width;j.scale.set(P)}j.anchor.set(.5);let Ct=(te=l.title_offset_y)!=null?te:30,Oe=Ct+((ee=H.animation_start_y_offset)!=null?ee:-20);j.position.set(0,Oe),j.alpha=0,h.addChild(j);let D=o==null?void 0:o.ui,St=((ne=o==null?void 0:o.gameplay)==null?void 0:ne.tuning)||{},Ie=(D==null?void 0:D.text)||"RESCUE COMPLETE",At=(D==null?void 0:D.font)||"brand.body",Ue=(D==null?void 0:D.fontSize)||11,tn=(ae=D==null?void 0:D.letterSpacing)!=null?ae:.5,nt=(se=o==null?void 0:o.render)==null?void 0:se.tint,en=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=new tt({text:Ie,style:{fontFamily:X(At),fontSize:Ue,fontWeight:N(At),fill:en,align:"center",letterSpacing:tn}});Z.anchor.set(.5);let nn=Ct+20+((ie=St.animation_start_y_offset)!=null?ie:-10);Z.position.set(0,nn),Z.alpha=0,Z.animationStartYOffset=(oe=St.animation_start_y_offset)!=null?oe:-10,h.addChild(Z);let L=r==null?void 0:r.ui,vt=((re=r==null?void 0:r.gameplay)==null?void 0:re.tuning)||{},an=(L==null?void 0:L.text)||((le=u.ui)==null?void 0:le.cta_hint)||"Continue the adventure!",Ft=(L==null?void 0:L.font)||"brand.body",sn=(L==null?void 0:L.fontSize)||16,at=(ce=r==null?void 0:r.render)==null?void 0:ce.tint,on=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#FFFFFF",rn=(de=vt.max_width)!=null?de:m-_*2,ln=(he=vt.line_height)!=null?he:1.4,O=new tt({text:an,style:{fontFamily:X(Ft),fontSize:sn,fontWeight:N(Ft),fill:on,align:"center",wordWrap:!0,wordWrapWidth:rn,lineHeight:ln}});O.anchor.set(.5);let cn=(pe=l.footer_offset_y)!=null?pe:120;O.position.set(0,cn);let dn=((ue=r==null?void 0:r.render)==null?void 0:ue.alpha)!==void 0&&((fe=r==null?void 0:r.render)==null?void 0:fe.alpha)!==null?r.render.alpha:1;O.alpha=0,O.targetAlpha=dn,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=(ye=G.button_width)!=null?ye:260,it=(ge=G.button_height)!=null?ge:56,Pt=(_e=G.button_radius)!=null?_e:16,hn=G.button_bg_color||((be=u.theme)==null?void 0:be.cta_background)||"#ffb43b",pn=(xe=G.button_bg_alpha)!=null?xe:1,un=G.button_border_color||"#ffffff",fn=(we=G.button_border_width)!=null?we:2,mn=(Te=G.button_border_alpha)!=null?Te:.2,ot=(Ce=l.cta_offset_y)!=null?Ce:160,W=new ut;W.roundRect(-st/2,-it/2,st,it,Pt);let yn=hn.replace("#","");W.fill({color:parseInt(yn,16),alpha:pn});let gn=un.replace("#","");W.stroke({color:parseInt(gn,16),width:fn,alpha:mn});let ft=new ut;ft.roundRect(-st/2+2,-it/2+2,st-4,it-4,Pt-2),ft.stroke({color:0,width:1,alpha:.15}),W.addChild(ft),W.position.set(0,ot),W.alpha=0,W.eventMode="static",W.cursor="pointer",h.addChild(W);let _n=(Y==null?void 0:Y.text)||((Se=u.ui)==null?void 0:Se.cta_label_end)||"DOWNLOAD",Et=(Y==null?void 0:Y.font)||"brand.heading",bn=(Y==null?void 0:Y.fontSize)||20,xn=G.button_text_color||((Ae=u.theme)==null?void 0:Ae.cta_text)||"#1a0a0a",U=new tt({text:_n,style:{fontFamily:X(Et),fontSize:bn,fontWeight:N(Et),fill:xn,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,Dt=((Fe=d==null?void 0:d.gameplay)==null?void 0:Fe.tuning)||{},wn=(k==null?void 0:k.text)||"Play the full game",Yt=(k==null?void 0:k.font)||"brand.body",Tn=(k==null?void 0:k.fontSize)||11,Cn=(Pe=k==null?void 0:k.letterSpacing)!=null?Pe:0,rt=(Ee=d==null?void 0:d.render)==null?void 0:Ee.tint,Sn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",I=new tt({text:wn,style:{fontFamily:X(Yt),fontSize:Tn,fontWeight:N(Yt),fill:Sn,align:"center",letterSpacing:Cn}});I.anchor.set(.5);let An=ot+35+((De=Dt.animation_start_y_offset)!=null?De:5);I.position.set(0,An),I.alpha=0,I.animationStartYOffset=(Ye=Dt.animation_start_y_offset)!=null?Ye:5,h.addChild(I);let mt=((ke=p==null?void 0:p.gameplay)==null?void 0:ke.tuning)||{},vn=(ze=mt.hand_offset_x)!=null?ze:50,Fn=(Me=mt.hand_offset_y)!=null?Me:50,Pn=(We=(He=p==null?void 0:p.transform)==null?void 0:He.scale)!=null?We:.1875,En=(Re=mt.hand_scale_multiplier)!=null?Re:2.5,J=new Ge(t||_t.EMPTY);return J.anchor.set(.5),J.scale.set(Pn*En),J.position.set(vn,ot+Fn),J.alpha=0,J.visible=!1,h.addChild(J),{panel:h,logo:F,title:j,subtitle:Z,footer:O,ctaButton:W,ctaText:U,ctaHint:I,hand:J}}function Wn(e,t,n){var A,w,T,g,v,z,R,$;let i=t.objects.get("ui_endgame_1"),s=((A=i==null?void 0:i.gameplay)==null?void 0:A.tuning)||{},a=(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=(v=s.logo_animation_delay_ms)!=null?v:100,d=(z=s.title_animation_delay_ms)!=null?z:200,p=(R=s.footer_animation_delay_ms)!=null?R:300,u=($=s.cta_animation_delay_ms)!=null?$:400,{panel:h,logo:l,title:f,subtitle:m,footer:y,ctaButton:_,ctaText:b,ctaHint:C}=e;h.visible=!0;let x=Date.now(),S=()=>{let M=Date.now()-x,B=Math.min(M/o,1),V=1-Math.pow(1-B,3);h.alpha=V,h.scale.set(1+r*(1-V)),B<1?requestAnimationFrame(S):(setTimeout(()=>Rn(l,a,t),c),setTimeout(()=>{Bn(f,a),setTimeout(()=>Ln(m,a),50)},d),setTimeout(()=>Gn(y,a),p),setTimeout(()=>{qn(_,b,a),setTimeout(()=>Xn(C,a),50),n&&n()},u))};S()}function Rn(e,t,n){var h,l,f,m,y;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),a=(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=(f=e.targetAlpha)!=null?f:1,d=(m=e.baseScaleX)!=null?m: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=a+(1-a)*C;e.scale.set(d*x,p*x),b<1&&requestAnimationFrame(u)};u()}function Bn(e,t){let n=Date.now(),i=e.alpha,s=e.y,a=()=>{let o=Date.now()-n,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(a)};a()}function Ln(e,t){var r;let n=Date.now(),i=e.alpha,s=e.position.y,a=s-((r=e.animationStartYOffset)!=null?r:-10),o=()=>{let c=Date.now()-n,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=i+(1-i)*p,e.position.y=s+(a-s)*p,d<1&&requestAnimationFrame(o)};o()}function Gn(e,t){var o;let n=Date.now(),i=e.alpha,s=(o=e.targetAlpha)!=null?o:1,a=()=>{let r=Date.now()-n,c=Math.min(r/t,1),d=1-Math.pow(1-c,2);e.alpha=i+(s-i)*d,c<1&&requestAnimationFrame(a)};a()}function qn(e,t,n){let i=Date.now(),s=e.alpha,a=()=>{let o=Date.now()-i,r=Math.min(o/n,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(a)};a()}function Xn(e,t){var r;let n=Date.now(),i=e.alpha,s=e.position.y,a=s-((r=e.animationStartYOffset)!=null?r:5),o=()=>{let c=Date.now()-n,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=i+(1-i)*p,e.position.y=s+(a-s)*p,d<1&&requestAnimationFrame(o)};o()}function Nn(e,t,n,i){var p,u,h,l;let s=n.objects.get("ui_endgame_hand_1"),a=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},o=(u=a.click_animation_duration_ms)!=null?u:600,r=(h=a.click_delay_ms)!=null?h:2e3,c=(l=a.click_repeat_delay_ms)!=null?l:3e3,d=()=>{var A,w;e.visible=!0,e.alpha=1;let f=e.x,m=e.y,y=(A=a.hand_offset_x)!=null?A:50,_=(w=a.hand_offset_y)!=null?w:50,b=t.x+y,C=t.y+_,x=Date.now(),S=()=>{var M,B,V;let T=Date.now()-x,g=Math.min(T/o,1),v=g<.5?2*g*g:1-Math.pow(-2*g+2,2)/2;e.x=f+(b-f)*v,e.y=m+(C-m)*v;let z=(B=(M=s==null?void 0:s.transform)==null?void 0:M.scale)!=null?B:.1875,R=(V=a.hand_scale_multiplier)!=null?V:2.5,$=z*R;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=f,e.y=m,d()},c)},500))};S()};setTimeout(d,r)}import{Sprite as $n,Text as jn}from"pixi.js";function Vn(e,t,n){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)||{},a=(i==null?void 0:i.render)||{},o=(i==null?void 0:i.transform)||{},r=new $n(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=a.z_index)!=null?l:99999,r}function Jn(e){var f,m,y,_,b,C,x,S,A,w;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},s=((f=e.engine.runtime)==null?void 0:f.ui_styles)||{},a=((m=e.engine.runtime)==null?void 0:m.ui)||{},o=(n==null?void 0:n.text)||a.tutorial_label||a.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",c=(n==null?void 0:n.fontSize)||s.label_font_size||52,d=(_=n==null?void 0:n.letterSpacing)!=null?_:(y=s.label_letter_spacing)!=null?y:-1,p=(n==null?void 0:n.align)||"center",u=i.tint,h=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",l=new jn({text:o,style:{fontFamily:X(r),fontSize:c,fontWeight:N(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=(A=i.alpha)!=null?A:0,l.visible=(w=i.visible)!=null?w:!0,l}function Kn(e,t,n,i,s){var c,d,p,u,h,l,f;let a=s.objects.get("hand_tutorial_1"),o=((c=a==null?void 0:a.gameplay)==null?void 0:c.tuning)||{},r=(a==null?void 0:a.transform)||{};if(!i){let m=(d=o.animation_duration)!=null?d:1.5,y=n%m/m,_=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,A=x,w=t.x+b+S,T=t.y+C+A,g=w+S,v=T+A;e.x=w+(g-w)*_,e.y=T+(v-T)*_;let z=(l=r.scale)!=null?l:.1875,R=(f=o.hand_scale_multiplier)!=null?f:2.5;e.scale.set(z*R)}}import{Graphics as Qn,Assets as Xe,Texture as Zn,Rectangle as On,Color as qe}from"pixi.js";var bt=null,xt=null;async function Ne(){if(bt)return bt;if(!xt){let t=typeof window!="undefined"?window.location.pathname:"",n=t.substring(0,t.lastIndexOf("/")+1),o="./"+"inline-assets"+".js";xt=new Function("path","return import(path)")(o).then(r=>r.INLINE_ASSETS||{}).catch(()=>({}))}let e=await xt;return bt=e||{},e||{}}function In(e,t){if(!e)return;let n=t[e];if(n)return n;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 a=i.replace(/^\.?\/*/,"");if(a!==i&&t[a])return t[a]}function $e(e,t){let n=In(e,t);if(!n)throw new Error(`[assets] inline asset not found: ${e}`);return n}async function Un(e,t,n=16777215,i=!1){let s=await Ne(),a=$e(e,s);try{return await Xe.load(a)}catch{throw new Error(`[assets] inline asset failed to load: ${e}`)}}async function ta(e,t,n){var m,y,_,b,C,x,S,A,w,T;let i=await Ne(),s=$e(e,i),a;try{a=await Xe.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch{throw new Error(`[assets] inline character sheet failed to load: ${e}`)}let o=a.source||a.baseTexture||a;o&&"valid"in o&&o.valid===!1&&typeof o.once=="function"&&await new Promise(g=>o.once("loaded",g));let r=n.gameplay.character_sheet||{},c=(m=r.cols)!=null?m: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:a.width,u=(T=(w=(S=o==null?void 0:o.height)!=null?S:o==null?void 0:o.pixelHeight)!=null?w:(A=o==null?void 0:o.baseTexture)==null?void 0:A.height)!=null?T:a.height,h=p/c,l=u/d;if(!Number.isFinite(h)||!Number.isFinite(l)||h<=0||l<=0||!o)return[a];let f=[];for(let g=0;g<d;g++)for(let v=0;v<c;v++)f.push(new Zn({source:o,frame:new On(v*h,g*l,h,l)}));return f.length>2&&f.push(...f.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:f.length}),f}function ea(e,t){var p,u,h,l;let n=t.gameplay.brush||{},i=new qe(t.theme.brush_color||"#ffffff").toNumber(),s=(p=n.radius)!=null?p:20,a=(u=n.inner_radius)!=null?u:15,o=(h=n.alpha)!=null?h:.8,r=(l=n.inner_alpha)!=null?l:.3,c=n.inner_color||"#ffffff",d=new Qn;return d.circle(0,0,s).fill({color:i,alpha:o}),d.circle(0,0,a).fill({color:new qe(c).toNumber(),alpha:r}),e.renderer.generateTexture(d)}export{ht as GameObject,gt as GameObjectManager,dt as Renderer,ct as Transform,Nn as animateHandClick,Wn as animatePanelEntrance,ea as createBrushTexture,Hn as createEndGamePanel,Vn as createHandTutorial,Yn as createPixiBase,Jn as createTutorialLabel,zn as getRegisteredFontIds,Un as loadAsset,ta as loadCharacterFrames,kn as registerFont,X as resolveFont,N as resolveFontWeight,Kn as updateHandAnimation};
|
|
1
|
+
import{b as ct}from"../chunk-AOCUS265.mjs";import{Application as kn}from"pixi.js";async function Mn(e,t={}){let n=new kn;await n.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let s=a=>{var c,d,u,p,h,l;let o=(u=(d=(c=a==null?void 0:a.width)!=null?c:e.clientWidth)!=null?d:window.innerWidth)!=null?u:320,r=(l=(h=(p=a==null?void 0:a.height)!=null?p:e.clientHeight)!=null?h:window.innerHeight)!=null?l: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 i=document.createElement("div");return i.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(i),ct.on("pause",()=>{n.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),ct.on("resume",()=>{n.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),ct.on("resize",({payload:a})=>{s({width:a==null?void 0:a.width,height:a==null?void 0:a.height})}),window.addEventListener("resize",()=>s()),requestAnimationFrame(()=>s()),{app:n,stage:n.stage,overlay:i,applySize:s}}var dt=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)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},ht=class{constructor(t){var n,s,i,a;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=(i=t==null?void 0:t.visible)!=null?i:!0,this.tint=(a=t==null?void 0:t.tint)!=null?a: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)}},ut=class{constructor(t,n,s,i){this.instanceId=t,this.objectConfig=n,this.pixiObject=s,this._config=i,this.transform=new dt(i.transform),this.renderer=new ht(i.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)}},_t=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 i=new ut(t,s.object_config||t,n,s);return this.objects.set(t,i),i}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,s]of this.objects.entries()){let i=t.objects.get(n);i&&s.updateConfig(i)}}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 $(e){let t=pt[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=pt[e];return t&&(n=t.weight)!=null?n:"400"}function Dn(e,t){pt[e]=t}function zn(){return Object.keys(pt)}import{Container as Yn,Graphics as mt,Text as et,Sprite as Ne,Texture as bt}from"pixi.js";function Hn(e,t,n){var zt,Yt,Ht,Wt,Rt,Bt,Lt,Gt,Nt,qt,Xt,$t,jt,Kt,Vt,Jt,Qt,Zt,It,Ot,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,de,he,ue,pe,me,fe,ye,ge,_e,be,xe,we,Te,Se,Ce,Ae,ve,Fe,Pe,Ee,ke,Me,De,ze,Ye,He,We,Re,Be;let s=e.objects.get("ui_endgame_1"),i=e.objects.get("ui_endgame_logo_1"),a=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"),u=e.objects.get("ui_endgame_hand_1"),p=e.engine.runtime||{},h=new Yn;h.alpha=0,h.visible=!1;let l=((zt=s==null?void 0:s.gameplay)==null?void 0:zt.tuning)||{},m=(s==null?void 0:s.render)||{},f=(Yt=l.panel_width)!=null?Yt:320,y=(Ht=l.panel_height)!=null?Ht:400,_=(Wt=l.panel_padding)!=null?Wt:32,b=(Rt=l.panel_radius)!=null?Rt:24,g=m.background_color||l.panel_bg_color||"#1a0a0a",x=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(Bt=l.panel_bg_alpha)!=null?Bt:.98,C=m.border_color||l.panel_border_color||"#ffffff",A=(Lt=l.panel_border_width)!=null?Lt:2,w=(Gt=l.panel_border_alpha)!=null?Gt:.3,T=new mt;T.roundRect(-f/2,-y/2,f,y,b);let v=g.replace("#","");T.fill({color:parseInt(v,16),alpha:x});let k=C.replace("#","");T.stroke({color:parseInt(k,16),width:A,alpha:w});let F=new mt;F.roundRect(-f/2+2,-y/2+2,f-4,y-4,b-2),F.stroke({color:16777215,width:1,alpha:.1}),T.addChild(F),h.addChild(T);let M=((Nt=i==null?void 0:i.gameplay)==null?void 0:Nt.tuning)||{},R=(i==null?void 0:i.transform)||{},P=(qt=M.logo_size)!=null?qt:56,D=(Xt=R.scale)!=null?Xt:1,B=(jt=($t=R.offset)==null?void 0:$t.y)!=null?jt:-130,K=(Kt=M.logo_alpha)!=null?Kt:1,S=new Ne(n||bt.EMPTY);S.anchor.set(.5);let Q=0,Z=0;if(n&&n!==bt.EMPTY){let E=n.frame,X=n.baseTexture;E&&E.width&&E.height?(Q=E.width,Z=E.height):X&&X.width&&X.height?(Q=X.width,Z=X.height):n.width&&n.height&&(Q=n.width,Z=n.height)}if(Q>0&&Z>0){let E=Q/Z,X,gt;E>1?(X=P,gt=P/E):(gt=P,X=P*E);let Le=X/Q,Ge=gt/Z;Le*=D,Ge*=D,S.scale.set(Le,Ge)}else{let E=P/100*D;S.scale.set(E)}S.position.set(0,B),S.alpha=0,S.visible=!0,S.targetAlpha=K,S.baseScaleX=S.scale.x,S.baseScaleY=S.scale.y,h.addChild(S);let z=a==null?void 0:a.ui,L=((Vt=a==null?void 0:a.gameplay)==null?void 0:Vt.tuning)||{},Ke=(z==null?void 0:z.text)||"MISSION ACCOMPLISHED",Tt=(z==null?void 0:z.font)||"brand.heading",Ve=(z==null?void 0:z.fontSize)||24,Je=(Jt=z==null?void 0:z.letterSpacing)!=null?Jt:1,nt=(Qt=a==null?void 0:a.render)==null?void 0:Qt.tint,Qe=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#00FF88",St=f-_*2-30,Ze=L.font_weight_override?L.font_weight_override:j(Tt),V=new et({text:Ke,style:{fontFamily:$(Tt),fontSize:Ve,fontWeight:Ze,fill:Qe,align:"center",letterSpacing:Je,wordWrap:!1,stroke:{color:L.stroke_color||"#000000",width:(Zt=L.stroke_width)!=null?Zt:2},dropShadow:{color:L.shadow_color||"#000000",alpha:(It=L.shadow_alpha)!=null?It:.9,angle:(Ot=L.shadow_angle)!=null?Ot:0,blur:(Ut=L.shadow_blur)!=null?Ut:8,distance:(te=L.shadow_distance)!=null?te:4}}});if(V.width>St){let E=St/V.width;V.scale.set(E)}V.anchor.set(.5);let Ct=(ee=l.title_offset_y)!=null?ee:30,Ie=Ct+((ne=L.animation_start_y_offset)!=null?ne:-20);V.position.set(0,Ie),V.alpha=0,h.addChild(V);let Y=o==null?void 0:o.ui,At=((ae=o==null?void 0:o.gameplay)==null?void 0:ae.tuning)||{},Oe=(Y==null?void 0:Y.text)||"RESCUE COMPLETE",vt=(Y==null?void 0:Y.font)||"brand.body",Ue=(Y==null?void 0:Y.fontSize)||11,tn=(se=Y==null?void 0:Y.letterSpacing)!=null?se:.5,at=(ie=o==null?void 0:o.render)==null?void 0:ie.tint,en=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#B0B0B0",I=new et({text:Oe,style:{fontFamily:$(vt),fontSize:Ue,fontWeight:j(vt),fill:en,align:"center",letterSpacing:tn}});I.anchor.set(.5);let nn=Ct+20+((oe=At.animation_start_y_offset)!=null?oe:-10);I.position.set(0,nn),I.alpha=0,I.animationStartYOffset=(re=At.animation_start_y_offset)!=null?re:-10,h.addChild(I);let N=r==null?void 0:r.ui,Ft=((le=r==null?void 0:r.gameplay)==null?void 0:le.tuning)||{},an=(N==null?void 0:N.text)||((ce=p.ui)==null?void 0:ce.cta_hint)||"Continue the adventure!",Pt=(N==null?void 0:N.font)||"brand.body",sn=(N==null?void 0:N.fontSize)||16,st=(de=r==null?void 0:r.render)==null?void 0:de.tint,on=typeof st=="string"?st:st?`#${st.toString(16).padStart(6,"0")}`:"#FFFFFF",rn=(he=Ft.max_width)!=null?he:f-_*2,ln=(ue=Ft.line_height)!=null?ue:1.4,O=new et({text:an,style:{fontFamily:$(Pt),fontSize:sn,fontWeight:j(Pt),fill:on,align:"center",wordWrap:!0,wordWrapWidth:rn,lineHeight:ln}});O.anchor.set(.5);let cn=(pe=l.footer_offset_y)!=null?pe:120;O.position.set(0,cn);let dn=((me=r==null?void 0:r.render)==null?void 0:me.alpha)!==void 0&&((fe=r==null?void 0:r.render)==null?void 0:fe.alpha)!==null?r.render.alpha:1;O.alpha=0,O.targetAlpha=dn,h.addChild(O);let q=((ye=c==null?void 0:c.gameplay)==null?void 0:ye.tuning)||{},H=c==null?void 0:c.ui,it=(ge=q.button_width)!=null?ge:260,ot=(_e=q.button_height)!=null?_e:56,Et=(be=q.button_radius)!=null?be:16,hn=q.button_bg_color||((xe=p.theme)==null?void 0:xe.cta_background)||"#ffb43b",un=(we=q.button_bg_alpha)!=null?we:1,pn=q.button_border_color||"#ffffff",mn=(Te=q.button_border_width)!=null?Te:2,fn=(Se=q.button_border_alpha)!=null?Se:.2,rt=(Ce=l.cta_offset_y)!=null?Ce:160,G=new mt;G.roundRect(-it/2,-ot/2,it,ot,Et);let yn=hn.replace("#","");G.fill({color:parseInt(yn,16),alpha:un});let gn=pn.replace("#","");G.stroke({color:parseInt(gn,16),width:mn,alpha:fn});let ft=new mt;ft.roundRect(-it/2+2,-ot/2+2,it-4,ot-4,Et-2),ft.stroke({color:0,width:1,alpha:.15}),G.addChild(ft),G.position.set(0,rt),G.alpha=0,G.eventMode="static",G.cursor="pointer",h.addChild(G);let _n=(H==null?void 0:H.text)||((Ae=p.ui)==null?void 0:Ae.cta_label_end)||"DOWNLOAD",kt=(H==null?void 0:H.font)||"brand.heading",bn=(H==null?void 0:H.fontSize)||20,xn=q.button_text_color||((ve=p.theme)==null?void 0:ve.cta_text)||"#1a0a0a",tt=new et({text:_n,style:{fontFamily:$(kt),fontSize:bn,fontWeight:j(kt),fill:xn,align:"center",letterSpacing:(Fe=H==null?void 0:H.letterSpacing)!=null?Fe:1}});tt.anchor.set(.5),tt.position.set(0,rt),tt.alpha=0,h.addChild(tt);let W=d==null?void 0:d.ui,Mt=((Pe=d==null?void 0:d.gameplay)==null?void 0:Pe.tuning)||{},wn=(W==null?void 0:W.text)||"Play the full game",Dt=(W==null?void 0:W.font)||"brand.body",Tn=(W==null?void 0:W.fontSize)||11,Sn=(Ee=W==null?void 0:W.letterSpacing)!=null?Ee:0,lt=(ke=d==null?void 0:d.render)==null?void 0:ke.tint,Cn=typeof lt=="string"?lt:lt?`#${lt.toString(16).padStart(6,"0")}`:"#CCCCCC",U=new et({text:wn,style:{fontFamily:$(Dt),fontSize:Tn,fontWeight:j(Dt),fill:Cn,align:"center",letterSpacing:Sn}});U.anchor.set(.5);let An=rt+35+((Me=Mt.animation_start_y_offset)!=null?Me:5);U.position.set(0,An),U.alpha=0,U.animationStartYOffset=(De=Mt.animation_start_y_offset)!=null?De:5,h.addChild(U);let yt=((ze=u==null?void 0:u.gameplay)==null?void 0:ze.tuning)||{},vn=(Ye=yt.hand_offset_x)!=null?Ye:50,Fn=(He=yt.hand_offset_y)!=null?He:50,Pn=(Re=(We=u==null?void 0:u.transform)==null?void 0:We.scale)!=null?Re:.1875,En=(Be=yt.hand_scale_multiplier)!=null?Be:2.5,J=new Ne(t||bt.EMPTY);return J.anchor.set(.5),J.scale.set(Pn*En),J.position.set(vn,rt+Fn),J.alpha=0,J.visible=!1,h.addChild(J),{panel:h,logo:S,title:V,subtitle:I,footer:O,ctaButton:G,ctaText:tt,ctaHint:U,hand:J}}function Wn(e,t,n){var A,w,T,v,k,F,M,R;let s=t.objects.get("ui_endgame_1"),i=((A=s==null?void 0:s.gameplay)==null?void 0:A.tuning)||{},a=(w=i.animation_duration_ms)!=null?w:800,o=(T=i.fade_in_duration_ms)!=null?T:600,r=(v=i.scale_animation_intensity)!=null?v:.1,c=(k=i.logo_animation_delay_ms)!=null?k:100,d=(F=i.title_animation_delay_ms)!=null?F:200,u=(M=i.footer_animation_delay_ms)!=null?M:300,p=(R=i.cta_animation_delay_ms)!=null?R:400,{panel:h,logo:l,title:m,subtitle:f,footer:y,ctaButton:_,ctaText:b,ctaHint:g}=e;h.visible=!0;let x=Date.now(),C=()=>{let P=Date.now()-x,D=Math.min(P/o,1),B=1-Math.pow(1-D,3);h.alpha=B,h.scale.set(1+r*(1-B)),D<1?requestAnimationFrame(C):(setTimeout(()=>Rn(l,a,t),c),setTimeout(()=>{Bn(m,a),setTimeout(()=>Ln(f,a),50)},d),setTimeout(()=>Gn(y,a),u),setTimeout(()=>{Nn(_,b,a),setTimeout(()=>qn(g,a),50),n&&n()},p))};C()}function Rn(e,t,n){var h,l,m,f,y;let s=n==null?void 0:n.objects.get("ui_endgame_logo_1"),a=(l=(((h=s==null?void 0:s.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,u=(y=e.baseScaleY)!=null?y:e.scale.y,p=()=>{let _=Date.now()-o,b=Math.min(_/t,1),g=1-Math.pow(1-b,2);e.alpha=r+(c-r)*g;let x=a+(1-a)*g;e.scale.set(d*x,u*x),b<1&&requestAnimationFrame(p)};p()}function Bn(e,t){let n=Date.now(),s=e.alpha,i=e.y,a=()=>{let o=Date.now()-n,r=Math.min(o/t,1),c=1-Math.pow(1-r,2);e.alpha=s+(1-s)*c,e.y=i-20*(1-c),r<1&&requestAnimationFrame(a)};a()}function Ln(e,t){var r;let n=Date.now(),s=e.alpha,i=e.position.y,a=i-((r=e.animationStartYOffset)!=null?r:-10),o=()=>{let c=Date.now()-n,d=Math.min(c/t,1),u=1-Math.pow(1-d,2);e.alpha=s+(1-s)*u,e.position.y=i+(a-i)*u,d<1&&requestAnimationFrame(o)};o()}function Gn(e,t){var o;let n=Date.now(),s=e.alpha,i=(o=e.targetAlpha)!=null?o:1,a=()=>{let r=Date.now()-n,c=Math.min(r/t,1),d=1-Math.pow(1-c,2);e.alpha=s+(i-s)*d,c<1&&requestAnimationFrame(a)};a()}function Nn(e,t,n){let s=Date.now(),i=e.alpha,a=()=>{let o=Date.now()-s,r=Math.min(o/n,1),c=1-Math.pow(1-r,2);e.alpha=i+(1-i)*c,t.alpha=i+(1-i)*c,e.scale.set(1+.1*(1-c)),r<1&&requestAnimationFrame(a)};a()}function qn(e,t){var r;let n=Date.now(),s=e.alpha,i=e.position.y,a=i-((r=e.animationStartYOffset)!=null?r:5),o=()=>{let c=Date.now()-n,d=Math.min(c/t,1),u=1-Math.pow(1-d,2);e.alpha=s+(1-s)*u,e.position.y=i+(a-i)*u,d<1&&requestAnimationFrame(o)};o()}function Xn(e,t,n,s){var u,p,h,l;let i=n.objects.get("ui_endgame_hand_1"),a=((u=i==null?void 0:i.gameplay)==null?void 0:u.tuning)||{},o=(p=a.click_animation_duration_ms)!=null?p:600,r=(h=a.click_delay_ms)!=null?h:2e3,c=(l=a.click_repeat_delay_ms)!=null?l:3e3,d=()=>{var A,w;e.visible=!0,e.alpha=1;let m=e.x,f=e.y,y=(A=a.hand_offset_x)!=null?A:50,_=(w=a.hand_offset_y)!=null?w:50,b=t.x+y,g=t.y+_,x=Date.now(),C=()=>{var P,D,B;let T=Date.now()-x,v=Math.min(T/o,1),k=v<.5?2*v*v:1-Math.pow(-2*v+2,2)/2;e.x=m+(b-m)*k,e.y=f+(g-f)*k;let F=(D=(P=i==null?void 0:i.transform)==null?void 0:P.scale)!=null?D:.1875,M=(B=a.hand_scale_multiplier)!=null?B:2.5,R=F*M;e.scale.set(R+R*.2*Math.sin(v*Math.PI)),v<1?requestAnimationFrame(C):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),s()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=m,e.y=f,d()},c)},500))};C()};setTimeout(d,r)}import{Sprite as $n,Text as jn}from"pixi.js";function Kn(e,t,n){var u,p,h,l;let s=t.objects.get("hand_tutorial_1"),i=((u=s==null?void 0:s.gameplay)==null?void 0:u.tuning)||{},a=(s==null?void 0:s.render)||{},o=(s==null?void 0:s.transform)||{},r=new $n(e);r.anchor.set(.5),r.alpha=0;let c=(p=i.hand_scale_multiplier)!=null?p:2.5,d=(h=o.scale)!=null?h:.1875;return r.scale.set(d*c),r.zIndex=(l=a.z_index)!=null?l:99999,r}function Vn(e){var m,f,y,_,b,g,x,C,A,w;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,s=(t==null?void 0:t.render)||{},i=((m=e.engine.runtime)==null?void 0:m.ui_styles)||{},a=((f=e.engine.runtime)==null?void 0:f.ui)||{},o=(n==null?void 0:n.text)||a.tutorial_label||a.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",c=(n==null?void 0:n.fontSize)||i.label_font_size||52,d=(_=n==null?void 0:n.letterSpacing)!=null?_:(y=i.label_letter_spacing)!=null?y:-1,u=(n==null?void 0:n.align)||"center",p=s.tint,h=typeof p=="string"?p:p?`#${p.toString(16).padStart(6,"0")}`:i.label_fill||"#FFF1C1",l=new jn({text:o,style:{fontFamily:$(r),fontSize:c,fontWeight:j(r),fill:h,align:u,letterSpacing:d,stroke:{color:i.label_stroke||"#8B0000",width:2},dropShadow:{color:i.label_shadow_color||"#000000",alpha:(b=i.label_shadow_alpha)!=null?b:.8,angle:(g=i.label_shadow_angle)!=null?g:0,blur:(x=i.label_shadow_blur)!=null?x:4,distance:(C=i.label_shadow_distance)!=null?C:2}}});return l.anchor.set(.5,0),l.alpha=(A=s.alpha)!=null?A:0,l.visible=(w=s.visible)!=null?w:!0,l}function Jn(e,t,n,s,i){var c,d,u,p,h,l,m;let a=i.objects.get("hand_tutorial_1"),o=((c=a==null?void 0:a.gameplay)==null?void 0:c.tuning)||{},r=(a==null?void 0:a.transform)||{};if(!s){let f=(d=o.animation_duration)!=null?d:1.5,y=n%f/f,_=y<.5?2*y*y:-1+(4-2*y)*y,b=(u=o.x_offset)!=null?u:0,g=(p=o.y_offset)!=null?p:0,x=(h=o.animation_range)!=null?h:40,C=x*.7,A=x,w=t.x+b+C,T=t.y+g+A,v=w+C,k=T+A;e.x=w+(v-w)*_,e.y=T+(k-T)*_;let F=(l=r.scale)!=null?l:.1875,M=(m=o.hand_scale_multiplier)!=null?m:2.5;e.scale.set(F*M)}}import{Graphics as Qn,Assets as Xe,Texture as Zn,Rectangle as In,Color as qe}from"pixi.js";var xt=null,wt=null;async function $e(){if(xt)return xt;if(!wt){let n=(()=>{if(typeof window!="undefined")try{return new URL("inline-assets.js",window.location.href).href}catch{return"./inline-assets.js"}return"./inline-assets.js"})();wt=new Function("path","return import(path)")(n).then(s=>s?s.INLINE_ASSETS?s.INLINE_ASSETS:(console.warn("[assets] Module does not have INLINE_ASSETS export. Module keys:",Object.keys(s)),{}):(console.warn("[assets] Module import returned undefined"),{})).catch(s=>(console.warn("[assets] Failed to load inline-assets.js:",s),{}))}let e=await wt;return xt=e||{},e||{}}function On(e,t){if(!e)return;let n=t[e];if(n)return console.log("[assets] resolveInlineAsset: direct match",{path:e}),n;let s=e.split("?")[0].split("#")[0];if(s!==e&&t[s])return console.log("[assets] resolveInlineAsset: trimmed match",{path:e,trimmed:s}),t[s];let i=s.split("/").pop();if(i&&t[i])return console.log("[assets] resolveInlineAsset: filename match",{path:e,filename:i}),t[i];let a=s.replace(/^\.?\/*/,"");if(a!==s&&t[a])return console.log("[assets] resolveInlineAsset: normalized match",{path:e,normalized:a}),t[a];console.warn("[assets] resolveInlineAsset: no match found",{path:e,trimmed:s,filename:i,normalized:a,availableKeys:Object.keys(t).slice(0,10)})}function je(e,t){let n=On(e,t);if(!n)throw new Error(`[assets] inline asset not found: ${e}`);return n}async function Un(e,t,n=16777215,s=!1){let i=await $e(),a=je(e,i);console.log("[assets] loadAsset",{path:e,resolvedSource:(a==null?void 0:a.substring(0,50))+"...",hasInlineMap:!!i,inlineMapKeys:Object.keys(i).length});try{let o=await Xe.load(a);return console.log("[assets] loadAsset success",{path:e,textureWidth:o.width,textureHeight:o.height}),o}catch(o){throw console.error("[assets] loadAsset failed",{path:e,source:a,error:o}),new Error(`[assets] inline asset failed to load: ${e}`)}}async function ta(e,t,n){var f,y,_,b,g,x,C,A,w,T,v,k,F,M,R,P,D,B;let s=await $e(),i=je(e,s),a;try{a=await Xe.load(i),console.log("[character] loaded sheet",{path:e,sourceUsed:i})}catch{throw new Error(`[assets] inline character sheet failed to load: ${e}`)}let o=a.source||a.baseTexture||a;o&&"valid"in o&&o.valid===!1&&typeof o.once=="function"&&await new Promise(K=>o.once("loaded",K));let r=((f=n==null?void 0:n.gameplay)==null?void 0:f.character_sheet)||((b=(_=(y=n==null?void 0:n.engine)==null?void 0:y.runtime)==null?void 0:_.gameplay)==null?void 0:b.character_sheet)||((A=(C=(x=(g=n==null?void 0:n.objects)==null?void 0:g.get)==null?void 0:x.call(g,"character_1"))==null?void 0:C.gameplay)==null?void 0:A.character_sheet)||{},c=(w=r.cols)!=null?w:3,d=(T=r.rows)!=null?T:2,u=(M=(F=(v=o==null?void 0:o.width)!=null?v:o==null?void 0:o.pixelWidth)!=null?F:(k=o==null?void 0:o.baseTexture)==null?void 0:k.width)!=null?M:a.width,p=(B=(D=(R=o==null?void 0:o.height)!=null?R:o==null?void 0:o.pixelHeight)!=null?D:(P=o==null?void 0:o.baseTexture)==null?void 0:P.height)!=null?B:a.height,h=u/c,l=p/d;if(!Number.isFinite(h)||!Number.isFinite(l)||h<=0||l<=0||!o)return[a];let m=[];for(let K=0;K<d;K++)for(let S=0;S<c;S++)m.push(new Zn({source:o,frame:new In(S*h,K*l,h,l)}));return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function ea(e,t){var u,p,h,l;let n=t.gameplay.brush||{},s=new qe(t.theme.brush_color||"#ffffff").toNumber(),i=(u=n.radius)!=null?u:20,a=(p=n.inner_radius)!=null?p:15,o=(h=n.alpha)!=null?h:.8,r=(l=n.inner_alpha)!=null?l:.3,c=n.inner_color||"#ffffff",d=new Qn;return d.circle(0,0,i).fill({color:s,alpha:o}),d.circle(0,0,a).fill({color:new qe(c).toNumber(),alpha:r}),e.renderer.generateTexture(d)}export{ut as GameObject,_t as GameObjectManager,ht as Renderer,dt as Transform,Xn as animateHandClick,Wn as animatePanelEntrance,ea as createBrushTexture,Hn as createEndGamePanel,Kn as createHandTutorial,Mn as createPixiBase,Vn as createTutorialLabel,zn as getRegisteredFontIds,Un as loadAsset,ta as loadCharacterFrames,Dn as registerFont,$ as resolveFont,j as resolveFontWeight,Jn as updateHandAnimation};
|
package/dist/three/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ga=Object.create;var Pe=Object.defineProperty;var ba=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var Ea=Object.getPrototypeOf,xa=Object.prototype.hasOwnProperty;var _a=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},Yn=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of wa(t))!xa.call(e,a)&&a!==n&&Pe(e,a,{get:()=>t[a],enumerable:!(i=ba(t,a))||i.enumerable});return e};var we=(e,t,n)=>(n=e!=null?ga(Ea(e)):{},Yn(t||!e||!e.__esModule?Pe(n,"default",{value:e,enumerable:!0}):n,e)),Ta=e=>Yn(Pe({},"__esModule",{value:!0}),e);var Ia={};_a(Ia,{AspectClass:()=>ut,GameObject:()=>Ce,GameObjectManager:()=>Ve,Renderer:()=>Ae,ResponsiveUISystem:()=>fe,Transform:()=>Re,animateHandClick:()=>_i,animatePanelEntrance:()=>xi,createBrushTexture:()=>Hi,createEndGamePanel:()=>Ei,createHandTutorial:()=>Ti,createThreeBase:()=>gi,createTutorialLabel:()=>vi,getAspectClass:()=>je,getRegisteredFontIds:()=>wi,loadAsset:()=>yt,loadCharacterFrames:()=>Ci,registerFont:()=>bi,resolveFont:()=>G,resolveFontWeight:()=>j,updateHandAnimation:()=>Si});module.exports=Ta(Ia);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.3",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,Sa=B++,In=B++,Gn=B++,jn=B++,Vn=B++,qn=B++,Xn=B++,Kn=B++,Jn=B++,Zn=B++,Qn=B++,Un=B++,v=Sa;function ei(){return v===In}function ti(){return v===Gn}function ni(){return v===jn}function ii(){return v===Vn}function le(){return v===qn}function ce(){return v===Xn}function ai(){return v===Kn}function si(){return v===Jn}function oi(){return v===Zn}function ot(){return v===Qn}function rt(){return v===Un}function ri(){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=In;return}catch{}else if(e==="dapi")try{dapi.isReady(),v=Gn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(v=jn)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(v=Vn)}catch{}else if(t==="mintegral")window.gameReady&&(v=qn);else if(t==="tapjoy")window.TJ_API&&(v=Xn);else if(t==="tiktok")window.openAppStore&&(v=Kn);else if(t==="smadex")try{window.smxTracking&&(v=Jn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(v=Zn)}catch{}else t==="vungle"?v=Qn:(e==="nucleo"||t==="nucleo")&&(v=Un)}var ui={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"},Ra=Math.random().toString(36).slice(2),de=null,xe={...ui},hi="web_embed",Aa={},lt=!1,Ee=!1,Te=!1,fi=!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,li=!1,ci=!1,ct=!1,Oe=null;function di(){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 yi(e,t){return{event_name:e,ts:Date.now(),session_id:Ra,deployment_id:xe.deployment_id,variant_id:xe.variant_id,export_profile_id:xe.profile_id,instance_id:xe.instance_id||"default",env:hi==="mraid"?"mraid":"web",payload:t}}function w(e,t){let n=Ne(e),i=yi(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&&(fi=!0),!Te&&(Te=!0,w("pause"),ue(0))}function Se(e){!e&&fi||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 Ca(){if(ei())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 Ha(){if(ti())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 pi(){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 Ma(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(li=!0),!(li&&t instanceof MouseEvent)&&(dt+=1,w("interaction",dt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function La(e){var i,a,s,r,m,l,u,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(ni())(m=(r=window.FbPlayableAd)==null?void 0:r.onCTAClick)==null||m.call(r);else if(oi())(u=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||u.call(l);else if(si())try{(y=(p=window.smxTracking)==null?void 0:p.redirect)==null||y.call(p)}catch(o){console.warn("Smadex redirect failed",o)}else if(ii()){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):ai()?(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 ka(){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 Fa(){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 mi(){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 Da(){le()&&(window.mintGameStart=()=>{Se(!0),U()},window.mintGameClose=()=>{he(!0)})}function $a(){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(hi=e.profile||"web_embed",Aa=e.consent||{},xe={...ui,...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,di(),Pa(de),ri(),Ca(),Ha(),!Ie){if(document.readyState==="complete")pi();else if(!ci){ci=!0;let n=()=>{pi(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Ma(),ka(),Fa(),Da(),$a(),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 di()},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()&&mi())},install(e){if(!Ee){Ee=!0,ce()?(mi(),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"),La(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=yi(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 Pa(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
1
|
+
"use strict";var ga=Object.create;var Pe=Object.defineProperty;var ba=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var Ea=Object.getPrototypeOf,xa=Object.prototype.hasOwnProperty;var _a=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},In=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of wa(t))!xa.call(e,a)&&a!==n&&Pe(e,a,{get:()=>t[a],enumerable:!(i=ba(t,a))||i.enumerable});return e};var we=(e,t,n)=>(n=e!=null?ga(Ea(e)):{},In(t||!e||!e.__esModule?Pe(n,"default",{value:e,enumerable:!0}):n,e)),Ta=e=>In(Pe({},"__esModule",{value:!0}),e);var Ya={};_a(Ya,{AspectClass:()=>ut,GameObject:()=>Ce,GameObjectManager:()=>Ve,Renderer:()=>Ae,ResponsiveUISystem:()=>fe,Transform:()=>Re,animateHandClick:()=>_i,animatePanelEntrance:()=>xi,createBrushTexture:()=>Hi,createEndGamePanel:()=>Ei,createHandTutorial:()=>Ti,createThreeBase:()=>gi,createTutorialLabel:()=>vi,getAspectClass:()=>Ge,getRegisteredFontIds:()=>wi,loadAsset:()=>yt,loadCharacterFrames:()=>Ci,registerFont:()=>bi,resolveFont:()=>j,resolveFontWeight:()=>G,updateHandAnimation:()=>Si});module.exports=Ta(Ya);var O=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.5",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,Sa=B++,Yn=B++,jn=B++,Gn=B++,Vn=B++,qn=B++,Xn=B++,Kn=B++,Jn=B++,Zn=B++,Qn=B++,Un=B++,v=Sa;function ei(){return v===Yn}function ti(){return v===jn}function ni(){return v===Gn}function ii(){return v===Vn}function le(){return v===qn}function ce(){return v===Xn}function ai(){return v===Kn}function si(){return v===Jn}function oi(){return v===Zn}function ot(){return v===Qn}function rt(){return v===Un}function ri(){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=Yn;return}catch{}else if(e==="dapi")try{dapi.isReady(),v=jn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(v=Gn)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(v=Vn)}catch{}else if(t==="mintegral")window.gameReady&&(v=qn);else if(t==="tapjoy")window.TJ_API&&(v=Xn);else if(t==="tiktok")window.openAppStore&&(v=Kn);else if(t==="smadex")try{window.smxTracking&&(v=Jn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(v=Zn)}catch{}else t==="vungle"?v=Qn:(e==="nucleo"||t==="nucleo")&&(v=Un)}var ui={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"},Ra=Math.random().toString(36).slice(2),de=null,xe={...ui},hi="web_embed",Aa={},lt=!1,Ee=!1,Te=!1,fi=!1,mt=1,dt=0,Ye=!1,K=!1,Ie="",pe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),pt=pe>me,J=!1,_e=!1,li=!1,ci=!1,ct=!1,Ne=null;function di(){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 Oe(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function yi(e,t){return{event_name:e,ts:Date.now(),session_id:Ra,deployment_id:xe.deployment_id,variant_id:xe.variant_id,export_profile_id:xe.profile_id,instance_id:xe.instance_id||"default",env:hi==="mraid"?"mraid":"web",payload:t}}function w(e,t){let n=Oe(e),i=yi(n,t);ze(n,i),n!==e&&ze(e,i)}function ve(){Ne&&(Ne(pe,me),Ne=null)}function ue(e){mt=e,w("volume",e)}function he(e){e&&(fi=!0),!Te&&(Te=!0,w("pause"),ue(0))}function Se(e){!e&&fi||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 Ca(){if(ei())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)}),Ye=!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 Ha(){if(ti())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)),Ye=!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 pi(){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),Ye=!0}function Ma(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(li=!0),!(li&&t instanceof MouseEvent)&&(dt+=1,w("interaction",dt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function La(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(ni())(u=(r=window.FbPlayableAd)==null?void 0:r.onCTAClick)==null||u.call(r);else if(oi())(m=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||m.call(l);else if(si())try{(y=(p=window.smxTracking)==null?void 0:p.redirect)==null||y.call(p)}catch(o){console.warn("Smadex redirect failed",o)}else if(ii()){let o=window.ExitApi;o&&typeof o.exit=="function"?o.exit(e||Ie||""):e&&window.open(e)}else le()?(f=window.install)==null||f.call(window):ai()?(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 ka(){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 Fa(){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 mi(){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 Da(){le()&&(window.mintGameStart=()=>{Se(!0),U()},window.mintGameClose=()=>{he(!0)})}function $a(){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,Ie)}),Q.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var Q={init(e={},t){if(hi=e.profile||"web_embed",Aa=e.consent||{},xe={...ui,...e.ids||{}},de=e.rootEl||de,Ie=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Ne=t),w("init"),document.body.oncontextmenu=()=>!1,di(),Pa(de),ri(),Ca(),Ha(),!Ye){if(document.readyState==="complete")pi();else if(!ci){ci=!0;let n=()=>{pi(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Ma(),ka(),Fa(),Da(),$a(),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 di()},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(Oe(e),t)},off(e,t){st(Oe(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()&&mi())},install(e){if(!Ee){Ee=!0,ce()?(mi(),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"),La(e||Ie))},emit(e,t){let n=Oe(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=yi(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)}},je=Q;function Pa(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,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
events.forEach(function(e){ document.addEventListener(e, unlock, false); });
|
|
16
16
|
})();
|
|
17
|
-
`,e.appendChild(t)}var ut=(i=>(i[i.PHONE_TALL=0]="PHONE_TALL",i[i.TABLET=1]="TABLET",i[i.LANDSCAPE=2]="LANDSCAPE",i))(ut||{});function
|
|
17
|
+
`,e.appendChild(t)}var ut=(i=>(i[i.PHONE_TALL=0]="PHONE_TALL",i[i.TABLET=1]="TABLET",i[i.LANDSCAPE=2]="LANDSCAPE",i))(ut||{});function Ge(e,t){let n=e/t;return n<=.62?0:n<=.85?1:2}var fe=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=Ge(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 Ge(t.width,t.height)}};async function gi(e,t={}){let n=()=>{let d=e.getBoundingClientRect(),c=Math.floor(d.width),b=Math.floor(d.height);return(c<=0||!isFinite(c)||c!==c)&&(c=e.clientWidth||window.innerWidth||320),(b<=0||!isFinite(b)||b!==b)&&(b=e.clientHeight||window.innerHeight||480),(c<=0||!isFinite(c)||c!==c)&&(c=320),(b<=0||!isFinite(b)||b!==b)&&(b=480),console.log("[THREE-BASE] getSize result:",{width:c,height:b,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:c,height:b}},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 r=document.createElement("div");r.style.cssText=`
|
|
18
18
|
position: absolute !important;
|
|
19
19
|
inset: 0 !important;
|
|
20
20
|
width: 100% !important;
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
padding: 0 !important;
|
|
36
36
|
border: none !important;
|
|
37
37
|
overflow: hidden !important;
|
|
38
|
-
`,e.appendChild(r);let
|
|
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 O.Scene,{width:m,height:p}=n(),y=new O.AmbientLight(16777215,.6);l.add(y);let f=new O.DirectionalLight(16777215,.8);f.position.set(5,5,5),f.castShadow=!1,l.add(f);let h=new O.DirectionalLight(16777215,.3);h.position.set(-5,0,5),l.add(h);let g=new O.PerspectiveCamera(55,m/p,.1,100);g.position.set(0,0,3.2),g.lookAt(0,0,0),g.updateMatrixWorld();let o=new O.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,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),H=c.width*.1;L>H?console.warn("[THREE-BASE] Provided width ignored (too different from container):",{provided:d.width,container:c.width,difference:L,tolerance:H,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),H=c.height*.1;L>H?console.warn("[THREE-BASE] Provided height ignored (too different from container):",{provided:d.height,container:c.height,difference:L,tolerance:H,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 C=Math.floor(_),F=Math.floor(S);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:C,finalHeight:F,aspectRatio:C/F,beforeRendererSize:{width:o.domElement.width,height:o.domElement.height},beforeRendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height}}),o.setSize(C,F),o.setPixelRatio(window.devicePixelRatio||1),g.aspect=C/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;
|
|
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),H=c.width*.1;L>H?console.warn("[THREE-BASE] Provided width ignored (too different from container):",{provided:d.width,container:c.width,difference:L,tolerance:H,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),H=c.height*.1;L>H?console.warn("[THREE-BASE] Provided height ignored (too different from container):",{provided:d.height,container:c.height,difference:L,tolerance:H,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 C=Math.floor(_),F=Math.floor(S);console.log("[THREE-BASE] applySize setting renderer size:",{finalWidth:C,finalHeight:F,aspectRatio:C/F,beforeRendererSize:{width:o.domElement.width,height:o.domElement.height},beforeRendererStyle:{width:o.domElement.style.width,height:o.domElement.style.height}}),o.setSize(C,F),o.setPixelRatio(window.devicePixelRatio||1),g.aspect=C/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;je.on("pause",()=>{T=!0,document.querySelectorAll("audio").forEach(c=>c.pause())}),je.on("resume",()=>{T=!1,document.querySelectorAll("audio").forEach(c=>{c.currentTime>0&&!c.ended&&c.play().catch(()=>{})})});let x=new fe(e,r);return je.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)}}},Ce=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 Ce(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 j(e){let t=qe[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=qe[e];return t&&(n=t.weight)!=null?n:"400"}function bi(e,t){qe[e]=t}function wi(){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 Ei(e,t,n,i){var kt,Ft,Dt,$t,Pt,Wt,zt,Bt,Nt,Ot,It,Yt,jt,Gt,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,Cn,Hn,Mn,Ln,kn,Fn,Dn,$n,Pn,Wn,zn,Bn,Nn,On;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=((kt=a==null?void 0:a.gameplay)==null?void 0:kt.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((Ft=h.panel_width)!=null?Ft:320,E),d=Math.min((Dt=h.panel_height)!=null?Dt:400,T),c=($t=h.panel_padding)!=null?$t:32,b=(Pt=h.panel_radius)!=null?Pt:24,_=g.background_color||h.panel_bg_color||"#1a0a0a",S=g.background_alpha!==void 0&&g.background_alpha!==null?g.background_alpha:(Wt=h.panel_bg_alpha)!=null?Wt:.98,C=g.border_color||h.panel_border_color||"#ffffff",F=(zt=h.panel_border_width)!=null?zt:2,R=(Bt=h.panel_border_alpha)!=null?Bt:.3,A=document.createElement("div");A.style.cssText=`
|
|
41
41
|
position: absolute;
|
|
42
42
|
width: ${x}px;
|
|
43
43
|
height: ${d}px;
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
z-index: 1000;
|
|
57
57
|
box-sizing: border-box;
|
|
58
58
|
padding: ${c}px;
|
|
59
|
-
`,i.appendChild(A);let L=se(A);L.element=A;let H=((
|
|
60
|
-
font-family: ${
|
|
59
|
+
`,i.appendChild(A);let L=se(A);L.element=A;let H=((Nt=s==null?void 0:s.gameplay)==null?void 0:Nt.tuning)||{},ee=(s==null?void 0:s.transform)||{},N=(Ot=H.logo_size)!=null?Ot:56,I=(It=ee.scale)!=null?It:1,oe=(jt=(Yt=ee.offset)==null?void 0:Yt.y)!=null?jt:-130,He=(Gt=H.logo_alpha)!=null?Gt:1,Mi=new ye.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),Y=new ye.Sprite(Mi);Y.position.set(0,oe,0),Y.material.opacity=0;let Me=0,Le=0;if(n&&(Me=((Vt=n.image)==null?void 0:Vt.width)||100,Le=((qt=n.image)==null?void 0:qt.height)||100),Me>0&&Le>0){let re=Me/Le,it,at;re>1?(it=N,at=N/re):(at=N,it=N*re);let fa=it/Me*I,ya=at/Le*I;Y.scale.set(fa,ya,1)}else{let re=N/100*I;Y.scale.set(re,re,1)}Y.targetAlpha=He,Y.baseScaleX=Y.scale.x,Y.baseScaleY=Y.scale.y;let D=r==null?void 0:r.ui,V=((Xt=r==null?void 0:r.gameplay)==null?void 0:Xt.tuning)||{},Li=(D==null?void 0:D.text)||"MISSION ACCOMPLISHED",gt=(D==null?void 0:D.font)||"brand.heading",Ke=(D==null?void 0:D.fontSize)||24,ki=(Kt=D==null?void 0:D.letterSpacing)!=null?Kt:1,ke=(Jt=r==null?void 0:r.render)==null?void 0:Jt.tint,Fi=typeof ke=="string"?ke:ke?`#${ke.toString(16).padStart(6,"0")}`:"#00FF88",Di=x-c*2-30,$i=V.font_weight_override?V.font_weight_override:G(gt),te=document.createElement("div");te.textContent=Li,te.style.cssText=`
|
|
60
|
+
font-family: ${j(gt)};
|
|
61
61
|
font-size: ${Ke}px;
|
|
62
62
|
font-weight: ${$i};
|
|
63
63
|
color: ${Fi};
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
transform: translate(-50%, -50%);
|
|
71
71
|
white-space: nowrap;
|
|
72
72
|
max-width: ${Di}px;
|
|
73
|
-
`;let bt=c+30,Pi=((nn=h.title_offset_y)!=null?nn:bt+Ke/2)+((an=V.animation_start_y_offset)!=null?an:-20);te.style.top=`${Pi}px`,te.style.left="50%";let wt=se(te);wt.element=te,A.appendChild(te);let $=
|
|
74
|
-
font-family: ${
|
|
73
|
+
`;let bt=c+30,Pi=((nn=h.title_offset_y)!=null?nn:bt+Ke/2)+((an=V.animation_start_y_offset)!=null?an:-20);te.style.top=`${Pi}px`,te.style.left="50%";let wt=se(te);wt.element=te,A.appendChild(te);let $=u==null?void 0:u.ui,Et=((sn=u==null?void 0:u.gameplay)==null?void 0:sn.tuning)||{},Wi=($==null?void 0:$.text)||"RESCUE COMPLETE",xt=($==null?void 0:$.font)||"brand.body",Je=($==null?void 0:$.fontSize)||11,zi=(on=$==null?void 0:$.letterSpacing)!=null?on:.5,Fe=(rn=u==null?void 0:u.render)==null?void 0:rn.tint,Bi=typeof Fe=="string"?Fe:Fe?`#${Fe.toString(16).padStart(6,"0")}`:"#B0B0B0",ne=document.createElement("div");ne.textContent=Wi,ne.style.cssText=`
|
|
74
|
+
font-family: ${j(xt)};
|
|
75
75
|
font-size: ${Je}px;
|
|
76
|
-
font-weight: ${
|
|
76
|
+
font-weight: ${G(xt)};
|
|
77
77
|
color: ${Bi};
|
|
78
78
|
text-align: center;
|
|
79
79
|
letter-spacing: ${zi}px;
|
|
@@ -81,19 +81,19 @@
|
|
|
81
81
|
position: absolute;
|
|
82
82
|
transform: translate(-50%, -50%);
|
|
83
83
|
white-space: nowrap;
|
|
84
|
-
`;let _t=bt+Ke+15,
|
|
85
|
-
font-family: ${
|
|
84
|
+
`;let _t=bt+Ke+15,Ni=((ln=h.subtitle_offset_y)!=null?ln:_t+Je/2)+((cn=Et.animation_start_y_offset)!=null?cn:-10);ne.style.top=`${Ni}px`,ne.style.left="50%";let Ze=se(ne);Ze.element=ne,Ze.animationStartYOffset=(dn=Et.animation_start_y_offset)!=null?dn:-10,A.appendChild(ne);let q=l==null?void 0:l.ui,Tt=((pn=l==null?void 0:l.gameplay)==null?void 0:pn.tuning)||{},Oi=(q==null?void 0:q.text)||((mn=f.ui)==null?void 0:mn.cta_hint)||"Continue the adventure!",vt=(q==null?void 0:q.font)||"brand.body",St=(q==null?void 0:q.fontSize)||16,De=(un=l==null?void 0:l.render)==null?void 0:un.tint,Ii=typeof De=="string"?De:De?`#${De.toString(16).padStart(6,"0")}`:"#FFFFFF",Yi=(hn=Tt.max_width)!=null?hn:x-c*2,ji=(fn=Tt.line_height)!=null?fn:1.4,ie=document.createElement("div");ie.textContent=Oi,ie.style.cssText=`
|
|
85
|
+
font-family: ${j(vt)};
|
|
86
86
|
font-size: ${St}px;
|
|
87
|
-
font-weight: ${
|
|
88
|
-
color: ${
|
|
87
|
+
font-weight: ${G(vt)};
|
|
88
|
+
color: ${Ii};
|
|
89
89
|
text-align: center;
|
|
90
90
|
opacity: 0;
|
|
91
91
|
position: absolute;
|
|
92
92
|
transform: translate(-50%, -50%);
|
|
93
|
-
max-width: ${
|
|
94
|
-
line-height: ${
|
|
93
|
+
max-width: ${Yi}px;
|
|
94
|
+
line-height: ${ji};
|
|
95
95
|
word-wrap: break-word;
|
|
96
|
-
`;let
|
|
96
|
+
`;let Gi=_t+Je+30,Vi=(yn=h.footer_offset_y)!=null?yn:Gi+St/2;ie.style.top=`${Vi}px`,ie.style.left="50%";let Qe=se(ie);Qe.element=ie;let qi=((gn=l==null?void 0:l.render)==null?void 0:gn.alpha)!==void 0&&((bn=l==null?void 0:l.render)==null?void 0:bn.alpha)!==null?l.render.alpha:1;Qe.targetAlpha=qi,A.appendChild(ie);let X=((wn=m==null?void 0:m.gameplay)==null?void 0:wn.tuning)||{},P=m==null?void 0:m.ui,Xi=(En=X.button_width)!=null?En:260,Rt=(xn=X.button_height)!=null?xn:56,Ki=(_n=X.button_radius)!=null?_n:16,Ji=X.button_bg_color||((Tn=f.theme)==null?void 0:Tn.cta_background)||"#ffb43b",Zi=(vn=X.button_bg_alpha)!=null?vn:1,Qi=X.button_border_color||"#ffffff",Ui=(Sn=X.button_border_width)!=null?Sn:2,Va=(Rn=X.button_border_alpha)!=null?Rn:.2,Ue=(An=h.cta_offset_y)!=null?An:d*.7,M=document.createElement("button");M.style.cssText=`
|
|
97
97
|
width: ${Xi}px;
|
|
98
98
|
height: ${Rt}px;
|
|
99
99
|
background: ${Ji};
|
|
@@ -105,10 +105,10 @@
|
|
|
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),A.appendChild(M);let ea=(P==null?void 0:P.text)||((Cn=f.ui)==null?void 0:Cn.cta_label_end)||"DOWNLOAD",At=(P==null?void 0:P.font)||"brand.heading",ta=(P==null?void 0:P.fontSize)||20,na=X.button_text_color||((Hn=f.theme)==null?void 0:Hn.cta_text)||"#1a0a0a";M.textContent=ea,M.style.fontFamily=
|
|
109
|
-
font-family: ${
|
|
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 ea=(P==null?void 0:P.text)||((Cn=f.ui)==null?void 0:Cn.cta_label_end)||"DOWNLOAD",At=(P==null?void 0:P.font)||"brand.heading",ta=(P==null?void 0:P.fontSize)||20,na=X.button_text_color||((Hn=f.theme)==null?void 0:Hn.cta_text)||"#1a0a0a";M.textContent=ea,M.style.fontFamily=j(At),M.style.fontSize=`${ta}px`,M.style.fontWeight=String(G(At)),M.style.color=na,M.style.letterSpacing=`${(Mn=P==null?void 0:P.letterSpacing)!=null?Mn:1}px`;let Ct=se(M);Ct.element=M;let W=p==null?void 0:p.ui,Ht=((Ln=p==null?void 0:p.gameplay)==null?void 0:Ln.tuning)||{},ia=(W==null?void 0:W.text)||"Play the full game",Mt=(W==null?void 0:W.font)||"brand.body",aa=(W==null?void 0:W.fontSize)||11,sa=(kn=W==null?void 0:W.letterSpacing)!=null?kn:0,$e=(Fn=p==null?void 0:p.render)==null?void 0:Fn.tint,oa=typeof $e=="string"?$e:$e?`#${$e.toString(16).padStart(6,"0")}`:"#CCCCCC",ae=document.createElement("div");ae.textContent=ia,ae.style.cssText=`
|
|
109
|
+
font-family: ${j(Mt)};
|
|
110
110
|
font-size: ${aa}px;
|
|
111
|
-
font-weight: ${
|
|
111
|
+
font-weight: ${G(Mt)};
|
|
112
112
|
color: ${oa};
|
|
113
113
|
text-align: center;
|
|
114
114
|
letter-spacing: ${sa}px;
|
|
@@ -116,13 +116,13 @@
|
|
|
116
116
|
position: absolute;
|
|
117
117
|
transform: translate(-50%, -50%);
|
|
118
118
|
white-space: nowrap;
|
|
119
|
-
`;let ra=Ue+Rt/2+20,la=d-c-10,ca=Math.min(ra+((Dn=Ht.animation_start_y_offset)!=null?Dn:5),la);ae.style.top=`${ca}px`,ae.style.left="50%";let tt=se(ae);tt.element=ae,tt.animationStartYOffset=($n=Ht.animation_start_y_offset)!=null?$n:5,A.appendChild(ae);let nt=((Pn=y==null?void 0:y.gameplay)==null?void 0:Pn.tuning)||{},da=(Wn=nt.hand_offset_x)!=null?Wn:50,pa=(zn=nt.hand_offset_y)!=null?zn:50,ma=(
|
|
120
|
-
font-family: ${
|
|
119
|
+
`;let ra=Ue+Rt/2+20,la=d-c-10,ca=Math.min(ra+((Dn=Ht.animation_start_y_offset)!=null?Dn:5),la);ae.style.top=`${ca}px`,ae.style.left="50%";let tt=se(ae);tt.element=ae,tt.animationStartYOffset=($n=Ht.animation_start_y_offset)!=null?$n:5,A.appendChild(ae);let nt=((Pn=y==null?void 0:y.gameplay)==null?void 0:Pn.tuning)||{},da=(Wn=nt.hand_offset_x)!=null?Wn:50,pa=(zn=nt.hand_offset_y)!=null?zn:50,ma=(Nn=(Bn=y==null?void 0:y.transform)==null?void 0:Bn.scale)!=null?Nn:.1875,ua=(On=nt.hand_scale_multiplier)!=null?On:2.5,ha=new ye.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),be=new ye.Sprite(ha),Lt=ma*ua*100;return be.scale.set(Lt,Lt,1),be.position.set(da,Ue+pa,0),be.material.opacity=0,be.visible=!1,{panel:L,logo:Y,title:wt,subtitle:Ze,footer:Qe,ctaButton:et,ctaText:Ct,ctaHint:tt,hand:be}}function xi(e,t,n){var _,S,C,F,R,A,L,H;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=(C=a.fade_in_duration_ms)!=null?C: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=(H=a.cta_animation_delay_ms)!=null?H: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,N=Math.min(ee/r,1),I=1-Math.pow(1-N,3);f.alpha=I,f.element.style.opacity=I.toString();let oe=1+u*(1-I);f.element.style.transform=`translate(-50%, -50%) scale(${oe})`,N<1?requestAnimationFrame(b):(setTimeout(()=>Wa(h,s,t),l),setTimeout(()=>{za(g,s),setTimeout(()=>Ba(o,s),50)},m),setTimeout(()=>Na(E,s),p),setTimeout(()=>{Oa(T,x,s),setTimeout(()=>Ia(d,s),50),n&&n()},y))};b()}function Wa(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 za(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 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:-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 Na(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 Oa(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 Ia(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 _i(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,C;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=(C=s.hand_offset_y)!=null?C:50,x=t.element.getBoundingClientRect(),d=E,c=T,b=Date.now(),_=()=>{var I,oe,He;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=(I=a==null?void 0:a.transform)==null?void 0:I.scale)!=null?oe:.1875,H=(He=s.hand_scale_multiplier)!=null?He:2.5,ee=L*H*100,N=ee+ee*.2*Math.sin(R*Math.PI);e.scale.set(N,N,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 Ti(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 vi(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: ${j(u)};
|
|
121
121
|
font-size: ${l}px;
|
|
122
|
-
font-weight: ${
|
|
122
|
+
font-weight: ${G(u)};
|
|
123
123
|
color: ${f};
|
|
124
124
|
text-align: ${p};
|
|
125
|
-
letter-spacing: ${
|
|
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
|
-
`,h}function Si(e,t,n,i,a){var l,
|
|
134
|
+
`,h}function Si(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,C=t.y+d+_,F=S+b,R=C+_;e.position.set(S+(F-S)*T,C+(R-C)*T,0);let A=(h=u.scale)!=null?h:.1875,L=(g=r.hand_scale_multiplier)!=null?g:2.5,H=A*L*100;e.scale.set(H,H,1)}}var ge=we(require("three")),Ri=new ge.TextureLoader,ht=null,ft=null;async function Ai(){if(ht)return ht;if(!ft){let n=(()=>{if(typeof window!="undefined")try{return new URL("inline-assets.js",window.location.href).href}catch{return"./inline-assets.js"}return"./inline-assets.js"})();ft=new Function("path","return import(path)")(n).then(i=>i?i.INLINE_ASSETS?i.INLINE_ASSETS:(console.warn("[assets] Module does not have INLINE_ASSETS export. Module keys:",Object.keys(i)),{}):(console.warn("[assets] Module import returned undefined"),{})).catch(i=>(console.warn("[assets] Failed to load inline-assets.js:",i),{}))}let e=await ft;return ht=e||{},e||{}}async function yt(e,t,n=16777215,i=!1){try{let s=(await Ai())[e];return await Ri.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 Ci(e,t,n){var g,o,E,T;let a=(await Ai())[e]||e,s;try{s=await Ri.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 yt(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 Hi(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});
|
package/dist/three/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as dt}from"../chunk-
|
|
1
|
+
import{b as dt}from"../chunk-AOCUS265.mjs";import*as D from"three";var tn=(a=>(a[a.PHONE_TALL=0]="PHONE_TALL",a[a.TABLET=1]="TABLET",a[a.LANDSCAPE=2]="LANDSCAPE",a))(tn||{});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 Vn(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}},a=e.style.width&&!e.style.width.includes("%"),i=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=`
|
|
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-6MYM2EUT.mjs";import*as k from"three";var tn=(s=>(s
|
|
|
8
8
|
max-width: 100% !important;
|
|
9
9
|
max-height: 100% !important;
|
|
10
10
|
display: block !important;
|
|
11
|
-
background: ${
|
|
11
|
+
background: ${s} !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-6MYM2EUT.mjs";import*as k from"three";var tn=(s=>(s
|
|
|
19
19
|
padding: 0 !important;
|
|
20
20
|
border: none !important;
|
|
21
21
|
overflow: hidden !important;
|
|
22
|
-
`,e.appendChild(l);let
|
|
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 D.Scene,{width:h,height:p}=n(),f=new D.AmbientLight(16777215,.6);c.add(f);let y=new D.DirectionalLight(16777215,.8);y.position.set(5,5,5),y.castShadow=!1,c.add(y);let u=new D.DirectionalLight(16777215,.3);u.position.set(-5,0,5),c.add(u);let g=new D.PerspectiveCamera(55,h/p,.1,100);g.position.set(0,0,3.2),g.lookAt(0,0,0),g.updateMatrixWorld();let o=new D.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,_=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),g.aspect=R/F,g.updateProjectionMatrix();let
|
|
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),g.aspect=R/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(()=>{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:g,renderer:o,uiSystem:T,applySize:b}}import*as A from"three";var ht=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)}syncToThree(t){let n=t.position.z,a=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,a),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},pt=class{constructor(t){var n,a,i,s;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=(i=t==null?void 0:t.visible)!=null?i:!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(a=>{(a instanceof A.MeshBasicMaterial||a instanceof A.MeshStandardMaterial)&&a.color.copy(n)}):(t.material instanceof A.MeshBasicMaterial||t.material instanceof A.MeshStandardMaterial)&&t.material.color.copy(n)}}},mt=class{constructor(t,n,a,i){this.instanceId=t,this.objectConfig=n,this.threeObject=a,this._config=i,this.transform=new ht(i.transform),this.renderer=new pt(i.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 a=this.config.objects.get(t);if(!a)throw new Error(`Object config not found: ${t}`);let i=new mt(t,a.object_config||t,n,a);return this.objects.set(t,i),i}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,a]of this.objects.entries()){let i=t.objects.get(n);i&&a.updateConfig(i)}}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 jn(e,t){ut[e]=t}function Jn(){return Object.keys(ut)}import*as U from"three";function Q(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 Kn(e,t,n,a){var Zt,Vt,jt,Jt,Kt,Qt,It,Ot,Ut,te,ee,ne,ae,ie,se,oe,re,le,ce,de,he,pe,me,ue,ye,fe,ge,Ee,be,Te,xe,we,_e,Se,He,Re,ve,Ce,Me,Ae,Fe,Le,$e,We,ke,Be,De,ze,Pe,Ye,Ne,Ge,Xe,qe,Ze,Ve,je,Je,Ke,Qe,Ie,Oe,Ue;let i=e.objects.get("ui_endgame_1"),s=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"),f=e.objects.get("ui_endgame_hand_1"),y=e.engine.runtime||{},u=((Zt=i==null?void 0:i.gameplay)==null?void 0:Zt.tuning)||{},g=(i==null?void 0:i.render)||{},o=a.getBoundingClientRect(),b=o.width>0?o.width*.9:320,w=o.height>0?o.height*.85:400,T=Math.min((Vt=u.panel_width)!=null?Vt:320,b),d=Math.min((jt=u.panel_height)!=null?jt:400,w),r=(Jt=u.panel_padding)!=null?Jt:32,E=(Kt=u.panel_radius)!=null?Kt:24,x=g.background_color||u.panel_bg_color||"#1a0a0a",_=g.background_alpha!==void 0&&g.background_alpha!==null?g.background_alpha:(Qt=u.panel_bg_alpha)!=null?Qt:.98,R=g.border_color||u.panel_border_color||"#ffffff",F=(It=u.panel_border_width)!=null?It:2,S=(Ot=u.panel_border_alpha)!=null?Ot:.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
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-6MYM2EUT.mjs";import*as k from"three";var tn=(s=>(s
|
|
|
40
40
|
z-index: 1000;
|
|
41
41
|
box-sizing: border-box;
|
|
42
42
|
padding: ${r}px;
|
|
43
|
-
`,
|
|
43
|
+
`,a.appendChild(H);let M=Q(H);M.element=H;let v=((Ut=s==null?void 0:s.gameplay)==null?void 0:Ut.tuning)||{},Z=(s==null?void 0:s.transform)||{},B=(te=v.logo_size)!=null?te:56,z=(ee=Z.scale)!=null?ee:1,I=(ae=(ne=Z.offset)==null?void 0:ne.y)!=null?ae:-130,at=(ie=v.logo_alpha)!=null?ie:1,sn=new U.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),P=new U.Sprite(sn);P.position.set(0,I,0),P.material.opacity=0;let it=0,st=0;if(n&&(it=((se=n.image)==null?void 0:se.width)||100,st=((oe=n.image)==null?void 0:oe.height)||100),it>0&&st>0){let O=it/st,St,Ht;O>1?(St=B,Ht=B/O):(Ht=B,St=B*O);let qn=St/it*z,Zn=Ht/st*z;P.scale.set(qn,Zn,1)}else{let O=B/100*z;P.scale.set(O,O,1)}P.targetAlpha=at,P.baseScaleX=P.scale.x,P.baseScaleY=P.scale.y;let L=l==null?void 0:l.ui,Y=((re=l==null?void 0:l.gameplay)==null?void 0:re.tuning)||{},on=(L==null?void 0:L.text)||"MISSION ACCOMPLISHED",At=(L==null?void 0:L.font)||"brand.heading",ft=(L==null?void 0:L.fontSize)||24,rn=(le=L==null?void 0:L.letterSpacing)!=null?le:1,ot=(ce=l==null?void 0:l.render)==null?void 0:ce.tint,ln=typeof ot=="string"?ot:ot?`#${ot.toString(16).padStart(6,"0")}`:"#00FF88",cn=T-r*2-30,dn=Y.font_weight_override?Y.font_weight_override:q(At),V=document.createElement("div");V.textContent=on,V.style.cssText=`
|
|
44
44
|
font-family: ${X(At)};
|
|
45
45
|
font-size: ${ft}px;
|
|
46
46
|
font-weight: ${dn};
|
|
@@ -54,7 +54,7 @@ import{b as dt}from"../chunk-6MYM2EUT.mjs";import*as k from"three";var tn=(s=>(s
|
|
|
54
54
|
transform: translate(-50%, -50%);
|
|
55
55
|
white-space: nowrap;
|
|
56
56
|
max-width: ${cn}px;
|
|
57
|
-
`;let Ft=r+30,hn=((ye=u.title_offset_y)!=null?ye:Ft+ft/2)+((fe=Y.animation_start_y_offset)!=null?fe:-20);V.style.top=`${hn}px`,V.style.left="50%";let
|
|
57
|
+
`;let Ft=r+30,hn=((ye=u.title_offset_y)!=null?ye:Ft+ft/2)+((fe=Y.animation_start_y_offset)!=null?fe:-20);V.style.top=`${hn}px`,V.style.left="50%";let Lt=Q(V);Lt.element=V,H.appendChild(V);let $=m==null?void 0:m.ui,$t=((ge=m==null?void 0:m.gameplay)==null?void 0:ge.tuning)||{},pn=($==null?void 0:$.text)||"RESCUE COMPLETE",Wt=($==null?void 0:$.font)||"brand.body",gt=($==null?void 0:$.fontSize)||11,mn=(Ee=$==null?void 0:$.letterSpacing)!=null?Ee:.5,rt=(be=m==null?void 0:m.render)==null?void 0:be.tint,un=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#B0B0B0",j=document.createElement("div");j.textContent=pn,j.style.cssText=`
|
|
58
58
|
font-family: ${X(Wt)};
|
|
59
59
|
font-size: ${gt}px;
|
|
60
60
|
font-weight: ${q(Wt)};
|
|
@@ -65,10 +65,10 @@ import{b as dt}from"../chunk-6MYM2EUT.mjs";import*as k from"three";var tn=(s=>(s
|
|
|
65
65
|
position: absolute;
|
|
66
66
|
transform: translate(-50%, -50%);
|
|
67
67
|
white-space: nowrap;
|
|
68
|
-
`;let
|
|
69
|
-
font-family: ${X(
|
|
68
|
+
`;let kt=Ft+ft+15,yn=((Te=u.subtitle_offset_y)!=null?Te:kt+gt/2)+((xe=$t.animation_start_y_offset)!=null?xe:-10);j.style.top=`${yn}px`,j.style.left="50%";let Et=Q(j);Et.element=j,Et.animationStartYOffset=(we=$t.animation_start_y_offset)!=null?we:-10,H.appendChild(j);let N=c==null?void 0:c.ui,Bt=((_e=c==null?void 0:c.gameplay)==null?void 0:_e.tuning)||{},fn=(N==null?void 0:N.text)||((Se=y.ui)==null?void 0:Se.cta_hint)||"Continue the adventure!",Dt=(N==null?void 0:N.font)||"brand.body",zt=(N==null?void 0:N.fontSize)||16,lt=(He=c==null?void 0:c.render)==null?void 0:He.tint,gn=typeof lt=="string"?lt:lt?`#${lt.toString(16).padStart(6,"0")}`:"#FFFFFF",En=(Re=Bt.max_width)!=null?Re:T-r*2,bn=(ve=Bt.line_height)!=null?ve:1.4,J=document.createElement("div");J.textContent=fn,J.style.cssText=`
|
|
69
|
+
font-family: ${X(Dt)};
|
|
70
70
|
font-size: ${zt}px;
|
|
71
|
-
font-weight: ${q(
|
|
71
|
+
font-weight: ${q(Dt)};
|
|
72
72
|
color: ${gn};
|
|
73
73
|
text-align: center;
|
|
74
74
|
opacity: 0;
|
|
@@ -77,42 +77,42 @@ import{b as dt}from"../chunk-6MYM2EUT.mjs";import*as k from"three";var tn=(s=>(s
|
|
|
77
77
|
max-width: ${En}px;
|
|
78
78
|
line-height: ${bn};
|
|
79
79
|
word-wrap: break-word;
|
|
80
|
-
`;let Tn=
|
|
80
|
+
`;let Tn=kt+gt+30,xn=(Ce=u.footer_offset_y)!=null?Ce:Tn+zt/2;J.style.top=`${xn}px`,J.style.left="50%";let bt=Q(J);bt.element=J;let wn=((Me=c==null?void 0:c.render)==null?void 0:Me.alpha)!==void 0&&((Ae=c==null?void 0:c.render)==null?void 0:Ae.alpha)!==null?c.render.alpha:1;bt.targetAlpha=wn,H.appendChild(J);let G=((Fe=h==null?void 0:h.gameplay)==null?void 0:Fe.tuning)||{},W=h==null?void 0:h.ui,_n=(Le=G.button_width)!=null?Le:260,Pt=($e=G.button_height)!=null?$e:56,Sn=(We=G.button_radius)!=null?We:16,Hn=G.button_bg_color||((ke=y.theme)==null?void 0:ke.cta_background)||"#ffb43b",Rn=(Be=G.button_bg_alpha)!=null?Be:1,vn=G.button_border_color||"#ffffff",Cn=(De=G.button_border_width)!=null?De:2,ha=(ze=G.button_border_alpha)!=null?ze:.2,Tt=(Pe=u.cta_offset_y)!=null?Pe:d*.7,C=document.createElement("button");C.style.cssText=`
|
|
81
81
|
width: ${_n}px;
|
|
82
82
|
height: ${Pt}px;
|
|
83
|
-
background: ${
|
|
83
|
+
background: ${Hn};
|
|
84
84
|
opacity: ${Rn};
|
|
85
85
|
border: ${Cn}px solid ${vn};
|
|
86
|
-
border-radius: ${
|
|
86
|
+
border-radius: ${Sn}px;
|
|
87
87
|
cursor: pointer;
|
|
88
88
|
opacity: 0;
|
|
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=
|
|
92
|
+
`,C.style.top=`${Tt}px`,C.style.left="50%";let xt=Q(C);xt.element=C,xt.addEventListener=C.addEventListener.bind(C),H.appendChild(C);let Mn=(W==null?void 0:W.text)||((Ye=y.ui)==null?void 0:Ye.cta_label_end)||"DOWNLOAD",Yt=(W==null?void 0:W.font)||"brand.heading",An=(W==null?void 0:W.fontSize)||20,Fn=G.button_text_color||((Ne=y.theme)==null?void 0:Ne.cta_text)||"#1a0a0a";C.textContent=Mn,C.style.fontFamily=X(Yt),C.style.fontSize=`${An}px`,C.style.fontWeight=String(q(Yt)),C.style.color=Fn,C.style.letterSpacing=`${(Ge=W==null?void 0:W.letterSpacing)!=null?Ge:1}px`;let Nt=Q(C);Nt.element=C;let k=p==null?void 0:p.ui,Gt=((Xe=p==null?void 0:p.gameplay)==null?void 0:Xe.tuning)||{},Ln=(k==null?void 0:k.text)||"Play the full game",Xt=(k==null?void 0:k.font)||"brand.body",$n=(k==null?void 0:k.fontSize)||11,Wn=(qe=k==null?void 0:k.letterSpacing)!=null?qe:0,ct=(Ze=p==null?void 0:p.render)==null?void 0:Ze.tint,kn=typeof ct=="string"?ct:ct?`#${ct.toString(16).padStart(6,"0")}`:"#CCCCCC",K=document.createElement("div");K.textContent=Ln,K.style.cssText=`
|
|
93
93
|
font-family: ${X(Xt)};
|
|
94
|
-
font-size: ${
|
|
94
|
+
font-size: ${$n}px;
|
|
95
95
|
font-weight: ${q(Xt)};
|
|
96
|
-
color: ${
|
|
96
|
+
color: ${kn};
|
|
97
97
|
text-align: center;
|
|
98
98
|
letter-spacing: ${Wn}px;
|
|
99
99
|
opacity: 0;
|
|
100
100
|
position: absolute;
|
|
101
101
|
transform: translate(-50%, -50%);
|
|
102
102
|
white-space: nowrap;
|
|
103
|
-
`;let
|
|
104
|
-
font-family: ${X(
|
|
103
|
+
`;let Bn=Tt+Pt/2+20,Dn=d-r-10,zn=Math.min(Bn+((Ve=Gt.animation_start_y_offset)!=null?Ve:5),Dn);K.style.top=`${zn}px`,K.style.left="50%";let wt=Q(K);wt.element=K,wt.animationStartYOffset=(je=Gt.animation_start_y_offset)!=null?je:5,H.appendChild(K);let _t=((Je=f==null?void 0:f.gameplay)==null?void 0:Je.tuning)||{},Pn=(Ke=_t.hand_offset_x)!=null?Ke:50,Yn=(Qe=_t.hand_offset_y)!=null?Qe:50,Nn=(Oe=(Ie=f==null?void 0:f.transform)==null?void 0:Ie.scale)!=null?Oe:.1875,Gn=(Ue=_t.hand_scale_multiplier)!=null?Ue:2.5,Xn=new U.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),et=new U.Sprite(Xn),qt=Nn*Gn*100;return et.scale.set(qt,qt,1),et.position.set(Pn,Tt+Yn,0),et.material.opacity=0,et.visible=!1,{panel:M,logo:P,title:Lt,subtitle:Et,footer:bt,ctaButton:xt,ctaText:Nt,ctaHint:wt,hand:et}}function Qn(e,t,n){var x,_,R,F,S,H,M,v;let a=t.objects.get("ui_endgame_1"),i=((x=a==null?void 0:a.gameplay)==null?void 0:x.tuning)||{},s=(_=i.animation_duration_ms)!=null?_:800,l=(R=i.fade_in_duration_ms)!=null?R:600,m=(F=i.scale_animation_intensity)!=null?F:.1,c=(S=i.logo_animation_delay_ms)!=null?S:100,h=(H=i.title_animation_delay_ms)!=null?H:200,p=(M=i.footer_animation_delay_ms)!=null?M:300,f=(v=i.cta_animation_delay_ms)!=null?v:400,{panel:y,logo:u,title:g,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,B=Math.min(Z/l,1),z=1-Math.pow(1-B,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})`,B<1?requestAnimationFrame(E):(setTimeout(()=>In(u,s,t),c),setTimeout(()=>{On(g,s),setTimeout(()=>Un(o,s),50)},h),setTimeout(()=>ta(b,s),p),setTimeout(()=>{ea(w,T,s),setTimeout(()=>na(d,s),50),n&&n()},f))};E()}function In(e,t,n){var y,u,g,o,b;let a=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(u=(((y=a==null?void 0:a.gameplay)==null?void 0:y.tuning)||{}).animation_start_scale)!=null?u:1.2,l=Date.now(),m=e.material.opacity,c=(g=e.targetAlpha)!=null?g:1,h=(o=e.baseScaleX)!=null?o:e.scale.x,p=(b=e.baseScaleY)!=null?b:e.scale.y,f=()=>{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=s+(1-s)*d;e.scale.set(h*r,p*r,1),T<1&&requestAnimationFrame(f)};f()}function On(e,t){let n=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=parseFloat(e.element.style.top||"0"),s=()=>{let l=Date.now()-n,m=Math.min(l/t,1),c=1-Math.pow(1-m,2);e.element.style.opacity=(a+(1-a)*c).toString(),e.element.style.top=`${i-20*(1-c)}px`,m<1&&requestAnimationFrame(s)};s()}function Un(e,t){var m;let n=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=parseFloat(e.element.style.top||"0"),s=i-((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=(a+(1-a)*p).toString(),e.element.style.top=`${i+(s-i)*p}px`,h<1&&requestAnimationFrame(l)};l()}function ta(e,t){var l;let n=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=(l=e.targetAlpha)!=null?l:1,s=()=>{let m=Date.now()-n,c=Math.min(m/t,1),h=1-Math.pow(1-c,2);e.element.style.opacity=(a+(i-a)*h).toString(),c<1&&requestAnimationFrame(s)};s()}function ea(e,t,n){let a=Date.now(),i=parseFloat(e.element.style.opacity||"0"),s=()=>{let l=Date.now()-a,m=Math.min(l/n,1),c=1-Math.pow(1-m,2);e.element.style.opacity=(i+(1-i)*c).toString(),t.element.style.opacity=(i+(1-i)*c).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-c)})`,m<1&&requestAnimationFrame(s)};s()}function na(e,t){var m;let n=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=parseFloat(e.element.style.top||"0"),s=i-((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=(a+(1-a)*p).toString(),e.element.style.top=`${i+(s-i)*p}px`,h<1&&requestAnimationFrame(l)};l()}function aa(e,t,n,a){var p,f,y,u;let i=n.objects.get("ui_endgame_hand_1"),s=((p=i==null?void 0:i.gameplay)==null?void 0:p.tuning)||{},l=(f=s.click_animation_duration_ms)!=null?f:600,m=(y=s.click_delay_ms)!=null?y:2e3,c=(u=s.click_repeat_delay_ms)!=null?u:3e3,h=()=>{var _,R;e.visible=!0,e.material.opacity=1;let g=e.position.x,o=e.position.y,b=(_=s.hand_offset_x)!=null?_:50,w=(R=s.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(g+(d-g)*H,o+(r-o)*H,0);let M=(I=(z=i==null?void 0:i.transform)==null?void 0:z.scale)!=null?I:.1875,v=(at=s.hand_scale_multiplier)!=null?at:2.5,Z=M*v*100,B=Z+Z*.2*Math.sin(S*Math.PI);e.scale.set(B,B,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)",a()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(g,o,0),h()},c)},500))};x()};setTimeout(h,m)}import*as yt from"three";function ia(e,t,n){var u,g,o,b,w,T,d;let a=t.objects.get("hand_tutorial_1"),i=((u=a==null?void 0:a.gameplay)==null?void 0:u.tuning)||{},s=(a==null?void 0:a.render)||{},l=(a==null?void 0:a.transform)||{},m=new yt.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),c=new yt.Sprite(m),h=l.position||{},p=(g=h==null?void 0:h.z)!=null?g: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=s.alpha!==void 0&&s.alpha!==null?s.alpha:0,c.visible=s.visible!==void 0&&s.visible!==null?s.visible:!1;let f=(w=i.hand_scale_multiplier)!=null?w:2.5,y=(T=l.scale)!=null?T:.1875;return c.scale.set(y*f*100,y*f*100,1),c.renderOrder=(d=s.z_index)!=null?d:99999,c}function sa(e){var g,o,b,w,T,d,r,E,x;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,a=(t==null?void 0:t.render)||{},i=((g=e.engine.runtime)==null?void 0:g.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!",m=(n==null?void 0:n.font)||"brand.warning",c=(n==null?void 0:n.fontSize)||i.label_font_size||52,h=(w=n==null?void 0:n.letterSpacing)!=null?w:(b=i.label_letter_spacing)!=null?b:-1,p=(n==null?void 0:n.align)||"center",f=a.tint,y=typeof f=="string"?f:f?`#${f.toString(16).padStart(6,"0")}`:i.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(
|
|
106
|
+
font-weight: ${q(m)};
|
|
107
107
|
color: ${y};
|
|
108
|
-
text-align: ${
|
|
109
|
-
letter-spacing: ${
|
|
110
|
-
text-shadow: ${(T=
|
|
111
|
-
-webkit-text-stroke: ${
|
|
112
|
-
opacity: ${(x=
|
|
113
|
-
visibility: ${
|
|
108
|
+
text-align: ${p};
|
|
109
|
+
letter-spacing: ${h}px;
|
|
110
|
+
text-shadow: ${(T=i.label_shadow_distance)!=null?T:2}px ${(d=i.label_shadow_distance)!=null?d:2}px ${(r=i.label_shadow_blur)!=null?r:4}px rgba(0,0,0,${(E=i.label_shadow_alpha)!=null?E:.8});
|
|
111
|
+
-webkit-text-stroke: ${i.label_stroke||"#8B0000"} 2px;
|
|
112
|
+
opacity: ${(x=a.alpha)!=null?x:0};
|
|
113
|
+
visibility: ${a.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
|
-
`,u}function oa(e,t,n,
|
|
118
|
+
`,u}function oa(e,t,n,a,i){var c,h,p,f,y,u,g;let s=i.objects.get("hand_tutorial_1"),l=((c=s==null?void 0:s.gameplay)==null?void 0:c.tuning)||{},m=(s==null?void 0:s.transform)||{};if(!a){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=(f=l.y_offset)!=null?f: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=(g=l.hand_scale_multiplier)!=null?g:2.5,v=H*M*100;e.scale.set(v,v,1)}}import*as tt from"three";var en=new tt.TextureLoader,Ct=null,Mt=null;async function nn(){if(Ct)return Ct;if(!Mt){let n=(()=>{if(typeof window!="undefined")try{return new URL("inline-assets.js",window.location.href).href}catch{return"./inline-assets.js"}return"./inline-assets.js"})();Mt=new Function("path","return import(path)")(n).then(a=>a?a.INLINE_ASSETS?a.INLINE_ASSETS:(console.warn("[assets] Module does not have INLINE_ASSETS export. Module keys:",Object.keys(a)),{}):(console.warn("[assets] Module import returned undefined"),{})).catch(a=>(console.warn("[assets] Failed to load inline-assets.js:",a),{}))}let e=await Mt;return Ct=e||{},e||{}}async function an(e,t,n=16777215,a=!1){try{let s=(await nn())[e];return await en.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")}`,a?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 ra(e,t,n){var g,o,b,w;let i=(await nn())[e]||e,s;try{s=await en.loadAsync(i),console.log("[character] loaded sheet",{path:e,sourceUsed:i})}catch(T){let E=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");s=await an(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||{},m=(g=l.cols)!=null?g:3,c=(o=l.rows)!=null?o:2,h=((b=s.image)==null?void 0:b.width)||0,p=((w=s.image)==null?void 0:w.height)||0,f=h/m,y=p/c;if(!Number.isFinite(f)||!Number.isFinite(y)||f<=0||y<=0)return[s];let u=[];for(let T=0;T<c;T++)for(let d=0;d<m;d++){let r=document.createElement("canvas");r.width=f,r.height=y;let E=r.getContext("2d");E&&s.image&&E.drawImage(s.image,d*f,T*y,f,y,0,0,f,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 la(e,t){var f,y,u,g;let n=t.gameplay.brush||{},a=t.theme.brush_color||"#ffffff",i=(f=n.radius)!=null?f:20,s=(y=n.inner_radius)!=null?y:15,l=(u=n.alpha)!=null?u:.8,m=(g=n.inner_alpha)!=null?g:.3,c=n.inner_color||"#ffffff",h=document.createElement("canvas");h.width=i*2,h.height=i*2;let p=h.getContext("2d");return p&&(p.clearRect(0,0,h.width,h.height),p.beginPath(),p.arc(i,i,i,0,Math.PI*2),p.fillStyle=a,p.globalAlpha=l,p.fill(),p.beginPath(),p.arc(i,i,s,0,Math.PI*2),p.fillStyle=c,p.globalAlpha=m,p.fill()),new tt.CanvasTexture(h)}export{tn as AspectClass,mt as GameObject,vt as GameObjectManager,pt as Renderer,nt as ResponsiveUISystem,ht as Transform,aa as animateHandClick,Qn as animatePanelEntrance,la as createBrushTexture,Kn as createEndGamePanel,ia as createHandTutorial,Vn as createThreeBase,sa as createTutorialLabel,Rt as getAspectClass,Jn as getRegisteredFontIds,an as loadAsset,ra as loadCharacterFrames,jn as registerFont,X as resolveFont,q as resolveFontWeight,oa as updateHandAnimation};
|
package/package.json
CHANGED