handler-playable-sdk 0.2.1 → 0.2.3
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-SYQVN25U.mjs → chunk-6MYM2EUT.mjs} +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/pixi/index.js +2 -2
- package/dist/pixi/index.mjs +1 -1
- package/dist/three/index.js +43 -43
- package/dist/three/index.mjs +45 -45
- 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.1",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var s=0,Se=s++,Z=s++,ee=s++,te=s++,ne=s++,ie=s++,oe=s++,re=s++,ae=s++,se=s++,de=s++,le=s++,r=Se;function ce(){return r===Z}function ue(){return r===ee}function pe(){return r===te}function fe(){return r===ne}function g(){return r===ie}function y(){return r===oe}function me(){return r===re}function ge(){return r===ae}function ye(){return r===se}function H(){return r===de}function F(){return r===le}function we(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=Z;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=ee;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=te)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ne)}catch{}else if(t==="mintegral")window.gameReady&&(r=ie);else if(t==="tapjoy")window.TJ_API&&(r=oe);else if(t==="tiktok")window.openAppStore&&(r=re);else if(t==="smadex")try{window.smxTracking&&(r=ae)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=se)}catch{}else t==="vungle"?r=de:(e==="nucleo"||t==="nucleo")&&(r=le)}var Ee={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ce=Math.random().toString(36).slice(2),w=null,A={...Ee},Ae="web_embed",De={},G=!1,E=!1,T=!1,ke=!1,B=1,W=0,z=!1,d=!1,N="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),K=h>b,l=!1,k=!1,he=!1,be=!1,U=!1,M=null;function _e(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function j(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Te(e,t){return{event_name:e,ts:Date.now(),session_id:Ce,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:Ae==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=j(e),i=Te(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){B=e,o("volume",e)}function v(e){e&&(ke=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&ke||T&&(T=!1,o("resume"),_(B))}function f(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),K=h>b,o("resize",{width:h,height:b})}function Le(){if(ce())try{let e=mraid.getMaxSize();f(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();f(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ie(){if(ue())try{let e=dapi.getScreenSize();f(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();f(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function ve(){let e=()=>{l||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(l=!0,o("boot"),o("view"),o("ready"),d=!0,O(),k&&(k=!1,p.start()))};window.addEventListener("resize",()=>f()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function Pe(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(he=!0),!(he&&t instanceof MouseEvent)&&(W+=1,o("interaction",W))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Re(e){var i,c,x,C,J,D,q,L,$,X,Y,Q;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(c=window.TJ_API)==null?void 0:c.click)==null||x.call(c);else if(pe())(J=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||J.call(C);else if(ye())(q=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||q.call(D);else if(ge())try{($=(L=window.smxTracking)==null?void 0:L.redirect)==null||$.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(fe()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||N||""):e&&window.open(e)}else g()?(X=window.install)==null||X.call(window):me()?(Y=window.openAppStore)==null||Y.call(window):H()?(Q=parent==null?void 0:parent.postMessage)==null||Q.call(parent,"download","*"):e&&window.open(e)}function Me(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;a("view",()=>t(n.mraid_viewable)),a("start",()=>t(n.game_viewable)),a("engagement",()=>t(n.engagement));let i=()=>t(n.complete);a("complete",i),I("engagement",c=>{var x;((x=c==null?void 0:c.payload)==null?void 0:x.count)>3&&i()}),a("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;a("view",()=>t(n.Ad_Load_Start)),a("start",()=>t(n.Ad_Viewable)),a("engagement",()=>t(n.First_Engagement)),a("complete",()=>t(n.Gameplay_Complete)),a("cta_click",()=>t(n.DSP_Click)),a("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function je(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{p.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function xe(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function Ne(){g()&&(window.mintGameStart=()=>{S(!0),f()},window.mintGameClose=()=>{v(!0)})}function ze(){if(!F())return;let e=window.NUC;!e||!e.trigger||(p.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,N)}),p.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var p={init(e={},t){if(Ae=e.profile||"web_embed",De=e.consent||{},A={...Ee,...e.ids||{}},w=e.rootEl||w,N=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,_e(),Ve(w),we(),Le(),Ie(),!z){if(document.readyState==="complete")ve();else if(!be){be=!0;let n=()=>{ve(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Pe(),Me(),je(),Ne(),ze(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),l&&!d&&(o("boot"),o("view"),o("ready"),k&&(k=!1,p.start()),d=!0),d=l},getRoot(){return _e()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return K},get isReady(){return d},get isStarted(){return G},get isPaused(){return T},get isFinished(){return E},get volume(){return B},get interactions(){return W},on(e,t){I(j(e),t)},off(e,t){V(j(e),t)},start(){var e,t;if(!G){if(!l){k=!0;return}if(G=!0,o("start"),f(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:K?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):H()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&xe())},install(e){if(!E){E=!0,y()?(xe(),setTimeout(()=>p.install(e),300)):(o("complete"),setTimeout(()=>p.install(e),0));return}U||(U=!0,setTimeout(()=>U=!1,500),o("cta_click"),o("conversion"),Re(e||N))},emit(e,t){let n=j(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Te(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(F()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){f(e,t)}},Be=p;function Ve(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
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=`
|
|
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.1",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var d=0,Me=d++,ee=d++,te=d++,ne=d++,ie=d++,oe=d++,re=d++,ae=d++,se=d++,de=d++,le=d++,ce=d++,r=Me;function ue(){return r===ee}function pe(){return r===te}function fe(){return r===ne}function me(){return r===ie}function g(){return r===oe}function y(){return r===re}function ge(){return r===ae}function ye(){return r===se}function we(){return r===de}function F(){return r===le}function G(){return r===ce}function he(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=ee;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=te;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=ne)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ie)}catch{}else if(t==="mintegral")window.gameReady&&(r=oe);else if(t==="tapjoy")window.TJ_API&&(r=re);else if(t==="tiktok")window.openAppStore&&(r=ae);else if(t==="smadex")try{window.smxTracking&&(r=se)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=de)}catch{}else t==="vungle"?r=le:(e==="nucleo"||t==="nucleo")&&(r=ce)}var Ae={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},je=Math.random().toString(36).slice(2),w=null,A={...Ae},ke="web_embed",Ne={},U=!1,E=!1,T=!1,Te=!1,J=1,K=0,z=!1,l=!1,N="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),B=h>b,c=!1,k=!1,be=!1,_e=!1,W=!1,M=null;function ve(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function j(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Oe(e,t){return{event_name:e,ts:Date.now(),session_id:je,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:ke==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=j(e),i=Oe(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){J=e,o("volume",e)}function v(e){e&&(Te=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&Te||T&&(T=!1,o("resume"),_(J))}function f(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),B=h>b,o("resize",{width:h,height:b})}function ze(){if(ue())try{let e=mraid.getMaxSize();f(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();f(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ve(){if(pe())try{let e=dapi.getScreenSize();f(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();f(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function xe(){let e=()=>{c||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(c=!0,o("boot"),o("view"),o("ready"),l=!0,O(),k&&(k=!1,u.start()))};window.addEventListener("resize",()=>f()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function He(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(be=!0),!(be&&t instanceof MouseEvent)&&(K+=1,o("interaction",K))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Fe(e){var i,a,x,C,q,D,$,L,X,Y,Q,Z;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(a=window.TJ_API)==null?void 0:a.click)==null||x.call(a);else if(fe())(q=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||q.call(C);else if(we())($=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||$.call(D);else if(ye())try{(X=(L=window.smxTracking)==null?void 0:L.redirect)==null||X.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(me()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||N||""):e&&window.open(e)}else g()?(Y=window.install)==null||Y.call(window):ge()?(Q=window.openAppStore)==null||Q.call(window):F()?(Z=parent==null?void 0:parent.postMessage)==null||Z.call(parent,"download","*"):e&&window.open(e)}function Ge(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;s("view",()=>t(n.mraid_viewable)),s("start",()=>t(n.game_viewable)),s("engagement",()=>t(n.engagement));let i=()=>t(n.complete);s("complete",i),I("engagement",a=>{var x;((x=a==null?void 0:a.payload)==null?void 0:x.count)>3&&i()}),s("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;s("view",()=>t(n.Ad_Load_Start)),s("start",()=>t(n.Ad_Viewable)),s("engagement",()=>t(n.First_Engagement)),s("complete",()=>t(n.Gameplay_Complete)),s("cta_click",()=>t(n.DSP_Click)),s("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ue(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{u.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Ee(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function We(){g()&&(window.mintGameStart=()=>{S(!0),f()},window.mintGameClose=()=>{v(!0)})}function Ke(){if(!G())return;let e=window.NUC;!e||!e.trigger||(u.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,N)}),u.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var u={init(e={},t){if(ke=e.profile||"web_embed",Ne=e.consent||{},A={...Ae,...e.ids||{}},w=e.rootEl||w,N=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,ve(),Je(w),he(),ze(),Ve(),!z){if(document.readyState==="complete")xe();else if(!_e){_e=!0;let n=()=>{xe(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}He(),Ge(),Ue(),We(),Ke(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),c&&!l&&(o("boot"),o("view"),o("ready"),k&&(k=!1,u.start()),l=!0),l=c},getRoot(){return ve()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return B},get isReady(){return l},get isStarted(){return U},get isPaused(){return T},get isFinished(){return E},get volume(){return J},get interactions(){return K},on(e,t){I(j(e),t)},off(e,t){H(j(e),t)},start(){var e,t;if(!U){if(!c){k=!0;return}if(U=!0,o("start"),f(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:B?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):F()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&Ee())},install(e){if(!E){E=!0,y()?(Ee(),setTimeout(()=>u.install(e),300)):(o("complete"),setTimeout(()=>u.install(e),0));return}W||(W=!0,setTimeout(()=>W=!1,500),o("cta_click"),o("conversion"),Fe(e||N))},emit(e,t){let n=j(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Oe(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(G()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){f(e,t)}},Be=u;function Je(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
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=`
|
|
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-6MYM2EUT.mjs";export{a as Handler,b as default};
|
package/dist/pixi/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ke=Object.defineProperty;var $a=Object.getOwnPropertyDescriptor;var Ja=Object.getOwnPropertyNames;var Qa=Object.prototype.hasOwnProperty;var Za=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},Ua=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ja(t))!Qa.call(e,s)&&s!==n&&Ke(e,s,{get:()=>t[s],enumerable:!(a=$a(t,s))||a.enumerable});return e};var ei=e=>Ua(Ke({},"__esModule",{value:!0}),e);var wi={};Za(wi,{GameObject:()=>Ae,GameObjectManager:()=>Ie,Renderer:()=>Ce,Transform:()=>Se,animateHandClick:()=>ia,animatePanelEntrance:()=>aa,createBrushTexture:()=>da,createEndGamePanel:()=>na,createHandTutorial:()=>sa,createPixiBase:()=>Un,createTutorialLabel:()=>oa,getRegisteredFontIds:()=>ta,loadAsset:()=>at,loadCharacterFrames:()=>ca,registerFont:()=>ea,resolveFont:()=>j,resolveFontWeight:()=>G,updateHandAnimation:()=>ra});module.exports=ei(wi);var Zn=require("pixi.js");var ee={};function Re(e,t,n=!1){ee[e]||(ee[e]=[]),ee[e].push({fn:t,once:n})}function $e(e,t){if(ee[e]){if(!t){delete ee[e];return}ee[e]=ee[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=ee[e];if(n)for(let a of[...n])a.fn(...t),a.once&&$e(e,a.fn)}function W(e,t){Re(e,t,!0)}var He={name:"handler-playable-sdk",version:"0.2.1",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var N=0,ni=N++,Sn=N++,Cn=N++,An=N++,En=N++,kn=N++,Dn=N++,Pn=N++,Fn=N++,Mn=N++,Ln=N++,Rn=N++,_=ni;function zn(){return _===Sn}function Hn(){return _===Cn}function On(){return _===An}function Wn(){return _===En}function de(){return _===kn}function ue(){return _===Dn}function Nn(){return _===Pn}function Yn(){return _===Fn}function Bn(){return _===Mn}function Je(){return _===Ln}function Qe(){return _===Rn}function In(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),_=Sn;return}catch{}else if(e==="dapi")try{dapi.isReady(),_=Cn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(_=An)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(_=En)}catch{}else if(t==="mintegral")window.gameReady&&(_=kn);else if(t==="tapjoy")window.TJ_API&&(_=Dn);else if(t==="tiktok")window.openAppStore&&(_=Pn);else if(t==="smadex")try{window.smxTracking&&(_=Fn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(_=Mn)}catch{}else t==="vungle"?_=Ln:(e==="nucleo"||t==="nucleo")&&(_=Rn)}var Kn={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},ai=Math.random().toString(36).slice(2),pe=null,be={...Kn},$n="web_embed",ii={},Ze=!1,_e=!1,xe=!1,Jn=!1,nt=1,et=0,Ye=!1,J=!1,Ne="",fe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),tt=fe>me,Q=!1,we=!1,jn=!1,Gn=!1,Ue=!1,Oe=null;function Vn(){if(pe)return pe;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),pe=e,e}function We(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Qn(e,t){return{event_name:e,ts:Date.now(),session_id:ai,deployment_id:be.deployment_id,variant_id:be.variant_id,export_profile_id:be.profile_id,instance_id:be.instance_id||"default",env:$n==="mraid"?"mraid":"web",payload:t}}function y(e,t){let n=We(e),a=Qn(n,t);ze(n,a),n!==e&&ze(e,a)}function Te(){Oe&&(Oe(fe,me),Oe=null)}function he(e){nt=e,y("volume",e)}function ye(e){e&&(Jn=!0),!xe&&(xe=!0,y("pause"),he(0))}function ve(e){!e&&Jn||xe&&(xe=!1,y("resume"),he(nt))}function ne(e,t){fe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),tt=fe>me,y("resize",{width:fe,height:me})}function si(){if(zn())try{let e=mraid.getMaxSize();ne(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ve():ye()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ne(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();he(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&he(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Ye=!0,mraid.isViewable()&&mraid.getState()!=="hidden")Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function oi(){if(Hn())try{let e=dapi.getScreenSize();ne(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ve():ye()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();ne(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(he(t?1:0),dapi.addEventListener("audioVolumeChange",n=>he(n?1:0)),Ye=!0,dapi.isViewable())Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function qn(){let e=()=>{Q||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te(),we&&(we=!1,te.start()))};window.addEventListener("resize",()=>ne()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ve(),e()):ye()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ye=!0}function ri(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(jn=!0),!(jn&&t instanceof MouseEvent)&&(et+=1,y("interaction",et))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function li(e){var a,s,i,o,r,l,d,p,f,u,c,h;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(a=window.ExitApi)==null||a.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ue())(i=(s=window.TJ_API)==null?void 0:s.click)==null||i.call(s);else if(On())(r=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||r.call(o);else if(Bn())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Yn())try{(f=(p=window.smxTracking)==null?void 0:p.redirect)==null||f.call(p)}catch(m){console.warn("Smadex redirect failed",m)}else if(Wn()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||Ne||""):e&&window.open(e)}else de()?(u=window.install)==null||u.call(window):Nn()?(c=window.openAppStore)==null||c.call(window):Je()?(h=parent==null?void 0:parent.postMessage)==null||h.call(parent,"download","*"):e&&window.open(e)}function ci(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let a=new Image;a.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;W("view",()=>t(n.mraid_viewable)),W("start",()=>t(n.game_viewable)),W("engagement",()=>t(n.engagement));let a=()=>t(n.complete);W("complete",a),Re("engagement",s=>{var i;((i=s==null?void 0:s.payload)==null?void 0:i.count)>3&&a()}),W("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;W("view",()=>t(n.Ad_Load_Start)),W("start",()=>t(n.Ad_Viewable)),W("engagement",()=>t(n.First_Engagement)),W("complete",()=>t(n.Gameplay_Complete)),W("cta_click",()=>t(n.DSP_Click)),W("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function di(){if(!ue())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Xn(){var t,n,a;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(a=e==null?void 0:e.gameplayFinished)==null||a.call(e)}function ui(){de()&&(window.mintGameStart=()=>{ve(!0),ne()},window.mintGameClose=()=>{ye(!0)})}function pi(){if(!Qe())return;let e=window.NUC;!e||!e.trigger||(te.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ne)}),te.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var te={init(e={},t){if($n=e.profile||"web_embed",ii=e.consent||{},be={...Kn,...e.ids||{}},pe=e.rootEl||pe,Ne=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),y("init"),document.body.oncontextmenu=()=>!1,Vn(),fi(pe),In(),si(),oi(),!Ye){if(document.readyState==="complete")qn();else if(!Gn){Gn=!0;let n=()=>{qn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}ri(),ci(),di(),ui(),pi(),console.log(`%c @handler/playable-sdk %c v${He.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),Q&&!J&&(y("boot"),y("view"),y("ready"),we&&(we=!1,te.start()),J=!0),J=Q},getRoot(){return Vn()},get version(){return He.version||"0.0.0"},get maxWidth(){return fe},get maxHeight(){return me},get isLandscape(){return tt},get isReady(){return J},get isStarted(){return Ze},get isPaused(){return xe},get isFinished(){return _e},get volume(){return nt},get interactions(){return et},on(e,t){Re(We(e),t)},off(e,t){$e(We(e),t)},start(){var e,t;if(!Ze){if(!Q){we=!0;return}if(Ze=!0,y("start"),ne(),de())ye(),(e=window.gameReady)==null||e.call(window);else if(ue()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:tt?"landscape":"portrait",buildID:He.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,y("complete"),de()?(e=window.gameEnd)==null||e.call(window):Je()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ue()&&Xn())},install(e){if(!_e){_e=!0,ue()?(Xn(),setTimeout(()=>te.install(e),300)):(y("complete"),setTimeout(()=>te.install(e),0));return}Ue||(Ue=!0,setTimeout(()=>Ue=!1,500),y("cta_click"),y("conversion"),li(e||Ne))},emit(e,t){let n=We(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let a=Qn(n,t);ze(n,a)},retry(){var e,t,n;if(de())(e=window.gameRetry)==null||e.call(window);else if(Qe()){let a=window.NUC;(n=(t=a==null?void 0:a.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}y("engagement",{action:"retry"})},pause(){ye(!0)},resume(){ve(!0)},resize(e,t){ne(e,t)}},Be=te;function fi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
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=`
|
|
2
2
|
(function(){
|
|
3
3
|
var events = ['touchstart','touchend','mousedown','keydown'];
|
|
4
4
|
function unlock(){
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
}
|
|
15
15
|
events.forEach(function(e){ document.addEventListener(e, unlock, false); });
|
|
16
16
|
})();
|
|
17
|
-
`,e.appendChild(t)}async function Un(e,t={}){let n=new Zn.Application;await n.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let a=i=>{var l,d,p,f,u,c;let o=(p=(d=(l=i==null?void 0:i.width)!=null?l:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(c=(u=(f=i==null?void 0:i.height)!=null?f:e.clientHeight)!=null?u:window.innerHeight)!=null?c:480;n.renderer.resize(o,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(n.canvas);let s=document.createElement("div");return s.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(s),Be.on("pause",()=>{n.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),Be.on("resume",()=>{n.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),Be.on("resize",({payload:i})=>{a({width:i==null?void 0:i.width,height:i==null?void 0:i.height})}),window.addEventListener("resize",()=>a()),requestAnimationFrame(()=>a()),{app:n,stage:n.stage,overlay:s,applySize:a}}var Se=class{constructor(t){var n,a;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(a=t==null?void 0:t.rotation)!=null?a:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},Ce=class{constructor(t){var n,a,s,i;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(a=t==null?void 0:t.alpha)!=null?a:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(i=t==null?void 0:t.tint)!=null?i:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},Ae=class{constructor(t,n,a,s){this.instanceId=t,this.objectConfig=n,this.pixiObject=a,this._config=s,this.transform=new Se(s.transform),this.renderer=new Ce(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},Ie=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let a=this.config.objects.get(t);if(!a)throw new Error(`Object config not found: ${t}`);let s=new Ae(t,a.object_config||t,n,a);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,a]of this.objects.entries()){let s=t.objects.get(n);s&&a.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var je={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function j(e){let t=je[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function G(e){var n;let t=je[e];return t&&(n=t.weight)!=null?n:"400"}function ea(e,t){je[e]=t}function ta(){return Object.keys(je)}var w=require("pixi.js");function na(e,t,n){var ht,yt,gt,_t,bt,wt,xt,Tt,vt,St,Ct,At,Et,kt,Dt,Pt,Ft,Mt,Lt,Rt,zt,Ht,Ot,Wt,Nt,Yt,Bt,It,jt,Gt,Vt,qt,Xt,Kt,$t,Jt,Qt,Zt,Ut,en,tn,nn,an,sn,on,rn,ln,cn,dn,un,pn,fn,mn,hn,yn,gn,_n,bn,wn,xn;let a=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),i=e.objects.get("ui_endgame_title_1"),o=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),l=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),f=e.engine.runtime||{},u=new w.Container;u.alpha=0,u.visible=!1;let c=((ht=a==null?void 0:a.gameplay)==null?void 0:ht.tuning)||{},h=(a==null?void 0:a.render)||{},m=(yt=c.panel_width)!=null?yt:320,g=(gt=c.panel_height)!=null?gt:400,x=(_t=c.panel_padding)!=null?_t:32,T=(bt=c.panel_radius)!=null?bt:24,A=h.background_color||c.panel_bg_color||"#1a0a0a",v=h.background_alpha!==void 0&&h.background_alpha!==null?h.background_alpha:(wt=c.panel_bg_alpha)!=null?wt:.98,E=h.border_color||c.panel_border_color||"#ffffff",k=(xt=c.panel_border_width)!=null?xt:2,S=(Tt=c.panel_border_alpha)!=null?Tt:.3,C=new w.Graphics;C.roundRect(-m/2,-g/2,m,g,T);let b=A.replace("#","");C.fill({color:parseInt(b,16),alpha:v});let D=E.replace("#","");C.stroke({color:parseInt(D,16),width:k,alpha:S});let L=new w.Graphics;L.roundRect(-m/2+2,-g/2+2,m-4,g-4,T-2),L.stroke({color:16777215,width:1,alpha:.1}),C.addChild(L),u.addChild(C);let V=((vt=s==null?void 0:s.gameplay)==null?void 0:vt.tuning)||{},Z=(s==null?void 0:s.transform)||{},Y=(St=V.logo_size)!=null?St:56,q=(Ct=Z.scale)!=null?Ct:1,ae=(Et=(At=Z.offset)==null?void 0:At.y)!=null?Et:-130,ua=(kt=V.logo_alpha)!=null?kt:1,F=new w.Sprite(n||w.Texture.EMPTY);F.anchor.set(.5);let se=0,oe=0;if(n&&n!==w.Texture.EMPTY){let M=n.frame,$=n.baseTexture;M&&M.width&&M.height?(se=M.width,oe=M.height):$&&$.width&&$.height?(se=$.width,oe=$.height):n.width&&n.height&&(se=n.width,oe=n.height)}if(se>0&&oe>0){let M=se/oe,$,Xe;M>1?($=Y,Xe=Y/M):(Xe=Y,$=Y*M);let Tn=$/se,vn=Xe/oe;Tn*=q,vn*=q,F.scale.set(Tn,vn)}else{let M=Y/100*q;F.scale.set(M)}F.position.set(0,ae),F.alpha=0,F.visible=!0,F.targetAlpha=ua,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,u.addChild(F);let R=i==null?void 0:i.ui,B=((Dt=i==null?void 0:i.gameplay)==null?void 0:Dt.tuning)||{},pa=(R==null?void 0:R.text)||"MISSION ACCOMPLISHED",it=(R==null?void 0:R.font)||"brand.heading",fa=(R==null?void 0:R.fontSize)||24,ma=(Pt=R==null?void 0:R.letterSpacing)!=null?Pt:1,Ee=(Ft=i==null?void 0:i.render)==null?void 0:Ft.tint,ha=typeof Ee=="string"?Ee:Ee?`#${Ee.toString(16).padStart(6,"0")}`:"#00FF88",st=m-x*2-30,ya=B.font_weight_override?B.font_weight_override:G(it),U=new w.Text({text:pa,style:{fontFamily:j(it),fontSize:fa,fontWeight:ya,fill:ha,align:"center",letterSpacing:ma,wordWrap:!1,stroke:{color:B.stroke_color||"#000000",width:(Mt=B.stroke_width)!=null?Mt:2},dropShadow:{color:B.shadow_color||"#000000",alpha:(Lt=B.shadow_alpha)!=null?Lt:.9,angle:(Rt=B.shadow_angle)!=null?Rt:0,blur:(zt=B.shadow_blur)!=null?zt:8,distance:(Ht=B.shadow_distance)!=null?Ht:4}}});if(U.width>st){let M=st/U.width;U.scale.set(M)}U.anchor.set(.5);let ot=(Ot=c.title_offset_y)!=null?Ot:30,ga=ot+((Wt=B.animation_start_y_offset)!=null?Wt:-20);U.position.set(0,ga),U.alpha=0,u.addChild(U);let z=o==null?void 0:o.ui,rt=((Nt=o==null?void 0:o.gameplay)==null?void 0:Nt.tuning)||{},_a=(z==null?void 0:z.text)||"RESCUE COMPLETE",lt=(z==null?void 0:z.font)||"brand.body",ba=(z==null?void 0:z.fontSize)||11,wa=(Yt=z==null?void 0:z.letterSpacing)!=null?Yt:.5,ke=(Bt=o==null?void 0:o.render)==null?void 0:Bt.tint,xa=typeof ke=="string"?ke:ke?`#${ke.toString(16).padStart(6,"0")}`:"#B0B0B0",re=new w.Text({text:_a,style:{fontFamily:j(lt),fontSize:ba,fontWeight:G(lt),fill:xa,align:"center",letterSpacing:wa}});re.anchor.set(.5);let Ta=ot+20+((It=rt.animation_start_y_offset)!=null?It:-10);re.position.set(0,Ta),re.alpha=0,re.animationStartYOffset=(jt=rt.animation_start_y_offset)!=null?jt:-10,u.addChild(re);let X=r==null?void 0:r.ui,ct=((Gt=r==null?void 0:r.gameplay)==null?void 0:Gt.tuning)||{},va=(X==null?void 0:X.text)||((Vt=f.ui)==null?void 0:Vt.cta_hint)||"Continue the adventure!",dt=(X==null?void 0:X.font)||"brand.body",Sa=(X==null?void 0:X.fontSize)||16,De=(qt=r==null?void 0:r.render)==null?void 0:qt.tint,Ca=typeof De=="string"?De:De?`#${De.toString(16).padStart(6,"0")}`:"#FFFFFF",Aa=(Xt=ct.max_width)!=null?Xt:m-x*2,Ea=(Kt=ct.line_height)!=null?Kt:1.4,le=new w.Text({text:va,style:{fontFamily:j(dt),fontSize:Sa,fontWeight:G(dt),fill:Ca,align:"center",wordWrap:!0,wordWrapWidth:Aa,lineHeight:Ea}});le.anchor.set(.5);let ka=($t=c.footer_offset_y)!=null?$t:120;le.position.set(0,ka);let Da=((Jt=r==null?void 0:r.render)==null?void 0:Jt.alpha)!==void 0&&((Qt=r==null?void 0:r.render)==null?void 0:Qt.alpha)!==null?r.render.alpha:1;le.alpha=0,le.targetAlpha=Da,u.addChild(le);let K=((Zt=l==null?void 0:l.gameplay)==null?void 0:Zt.tuning)||{},H=l==null?void 0:l.ui,Pe=(Ut=K.button_width)!=null?Ut:260,Fe=(en=K.button_height)!=null?en:56,ut=(tn=K.button_radius)!=null?tn:16,Pa=K.button_bg_color||((nn=f.theme)==null?void 0:nn.cta_background)||"#ffb43b",Fa=(an=K.button_bg_alpha)!=null?an:1,Ma=K.button_border_color||"#ffffff",La=(sn=K.button_border_width)!=null?sn:2,Ra=(on=K.button_border_alpha)!=null?on:.2,Me=(rn=c.cta_offset_y)!=null?rn:160,I=new w.Graphics;I.roundRect(-Pe/2,-Fe/2,Pe,Fe,ut);let za=Pa.replace("#","");I.fill({color:parseInt(za,16),alpha:Fa});let Ha=Ma.replace("#","");I.stroke({color:parseInt(Ha,16),width:La,alpha:Ra});let Ve=new w.Graphics;Ve.roundRect(-Pe/2+2,-Fe/2+2,Pe-4,Fe-4,ut-2),Ve.stroke({color:0,width:1,alpha:.15}),I.addChild(Ve),I.position.set(0,Me),I.alpha=0,I.eventMode="static",I.cursor="pointer",u.addChild(I);let Oa=(H==null?void 0:H.text)||((ln=f.ui)==null?void 0:ln.cta_label_end)||"DOWNLOAD",pt=(H==null?void 0:H.font)||"brand.heading",Wa=(H==null?void 0:H.fontSize)||20,Na=K.button_text_color||((cn=f.theme)==null?void 0:cn.cta_text)||"#1a0a0a",ge=new w.Text({text:Oa,style:{fontFamily:j(pt),fontSize:Wa,fontWeight:G(pt),fill:Na,align:"center",letterSpacing:(dn=H==null?void 0:H.letterSpacing)!=null?dn:1}});ge.anchor.set(.5),ge.position.set(0,Me),ge.alpha=0,u.addChild(ge);let O=d==null?void 0:d.ui,ft=((un=d==null?void 0:d.gameplay)==null?void 0:un.tuning)||{},Ya=(O==null?void 0:O.text)||"Play the full game",mt=(O==null?void 0:O.font)||"brand.body",Ba=(O==null?void 0:O.fontSize)||11,Ia=(pn=O==null?void 0:O.letterSpacing)!=null?pn:0,Le=(fn=d==null?void 0:d.render)==null?void 0:fn.tint,ja=typeof Le=="string"?Le:Le?`#${Le.toString(16).padStart(6,"0")}`:"#CCCCCC",ce=new w.Text({text:Ya,style:{fontFamily:j(mt),fontSize:Ba,fontWeight:G(mt),fill:ja,align:"center",letterSpacing:Ia}});ce.anchor.set(.5);let Ga=Me+35+((mn=ft.animation_start_y_offset)!=null?mn:5);ce.position.set(0,Ga),ce.alpha=0,ce.animationStartYOffset=(hn=ft.animation_start_y_offset)!=null?hn:5,u.addChild(ce);let qe=((yn=p==null?void 0:p.gameplay)==null?void 0:yn.tuning)||{},Va=(gn=qe.hand_offset_x)!=null?gn:50,qa=(_n=qe.hand_offset_y)!=null?_n:50,Xa=(wn=(bn=p==null?void 0:p.transform)==null?void 0:bn.scale)!=null?wn:.1875,Ka=(xn=qe.hand_scale_multiplier)!=null?xn:2.5,ie=new w.Sprite(t||w.Texture.EMPTY);return ie.anchor.set(.5),ie.scale.set(Xa*Ka),ie.position.set(Va,Me+qa),ie.alpha=0,ie.visible=!1,u.addChild(ie),{panel:u,logo:F,title:U,subtitle:re,footer:le,ctaButton:I,ctaText:ge,ctaHint:ce,hand:ie}}function aa(e,t,n){var k,S,C,b,D,L,V,Z;let a=t.objects.get("ui_endgame_1"),s=((k=a==null?void 0:a.gameplay)==null?void 0:k.tuning)||{},i=(S=s.animation_duration_ms)!=null?S:800,o=(C=s.fade_in_duration_ms)!=null?C:600,r=(b=s.scale_animation_intensity)!=null?b:.1,l=(D=s.logo_animation_delay_ms)!=null?D:100,d=(L=s.title_animation_delay_ms)!=null?L:200,p=(V=s.footer_animation_delay_ms)!=null?V:300,f=(Z=s.cta_animation_delay_ms)!=null?Z:400,{panel:u,logo:c,title:h,subtitle:m,footer:g,ctaButton:x,ctaText:T,ctaHint:A}=e;u.visible=!0;let v=Date.now(),E=()=>{let Y=Date.now()-v,q=Math.min(Y/o,1),ae=1-Math.pow(1-q,3);u.alpha=ae,u.scale.set(1+r*(1-ae)),q<1?requestAnimationFrame(E):(setTimeout(()=>mi(c,i,t),l),setTimeout(()=>{hi(h,i),setTimeout(()=>yi(m,i),50)},d),setTimeout(()=>gi(g,i),p),setTimeout(()=>{_i(x,T,i),setTimeout(()=>bi(A,i),50),n&&n()},f))};E()}function mi(e,t,n){var u,c,h,m,g;let a=n==null?void 0:n.objects.get("ui_endgame_logo_1"),i=(c=(((u=a==null?void 0:a.gameplay)==null?void 0:u.tuning)||{}).animation_start_scale)!=null?c:1.2,o=Date.now(),r=e.alpha,l=(h=e.targetAlpha)!=null?h:1,d=(m=e.baseScaleX)!=null?m:e.scale.x,p=(g=e.baseScaleY)!=null?g:e.scale.y,f=()=>{let x=Date.now()-o,T=Math.min(x/t,1),A=1-Math.pow(1-T,2);e.alpha=r+(l-r)*A;let v=i+(1-i)*A;e.scale.set(d*v,p*v),T<1&&requestAnimationFrame(f)};f()}function hi(e,t){let n=Date.now(),a=e.alpha,s=e.y,i=()=>{let o=Date.now()-n,r=Math.min(o/t,1),l=1-Math.pow(1-r,2);e.alpha=a+(1-a)*l,e.y=s-20*(1-l),r<1&&requestAnimationFrame(i)};i()}function yi(e,t){var r;let n=Date.now(),a=e.alpha,s=e.position.y,i=s-((r=e.animationStartYOffset)!=null?r:-10),o=()=>{let l=Date.now()-n,d=Math.min(l/t,1),p=1-Math.pow(1-d,2);e.alpha=a+(1-a)*p,e.position.y=s+(i-s)*p,d<1&&requestAnimationFrame(o)};o()}function gi(e,t){var o;let n=Date.now(),a=e.alpha,s=(o=e.targetAlpha)!=null?o:1,i=()=>{let r=Date.now()-n,l=Math.min(r/t,1),d=1-Math.pow(1-l,2);e.alpha=a+(s-a)*d,l<1&&requestAnimationFrame(i)};i()}function _i(e,t,n){let a=Date.now(),s=e.alpha,i=()=>{let o=Date.now()-a,r=Math.min(o/n,1),l=1-Math.pow(1-r,2);e.alpha=s+(1-s)*l,t.alpha=s+(1-s)*l,e.scale.set(1+.1*(1-l)),r<1&&requestAnimationFrame(i)};i()}function bi(e,t){var r;let n=Date.now(),a=e.alpha,s=e.position.y,i=s-((r=e.animationStartYOffset)!=null?r:5),o=()=>{let l=Date.now()-n,d=Math.min(l/t,1),p=1-Math.pow(1-d,2);e.alpha=a+(1-a)*p,e.position.y=s+(i-s)*p,d<1&&requestAnimationFrame(o)};o()}function ia(e,t,n,a){var p,f,u,c;let s=n.objects.get("ui_endgame_hand_1"),i=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},o=(f=i.click_animation_duration_ms)!=null?f:600,r=(u=i.click_delay_ms)!=null?u:2e3,l=(c=i.click_repeat_delay_ms)!=null?c:3e3,d=()=>{var k,S;e.visible=!0,e.alpha=1;let h=e.x,m=e.y,g=(k=i.hand_offset_x)!=null?k:50,x=(S=i.hand_offset_y)!=null?S:50,T=t.x+g,A=t.y+x,v=Date.now(),E=()=>{var Y,q,ae;let C=Date.now()-v,b=Math.min(C/o,1),D=b<.5?2*b*b:1-Math.pow(-2*b+2,2)/2;e.x=h+(T-h)*D,e.y=m+(A-m)*D;let L=(q=(Y=s==null?void 0:s.transform)==null?void 0:Y.scale)!=null?q:.1875,V=(ae=i.hand_scale_multiplier)!=null?ae:2.5,Z=L*V;e.scale.set(Z+Z*.2*Math.sin(b*Math.PI)),b<1?requestAnimationFrame(E):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),a()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=h,e.y=m,d()},l)},500))};E()};setTimeout(d,r)}var Ge=require("pixi.js");function sa(e,t,n){var p,f,u,c;let a=t.objects.get("hand_tutorial_1"),s=((p=a==null?void 0:a.gameplay)==null?void 0:p.tuning)||{},i=(a==null?void 0:a.render)||{},o=(a==null?void 0:a.transform)||{},r=new Ge.Sprite(e);r.anchor.set(.5),r.alpha=0;let l=(f=s.hand_scale_multiplier)!=null?f:2.5,d=(u=o.scale)!=null?u:.1875;return r.scale.set(d*l),r.zIndex=(c=i.z_index)!=null?c:99999,r}function oa(e){var h,m,g,x,T,A,v,E,k,S;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,a=(t==null?void 0:t.render)||{},s=((h=e.engine.runtime)==null?void 0:h.ui_styles)||{},i=((m=e.engine.runtime)==null?void 0:m.ui)||{},o=(n==null?void 0:n.text)||i.tutorial_label||i.label_text||"CLEAN!",r=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||s.label_font_size||52,d=(x=n==null?void 0:n.letterSpacing)!=null?x:(g=s.label_letter_spacing)!=null?g:-1,p=(n==null?void 0:n.align)||"center",f=a.tint,u=typeof f=="string"?f:f?`#${f.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",c=new Ge.Text({text:o,style:{fontFamily:j(r),fontSize:l,fontWeight:G(r),fill:u,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(T=s.label_shadow_alpha)!=null?T:.8,angle:(A=s.label_shadow_angle)!=null?A:0,blur:(v=s.label_shadow_blur)!=null?v:4,distance:(E=s.label_shadow_distance)!=null?E:2}}});return c.anchor.set(.5,0),c.alpha=(k=a.alpha)!=null?k:0,c.visible=(S=a.visible)!=null?S:!0,c}function ra(e,t,n,a,s){var l,d,p,f,u,c,h;let i=s.objects.get("hand_tutorial_1"),o=((l=i==null?void 0:i.gameplay)==null?void 0:l.tuning)||{},r=(i==null?void 0:i.transform)||{};if(!a){let m=(d=o.animation_duration)!=null?d:1.5,g=n%m/m,x=g<.5?2*g*g:-1+(4-2*g)*g,T=(p=o.x_offset)!=null?p:0,A=(f=o.y_offset)!=null?f:0,v=(u=o.animation_range)!=null?u:40,E=v*.7,k=v,S=t.x+T+E,C=t.y+A+k,b=S+E,D=C+k;e.x=S+(b-S)*x,e.y=C+(D-C)*x;let L=(c=r.scale)!=null?c:.1875,V=(h=o.hand_scale_multiplier)!=null?h:2.5;e.scale.set(L*V)}}var P=require("pixi.js");function la(e,t){if(!e)return;let n=t[e];if(n)return n;let a=e.split("?")[0].split("#")[0];if(a!==e&&t[a])return t[a];let s=a.split("/").pop();if(s&&t[s])return t[s];let i=a.replace(/^\.?\/*/,"");if(i!==a&&t[i])return t[i]}async function at(e,t,n=16777215,a=!1){try{let s=globalThis.INLINE_ASSETS||{},i=la(e,s)||e;return await P.Assets.load(i)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let i=new P.Graphics;return a?i.roundRect(0,0,60,120,10).fill({color:n}):(i.circle(30,30,30).fill({color:n}),i.rect(25,30,10,40).fill({color:n})),t.renderer.generateTexture(i)}}async function ca(e,t,n){var m,g,x,T,A,v,E,k,S,C;let a=globalThis.INLINE_ASSETS||{},s=la(e,a)||e,i;try{i=await P.Assets.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(b){let L=(n.gameplay.character_sheet||{}).fallback_color||"#ff00ff";i=await at(e,t,new P.Color(L).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:b})}let o=i.source||i.baseTexture||i;o&&"valid"in o&&o.valid===!1&&typeof o.once=="function"&&await new Promise(b=>o.once("loaded",b));let r=n.gameplay.character_sheet||{},l=(m=r.cols)!=null?m:3,d=(g=r.rows)!=null?g:2,p=(v=(A=(x=o==null?void 0:o.width)!=null?x:o==null?void 0:o.pixelWidth)!=null?A:(T=o==null?void 0:o.baseTexture)==null?void 0:T.width)!=null?v:i.width,f=(C=(S=(E=o==null?void 0:o.height)!=null?E:o==null?void 0:o.pixelHeight)!=null?S:(k=o==null?void 0:o.baseTexture)==null?void 0:k.height)!=null?C:i.height,u=p/l,c=f/d;if(!Number.isFinite(u)||!Number.isFinite(c)||u<=0||c<=0||!o)return[i];let h=[];for(let b=0;b<d;b++)for(let D=0;D<l;D++)h.push(new P.Texture({source:o,frame:new P.Rectangle(D*u,b*c,u,c)}));return h.length>2&&h.push(...h.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:h.length}),h}function da(e,t){var p,f,u,c;let n=t.gameplay.brush||{},a=new P.Color(t.theme.brush_color||"#ffffff").toNumber(),s=(p=n.radius)!=null?p:20,i=(f=n.inner_radius)!=null?f:15,o=(u=n.alpha)!=null?u:.8,r=(c=n.inner_alpha)!=null?c:.3,l=n.inner_color||"#ffffff",d=new P.Graphics;return d.circle(0,0,s).fill({color:a,alpha:o}),d.circle(0,0,i).fill({color:new P.Color(l).toNumber(),alpha:r}),e.renderer.generateTexture(d)}0&&(module.exports={GameObject,GameObjectManager,Renderer,Transform,animateHandClick,animatePanelEntrance,createBrushTexture,createEndGamePanel,createHandTutorial,createPixiBase,createTutorialLabel,getRegisteredFontIds,loadAsset,loadCharacterFrames,registerFont,resolveFont,resolveFontWeight,updateHandAnimation});
|
|
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});
|
package/dist/pixi/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as lt}from"../chunk-SYQVN25U.mjs";import{Application as En}from"pixi.js";async function Dn(e,t={}){let a=new En;await a.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let i=n=>{var c,d,p,u,h,l;let o=(p=(d=(c=n==null?void 0:n.width)!=null?c:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(l=(h=(u=n==null?void 0:n.height)!=null?u:e.clientHeight)!=null?h:window.innerHeight)!=null?l:480;a.renderer.resize(o,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(a.canvas);let s=document.createElement("div");return s.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),e.appendChild(s),lt.on("pause",()=>{a.ticker.stop(),document.querySelectorAll("audio").forEach(o=>o.pause())}),lt.on("resume",()=>{a.ticker.start(),document.querySelectorAll("audio").forEach(o=>{o.currentTime>0&&!o.ended&&o.play().catch(()=>{})})}),lt.on("resize",({payload:n})=>{i({width:n==null?void 0:n.width,height:n==null?void 0:n.height})}),window.addEventListener("resize",()=>i()),requestAnimationFrame(()=>i()),{app:a,stage:a.stage,overlay:s,applySize:i}}var ct=class{constructor(t){var a,i;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(a=t==null?void 0:t.scale)!=null?a:1,this.rotation=(i=t==null?void 0:t.rotation)!=null?i:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},dt=class{constructor(t){var a,i,s,n;this.z_index=(a=t==null?void 0:t.z_index)!=null?a:0,this.alpha=(i=t==null?void 0:t.alpha)!=null?i:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(n=t==null?void 0:t.tint)!=null?n:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},ht=class{constructor(t,a,i,s){this.instanceId=t,this.objectConfig=a,this.pixiObject=i,this._config=s,this.transform=new ct(s.transform),this.renderer=new dt(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,a){this.transform.position={x:t,y:a},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},gt=class{constructor(t){this.objects=new Map;this.config=t}create(t,a){let i=this.config.objects.get(t);if(!i)throw new Error(`Object config not found: ${t}`);let s=new ht(t,i.object_config||t,a,i);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[a,i]of this.objects.entries()){let s=t.objects.get(a);s&&i.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var pt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function X(e){let t=pt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var a;let t=pt[e];return t&&(a=t.weight)!=null?a:"400"}function Yn(e,t){pt[e]=t}function kn(){return Object.keys(pt)}import{Container as zn,Graphics as ut,Text as tt,Sprite as Le,Texture as _t}from"pixi.js";function Mn(e,t,a){var Yt,kt,zt,Mt,Ht,Wt,Bt,Rt,Lt,Gt,Nt,Xt,qt,$t,Vt,jt,Jt,Kt,Qt,Zt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,de,he,pe,ue,me,fe,ye,ge,_e,be,xe,we,Te,Ce,Se,ve,Ae,Fe,Pe,Ee,De,Ye,ke,ze,Me,He,We;let i=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),n=e.objects.get("ui_endgame_title_1"),o=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),c=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),u=e.engine.runtime||{},h=new zn;h.alpha=0,h.visible=!1;let l=((Yt=i==null?void 0:i.gameplay)==null?void 0:Yt.tuning)||{},m=(i==null?void 0:i.render)||{},f=(kt=l.panel_width)!=null?kt:320,y=(zt=l.panel_height)!=null?zt:400,_=(Mt=l.panel_padding)!=null?Mt:32,b=(Ht=l.panel_radius)!=null?Ht:24,C=m.background_color||l.panel_bg_color||"#1a0a0a",x=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(Wt=l.panel_bg_alpha)!=null?Wt:.98,S=m.border_color||l.panel_border_color||"#ffffff",v=(Bt=l.panel_border_width)!=null?Bt:2,w=(Rt=l.panel_border_alpha)!=null?Rt:.3,T=new ut;T.roundRect(-f/2,-y/2,f,y,b);let g=C.replace("#","");T.fill({color:parseInt(g,16),alpha:x});let A=S.replace("#","");T.stroke({color:parseInt(A,16),width:v,alpha:w});let E=new ut;E.roundRect(-f/2+2,-y/2+2,f-4,y-4,b-2),E.stroke({color:16777215,width:1,alpha:.1}),T.addChild(E),h.addChild(T);let B=((Lt=s==null?void 0:s.gameplay)==null?void 0:Lt.tuning)||{},$=(s==null?void 0:s.transform)||{},M=(Gt=B.logo_size)!=null?Gt:56,R=(Nt=$.scale)!=null?Nt:1,j=(qt=(Xt=$.offset)==null?void 0:Xt.y)!=null?qt:-130,$e=($t=B.logo_alpha)!=null?$t:1,F=new Le(a||_t.EMPTY);F.anchor.set(.5);let K=0,Q=0;if(a&&a!==_t.EMPTY){let P=a.frame,N=a.baseTexture;P&&P.width&&P.height?(K=P.width,Q=P.height):N&&N.width&&N.height?(K=N.width,Q=N.height):a.width&&a.height&&(K=a.width,Q=a.height)}if(K>0&&Q>0){let P=K/Q,N,yt;P>1?(N=M,yt=M/P):(yt=M,N=M*P);let Be=N/K,Re=yt/Q;Be*=R,Re*=R,F.scale.set(Be,Re)}else{let P=M/100*R;F.scale.set(P)}F.position.set(0,j),F.alpha=0,F.visible=!0,F.targetAlpha=$e,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,h.addChild(F);let D=n==null?void 0:n.ui,H=((Vt=n==null?void 0:n.gameplay)==null?void 0:Vt.tuning)||{},Ve=(D==null?void 0:D.text)||"MISSION ACCOMPLISHED",xt=(D==null?void 0:D.font)||"brand.heading",je=(D==null?void 0:D.fontSize)||24,Je=(jt=D==null?void 0:D.letterSpacing)!=null?jt:1,et=(Jt=n==null?void 0:n.render)==null?void 0:Jt.tint,Ke=typeof et=="string"?et:et?`#${et.toString(16).padStart(6,"0")}`:"#00FF88",wt=f-_*2-30,Qe=H.font_weight_override?H.font_weight_override:q(xt),V=new tt({text:Ve,style:{fontFamily:X(xt),fontSize:je,fontWeight:Qe,fill:Ke,align:"center",letterSpacing:Je,wordWrap:!1,stroke:{color:H.stroke_color||"#000000",width:(Kt=H.stroke_width)!=null?Kt:2},dropShadow:{color:H.shadow_color||"#000000",alpha:(Qt=H.shadow_alpha)!=null?Qt:.9,angle:(Zt=H.shadow_angle)!=null?Zt:0,blur:(Ot=H.shadow_blur)!=null?Ot:8,distance:(It=H.shadow_distance)!=null?It:4}}});if(V.width>wt){let P=wt/V.width;V.scale.set(P)}V.anchor.set(.5);let Tt=(Ut=l.title_offset_y)!=null?Ut:30,Ze=Tt+((te=H.animation_start_y_offset)!=null?te:-20);V.position.set(0,Ze),V.alpha=0,h.addChild(V);let Y=o==null?void 0:o.ui,Ct=((ee=o==null?void 0:o.gameplay)==null?void 0:ee.tuning)||{},Oe=(Y==null?void 0:Y.text)||"RESCUE COMPLETE",St=(Y==null?void 0:Y.font)||"brand.body",Ie=(Y==null?void 0:Y.fontSize)||11,Ue=(ne=Y==null?void 0:Y.letterSpacing)!=null?ne:.5,nt=(ae=o==null?void 0:o.render)==null?void 0:ae.tint,tn=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=new tt({text:Oe,style:{fontFamily:X(St),fontSize:Ie,fontWeight:q(St),fill:tn,align:"center",letterSpacing:Ue}});Z.anchor.set(.5);let en=Tt+20+((se=Ct.animation_start_y_offset)!=null?se:-10);Z.position.set(0,en),Z.alpha=0,Z.animationStartYOffset=(ie=Ct.animation_start_y_offset)!=null?ie:-10,h.addChild(Z);let L=r==null?void 0:r.ui,vt=((oe=r==null?void 0:r.gameplay)==null?void 0:oe.tuning)||{},nn=(L==null?void 0:L.text)||((re=u.ui)==null?void 0:re.cta_hint)||"Continue the adventure!",At=(L==null?void 0:L.font)||"brand.body",an=(L==null?void 0:L.fontSize)||16,at=(le=r==null?void 0:r.render)==null?void 0:le.tint,sn=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#FFFFFF",on=(ce=vt.max_width)!=null?ce:f-_*2,rn=(de=vt.line_height)!=null?de:1.4,O=new tt({text:nn,style:{fontFamily:X(At),fontSize:an,fontWeight:q(At),fill:sn,align:"center",wordWrap:!0,wordWrapWidth:on,lineHeight:rn}});O.anchor.set(.5);let ln=(he=l.footer_offset_y)!=null?he:120;O.position.set(0,ln);let cn=((pe=r==null?void 0:r.render)==null?void 0:pe.alpha)!==void 0&&((ue=r==null?void 0:r.render)==null?void 0:ue.alpha)!==null?r.render.alpha:1;O.alpha=0,O.targetAlpha=cn,h.addChild(O);let G=((me=c==null?void 0:c.gameplay)==null?void 0:me.tuning)||{},k=c==null?void 0:c.ui,st=(fe=G.button_width)!=null?fe:260,it=(ye=G.button_height)!=null?ye:56,Ft=(ge=G.button_radius)!=null?ge:16,dn=G.button_bg_color||((_e=u.theme)==null?void 0:_e.cta_background)||"#ffb43b",hn=(be=G.button_bg_alpha)!=null?be:1,pn=G.button_border_color||"#ffffff",un=(xe=G.button_border_width)!=null?xe:2,mn=(we=G.button_border_alpha)!=null?we:.2,ot=(Te=l.cta_offset_y)!=null?Te:160,W=new ut;W.roundRect(-st/2,-it/2,st,it,Ft);let fn=dn.replace("#","");W.fill({color:parseInt(fn,16),alpha:hn});let yn=pn.replace("#","");W.stroke({color:parseInt(yn,16),width:un,alpha:mn});let mt=new ut;mt.roundRect(-st/2+2,-it/2+2,st-4,it-4,Ft-2),mt.stroke({color:0,width:1,alpha:.15}),W.addChild(mt),W.position.set(0,ot),W.alpha=0,W.eventMode="static",W.cursor="pointer",h.addChild(W);let gn=(k==null?void 0:k.text)||((Ce=u.ui)==null?void 0:Ce.cta_label_end)||"DOWNLOAD",Pt=(k==null?void 0:k.font)||"brand.heading",_n=(k==null?void 0:k.fontSize)||20,bn=G.button_text_color||((Se=u.theme)==null?void 0:Se.cta_text)||"#1a0a0a",U=new tt({text:gn,style:{fontFamily:X(Pt),fontSize:_n,fontWeight:q(Pt),fill:bn,align:"center",letterSpacing:(ve=k==null?void 0:k.letterSpacing)!=null?ve:1}});U.anchor.set(.5),U.position.set(0,ot),U.alpha=0,h.addChild(U);let z=d==null?void 0:d.ui,Et=((Ae=d==null?void 0:d.gameplay)==null?void 0:Ae.tuning)||{},xn=(z==null?void 0:z.text)||"Play the full game",Dt=(z==null?void 0:z.font)||"brand.body",wn=(z==null?void 0:z.fontSize)||11,Tn=(Fe=z==null?void 0:z.letterSpacing)!=null?Fe:0,rt=(Pe=d==null?void 0:d.render)==null?void 0:Pe.tint,Cn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",I=new tt({text:xn,style:{fontFamily:X(Dt),fontSize:wn,fontWeight:q(Dt),fill:Cn,align:"center",letterSpacing:Tn}});I.anchor.set(.5);let Sn=ot+35+((Ee=Et.animation_start_y_offset)!=null?Ee:5);I.position.set(0,Sn),I.alpha=0,I.animationStartYOffset=(De=Et.animation_start_y_offset)!=null?De:5,h.addChild(I);let ft=((Ye=p==null?void 0:p.gameplay)==null?void 0:Ye.tuning)||{},vn=(ke=ft.hand_offset_x)!=null?ke:50,An=(ze=ft.hand_offset_y)!=null?ze:50,Fn=(He=(Me=p==null?void 0:p.transform)==null?void 0:Me.scale)!=null?He:.1875,Pn=(We=ft.hand_scale_multiplier)!=null?We:2.5,J=new Le(t||_t.EMPTY);return J.anchor.set(.5),J.scale.set(Fn*Pn),J.position.set(vn,ot+An),J.alpha=0,J.visible=!1,h.addChild(J),{panel:h,logo:F,title:V,subtitle:Z,footer:O,ctaButton:W,ctaText:U,ctaHint:I,hand:J}}function Hn(e,t,a){var v,w,T,g,A,E,B,$;let i=t.objects.get("ui_endgame_1"),s=((v=i==null?void 0:i.gameplay)==null?void 0:v.tuning)||{},n=(w=s.animation_duration_ms)!=null?w:800,o=(T=s.fade_in_duration_ms)!=null?T:600,r=(g=s.scale_animation_intensity)!=null?g:.1,c=(A=s.logo_animation_delay_ms)!=null?A:100,d=(E=s.title_animation_delay_ms)!=null?E:200,p=(B=s.footer_animation_delay_ms)!=null?B:300,u=($=s.cta_animation_delay_ms)!=null?$:400,{panel:h,logo:l,title:m,subtitle:f,footer:y,ctaButton:_,ctaText:b,ctaHint:C}=e;h.visible=!0;let x=Date.now(),S=()=>{let M=Date.now()-x,R=Math.min(M/o,1),j=1-Math.pow(1-R,3);h.alpha=j,h.scale.set(1+r*(1-j)),R<1?requestAnimationFrame(S):(setTimeout(()=>Wn(l,n,t),c),setTimeout(()=>{Bn(m,n),setTimeout(()=>Rn(f,n),50)},d),setTimeout(()=>Ln(y,n),p),setTimeout(()=>{Gn(_,b,n),setTimeout(()=>Nn(C,n),50),a&&a()},u))};S()}function Wn(e,t,a){var h,l,m,f,y;let i=a==null?void 0:a.objects.get("ui_endgame_logo_1"),n=(l=(((h=i==null?void 0:i.gameplay)==null?void 0:h.tuning)||{}).animation_start_scale)!=null?l:1.2,o=Date.now(),r=e.alpha,c=(m=e.targetAlpha)!=null?m:1,d=(f=e.baseScaleX)!=null?f:e.scale.x,p=(y=e.baseScaleY)!=null?y:e.scale.y,u=()=>{let _=Date.now()-o,b=Math.min(_/t,1),C=1-Math.pow(1-b,2);e.alpha=r+(c-r)*C;let x=n+(1-n)*C;e.scale.set(d*x,p*x),b<1&&requestAnimationFrame(u)};u()}function Bn(e,t){let a=Date.now(),i=e.alpha,s=e.y,n=()=>{let o=Date.now()-a,r=Math.min(o/t,1),c=1-Math.pow(1-r,2);e.alpha=i+(1-i)*c,e.y=s-20*(1-c),r<1&&requestAnimationFrame(n)};n()}function Rn(e,t){var r;let a=Date.now(),i=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:-10),o=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=i+(1-i)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(o)};o()}function Ln(e,t){var o;let a=Date.now(),i=e.alpha,s=(o=e.targetAlpha)!=null?o:1,n=()=>{let r=Date.now()-a,c=Math.min(r/t,1),d=1-Math.pow(1-c,2);e.alpha=i+(s-i)*d,c<1&&requestAnimationFrame(n)};n()}function Gn(e,t,a){let i=Date.now(),s=e.alpha,n=()=>{let o=Date.now()-i,r=Math.min(o/a,1),c=1-Math.pow(1-r,2);e.alpha=s+(1-s)*c,t.alpha=s+(1-s)*c,e.scale.set(1+.1*(1-c)),r<1&&requestAnimationFrame(n)};n()}function Nn(e,t){var r;let a=Date.now(),i=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:5),o=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=i+(1-i)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(o)};o()}function Xn(e,t,a,i){var p,u,h,l;let s=a.objects.get("ui_endgame_hand_1"),n=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},o=(u=n.click_animation_duration_ms)!=null?u:600,r=(h=n.click_delay_ms)!=null?h:2e3,c=(l=n.click_repeat_delay_ms)!=null?l:3e3,d=()=>{var v,w;e.visible=!0,e.alpha=1;let m=e.x,f=e.y,y=(v=n.hand_offset_x)!=null?v:50,_=(w=n.hand_offset_y)!=null?w:50,b=t.x+y,C=t.y+_,x=Date.now(),S=()=>{var M,R,j;let T=Date.now()-x,g=Math.min(T/o,1),A=g<.5?2*g*g:1-Math.pow(-2*g+2,2)/2;e.x=m+(b-m)*A,e.y=f+(C-f)*A;let E=(R=(M=s==null?void 0:s.transform)==null?void 0:M.scale)!=null?R:.1875,B=(j=n.hand_scale_multiplier)!=null?j:2.5,$=E*B;e.scale.set($+$*.2*Math.sin(g*Math.PI)),g<1?requestAnimationFrame(S):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),i()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=m,e.y=f,d()},c)},500))};S()};setTimeout(d,r)}import{Sprite as qn,Text as $n}from"pixi.js";function Vn(e,t,a){var p,u,h,l;let i=t.objects.get("hand_tutorial_1"),s=((p=i==null?void 0:i.gameplay)==null?void 0:p.tuning)||{},n=(i==null?void 0:i.render)||{},o=(i==null?void 0:i.transform)||{},r=new qn(e);r.anchor.set(.5),r.alpha=0;let c=(u=s.hand_scale_multiplier)!=null?u:2.5,d=(h=o.scale)!=null?h:.1875;return r.scale.set(d*c),r.zIndex=(l=n.z_index)!=null?l:99999,r}function jn(e){var m,f,y,_,b,C,x,S,v,w;let t=e.objects.get("ui_tutorial_1"),a=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},s=((m=e.engine.runtime)==null?void 0:m.ui_styles)||{},n=((f=e.engine.runtime)==null?void 0:f.ui)||{},o=(a==null?void 0:a.text)||n.tutorial_label||n.label_text||"CLEAN!",r=(a==null?void 0:a.font)||"brand.warning",c=(a==null?void 0:a.fontSize)||s.label_font_size||52,d=(_=a==null?void 0:a.letterSpacing)!=null?_:(y=s.label_letter_spacing)!=null?y:-1,p=(a==null?void 0:a.align)||"center",u=i.tint,h=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",l=new $n({text:o,style:{fontFamily:X(r),fontSize:c,fontWeight:q(r),fill:h,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(b=s.label_shadow_alpha)!=null?b:.8,angle:(C=s.label_shadow_angle)!=null?C:0,blur:(x=s.label_shadow_blur)!=null?x:4,distance:(S=s.label_shadow_distance)!=null?S:2}}});return l.anchor.set(.5,0),l.alpha=(v=i.alpha)!=null?v:0,l.visible=(w=i.visible)!=null?w:!0,l}function Jn(e,t,a,i,s){var c,d,p,u,h,l,m;let n=s.objects.get("hand_tutorial_1"),o=((c=n==null?void 0:n.gameplay)==null?void 0:c.tuning)||{},r=(n==null?void 0:n.transform)||{};if(!i){let f=(d=o.animation_duration)!=null?d:1.5,y=a%f/f,_=y<.5?2*y*y:-1+(4-2*y)*y,b=(p=o.x_offset)!=null?p:0,C=(u=o.y_offset)!=null?u:0,x=(h=o.animation_range)!=null?h:40,S=x*.7,v=x,w=t.x+b+S,T=t.y+C+v,g=w+S,A=T+v;e.x=w+(g-w)*_,e.y=T+(A-T)*_;let E=(l=r.scale)!=null?l:.1875,B=(m=o.hand_scale_multiplier)!=null?m:2.5;e.scale.set(E*B)}}import{Graphics as Ge,Assets as Ne,Texture as Kn,Rectangle as Qn,Color as bt}from"pixi.js";function Xe(e,t){if(!e)return;let a=t[e];if(a)return a;let i=e.split("?")[0].split("#")[0];if(i!==e&&t[i])return t[i];let s=i.split("/").pop();if(s&&t[s])return t[s];let n=i.replace(/^\.?\/*/,"");if(n!==i&&t[n])return t[n]}async function qe(e,t,a=16777215,i=!1){try{let s=globalThis.INLINE_ASSETS||{},n=Xe(e,s)||e;return await Ne.load(n)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let n=new Ge;return i?n.roundRect(0,0,60,120,10).fill({color:a}):(n.circle(30,30,30).fill({color:a}),n.rect(25,30,10,40).fill({color:a})),t.renderer.generateTexture(n)}}async function Zn(e,t,a){var f,y,_,b,C,x,S,v,w,T;let i=globalThis.INLINE_ASSETS||{},s=Xe(e,i)||e,n;try{n=await Ne.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(g){let E=(a.gameplay.character_sheet||{}).fallback_color||"#ff00ff";n=await qe(e,t,new bt(E).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:g})}let o=n.source||n.baseTexture||n;o&&"valid"in o&&o.valid===!1&&typeof o.once=="function"&&await new Promise(g=>o.once("loaded",g));let r=a.gameplay.character_sheet||{},c=(f=r.cols)!=null?f:3,d=(y=r.rows)!=null?y:2,p=(x=(C=(_=o==null?void 0:o.width)!=null?_:o==null?void 0:o.pixelWidth)!=null?C:(b=o==null?void 0:o.baseTexture)==null?void 0:b.width)!=null?x:n.width,u=(T=(w=(S=o==null?void 0:o.height)!=null?S:o==null?void 0:o.pixelHeight)!=null?w:(v=o==null?void 0:o.baseTexture)==null?void 0:v.height)!=null?T:n.height,h=p/c,l=u/d;if(!Number.isFinite(h)||!Number.isFinite(l)||h<=0||l<=0||!o)return[n];let m=[];for(let g=0;g<d;g++)for(let A=0;A<c;A++)m.push(new Kn({source:o,frame:new Qn(A*h,g*l,h,l)}));return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function On(e,t){var p,u,h,l;let a=t.gameplay.brush||{},i=new bt(t.theme.brush_color||"#ffffff").toNumber(),s=(p=a.radius)!=null?p:20,n=(u=a.inner_radius)!=null?u:15,o=(h=a.alpha)!=null?h:.8,r=(l=a.inner_alpha)!=null?l:.3,c=a.inner_color||"#ffffff",d=new Ge;return d.circle(0,0,s).fill({color:i,alpha:o}),d.circle(0,0,n).fill({color:new bt(c).toNumber(),alpha:r}),e.renderer.generateTexture(d)}export{ht as GameObject,gt as GameObjectManager,dt as Renderer,ct as Transform,Xn as animateHandClick,Hn as animatePanelEntrance,On as createBrushTexture,Mn as createEndGamePanel,Vn as createHandTutorial,Dn as createPixiBase,jn as createTutorialLabel,kn as getRegisteredFontIds,qe as loadAsset,Zn as loadCharacterFrames,Yn as registerFont,X as resolveFont,q as resolveFontWeight,Jn as updateHandAnimation};
|
|
1
|
+
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};
|
package/dist/three/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ha=Object.create;var Pe=Object.defineProperty;var fa=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var ga=Object.getPrototypeOf,ba=Object.prototype.hasOwnProperty;var wa=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},On=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ya(t))!ba.call(e,a)&&a!==n&&Pe(e,a,{get:()=>t[a],enumerable:!(i=fa(t,a))||i.enumerable});return e};var we=(e,t,n)=>(n=e!=null?ha(ga(e)):{},On(t||!e||!e.__esModule?Pe(n,"default",{value:e,enumerable:!0}):n,e)),Ea=e=>On(Pe({},"__esModule",{value:!0}),e);var Oa={};wa(Oa,{AspectClass:()=>ut,GameObject:()=>He,GameObjectManager:()=>Ve,Renderer:()=>Ae,ResponsiveUISystem:()=>fe,Transform:()=>Re,animateHandClick:()=>Ei,animatePanelEntrance:()=>wi,createBrushTexture:()=>Ri,createEndGamePanel:()=>bi,createHandTutorial:()=>xi,createThreeBase:()=>fi,createTutorialLabel:()=>_i,getAspectClass:()=>je,getRegisteredFontIds:()=>gi,loadAsset:()=>ht,loadCharacterFrames:()=>Si,registerFont:()=>yi,resolveFont:()=>G,resolveFontWeight:()=>j,updateHandAnimation:()=>Ti});module.exports=Ea(Oa);var N=we(require("three"));var Z={};function We(e,t,n=!1){Z[e]||(Z[e]=[]),Z[e].push({fn:t,once:n})}function st(e,t){if(Z[e]){if(!t){delete Z[e];return}Z[e]=Z[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=Z[e];if(n)for(let i of[...n])i.fn(...t),i.once&&st(e,i.fn)}function z(e,t){We(e,t,!0)}var Be={name:"handler-playable-sdk",version:"0.2.1",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.js patch","publish:update:minor":"node scripts/publish-and-update.js minor","publish:update:major":"node scripts/publish-and-update.js major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var B=0,_a=B++,Nn=B++,Yn=B++,In=B++,Gn=B++,jn=B++,Vn=B++,qn=B++,Xn=B++,Kn=B++,Jn=B++,Zn=B++,v=_a;function Qn(){return v===Nn}function Un(){return v===Yn}function ei(){return v===In}function ti(){return v===Gn}function le(){return v===jn}function ce(){return v===Vn}function ni(){return v===qn}function ii(){return v===Xn}function ai(){return v===Kn}function ot(){return v===Jn}function rt(){return v===Zn}function si(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),v=Nn;return}catch{}else if(e==="dapi")try{dapi.isReady(),v=Yn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(v=In)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(v=Gn)}catch{}else if(t==="mintegral")window.gameReady&&(v=jn);else if(t==="tapjoy")window.TJ_API&&(v=Vn);else if(t==="tiktok")window.openAppStore&&(v=qn);else if(t==="smadex")try{window.smxTracking&&(v=Xn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(v=Kn)}catch{}else t==="vungle"?v=Jn:(e==="nucleo"||t==="nucleo")&&(v=Zn)}var pi={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ta=Math.random().toString(36).slice(2),de=null,xe={...pi},mi="web_embed",va={},lt=!1,Ee=!1,Te=!1,ui=!1,mt=1,dt=0,Ie=!1,K=!1,Ye="",pe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),pt=pe>me,J=!1,_e=!1,oi=!1,ri=!1,ct=!1,Oe=null;function li(){if(de)return de;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),de=e,e}function Ne(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function hi(e,t){return{event_name:e,ts:Date.now(),session_id:Ta,deployment_id:xe.deployment_id,variant_id:xe.variant_id,export_profile_id:xe.profile_id,instance_id:xe.instance_id||"default",env:mi==="mraid"?"mraid":"web",payload:t}}function w(e,t){let n=Ne(e),i=hi(n,t);ze(n,i),n!==e&&ze(e,i)}function ve(){Oe&&(Oe(pe,me),Oe=null)}function ue(e){mt=e,w("volume",e)}function he(e){e&&(ui=!0),!Te&&(Te=!0,w("pause"),ue(0))}function Se(e){!e&&ui||Te&&(Te=!1,w("resume"),ue(mt))}function U(e,t){pe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),pt=pe>me,w("resize",{width:pe,height:me})}function Sa(){if(Qn())try{let e=mraid.getMaxSize();U(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?Se():he()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();U(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();ue(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&ue(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),Ie=!0,mraid.isViewable()&&mraid.getState()!=="hidden")J=!0,w("boot"),w("view"),w("ready"),K=!0,ve();else{let n=()=>{J=!0,w("boot"),w("view"),w("ready"),K=!0,ve()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ra(){if(Un())try{let e=dapi.getScreenSize();U(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?Se():he()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();U(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(ue(t?1:0),dapi.addEventListener("audioVolumeChange",n=>ue(n?1:0)),Ie=!0,dapi.isViewable())J=!0,w("boot"),w("view"),w("ready"),K=!0,ve();else{let n=()=>{J=!0,w("boot"),w("view"),w("ready"),K=!0,ve()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function ci(){let e=()=>{J||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(J=!0,w("boot"),w("view"),w("ready"),K=!0,ve(),_e&&(_e=!1,Q.start()))};window.addEventListener("resize",()=>U()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(Se(),e()):he()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ie=!0}function Aa(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(oi=!0),!(oi&&t instanceof MouseEvent)&&(dt+=1,w("interaction",dt))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Ha(e){var i,a,s,r,u,l,m,p,y,f,h,g;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ce())(s=(a=window.TJ_API)==null?void 0:a.click)==null||s.call(a);else if(ei())(u=(r=window.FbPlayableAd)==null?void 0:r.onCTAClick)==null||u.call(r);else if(ai())(m=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||m.call(l);else if(ii())try{(y=(p=window.smxTracking)==null?void 0:p.redirect)==null||y.call(p)}catch(o){console.warn("Smadex redirect failed",o)}else if(ti()){let o=window.ExitApi;o&&typeof o.exit=="function"?o.exit(e||Ye||""):e&&window.open(e)}else le()?(f=window.install)==null||f.call(window):ni()?(h=window.openAppStore)==null||h.call(window):ot()?(g=parent==null?void 0:parent.postMessage)==null||g.call(parent,"download","*"):e&&window.open(e)}function Ca(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;z("view",()=>t(n.mraid_viewable)),z("start",()=>t(n.game_viewable)),z("engagement",()=>t(n.engagement));let i=()=>t(n.complete);z("complete",i),We("engagement",a=>{var s;((s=a==null?void 0:a.payload)==null?void 0:s.count)>3&&i()}),z("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;z("view",()=>t(n.Ad_Load_Start)),z("start",()=>t(n.Ad_Viewable)),z("engagement",()=>t(n.First_Engagement)),z("complete",()=>t(n.Gameplay_Complete)),z("cta_click",()=>t(n.DSP_Click)),z("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ma(){if(!ce())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{Q.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function di(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function La(){le()&&(window.mintGameStart=()=>{Se(!0),U()},window.mintGameClose=()=>{he(!0)})}function ka(){if(!rt())return;let e=window.NUC;!e||!e.trigger||(Q.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ye)}),Q.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var Q={init(e={},t){if(mi=e.profile||"web_embed",va=e.consent||{},xe={...pi,...e.ids||{}},de=e.rootEl||de,Ye=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),w("init"),document.body.oncontextmenu=()=>!1,li(),Fa(de),si(),Sa(),Ra(),!Ie){if(document.readyState==="complete")ci();else if(!ri){ri=!0;let n=()=>{ci(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Aa(),Ca(),Ma(),La(),ka(),console.log(`%c @handler/playable-sdk %c v${Be.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),J&&!K&&(w("boot"),w("view"),w("ready"),_e&&(_e=!1,Q.start()),K=!0),K=J},getRoot(){return li()},get version(){return Be.version||"0.0.0"},get maxWidth(){return pe},get maxHeight(){return me},get isLandscape(){return pt},get isReady(){return K},get isStarted(){return lt},get isPaused(){return Te},get isFinished(){return Ee},get volume(){return mt},get interactions(){return dt},on(e,t){We(Ne(e),t)},off(e,t){st(Ne(e),t)},start(){var e,t;if(!lt){if(!J){_e=!0;return}if(lt=!0,w("start"),U(),le())he(),(e=window.gameReady)==null||e.call(window);else if(ce()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:pt?"landscape":"portrait",buildID:Be.version||"dev"})}}},finish(){var e,t;Ee||(Ee=!0,w("complete"),le()?(e=window.gameEnd)==null||e.call(window):ot()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ce()&&di())},install(e){if(!Ee){Ee=!0,ce()?(di(),setTimeout(()=>Q.install(e),300)):(w("complete"),setTimeout(()=>Q.install(e),0));return}ct||(ct=!0,setTimeout(()=>ct=!1,500),w("cta_click"),w("conversion"),Ha(e||Ye))},emit(e,t){let n=Ne(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=hi(n,t);ze(n,i)},retry(){var e,t,n;if(le())(e=window.gameRetry)==null||e.call(window);else if(rt()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}w("engagement",{action:"retry"})},pause(){he(!0)},resume(){Se(!0)},resize(e,t){U(e,t)}},Ge=Q;function Fa(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
|
|
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=`
|
|
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 je(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=je(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 je(t.width,t.height)}};async 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 je(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=je(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 je(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,15 +35,15 @@
|
|
|
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 m=document.createElement("div");m.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","min-width:100%","min-height:100%","max-width:100%","max-height:100%","pointer-events:auto","box-sizing:border-box","margin:0","padding:0","overflow:hidden"].join(";")),r.appendChild(m);let l=new N.Scene,{width:u,height:p}=n(),y=new N.AmbientLight(16777215,.6);l.add(y);let f=new N.DirectionalLight(16777215,.8);f.position.set(5,5,5),f.castShadow=!1,l.add(f);let h=new N.DirectionalLight(16777215,.3);h.position.set(-5,0,5),l.add(h);let g=new N.PerspectiveCamera(55,u/p,.1,100);g.position.set(0,0,3.2),g.lookAt(0,0,0),g.updateMatrixWorld();let o=new N.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});o.setPixelRatio(window.devicePixelRatio||1),o.setSize(u,p),o.setClearColor(0,0),o.domElement.style.position="absolute",o.domElement.style.top="0",o.domElement.style.left="0",o.domElement.style.right="0",o.domElement.style.bottom="0",o.domElement.style.width="100%",o.domElement.style.height="100%",o.domElement.style.minWidth="100%",o.domElement.style.minHeight="100%",o.domElement.style.maxWidth="100%",o.domElement.style.maxHeight="100%",o.domElement.style.display="block",o.domElement.style.pointerEvents="auto",o.domElement.style.margin="0",o.domElement.style.padding="0",o.domElement.style.boxSizing="border-box",m.appendChild(o.domElement);let E=d=>{var 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),
|
|
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;Ge.on("pause",()=>{T=!0,document.querySelectorAll("audio").forEach(c=>c.pause())}),Ge.on("resume",()=>{T=!1,document.querySelectorAll("audio").forEach(c=>{c.currentTime>0&&!c.ended&&c.play().catch(()=>{})})});let x=new fe(e,r);return Ge.on("resize",({payload:d})=>{console.log("[THREE-BASE] Handler resize event received:",{payload:d,timestamp:Date.now(),rootRect:e.getBoundingClientRect()}),E({width:d==null?void 0:d.width,height:d==null?void 0:d.height}),x.updateLayout()}),window.addEventListener("resize",()=>{console.log("[THREE-BASE] Window resize event received:",{timestamp:Date.now(),windowSize:{width:window.innerWidth,height:window.innerHeight},rootRect:e.getBoundingClientRect()}),E(),x.updateLayout()}),{scene:l,camera:g,renderer:o,uiSystem:x,applySize:E}}var k=we(require("three")),Re=class{constructor(t){var n,i;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(i=t==null?void 0:t.rotation)!=null?i:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToThree(t){let n=t.position.z,i=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,i),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},Ae=class{constructor(t){var n,i,a,s;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(i=t==null?void 0:t.alpha)!=null?i:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(s=t==null?void 0:t.tint)!=null?s:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof k.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof k.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof k.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof k.Mesh&&t.material){let n=typeof this.tint=="string"?new k.Color(this.tint):new k.Color(this.tint);Array.isArray(t.material)?t.material.forEach(i=>{(i instanceof k.MeshBasicMaterial||i instanceof k.MeshStandardMaterial)&&i.color.copy(n)}):(t.material instanceof k.MeshBasicMaterial||t.material instanceof k.MeshStandardMaterial)&&t.material.color.copy(n)}}},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 G(e){let t=qe[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function j(e){var n;let t=qe[e];return t&&(n=t.weight)!=null?n:"400"}function 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,Ot,Nt,Yt,It,Gt,jt,Vt,qt,Xt,Kt,Jt,Zt,Qt,Ut,en,tn,nn,an,sn,on,rn,ln,cn,dn,pn,mn,un,hn,fn,yn,gn,bn,wn,En,xn,_n,Tn,vn,Sn,Rn,An,Cn,Hn,Mn,Ln,kn,Fn,Dn,$n,Pn,Wn,zn,Bn,On,Nn;let a=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),r=e.objects.get("ui_endgame_title_1"),m=e.objects.get("ui_endgame_subtitle_1"),l=e.objects.get("ui_endgame_footer_1"),u=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;
|
|
44
44
|
background: ${_};
|
|
45
45
|
opacity: ${S};
|
|
46
|
-
border: ${F}px solid ${
|
|
46
|
+
border: ${F}px solid ${C};
|
|
47
47
|
border-opacity: ${R};
|
|
48
48
|
border-radius: ${b}px;
|
|
49
49
|
display: block;
|
|
@@ -56,73 +56,73 @@
|
|
|
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
|
|
60
|
-
font-family: ${G(
|
|
59
|
+
`,i.appendChild(A);let L=se(A);L.element=A;let H=((Ot=s==null?void 0:s.gameplay)==null?void 0:Ot.tuning)||{},ee=(s==null?void 0:s.transform)||{},O=(Nt=H.logo_size)!=null?Nt:56,Y=(Yt=ee.scale)!=null?Yt:1,oe=(Gt=(It=ee.offset)==null?void 0:It.y)!=null?Gt:-130,He=(jt=H.logo_alpha)!=null?jt:1,Mi=new ye.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),I=new ye.Sprite(Mi);I.position.set(0,oe,0),I.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=O,at=O/re):(at=O,it=O*re);let fa=it/Me*Y,ya=at/Le*Y;I.scale.set(fa,ya,1)}else{let re=O/100*Y;I.scale.set(re,re,1)}I.targetAlpha=He,I.baseScaleX=I.scale.x,I.baseScaleY=I.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:j(gt),te=document.createElement("div");te.textContent=Li,te.style.cssText=`
|
|
60
|
+
font-family: ${G(gt)};
|
|
61
61
|
font-size: ${Ke}px;
|
|
62
|
-
font-weight: ${
|
|
63
|
-
color: ${
|
|
62
|
+
font-weight: ${$i};
|
|
63
|
+
color: ${Fi};
|
|
64
64
|
text-align: center;
|
|
65
|
-
letter-spacing: ${
|
|
66
|
-
-webkit-text-stroke: ${(
|
|
67
|
-
text-shadow: ${(
|
|
65
|
+
letter-spacing: ${ki}px;
|
|
66
|
+
-webkit-text-stroke: ${(Zt=V.stroke_width)!=null?Zt:2}px ${V.stroke_color||"#000000"};
|
|
67
|
+
text-shadow: ${(Qt=V.shadow_distance)!=null?Qt:4}px ${(Ut=V.shadow_distance)!=null?Ut:4}px ${(en=V.shadow_blur)!=null?en:8}px rgba(0,0,0,${(tn=V.shadow_alpha)!=null?tn:.9});
|
|
68
68
|
opacity: 0;
|
|
69
69
|
position: absolute;
|
|
70
70
|
transform: translate(-50%, -50%);
|
|
71
71
|
white-space: nowrap;
|
|
72
|
-
max-width: ${
|
|
73
|
-
`;let
|
|
74
|
-
font-family: ${G(
|
|
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 $=m==null?void 0:m.ui,Et=((sn=m==null?void 0:m.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=m==null?void 0:m.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: ${G(xt)};
|
|
75
75
|
font-size: ${Je}px;
|
|
76
|
-
font-weight: ${j(
|
|
77
|
-
color: ${
|
|
76
|
+
font-weight: ${j(xt)};
|
|
77
|
+
color: ${Bi};
|
|
78
78
|
text-align: center;
|
|
79
|
-
letter-spacing: ${
|
|
79
|
+
letter-spacing: ${zi}px;
|
|
80
80
|
opacity: 0;
|
|
81
81
|
position: absolute;
|
|
82
82
|
transform: translate(-50%, -50%);
|
|
83
83
|
white-space: nowrap;
|
|
84
|
-
`;let
|
|
85
|
-
font-family: ${G(
|
|
86
|
-
font-size: ${
|
|
87
|
-
font-weight: ${j(
|
|
88
|
-
color: ${
|
|
84
|
+
`;let _t=bt+Ke+15,Oi=((ln=h.subtitle_offset_y)!=null?ln:_t+Je/2)+((cn=Et.animation_start_y_offset)!=null?cn:-10);ne.style.top=`${Oi}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)||{},Ni=(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,Yi=typeof De=="string"?De:De?`#${De.toString(16).padStart(6,"0")}`:"#FFFFFF",Ii=(hn=Tt.max_width)!=null?hn:x-c*2,Gi=(fn=Tt.line_height)!=null?fn:1.4,ie=document.createElement("div");ie.textContent=Ni,ie.style.cssText=`
|
|
85
|
+
font-family: ${G(vt)};
|
|
86
|
+
font-size: ${St}px;
|
|
87
|
+
font-weight: ${j(vt)};
|
|
88
|
+
color: ${Yi};
|
|
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: ${Ii}px;
|
|
94
|
+
line-height: ${Gi};
|
|
95
95
|
word-wrap: break-word;
|
|
96
|
-
`;let
|
|
97
|
-
width: ${
|
|
98
|
-
height: ${
|
|
99
|
-
background: ${
|
|
100
|
-
opacity: ${
|
|
101
|
-
border: ${
|
|
102
|
-
border-radius: ${
|
|
96
|
+
`;let ji=_t+Je+30,Vi=(yn=h.footer_offset_y)!=null?yn:ji+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=u==null?void 0:u.gameplay)==null?void 0:wn.tuning)||{},P=u==null?void 0:u.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
|
+
width: ${Xi}px;
|
|
98
|
+
height: ${Rt}px;
|
|
99
|
+
background: ${Ji};
|
|
100
|
+
opacity: ${Zi};
|
|
101
|
+
border: ${Ui}px solid ${Qi};
|
|
102
|
+
border-radius: ${Ki}px;
|
|
103
103
|
cursor: pointer;
|
|
104
104
|
opacity: 0;
|
|
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
|
|
109
|
-
font-family: ${G(
|
|
110
|
-
font-size: ${
|
|
111
|
-
font-weight: ${j(
|
|
112
|
-
color: ${
|
|
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=G(At),M.style.fontSize=`${ta}px`,M.style.fontWeight=String(j(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: ${G(Mt)};
|
|
110
|
+
font-size: ${aa}px;
|
|
111
|
+
font-weight: ${j(Mt)};
|
|
112
|
+
color: ${oa};
|
|
113
113
|
text-align: center;
|
|
114
|
-
letter-spacing: ${
|
|
114
|
+
letter-spacing: ${sa}px;
|
|
115
115
|
opacity: 0;
|
|
116
116
|
position: absolute;
|
|
117
117
|
transform: translate(-50%, -50%);
|
|
118
118
|
white-space: nowrap;
|
|
119
|
-
`;let
|
|
120
|
-
font-family: ${G(
|
|
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=(On=(Bn=y==null?void 0:y.transform)==null?void 0:Bn.scale)!=null?On:.1875,ua=(Nn=nt.hand_scale_multiplier)!=null?Nn: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:I,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,m=(F=a.scale_animation_intensity)!=null?F:.1,l=(R=a.logo_animation_delay_ms)!=null?R:100,u=(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,O=Math.min(ee/r,1),Y=1-Math.pow(1-O,3);f.alpha=Y,f.element.style.opacity=Y.toString();let oe=1+m*(1-Y);f.element.style.transform=`translate(-50%, -50%) scale(${oe})`,O<1?requestAnimationFrame(b):(setTimeout(()=>Wa(h,s,t),l),setTimeout(()=>{za(g,s),setTimeout(()=>Ba(o,s),50)},u),setTimeout(()=>Oa(E,s),p),setTimeout(()=>{Na(T,x,s),setTimeout(()=>Ya(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(),m=e.material.opacity,l=(g=e.targetAlpha)!=null?g:1,u=(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=m+(l-m)*d;let c=s+(1-s)*d;e.scale.set(u*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,m=Math.min(r/t,1),l=1-Math.pow(1-m,2);e.element.style.opacity=(i+(1-i)*l).toString(),e.element.style.top=`${a-20*(1-l)}px`,m<1&&requestAnimationFrame(s)};s()}function Ba(e,t){var m;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((m=e.animationStartYOffset)!=null?m:-10),r=()=>{let l=Date.now()-n,u=Math.min(l/t,1),p=1-Math.pow(1-u,2);e.element.style.opacity=(i+(1-i)*p).toString(),e.element.style.top=`${a+(s-a)*p}px`,u<1&&requestAnimationFrame(r)};r()}function Oa(e,t){var r;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=(r=e.targetAlpha)!=null?r:1,s=()=>{let m=Date.now()-n,l=Math.min(m/t,1),u=1-Math.pow(1-l,2);e.element.style.opacity=(i+(a-i)*u).toString(),l<1&&requestAnimationFrame(s)};s()}function Na(e,t,n){let i=Date.now(),a=parseFloat(e.element.style.opacity||"0"),s=()=>{let r=Date.now()-i,m=Math.min(r/n,1),l=1-Math.pow(1-m,2);e.element.style.opacity=(a+(1-a)*l).toString(),t.element.style.opacity=(a+(1-a)*l).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-l)})`,m<1&&requestAnimationFrame(s)};s()}function Ya(e,t){var m;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((m=e.animationStartYOffset)!=null?m:5),r=()=>{let l=Date.now()-n,u=Math.min(l/t,1),p=1-Math.pow(1-u,2);e.element.style.opacity=(i+(1-i)*p).toString(),e.element.style.top=`${a+(s-a)*p}px`,u<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,m=(f=s.click_delay_ms)!=null?f:2e3,l=(h=s.click_repeat_delay_ms)!=null?h:3e3,u=()=>{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 Y,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=(Y=a==null?void 0:a.transform)==null?void 0:Y.scale)!=null?oe:.1875,H=(He=s.hand_scale_multiplier)!=null?He:2.5,ee=L*H*100,O=ee+ee*.2*Math.sin(R*Math.PI);e.scale.set(O,O,1),R<1?requestAnimationFrame(_):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",i()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(g,o,0),u()},l)},500))};_()};setTimeout(u,m)}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)||{},m=new Xe.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),l=new Xe.Sprite(m),u=r.position||{},p=(g=u==null?void 0:u.z)!=null?g:0;l.position.set(n.x+((o=u==null?void 0:u.x)!=null?o:0),n.y+((E=u==null?void 0:u.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!",m=(n==null?void 0:n.font)||"brand.warning",l=(n==null?void 0:n.fontSize)||a.label_font_size||52,u=(T=n==null?void 0:n.letterSpacing)!=null?T:(E=a.label_letter_spacing)!=null?E:-1,p=(n==null?void 0:n.align)||"center",y=i.tint,f=typeof y=="string"?y:y?`#${y.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",h=document.createElement("div");return h.textContent=r,h.style.cssText=`
|
|
120
|
+
font-family: ${G(m)};
|
|
121
121
|
font-size: ${l}px;
|
|
122
|
-
font-weight: ${j(
|
|
122
|
+
font-weight: ${j(m)};
|
|
123
123
|
color: ${f};
|
|
124
124
|
text-align: ${p};
|
|
125
|
-
letter-spacing: ${
|
|
125
|
+
letter-spacing: ${u}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
|
|
134
|
+
`,h}function Si(e,t,n,i,a){var l,u,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)||{},m=(s==null?void 0:s.transform)||{};if(!i){let o=(u=r.animation_duration)!=null?u: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=m.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 t=typeof window!="undefined"?window.location.pathname:"",n=t.substring(0,t.lastIndexOf("/")+1),r="./"+"inline-assets"+".js";ft=new Function("path","return import(path)")(r).then(m=>m.INLINE_ASSETS||{}).catch(()=>({}))}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||{},m=(g=r.cols)!=null?g:3,l=(o=r.rows)!=null?o:2,u=((E=s.image)==null?void 0:E.width)||0,p=((T=s.image)==null?void 0:T.height)||0,y=u/m,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<m;d++){let c=document.createElement("canvas");c.width=y,c.height=f;let b=c.getContext("2d");b&&s.image&&b.drawImage(s.image,d*y,x*f,y,f,0,0,y,f),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,m=(g=n.inner_alpha)!=null?g:.3,l=n.inner_color||"#ffffff",u=document.createElement("canvas");u.width=a*2,u.height=a*2;let p=u.getContext("2d");return p&&(p.clearRect(0,0,u.width,u.height),p.beginPath(),p.arc(a,a,a,0,Math.PI*2),p.fillStyle=i,p.globalAlpha=r,p.fill(),p.beginPath(),p.arc(a,a,s,0,Math.PI*2),p.fillStyle=l,p.globalAlpha=m,p.fill()),new ge.CanvasTexture(u)}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-6MYM2EUT.mjs";import*as k from"three";var tn=(s=>(s[s.PHONE_TALL=0]="PHONE_TALL",s[s.TABLET=1]="TABLET",s[s.LANDSCAPE=2]="LANDSCAPE",s))(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}},s=e.style.width&&!e.style.width.includes("%"),a=e.style.height&&!e.style.height.includes("%");e.style.position||(e.style.position="relative"),e.style.display||(e.style.display="block"),e.style.width=e.style.width||"100%",e.style.height=e.style.height||"100%",e.style.minWidth="100%",e.style.minHeight="100%",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",e.style.margin="0",e.style.padding="0",e.style.border="none";let i=t.background||"linear-gradient(160deg, #0d1020, #0f1c2f)";e.style.setProperty("background",i,"important"),e.style.setProperty("background-size","cover","important"),e.style.setProperty("background-position","center","important"),e.style.setProperty("background-repeat","no-repeat","important");let l=document.createElement("div");l.style.cssText=`
|
|
2
2
|
position: absolute !important;
|
|
3
3
|
inset: 0 !important;
|
|
4
4
|
width: 100% !important;
|
|
@@ -19,16 +19,16 @@ import{b as dt}from"../chunk-SYQVN25U.mjs";import*as k from"three";var Oe=(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 h=document.createElement("div");h.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(h);let c=new k.Scene,{width:p,height:m}=n(),f=new k.AmbientLight(16777215,.6);c.add(f);let y=new k.DirectionalLight(16777215,.8);y.position.set(5,5,5),y.castShadow=!1,c.add(y);let u=new k.DirectionalLight(16777215,.3);u.position.set(-5,0,5),c.add(u);let g=new k.PerspectiveCamera(55,p/m,.1,100);g.position.set(0,0,3.2),g.lookAt(0,0,0),g.updateMatrixWorld();let o=new k.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});o.setPixelRatio(window.devicePixelRatio||1),o.setSize(p,m),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",h.appendChild(o.domElement);let b=d=>{var S;let r=e.getBoundingClientRect(),E=window.getComputedStyle(e);console.log("[THREE-BASE] applySize called:",{providedSize:d,rootRect:{width:r.width,height:r.height},clientSize:{width:e.clientWidth,height:e.clientHeight},styleSize:{width:e.style.width,height:e.style.height},computedStyle:{width:E.width,height:E.height,transform:E.transform,scale:E.scale},rendererCurrentSize:{width:o.domElement.width,height:o.domElement.height},rendererStyleSize:{width:o.domElement.style.width,height:o.domElement.style.height},stackTrace:(S=new Error().stack)==null?void 0:S.split(`
|
|
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),
|
|
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 H=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:H.width,height:H.height},cameraAspect:g.aspect,matches:{width:Math.abs(o.domElement.width-H.width)<1,height:Math.abs(o.domElement.height-H.height)<1},sizeDifference:{width:o.domElement.width-H.width,height:o.domElement.height-H.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,s;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(s=t==null?void 0:t.rotation)!=null?s:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToThree(t){let n=t.position.z,s=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,s),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},pt=class{constructor(t){var n,s,a,i;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(s=t==null?void 0:t.alpha)!=null?s:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(i=t==null?void 0:t.tint)!=null?i:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof A.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof A.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof A.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof A.Mesh&&t.material){let n=typeof this.tint=="string"?new A.Color(this.tint):new A.Color(this.tint);Array.isArray(t.material)?t.material.forEach(s=>{(s instanceof A.MeshBasicMaterial||s instanceof A.MeshStandardMaterial)&&s.color.copy(n)}):(t.material instanceof A.MeshBasicMaterial||t.material instanceof A.MeshStandardMaterial)&&t.material.color.copy(n)}}},mt=class{constructor(t,n,s,a){this.instanceId=t,this.objectConfig=n,this.threeObject=s,this._config=a,this.transform=new ht(a.transform),this.renderer=new pt(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,n){this.transform.position={x:t,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToThree(this.threeObject)}},vt=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let s=this.config.objects.get(t);if(!s)throw new Error(`Object config not found: ${t}`);let a=new mt(t,s.object_config||t,n,s);return this.objects.set(t,a),a}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,s]of this.objects.entries()){let a=t.objects.get(n);a&&s.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var ut={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function X(e){let t=ut[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var n;let t=ut[e];return t&&(n=t.weight)!=null?n:"400"}function Jn(e,t){ut[e]=t}function Kn(){return Object.keys(ut)}import*as U from"three";function j(e){return{element:e,get alpha(){return parseFloat(e.style.opacity||"1")},set alpha(t){e.style.opacity=t.toString()},get visible(){return e.style.display!=="none"},set visible(t){e.style.display=t?"":"none"},position:{set(t,n){e.style.left=`${t}px`,e.style.top=`${n}px`},get x(){return parseFloat(e.style.left||"0")},get y(){return parseFloat(e.style.top||"0")}},scale:{set(t,n){e.style.transform=`scale(${t})`},get x(){let t=e.style.transform.match(/scale\(([^)]+)\)/);return t?parseFloat(t[1]):1}}}}function Qn(e,t,n,s){var Zt,Vt,Jt,Kt,Qt,jt,Ot,It,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,He,Se,Re,ve,Ce,Me,Ae,Fe,$e,Le,We,Be,De,ke,ze,Pe,Ye,Ne,Ge,Xe,qe,Ze,Ve,Je,Ke,Qe,je,Oe,Ie,Ue;let a=e.objects.get("ui_endgame_1"),i=e.objects.get("ui_endgame_logo_1"),l=e.objects.get("ui_endgame_title_1"),h=e.objects.get("ui_endgame_subtitle_1"),c=e.objects.get("ui_endgame_footer_1"),p=e.objects.get("ui_endgame_cta_1"),m=e.objects.get("ui_endgame_cta_hint_1"),f=e.objects.get("ui_endgame_hand_1"),y=e.engine.runtime||{},u=((Zt=a==null?void 0:a.gameplay)==null?void 0:Zt.tuning)||{},g=(a==null?void 0:a.render)||{},o=s.getBoundingClientRect(),b=o.width>0?o.width*.9:320,w=o.height>0?o.height*.85:400,T=Math.min((Vt=u.panel_width)!=null?Vt:320,b),d=Math.min((Jt=u.panel_height)!=null?Jt:400,w),r=(Kt=u.panel_padding)!=null?Kt:32,E=(Qt=u.panel_radius)!=null?Qt:24,x=g.background_color||u.panel_bg_color||"#1a0a0a",_=g.background_alpha!==void 0&&g.background_alpha!==null?g.background_alpha:(jt=u.panel_bg_alpha)!=null?jt:.98,R=g.border_color||u.panel_border_color||"#ffffff",F=(Ot=u.panel_border_width)!=null?Ot:2,H=(It=u.panel_border_alpha)!=null?It:.3,S=document.createElement("div");S.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: ${H};
|
|
32
32
|
border-radius: ${E}px;
|
|
33
33
|
display: block;
|
|
34
34
|
transform: translate(-50%, -50%);
|
|
@@ -40,73 +40,73 @@ import{b as dt}from"../chunk-SYQVN25U.mjs";import*as k from"three";var Oe=(s=>(s
|
|
|
40
40
|
z-index: 1000;
|
|
41
41
|
box-sizing: border-box;
|
|
42
42
|
padding: ${r}px;
|
|
43
|
-
`,s.appendChild(
|
|
44
|
-
font-family: ${X(
|
|
45
|
-
font-size: ${
|
|
46
|
-
font-weight: ${
|
|
47
|
-
color: ${
|
|
43
|
+
`,s.appendChild(S);let M=j(S);M.element=S;let v=((Ut=i==null?void 0:i.gameplay)==null?void 0:Ut.tuning)||{},Z=(i==null?void 0:i.transform)||{},D=(te=v.logo_size)!=null?te:56,z=(ee=Z.scale)!=null?ee:1,O=(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,O,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 I=it/st,Ht,St;I>1?(Ht=D,St=D/I):(St=D,Ht=D*I);let qn=Ht/it*z,Zn=St/st*z;P.scale.set(qn,Zn,1)}else{let I=D/100*z;P.scale.set(I,I,1)}P.targetAlpha=at,P.baseScaleX=P.scale.x,P.baseScaleY=P.scale.y;let $=l==null?void 0:l.ui,Y=((re=l==null?void 0:l.gameplay)==null?void 0:re.tuning)||{},on=($==null?void 0:$.text)||"MISSION ACCOMPLISHED",At=($==null?void 0:$.font)||"brand.heading",ft=($==null?void 0:$.fontSize)||24,rn=(le=$==null?void 0:$.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
|
+
font-family: ${X(At)};
|
|
45
|
+
font-size: ${ft}px;
|
|
46
|
+
font-weight: ${dn};
|
|
47
|
+
color: ${ln};
|
|
48
48
|
text-align: center;
|
|
49
|
-
letter-spacing: ${
|
|
50
|
-
-webkit-text-stroke: ${(
|
|
51
|
-
text-shadow: ${(
|
|
49
|
+
letter-spacing: ${rn}px;
|
|
50
|
+
-webkit-text-stroke: ${(de=Y.stroke_width)!=null?de:2}px ${Y.stroke_color||"#000000"};
|
|
51
|
+
text-shadow: ${(he=Y.shadow_distance)!=null?he:4}px ${(pe=Y.shadow_distance)!=null?pe:4}px ${(me=Y.shadow_blur)!=null?me:8}px rgba(0,0,0,${(ue=Y.shadow_alpha)!=null?ue:.9});
|
|
52
52
|
opacity: 0;
|
|
53
53
|
position: absolute;
|
|
54
54
|
transform: translate(-50%, -50%);
|
|
55
55
|
white-space: nowrap;
|
|
56
|
-
max-width: ${
|
|
57
|
-
`;let
|
|
58
|
-
font-family: ${X(
|
|
59
|
-
font-size: ${
|
|
60
|
-
font-weight: ${q(
|
|
61
|
-
color: ${
|
|
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 $t=j(V);$t.element=V,S.appendChild(V);let L=h==null?void 0:h.ui,Lt=((ge=h==null?void 0:h.gameplay)==null?void 0:ge.tuning)||{},pn=(L==null?void 0:L.text)||"RESCUE COMPLETE",Wt=(L==null?void 0:L.font)||"brand.body",gt=(L==null?void 0:L.fontSize)||11,mn=(Ee=L==null?void 0:L.letterSpacing)!=null?Ee:.5,rt=(be=h==null?void 0:h.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
|
+
font-family: ${X(Wt)};
|
|
59
|
+
font-size: ${gt}px;
|
|
60
|
+
font-weight: ${q(Wt)};
|
|
61
|
+
color: ${un};
|
|
62
62
|
text-align: center;
|
|
63
|
-
letter-spacing: ${
|
|
63
|
+
letter-spacing: ${mn}px;
|
|
64
64
|
opacity: 0;
|
|
65
65
|
position: absolute;
|
|
66
66
|
transform: translate(-50%, -50%);
|
|
67
67
|
white-space: nowrap;
|
|
68
|
-
`;let
|
|
69
|
-
font-family: ${X(
|
|
70
|
-
font-size: ${
|
|
71
|
-
font-weight: ${q(
|
|
72
|
-
color: ${
|
|
68
|
+
`;let Bt=Ft+ft+15,yn=((Te=u.subtitle_offset_y)!=null?Te:Bt+gt/2)+((xe=Lt.animation_start_y_offset)!=null?xe:-10);J.style.top=`${yn}px`,J.style.left="50%";let Et=j(J);Et.element=J,Et.animationStartYOffset=(we=Lt.animation_start_y_offset)!=null?we:-10,S.appendChild(J);let N=c==null?void 0:c.ui,Dt=((_e=c==null?void 0:c.gameplay)==null?void 0:_e.tuning)||{},fn=(N==null?void 0:N.text)||((He=y.ui)==null?void 0:He.cta_hint)||"Continue the adventure!",kt=(N==null?void 0:N.font)||"brand.body",zt=(N==null?void 0:N.fontSize)||16,lt=(Se=c==null?void 0:c.render)==null?void 0:Se.tint,gn=typeof lt=="string"?lt:lt?`#${lt.toString(16).padStart(6,"0")}`:"#FFFFFF",En=(Re=Dt.max_width)!=null?Re:T-r*2,bn=(ve=Dt.line_height)!=null?ve:1.4,K=document.createElement("div");K.textContent=fn,K.style.cssText=`
|
|
69
|
+
font-family: ${X(kt)};
|
|
70
|
+
font-size: ${zt}px;
|
|
71
|
+
font-weight: ${q(kt)};
|
|
72
|
+
color: ${gn};
|
|
73
73
|
text-align: center;
|
|
74
74
|
opacity: 0;
|
|
75
75
|
position: absolute;
|
|
76
76
|
transform: translate(-50%, -50%);
|
|
77
|
-
max-width: ${
|
|
78
|
-
line-height: ${
|
|
77
|
+
max-width: ${En}px;
|
|
78
|
+
line-height: ${bn};
|
|
79
79
|
word-wrap: break-word;
|
|
80
|
-
`;let
|
|
81
|
-
width: ${
|
|
82
|
-
height: ${
|
|
83
|
-
background: ${
|
|
84
|
-
opacity: ${
|
|
85
|
-
border: ${
|
|
86
|
-
border-radius: ${
|
|
80
|
+
`;let Tn=Bt+gt+30,xn=(Ce=u.footer_offset_y)!=null?Ce:Tn+zt/2;K.style.top=`${xn}px`,K.style.left="50%";let bt=j(K);bt.element=K;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,S.appendChild(K);let G=((Fe=p==null?void 0:p.gameplay)==null?void 0:Fe.tuning)||{},W=p==null?void 0:p.ui,_n=($e=G.button_width)!=null?$e:260,Pt=(Le=G.button_height)!=null?Le:56,Hn=(We=G.button_radius)!=null?We:16,Sn=G.button_bg_color||((Be=y.theme)==null?void 0:Be.cta_background)||"#ffb43b",Rn=(De=G.button_bg_alpha)!=null?De:1,vn=G.button_border_color||"#ffffff",Cn=(ke=G.button_border_width)!=null?ke: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
|
+
width: ${_n}px;
|
|
82
|
+
height: ${Pt}px;
|
|
83
|
+
background: ${Sn};
|
|
84
|
+
opacity: ${Rn};
|
|
85
|
+
border: ${Cn}px solid ${vn};
|
|
86
|
+
border-radius: ${Hn}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=j(C);xt.element=C,xt.addEventListener=C.addEventListener.bind(C),
|
|
93
|
-
font-family: ${X(
|
|
94
|
-
font-size: ${
|
|
95
|
-
font-weight: ${q(
|
|
96
|
-
color: ${
|
|
92
|
+
`,C.style.top=`${Tt}px`,C.style.left="50%";let xt=j(C);xt.element=C,xt.addEventListener=C.addEventListener.bind(C),S.appendChild(C);let 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=j(C);Nt.element=C;let B=m==null?void 0:m.ui,Gt=((Xe=m==null?void 0:m.gameplay)==null?void 0:Xe.tuning)||{},$n=(B==null?void 0:B.text)||"Play the full game",Xt=(B==null?void 0:B.font)||"brand.body",Ln=(B==null?void 0:B.fontSize)||11,Wn=(qe=B==null?void 0:B.letterSpacing)!=null?qe:0,ct=(Ze=m==null?void 0:m.render)==null?void 0:Ze.tint,Bn=typeof ct=="string"?ct:ct?`#${ct.toString(16).padStart(6,"0")}`:"#CCCCCC",Q=document.createElement("div");Q.textContent=$n,Q.style.cssText=`
|
|
93
|
+
font-family: ${X(Xt)};
|
|
94
|
+
font-size: ${Ln}px;
|
|
95
|
+
font-weight: ${q(Xt)};
|
|
96
|
+
color: ${Bn};
|
|
97
97
|
text-align: center;
|
|
98
|
-
letter-spacing: ${
|
|
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 Dn=Tt+Pt/2+20,kn=d-r-10,zn=Math.min(Dn+((Ve=Gt.animation_start_y_offset)!=null?Ve:5),kn);Q.style.top=`${zn}px`,Q.style.left="50%";let wt=j(Q);wt.element=Q,wt.animationStartYOffset=(Je=Gt.animation_start_y_offset)!=null?Je:5,S.appendChild(Q);let _t=((Ke=f==null?void 0:f.gameplay)==null?void 0:Ke.tuning)||{},Pn=(Qe=_t.hand_offset_x)!=null?Qe:50,Yn=(je=_t.hand_offset_y)!=null?je:50,Nn=(Ie=(Oe=f==null?void 0:f.transform)==null?void 0:Oe.scale)!=null?Ie:.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:$t,subtitle:Et,footer:bt,ctaButton:xt,ctaText:Nt,ctaHint:wt,hand:et}}function jn(e,t,n){var x,_,R,F,H,S,M,v;let s=t.objects.get("ui_endgame_1"),a=((x=s==null?void 0:s.gameplay)==null?void 0:x.tuning)||{},i=(_=a.animation_duration_ms)!=null?_:800,l=(R=a.fade_in_duration_ms)!=null?R:600,h=(F=a.scale_animation_intensity)!=null?F:.1,c=(H=a.logo_animation_delay_ms)!=null?H:100,p=(S=a.title_animation_delay_ms)!=null?S:200,m=(M=a.footer_animation_delay_ms)!=null?M:300,f=(v=a.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,D=Math.min(Z/l,1),z=1-Math.pow(1-D,3);y.alpha=z,y.element.style.opacity=z.toString();let O=1+h*(1-z);y.element.style.transform=`translate(-50%, -50%) scale(${O})`,D<1?requestAnimationFrame(E):(setTimeout(()=>On(u,i,t),c),setTimeout(()=>{In(g,i),setTimeout(()=>Un(o,i),50)},p),setTimeout(()=>ta(b,i),m),setTimeout(()=>{ea(w,T,i),setTimeout(()=>na(d,i),50),n&&n()},f))};E()}function On(e,t,n){var y,u,g,o,b;let s=n==null?void 0:n.objects.get("ui_endgame_logo_1"),i=(u=(((y=s==null?void 0:s.gameplay)==null?void 0:y.tuning)||{}).animation_start_scale)!=null?u:1.2,l=Date.now(),h=e.material.opacity,c=(g=e.targetAlpha)!=null?g:1,p=(o=e.baseScaleX)!=null?o:e.scale.x,m=(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=h+(c-h)*d;let r=i+(1-i)*d;e.scale.set(p*r,m*r,1),T<1&&requestAnimationFrame(f)};f()}function In(e,t){let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=()=>{let l=Date.now()-n,h=Math.min(l/t,1),c=1-Math.pow(1-h,2);e.element.style.opacity=(s+(1-s)*c).toString(),e.element.style.top=`${a-20*(1-c)}px`,h<1&&requestAnimationFrame(i)};i()}function Un(e,t){var h;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=a-((h=e.animationStartYOffset)!=null?h:-10),l=()=>{let c=Date.now()-n,p=Math.min(c/t,1),m=1-Math.pow(1-p,2);e.element.style.opacity=(s+(1-s)*m).toString(),e.element.style.top=`${a+(i-a)*m}px`,p<1&&requestAnimationFrame(l)};l()}function ta(e,t){var l;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=(l=e.targetAlpha)!=null?l:1,i=()=>{let h=Date.now()-n,c=Math.min(h/t,1),p=1-Math.pow(1-c,2);e.element.style.opacity=(s+(a-s)*p).toString(),c<1&&requestAnimationFrame(i)};i()}function ea(e,t,n){let s=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=()=>{let l=Date.now()-s,h=Math.min(l/n,1),c=1-Math.pow(1-h,2);e.element.style.opacity=(a+(1-a)*c).toString(),t.element.style.opacity=(a+(1-a)*c).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-c)})`,h<1&&requestAnimationFrame(i)};i()}function na(e,t){var h;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=a-((h=e.animationStartYOffset)!=null?h:5),l=()=>{let c=Date.now()-n,p=Math.min(c/t,1),m=1-Math.pow(1-p,2);e.element.style.opacity=(s+(1-s)*m).toString(),e.element.style.top=`${a+(i-a)*m}px`,p<1&&requestAnimationFrame(l)};l()}function aa(e,t,n,s){var m,f,y,u;let a=n.objects.get("ui_endgame_hand_1"),i=((m=a==null?void 0:a.gameplay)==null?void 0:m.tuning)||{},l=(f=i.click_animation_duration_ms)!=null?f:600,h=(y=i.click_delay_ms)!=null?y:2e3,c=(u=i.click_repeat_delay_ms)!=null?u:3e3,p=()=>{var _,R;e.visible=!0,e.material.opacity=1;let g=e.position.x,o=e.position.y,b=(_=i.hand_offset_x)!=null?_:50,w=(R=i.hand_offset_y)!=null?R:50,T=t.element.getBoundingClientRect(),d=b,r=w,E=Date.now(),x=()=>{var z,O,at;let F=Date.now()-E,H=Math.min(F/l,1),S=H<.5?2*H*H:1-Math.pow(-2*H+2,2)/2;e.position.set(g+(d-g)*S,o+(r-o)*S,0);let M=(O=(z=a==null?void 0:a.transform)==null?void 0:z.scale)!=null?O:.1875,v=(at=i.hand_scale_multiplier)!=null?at:2.5,Z=M*v*100,D=Z+Z*.2*Math.sin(H*Math.PI);e.scale.set(D,D,1),H<1?requestAnimationFrame(x):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",s()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(g,o,0),p()},c)},500))};x()};setTimeout(p,h)}import*as yt from"three";function ia(e,t,n){var u,g,o,b,w,T,d;let s=t.objects.get("hand_tutorial_1"),a=((u=s==null?void 0:s.gameplay)==null?void 0:u.tuning)||{},i=(s==null?void 0:s.render)||{},l=(s==null?void 0:s.transform)||{},h=new yt.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),c=new yt.Sprite(h),p=l.position||{},m=(g=p==null?void 0:p.z)!=null?g:0;c.position.set(n.x+((o=p==null?void 0:p.x)!=null?o:0),n.y+((b=p==null?void 0:p.y)!=null?b:0),m),c.material.opacity=i.alpha!==void 0&&i.alpha!==null?i.alpha:0,c.visible=i.visible!==void 0&&i.visible!==null?i.visible:!1;let f=(w=a.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=i.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,s=(t==null?void 0:t.render)||{},a=((g=e.engine.runtime)==null?void 0:g.ui_styles)||{},i=((o=e.engine.runtime)==null?void 0:o.ui)||{},l=(n==null?void 0:n.text)||i.tutorial_label||i.label_text||"CLEAN!",h=(n==null?void 0:n.font)||"brand.warning",c=(n==null?void 0:n.fontSize)||a.label_font_size||52,p=(w=n==null?void 0:n.letterSpacing)!=null?w:(b=a.label_letter_spacing)!=null?b:-1,m=(n==null?void 0:n.align)||"center",f=s.tint,y=typeof f=="string"?f:f?`#${f.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",u=document.createElement("div");return u.textContent=l,u.style.cssText=`
|
|
104
|
+
font-family: ${X(h)};
|
|
105
105
|
font-size: ${c}px;
|
|
106
|
-
font-weight: ${q(
|
|
106
|
+
font-weight: ${q(h)};
|
|
107
107
|
color: ${y};
|
|
108
|
-
text-align: ${
|
|
109
|
-
letter-spacing: ${
|
|
108
|
+
text-align: ${m};
|
|
109
|
+
letter-spacing: ${p}px;
|
|
110
110
|
text-shadow: ${(T=a.label_shadow_distance)!=null?T:2}px ${(d=a.label_shadow_distance)!=null?d:2}px ${(r=a.label_shadow_blur)!=null?r:4}px rgba(0,0,0,${(E=a.label_shadow_alpha)!=null?E:.8});
|
|
111
111
|
-webkit-text-stroke: ${a.label_stroke||"#8B0000"} 2px;
|
|
112
112
|
opacity: ${(x=s.alpha)!=null?x:0};
|
|
@@ -115,4 +115,4 @@ import{b as dt}from"../chunk-SYQVN25U.mjs";import*as k from"three";var Oe=(s=>(s
|
|
|
115
115
|
position: absolute;
|
|
116
116
|
transform: translate(-50%, -50%);
|
|
117
117
|
white-space: nowrap;
|
|
118
|
-
`,u}function
|
|
118
|
+
`,u}function oa(e,t,n,s,a){var c,p,m,f,y,u,g;let i=a.objects.get("hand_tutorial_1"),l=((c=i==null?void 0:i.gameplay)==null?void 0:c.tuning)||{},h=(i==null?void 0:i.transform)||{};if(!s){let o=(p=l.animation_duration)!=null?p:1.5,b=n%o/o,w=b<.5?2*b*b:-1+(4-2*b)*b,T=(m=l.x_offset)!=null?m: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,H=R+x;e.position.set(_+(F-_)*w,R+(H-R)*w,0);let S=(u=h.scale)!=null?u:.1875,M=(g=l.hand_scale_multiplier)!=null?g:2.5,v=S*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 t=typeof window!="undefined"?window.location.pathname:"",n=t.substring(0,t.lastIndexOf("/")+1),l="./"+"inline-assets"+".js";Mt=new Function("path","return import(path)")(l).then(h=>h.INLINE_ASSETS||{}).catch(()=>({}))}let e=await Mt;return Ct=e||{},e||{}}async function an(e,t,n=16777215,s=!1){try{let i=(await nn())[e];return await en.loadAsync(i||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let i=document.createElement("canvas");i.width=64,i.height=64;let l=i.getContext("2d");return l&&(l.fillStyle=`#${n.toString(16).padStart(6,"0")}`,s?l.fillRect(0,0,30,60):(l.beginPath(),l.arc(32,32,30,0,Math.PI*2),l.fill(),l.fillRect(27,32,10,40))),new tt.CanvasTexture(i)}}async function ra(e,t,n){var g,o,b,w;let a=(await nn())[e]||e,i;try{i=await en.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(T){let E=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");i=await an(e,t,parseInt(E,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:T})}if(!i)return[];let l=n.gameplay.character_sheet||{},h=(g=l.cols)!=null?g:3,c=(o=l.rows)!=null?o:2,p=((b=i.image)==null?void 0:b.width)||0,m=((w=i.image)==null?void 0:w.height)||0,f=p/h,y=m/c;if(!Number.isFinite(f)||!Number.isFinite(y)||f<=0||y<=0)return[i];let u=[];for(let T=0;T<c;T++)for(let d=0;d<h;d++){let r=document.createElement("canvas");r.width=f,r.height=y;let E=r.getContext("2d");E&&i.image&&E.drawImage(i.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||{},s=t.theme.brush_color||"#ffffff",a=(f=n.radius)!=null?f:20,i=(y=n.inner_radius)!=null?y:15,l=(u=n.alpha)!=null?u:.8,h=(g=n.inner_alpha)!=null?g:.3,c=n.inner_color||"#ffffff",p=document.createElement("canvas");p.width=a*2,p.height=a*2;let m=p.getContext("2d");return m&&(m.clearRect(0,0,p.width,p.height),m.beginPath(),m.arc(a,a,a,0,Math.PI*2),m.fillStyle=s,m.globalAlpha=l,m.fill(),m.beginPath(),m.arc(a,a,i,0,Math.PI*2),m.fillStyle=c,m.globalAlpha=h,m.fill()),new tt.CanvasTexture(p)}export{tn as AspectClass,mt as GameObject,vt as GameObjectManager,pt as Renderer,nt as ResponsiveUISystem,ht as Transform,aa as animateHandClick,jn as animatePanelEntrance,la as createBrushTexture,Qn as createEndGamePanel,ia as createHandTutorial,Vn as createThreeBase,sa as createTutorialLabel,Rt as getAspectClass,Kn as getRegisteredFontIds,an as loadAsset,ra as loadCharacterFrames,Jn as registerFont,X as resolveFont,q as resolveFontWeight,oa as updateHandAnimation};
|
package/package.json
CHANGED