@fabi-play/engine 0.1.0 → 0.3.0
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/fabi-play-engine.d.ts +3 -1
- package/dist/fabi-play-engine.js +14 -14
- package/dist/fabi-play-engine.lite.d.ts +3 -1
- package/dist/fabi-play-engine.lite.js +11 -11
- package/dist/fabi-play-engine.lite.umd.js +1 -1
- package/dist/fabi-play-engine.lite.umd.min.js +1 -1
- package/dist/fabi-play-engine.umd.js +8 -4
- package/dist/fabi-play-engine.umd.min.js +11 -11
- package/dist/index.d.ts +3 -1
- package/dist/index.js +11 -11
- package/dist/integrity.json +9 -9
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fabi-play/engine 0.
|
|
1
|
+
/*! @fabi-play/engine 0.3.0 (lite: load fabi-play.js first) | Fabi Play Kit License | https://docs.fabiplay.app */
|
|
2
2
|
(function (root, factory) {
|
|
3
3
|
var script = typeof document !== 'undefined' ? document.currentScript : null;
|
|
4
4
|
if (typeof define === 'function' && define.amd) define([], function () { return factory(script); });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fabi-play/engine 0.1.0 (lite: load fabi-play.js first) | Fabi Play Kit License | https://docs.fabiplay.app */(function(Ds,_t){var ce=typeof document<"u"?document.currentScript:null;typeof define=="function"&&define.amd?define([],function(){return _t(ce)}):typeof module=="object"&&module&&module.exports?module.exports=_t(ce):Ds.FabiEngine=_t(ce)})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:this,function(Ds){"use strict";var _t={exports:{}},ce=_t.exports,fe=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,gn=Object.getOwnPropertyNames,mn=Object.prototype.hasOwnProperty,yn=(t,e,s)=>e in t?fe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,vn=(t,e)=>{for(var s in e)fe(t,s,{get:e[s],enumerable:!0})},wn=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gn(e))!mn.call(t,n)&&n!==s&&fe(t,n,{get:()=>e[n],enumerable:!(i=pn(e,n))||i.enumerable});return t},xn=t=>wn(fe({},"__esModule",{value:!0}),t),c=(t,e,s)=>yn(t,typeof e!="symbol"?e+"":e,s),Bs={};vn(Bs,{AnimatedSprite:()=>St,Atlas:()=>as,AvatarPainter:()=>xs,AvatarsNode:()=>qi,BitmapFont:()=>bs,DEFAULT_FONT:()=>Ei,EASE:()=>jt,Group:()=>ns,HALO:()=>ee,MAX_LAYERS:()=>es,NameTags:()=>vs,Node:()=>Et,NodePool:()=>Zi,Particles:()=>si,STAGE_HEIGHT:()=>Y,Shape:()=>Zt,ShelfPacker:()=>ii,Sound:()=>Ii,Sprite:()=>It,TIERS:()=>ut,Text:()=>se,Timeline:()=>Xi,Tweens:()=>$i,avatarPortrait:()=>kr,blur:()=>Ta,brightness:()=>wa,colorMatrix:()=>Ea,contrast:()=>xa,createAvatarRenderer:()=>Mr,createEngine:()=>qr,createRenderer:()=>ms,dropShadow:()=>Sa,grayscale:()=>Ma,handsOf:()=>Pi,hits:()=>ks,hueRotate:()=>Aa,invert:()=>_a,nodePool:()=>Ia,packColor:()=>Lt,parseBMFont:()=>Fe,parseColor:()=>ot,pickTier:()=>Oi,playerColor:()=>Ms,rendererOrder:()=>_i,rng:()=>Ln,saturate:()=>ba,sepia:()=>ka,shader:()=>Fa,shapeBounds:()=>ws,tier:()=>Ft,tint:()=>va,touching:()=>Ni,wrists:()=>Ci}),_t.exports=xn(Bs);var bn=33,zs={nose:0,leftShoulder:11,rightShoulder:12,leftElbow:13,rightElbow:14,leftWrist:15,rightWrist:16,leftHip:23,rightHip:24,leftKnee:25,rightKnee:26,leftAnkle:27,rightAnkle:28},Mn=4,ue=["#EE6A43","#6FA0E0","#8CC9A0","#C49BE0"],kn={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},Ha=kn["6-8"],An=(t,e)=>t?{x:t.x+e.x*t.w,y:t.y+e.y*t.h}:{x:e.x,y:e.y},_n=12,En=bn*4,Tn=t=>_n+t*En,Wa=Tn(Mn),Sn=t=>t.startsWith("fabi-play.")?`fablee-play.${t.slice(10)}`:null;function Fn(t,e,s=Sn(e)){if(!(!t||!s))try{const i=t.getItem(s);if(i===null)return;t.getItem(e)===null&&t.setItem(e,i),t.removeItem(s)}catch{}}var Gs=globalThis.FabiPlay?.avatars;if(!Gs)throw new Error("[engine] fabi-play-engine.lite.js needs fabi-play.js (with FabiPlay.avatars) loaded before it");var{avatarById:de,avatarShapes:Rn,BAND_BODY:Ya,DEFAULT_AVATAR:pe,drawShapes:Xs,frameOf:Cn,iconShapes:Pn}=Gs,Nt=()=>Float64Array.of(1,0,0,1,0,0);function ct(t,e,s,i,n,r,a){const h=n?Math.cos(n):1,l=n?Math.sin(n):0,o=h*r,u=l*r,f=-l*a,p=h*a;if(!e)return t[0]=o,t[1]=u,t[2]=f,t[3]=p,t[4]=s,t[5]=i,t;const g=e[0],d=e[1],y=e[2],m=e[3];return t[0]=g*o+y*u,t[1]=d*o+m*u,t[2]=g*f+y*p,t[3]=d*f+m*p,t[4]=g*s+y*i+e[4],t[5]=d*s+m*i+e[5],t}function Nn(t,e,s){const i=t[0]*t[3]-t[1]*t[2];if(Math.abs(i)<1e-12)return null;const n=e-t[4],r=s-t[5];return[(t[3]*n-t[2]*r)/i,(-t[1]*n+t[0]*r)/i]}var $s={white:16777215,black:0,red:16711680,transparent:0},Wt=new Map;function ot(t){if(typeof t=="number")return[t&16777215,1];const e=Wt.get(t);if(e)return e;let s=[16777215,1];const i=t.trim().toLowerCase();if(i[0]==="#"){const n=i.slice(1),r=n.length<=4?[...n].map(h=>h+h).join(""):n,a=parseInt(r.slice(0,6),16);Number.isFinite(a)&&(s=[a,r.length===8?parseInt(r.slice(6,8),16)/255:1])}else if(i.startsWith("rgb")){const n=i.match(/-?\d*\.?\d+%?/g)?.map(o=>o.endsWith("%")?parseFloat(o)/100*255:parseFloat(o))??[],[r=255,a=255,h=255]=n,l=n[3]===void 0?1:i.match(/,\s*[\d.]+%\s*\)$/)?n[3]/255:n[3];s=[(We(r)<<16|We(a)<<8|We(h))>>>0,Math.min(Math.max(l,0),1)]}else if(i in $s)s=[$s[i],i==="transparent"?0:1];else if(typeof document<"u"){const n=document.createElement("canvas").getContext("2d");if(n){n.fillStyle="#ffffff",n.fillStyle=i;const r=n.fillStyle;if(r!==i)return Wt.set(t,s=ot(r)),s}}return Wt.size>512&&Wt.clear(),Wt.set(t,s),s}var We=t=>Math.min(Math.max(Math.round(t),0),255);function Lt(t,e,s=!1){const i=Math.min(Math.max(e,0),1),n=(t>>16&255)*i,r=(t>>8&255)*i,a=(t&255)*i,h=s?0:i*255;return(Math.round(h)<<24|Math.round(a)<<16|Math.round(r)<<8|Math.round(n))>>>0}var Yt=(t,e=1)=>`rgba(${t>>16&255},${t>>8&255},${t&255},${e})`;function qs(t,e){if(t===16777215)return e;if(e===16777215)return t;const s=i=>Math.round((t>>i&255)*(e>>i&255)/255);return(s(16)<<16|s(8)<<8|s(0))>>>0}var jt={linear:t=>t,quadIn:t=>t*t,quadOut:t=>t*(2-t),quadInOut:t=>t<.5?2*t*t:-1+(4-2*t)*t,cubicOut:t=>1-(1-t)**3,sineInOut:t=>-(Math.cos(Math.PI*t)-1)/2,backOut:t=>1+(1.70158+1)*(t-1)**3+1.70158*(t-1)**2,elasticOut:t=>t===0||t===1?t:2**(-10*t)*Math.sin((t*10-.75)*(2*Math.PI/3))+1,bounceOut:t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375};function Ln(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let s=e;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}var Vt=1,Hs=2,ge=0,it=1,In=4294967295,A={cap:0,epoch:0,x:new Float64Array(0),y:new Float64Array(0),rot:new Float64Array(0),sx:new Float64Array(0),sy:new Float64Array(0),alpha:new Float64Array(0),la:new Float64Array(0),lb:new Float64Array(0),lc:new Float64Array(0),ld:new Float64Array(0),world:new Float64Array(0),tint:new Uint32Array(0),flags:new Uint8Array(0),moved:new Uint8Array(0),dirty:new Uint8Array(0),gen:new Uint32Array(0),parent:new Int32Array(0),first:new Int32Array(0),next:new Int32Array(0),prev:new Int32Array(0),stamp:new Uint32Array(0),pass:0,free:new Int32Array(0),freeHead:0,freeCount:0,top:2},gt=[],On="x y rot sx sy alpha la lb lc ld world tint flags moved dirty gen parent first next prev stamp".split(" ");function Ws(t){const e=A;for(const i of On){const n=e[i],r=new n.constructor(i==="world"?t*6:t);r.set(n),e[i]=r}const s=new Int32Array(t);for(let i=0;i<A.freeCount;i++)s[i]=A.free[(A.freeHead+i)%A.cap];for(A.free=s,A.freeHead=0,A.cap=t,A.epoch++;gt.length<t;)gt.push(null)}function Ye(t){A.x[t]=A.y[t]=A.rot[t]=0,A.sx[t]=A.sy[t]=A.alpha[t]=1,A.la[t]=A.ld[t]=1,A.lb[t]=A.lc[t]=0;const e=t*6,s=A.world;s[e]=s[e+3]=1,s[e+1]=s[e+2]=s[e+4]=s[e+5]=0,A.tint[t]=16777215,A.flags[t]=Vt|Hs,A.moved[t]=1,A.dirty[t]=0,A.parent[t]=A.first[t]=A.next[t]=A.prev[t]=-1}Ws(256),Ye(ge),A.flags[ge]=0,Ye(it),A.flags[it]=0;function Un(){let t;if(A.freeCount){t=A.free[A.freeHead],A.freeHead=(A.freeHead+1)%A.cap,A.freeCount--;const e=gt[t];e&&(e._i=ge,e._g=-1,gt[t]=null)}else A.top===A.cap&&Ws(A.cap*2),t=A.top++;return Ye(t),t}function Ys(t,e){je(t);for(let i=A.first[t];i>=0;){const n=A.next[i];A.parent[i]=A.next[i]=A.prev[i]=-1,i=n}A.first[t]=-1,A.flags[t]=A.flags[t]&~Hs,A.moved[t]=0;const s=A.gen[t]+1;A.gen[t]=s,s!==In&&(e&&(gt[t]=e),A.free[(A.freeHead+A.freeCount)%A.cap]=t,A.freeCount++)}function Dn(t){for(let e=0;e<gt.length;e++){const s=gt[e];s&&t(s)&&(s._i=ge,s._g=-1,gt[e]=null)}}function Bn(t,e){je(t);const s=A.first[e];A.parent[t]=e,A.next[t]=s,A.prev[t]=-1,s>=0&&(A.prev[s]=t),A.first[e]=t,A.moved[t]=1}function je(t){const e=A.parent[t];if(e<0)return;const s=A.next[t],i=A.prev[t];i>=0?A.next[i]=s:A.first[e]=s,s>=0&&(A.prev[s]=i),A.parent[t]=A.next[t]=A.prev[t]=-1}var Qt={root:-1,gen:-1,world:new Float64Array(6)};function zn(t){const e=++A.pass,s=A.world,i=t*6,n=Qt.world;let r=Qt.root!==t||Qt.gen!==A.gen[t];for(let a=0;a<6;a++)n[a]!==s[i+a]&&(r=!0),n[a]=s[i+a];Qt.root=t,Qt.gen=A.gen[t],A.stamp[t]=r?e:e-1}function Gn(t){A.stamp[t]=A.pass}function js(t){for(let e=A.first[t];e>=0;){const s=A.next[e];js(e),e=s}Ys(t)}var Ve=typeof FinalizationRegistry=="function"?new FinalizationRegistry(t=>A.gen[t.i]===t.g&&js(t.i)):null;function Vs(t){t._reg||!Ve||(t._reg=!0,Ve.register(t,{i:t._i,g:t._g},t))}function Xn(t){t._reg&&Ve.unregister(t)}var Qe=1,Ke=2,Ze=3,Je=4;function ts(t){if(t){for(let e=0;e<t.length;e++)if(t[e].enabled)return!0}return!1}function $n(t,e){let s=0;for(let i=0;i<t.length;i++){const n=t[i];n.enabled&&n.pad&&(s+=n.pad(e))}return s}var ht={gl:null,c2d:null,live:null},U=new Float64Array(3),es=4,qn=1,ss=()=>qn++,q=Nt(),S=A,Et=class{constructor(t){c(this,"kernel",t),c(this,"_i",Un()),c(this,"_g",S.gen[this._i]),c(this,"_wv",null),c(this,"_wi",-1),c(this,"_we",-1),c(this,"blend","normal"),c(this,"_data",null),c(this,"parent",null),c(this,"hitRadius",null),c(this,"clip",null),c(this,"mask",null),c(this,"filters",null),c(this,"_z",0),c(this,"anchorX",0),c(this,"anchorY",0),c(this,"_pool",null),c(this,"_free",!1),c(this,"_reg",!1)}get x(){return S.x[this._i]}set x(t){const e=this._i||it;S.x[e]=t,S.moved[e]=1}get y(){return S.y[this._i]}set y(t){const e=this._i||it;S.y[e]=t,S.moved[e]=1}get rotation(){return S.rot[this._i]}set rotation(t){const e=this._i||it;S.rot[e]=t,S.dirty[e]=S.moved[e]=1}get scaleX(){return S.sx[this._i]}set scaleX(t){const e=this._i||it;S.sx[e]=t,S.dirty[e]=S.moved[e]=1}get scaleY(){return S.sy[this._i]}set scaleY(t){const e=this._i||it;S.sy[e]=t,S.dirty[e]=S.moved[e]=1}get alpha(){return S.alpha[this._i]}set alpha(t){const e=this._i||it;S.alpha[e]=t,S.moved[e]=1}get visible(){return(S.flags[this._i]&Vt)!==0}set visible(t){const e=this._i||it;t?S.flags[e]=S.flags[e]|Vt:S.flags[e]=S.flags[e]&~Vt,S.moved[e]=1}get destroyed(){return S.gen[this._i]!==this._g}get world(){const t=this._i||it;return(this._wi!==t||this._we!==S.epoch)&&(this._wv=S.world.subarray(t*6,t*6+6),this._wi=t,this._we=S.epoch),this._wv}get data(){return this._data??(this._data={})}set data(t){this._data=t}get scale(){return this.scaleX}set scale(t){this.scaleX=this.scaleY=t}get z(){return this._z}set z(t){t!==this._z&&(this._z=t,this.parent&&(this.parent.sortDirty=!0))}get tint(){return S.tint[this._i]}set tint(t){S.tint[this._i||it]=typeof t=="number"?t&16777215:ot(t)[0]}set anchor(t){typeof t=="number"?this.anchorX=this.anchorY=t:(this.anchorX=t.x,this.anchorY=t.y)}get width(){return 0}set width(t){}get height(){return 0}set height(t){}set(t){for(const e in t){const s=t[e];s!==void 0&&(this[e]=s)}return this}destroy(){this.destroyed||(this.visible=!1,this.parent&&(this.parent.dead=!0,this.parent=null),Ys(this._i,this),Xn(this),this.kernel.tweens.stopAll(this),this._pool?.forget(this))}updateWorld(){const t=this.parent?this.parent.updateWorld():null;return ct(this.world,t,this.x,this.y,this.rotation,this.scaleX,this.scaleY)}draw(t,e,s){}};function Hn(t){Dn(e=>e.kernel===t)}var is=!1,Qs=Object.freeze([]),ns=class dn extends Et{constructor(e){super(e),c(this,"children",Qs),c(this,"sortDirty",!1),c(this,"dead",!1),Vs(this)}add(e,...s){this.adopt(e);for(let i=0;i<s.length;i++)this.adopt(s[i]);return e}adopt(e){e.parent&&e.parent.detach(e),e.parent=this,!e.destroyed&&!this.destroyed&&Bn(e._i,this._i),this.children===Qs&&(this.children=[]),this.children.push(e),(e.z!==0||this.sortDirty)&&(this.sortDirty=!0)}remove(e){this.detach(e),e._pool||Vs(e)}detach(e){const s=this.children,i=s.indexOf(e);if(i>=0){for(let n=i+1;n<s.length;n++)s[n-1]=s[n];s.pop()}e.parent===this&&(e.parent=null,e.destroyed||je(e._i))}clear(){for(const e of this.children)e.destroy()}destroy(){for(const e of this.children)e.destroy();super.destroy()}sweep(){if(this.dead){this.dead=!1;let e=0;for(const s of this.children)s.destroyed?s.parent===this&&(s.parent=null):this.children[e++]=s;this.children.length=e}for(const e of this.children)e instanceof dn&&e.sweep()}draw(e,s,i){if(is)return S.parent[this._i]<0&&!this.destroyed&&Gn(this._i),this.drawChildren(e,s,i);is=!0;try{this.destroyed||zn(this._i),this.drawChildren(e,s,i)}finally{is=!1}}drawChildren(e,s,i){if(this.sortDirty){const h=new Map(this.children.map((l,o)=>[l,o]));this.children.sort((l,o)=>l.z-o.z||h.get(l)-h.get(o)),this.sortDirty=!1}const n=this.children,r=this._i,a=S.stamp[r]===S.pass;for(let h=0;h<n.length;h++){const l=n[h],o=l._i,u=S.alpha[o];if(S.gen[o]!==l._g||!(S.flags[o]&Vt)||u<=0)continue;if(a||S.moved[o]){S.moved[o]=0,S.stamp[o]=S.pass;let g,d,y,m;if(S.dirty[o]){S.dirty[o]=0;const D=S.rot[o],W=D?Math.cos(D):1,X=D?Math.sin(D):0,z=S.sx[o],$t=S.sy[o];S.la[o]=g=W*z,S.lb[o]=d=X*z,S.lc[o]=y=-X*$t,S.ld[o]=m=W*$t}else g=S.la[o],d=S.lb[o],y=S.lc[o],m=S.ld[o];const w=S.world,x=S.x[o],_=S.y[o],M=o*6,k=r*6,F=w[k],R=w[k+1],N=w[k+2],I=w[k+3];w[M]=F*g+N*d,w[M+1]=R*g+I*d,w[M+2]=F*y+N*m,w[M+3]=R*y+I*m,w[M+4]=F*x+N*_+w[k+4],w[M+5]=R*x+I*_+w[k+5]}const f=s*u,p=qs(i,S.tint[o]);l.clip||l.mask||l.filters?Zs(e,l,f,p):l.draw(e,f,p)}}},V=new Float64Array(128),Tt=0,rs=new Float64Array(8);function Ks(t,e,s,i){e.clip||e.mask||e.filters?Zs(t,e,s,i):e.draw(t,s,i)}function Zs(t,e,s,i){const n=t.r,r=e.world,a=e.clip;let h=!1,l=!1;if(a)if(Math.abs(r[1])<1e-9&&Math.abs(r[2])<1e-9&&Tt<32){const f=r[0]*a.x+r[4],p=r[0]*(a.x+a.width)+r[4],g=r[3]*a.y+r[5],d=r[3]*(a.y+a.height)+r[5];let y=Math.min(f,p),m=Math.max(f,p),w=Math.min(g,d),x=Math.max(g,d);if(Tt){const M=(Tt-1)*4;y=Math.max(y,V[M]),w=Math.max(w,V[M+1]),m=Math.min(m,V[M+2]),x=Math.min(x,V[M+3])}const _=Tt++*4;V[_]=y,V[_+1]=w,V[_+2]=m,V[_+3]=x,n.clip(y,w,Math.max(m-y,0),Math.max(x-w,0)),l=!0}else h=!0;const o=e.mask&&e.mask.visible?e.mask:null,u=ts(e.filters)?e.filters:null;try{if(h&&n.beginLayer(),o&&n.beginLayer(),u?(e.draw(t,n.beginLayer()?1:s,i),n.endLayer(s,u)):e.draw(t,s,i),o&&(n.beginMask(),ct(o.world,r,o.x,o.y,o.rotation,o.scaleX,o.scaleY),Ks(t,o,o.alpha,16777215),n.endLayer(1)),h&&a){n.beginMask();for(let f=0;f<4;f++){const p=f===1||f===2?a.x+a.width:a.x,g=f>1?a.y+a.height:a.y;rs[f*2]=r[0]*p+r[2]*g+r[4],rs[f*2+1]=r[1]*p+r[3]*g+r[5]}n.polygon(rs,4,16777215,1),n.endLayer(1)}}finally{if(l)if(Tt--,Tt){const f=(Tt-1)*4;n.clip(V[f],V[f+1],V[f+2]-V[f],V[f+3]-V[f+1])}else n.unclip()}}var It=class extends Et{constructor(t,e,s){super(t),c(this,"_frame",null),c(this,"_w",null),c(this,"_h",null),c(this,"slice",0),c(this,"autoAnchor",!0),c(this,"frameName",null),e&&(this.frame=e),s?.anchor===void 0&&this.useFrameAnchor(),s&&this.set(s)}get frame(){return this._frame}set frame(t){this.frameName=typeof t=="string"?t:null,this._frame=typeof t=="string"?this.kernel.frame(t):t,this.autoAnchor&&this.useFrameAnchor()}set anchor(t){this.autoAnchor=!1,super.anchor=t}get naturalWidth(){const t=this.frameNow();return t?(t.sw??t.w)/t.scale-t.margin*2:0}get naturalHeight(){const t=this.frameNow();return t?(t.sh??t.h)/t.scale-t.margin*2:0}get width(){return this._w??this.naturalWidth}set width(t){this._w=t}get height(){return this._h??this.naturalHeight}set height(t){this._h=t}sizeQ(t){Dt[0]=this._w??(t.sw??t.w)/t.scale-t.margin*2,Dt[1]=this._h??(t.sh??t.h)/t.scale-t.margin*2}frameNow(){return this.frameName&&!this.kernel.atlas.valid(this._frame)&&(this._frame=this.kernel.frame(this.frameName)),this._frame}useFrameAnchor(){const t=this._frame;if(!t)return;const e=(t.sw??t.w)/t.scale-t.margin*2,s=(t.sh??t.h)/t.scale-t.margin*2;this.anchorX=e>0?(t.ox-t.margin)/e:0,this.anchorY=s>0?(t.oy-t.margin)/s:0}draw(t,e,s){const i=this.frameNow();if(!i)return;const n=Dt;this.sizeQ(i),n[2]=this.anchorX,n[3]=this.anchorY,n[4]=e,Wn(t,i,this.world,this.slice,s,this.blend)}},Ot=new Float64Array(12),Ut=new Float64Array(12),Kt={x:0,y:0,w:0,h:0};function Js(t,e,s,i,n,r){e=Math.max(e,0),s=Math.max(s,0),i=Math.max(i,0);const a=s+i>n?s*n/(s+i):s,h=s+i>n?i*n/(s+i):i;let l=a/r,o=h/r;if(l+o>e){const u=e/(l+o);l*=u,o*=u}t[0]=0,t[1]=l,t[2]=0,t[3]=a,t[4]=l,t[5]=e-l-o,t[6]=a,t[7]=n-a-h,t[8]=e-o,t[9]=o,t[10]=n-h,t[11]=h}var Dt=new Float64Array(5);function Wn(t,e,s,i,n,r){const a=Dt,h=a[0],l=a[1],o=a[2],u=a[3],f=a[4],p=t.tex(e.surface),g=i===0?e.slice??0:i;if(g===0){const M=(e.sw??e.w)/e.scale-e.margin*2,k=(e.sh??e.h)/e.scale-e.margin*2,F=M>0?h/M:1,R=k>0?l/k:1,N=-o*h+((e.tx??0)/e.scale-e.margin)*F,I=-u*l+((e.ty??0)/e.scale-e.margin)*R;me(s,N,I),U[0]=e.w/e.scale*F,U[1]=e.h/e.scale*R,U[2]=f,t.r.quadQ(p,e,q,n,r);return}const d=e.tx??0,y=e.ty??0,m=(e.sw??e.w)-e.w-d,w=(e.sh??e.h)-e.h-y,x=-o*h-e.margin+d/e.scale,_=-u*l-e.margin+y/e.scale;if(Js(Ot,h+e.margin*2-(d+m)/e.scale,(typeof g=="number"?g:g[3])-d,(typeof g=="number"?g:g[1])-m,e.w,e.scale),Js(Ut,l+e.margin*2-(y+w)/e.scale,(typeof g=="number"?g:g[0])-y,(typeof g=="number"?g:g[2])-w,e.h,e.scale),me(s,x,_),U[2]=f,!t.r.nineQ?.(p,e,Ot,Ut,q,n,r))for(let M=0;M<12;M+=4){const k=Ut[M+1],F=Ut[M+3];if(!(k<=0||F<=0))for(let R=0;R<12;R+=4){const N=Ot[R+1],I=Ot[R+3];N<=0||I<=0||(Kt.x=e.x+Ot[R+2],Kt.y=e.y+Ut[M+2],Kt.w=I,Kt.h=F,me(s,x+Ot[R],_+Ut[M]),U[0]=N,U[1]=k,U[2]=f,t.r.quadQ(p,Kt,q,n,r))}}}function me(t,e,s){q[0]=t[0],q[1]=t[1],q[2]=t[2],q[3]=t[3],q[4]=t[0]*e+t[2]*s+t[4],q[5]=t[1]*e+t[3]*s+t[5]}var Zt=class extends It{constructor(t,e,s={}){super(t,null),c(this,"_spec"),c(this,"baked",null),c(this,"bakedEffects",!0),this._spec=e,this.bake(),s.anchor===void 0&&this.useFrameAnchor(),this.set(s)}get spec(){return this._spec}set spec(t){this._spec=t,this.baked=null,this._w=this._h=null,this.bake()}bake(){const t=this.kernel;return this.baked&&t.atlas.valid(this.baked.frame)&&this.baked.frame.scale===t.pixelScale&&this.bakedEffects===t.effects?this.baked:(this.bakedEffects=t.effects,this.baked=t.shape(this._spec),this._frame=this.baked.frame,this.slice=this.baked.slice,this.baked)}frameNow(){return this.bake().frame}sizeQ(){const t=this.bake();Dt[0]=this._w??t.w,Dt[1]=this._h??t.h}get width(){return this._w??this.bake().w}set width(t){this._w=t}get height(){return this._h??this.bake().h}set height(t){this._h=t}},ti=(t,e,s)=>t===void 0?e:typeof t=="number"?t:t[0]+(t[1]-t[0])*s(),ei=class le extends Et{constructor(e,s,i={}){super(e),c(this,"max"),c(this,"f"),c(this,"tints"),c(this,"count",0),c(this,"gravity"),c(this,"drag"),c(this,"frameRef"),c(this,"random",Math.random),this.frameRef=s,this.max=Math.max(1,Math.floor(i.max??200)),this.f=new Float32Array(this.max*le.W),this.tints=new Uint32Array(this.max),this.blend=i.blend??"normal",this.gravity=i.gravity??0,this.drag=i.drag??1}get alive(){return this.count}burst(e,s,i,n={}){const r=le.W,a=this.random,h=n.tint===void 0?16777215:ot(n.tint)[0];for(let l=0;l<i;l++){let o=this.count;if(o>=this.max){let y=0,m=1/0;for(let w=0;w<this.max;w++){const x=this.f[w*r+5]-this.f[w*r+4];x<m&&(m=x,y=w)}o=y}else this.count++;const u=(n.angle??0)+(n.spread===void 0?a()*Math.PI*2:(a()-.5)*n.spread),f=ti(n.speed,200,a),p=Array.isArray(n.scale)?n.scale[0]:n.scale??1,g=Array.isArray(n.scale)?n.scale[1]:n.scale??1,d=o*r;this.f[d]=e,this.f[d+1]=s,this.f[d+2]=Math.cos(u)*f,this.f[d+3]=Math.sin(u)*f,this.f[d+4]=0,this.f[d+5]=Math.max(ti(n.life,.8,a),.01),this.f[d+6]=a()*Math.PI*2,this.f[d+7]=(a()-.5)*2*(n.spin??0),this.f[d+8]=p,this.f[d+9]=g,this.f[d+10]=n.alpha??1,this.tints[o]=h}}update(e){const s=le.W,i=this.f,n=this.drag>=1?1:Math.pow(Math.max(this.drag,0),e);for(let r=0;r<this.count;){const a=r*s;if(i[a+4]=i[a+4]+e,i[a+4]>=i[a+5]){const h=--this.count;r!==h&&(i.copyWithin(a,h*s,h*s+s),this.tints[r]=this.tints[h]);continue}i[a+3]=(i[a+3]+this.gravity*e)*n,i[a+2]=i[a+2]*n,i[a]=i[a]+i[a+2]*e,i[a+1]=i[a+1]+i[a+3]*e,i[a+6]=i[a+6]+i[a+7]*e,r++}}clear(){this.count=0}draw(e,s,i){if(!this.count)return;const n=typeof this.frameRef=="string"?this.frameRef=this.kernel.frame(this.frameRef):this.frameRef,r=le.W,a=this.f,h=this.world,l=n.w/n.scale,o=n.h/n.scale;for(let u=0;u<this.count;u++){const f=u*r,p=a[f+4]/a[f+5],g=a[f+8]+(a[f+9]-a[f+8])*p,d=s*a[f+10]*(1-p*p),y=a[f+6],m=Math.cos(y)*g,w=Math.sin(y)*g,x=a[f],_=a[f+1],M=h[0],k=h[1],F=h[2],R=h[3],N=M*m+F*w,I=k*m+R*w,D=F*m-M*w,W=R*m-k*w;q[0]=N,q[1]=I,q[2]=D,q[3]=W,q[4]=M*x+F*_+h[4]-(N*l+D*o)/2,q[5]=k*x+R*_+h[5]-(I*l+W*o)/2,U[0]=l,U[1]=o,U[2]=d,e.r.quadQ(e.tex(n.surface),n,q,qs(i,this.tints[u]),this.blend)}}};c(ei,"W",11);var si=ei,St=class extends It{constructor(t,e,s={}){const{fps:i,loop:n,playing:r,speed:a,onComplete:h,...l}=s;if(!e.frames.length)throw new Error("[engine] an animation needs at least one frame");super(t,e.frames[0],l),c(this,"frames"),c(this,"durations"),c(this,"fps"),c(this,"loop"),c(this,"speed"),c(this,"onComplete"),c(this,"_playing"),c(this,"index",0),c(this,"t",0),this.frames=e.frames,this.durations=e.durations&&i===void 0?e.durations:null,this.fps=i??12,this.loop=n!==!1,this.speed=a??1,this.onComplete=h??null,this._playing=r!==!1,this.speed<0&&this.show(e.frames.length-1)}get frameIndex(){return this.index}get frameCount(){return this.frames.length}get playing(){return this._playing}play(){return!this.loop&&!this._playing&&this.index===(this.speed<0?0:this.frames.length-1)&&this.show(this.speed<0?this.frames.length-1:0),this._playing=!0,this}stop(){return this._playing=!1,this}gotoFrame(t){const e=this.frames.length;return this.show((Math.floor(t)%e+e)%e),this.t=0,this}gotoAndPlay(t){return this._playing=!0,this.gotoFrame(t)}gotoAndStop(t){return this._playing=!1,this.gotoFrame(t)}show(t){t===this.index&&this._frame||(this.index=t,this.frame=this.frames[t])}secondsOf(t){const e=this.durations?.[t];return e!==void 0&&e>0?e:1/Math.max(this.fps,.001)}update(t){if(!this._playing||this.destroyed||this.speed===0)return;const e=this.frames.length,s=this.speed<0;this.t+=t*Math.abs(this.speed);let i=this.index;for(let n=0;n<1e3;n++){const r=this.secondsOf(i);if(this.t<r)break;this.t-=r;const a=s?i-1:i+1;if(a<0||a>=e){if(!this.loop){this.t=0,this._playing=!1,this.show(i),this.onComplete?.();return}i=s?e-1:0}else i=a}this.show(i)}},Yn=(t,e)=>t.localeCompare(e,void 0,{numeric:!0}),ii=class{constructor(t,e,s=2){c(this,"width",t),c(this,"height",e),c(this,"padding",s),c(this,"shelves",[]),c(this,"free",[]),c(this,"bottom",0)}alloc(t,e){const s=Math.ceil(t)+this.padding*2,i=Math.ceil(e)+this.padding*2;if(s>this.width||i>this.height)return null;for(let a=0;a<this.free.length;a++){const h=this.free[a];if(h.w>=s&&h.h>=i&&h.w*h.h<=s*i*2)return this.free.splice(a,1),this.inner(h.x,h.y,t,e)}let n=null;for(const a of this.shelves)a.h>=i&&a.h<=i*1.5+8&&this.width-a.x>=s&&(!n||a.h<n.h)&&(n=a);if(!n)if(this.bottom+i>this.height){for(const a of this.shelves)a.h>=i&&this.width-a.x>=s&&(n=a);if(!n)return null}else n={y:this.bottom,h:i,x:0},this.shelves.push(n),this.bottom+=i;const r=n.x;return n.x+=s,this.inner(r,n.y,t,e)}release(t){this.free.push({x:t.x-this.padding,y:t.y-this.padding,w:Math.ceil(t.w)+this.padding*2,h:Math.ceil(t.h)+this.padding*2})}get fill(){return this.bottom/this.height}reset(){this.shelves=[],this.free=[],this.bottom=0}inner(t,e,s,i){return{x:t+this.padding,y:e+this.padding,w:s,h:i}}},ye=t=>({source:t,texture:null,pending:[]}),as=class{constructor(t=2048,e=4){c(this,"pageSize",t),c(this,"maxPages",e),c(this,"pages",[]),c(this,"gen",1),c(this,"onPage",()=>{}),c(this,"onDrop",()=>{})}valid(t){return!!t&&(t.gen===this.gen||t.gen===0)}bake(t,e,s,i=1,n=0,r=0,a=0){const h=Math.max(1,Math.ceil(t)),l=Math.max(1,Math.ceil(e)),o=document.createElement("canvas");o.width=h,o.height=l;const u=o.getContext("2d");return s(u),this.put(o,h,l,i,n,r,a)}add(t,e=1,s=0,i=0){const n=document.createElement("canvas");return n.width=Math.max(1,t.width),n.height=Math.max(1,t.height),n.getContext("2d").drawImage(t,0,0),this.put(n,n.width,n.height,e,s,i,0)}release(t){if(t.gen!==this.gen)return;this.pages.find(s=>s.surface===t.surface)?.packer.release(t)}rebake(t,e,s,i,n=t.w,r=t.h){if(!this.valid(t)||e>n||s>r)return null;const a=Math.max(1,Math.ceil(e)),h=Math.max(1,Math.ceil(s)),l=this.pages.find(u=>u.surface===t.surface);if(!l)return null;const o=document.createElement("canvas");return o.width=Math.ceil(n),o.height=Math.ceil(r),i(o.getContext("2d")),l.ctx.clearRect(t.x,t.y,o.width,o.height),l.ctx.drawImage(o,t.x,t.y),t.surface.pending.push([o,t.x,t.y]),t.w=a,t.h=h,t}put(t,e,s,i,n,r,a){let h=null,l=this.pages.find(u=>(h=u.packer.alloc(e,s))!==null);if(l||(!(Math.max(e,s)+4>this.pageSize)&&this.pages.length>=this.maxPages&&(this.wipe(),l=this.pages[0],h=l?l.packer.alloc(e,s):null),(!l||!h)&&(l=this.newPage(Math.max(e,s)),h=l.packer.alloc(e,s))),!h)throw new Error(`[engine] ${e}\xD7${s} does not fit an atlas page`);const o=h;return l.ctx.drawImage(t,o.x,o.y),l.surface.pending.push([t,o.x,o.y]),{surface:l.surface,x:o.x,y:o.y,w:e,h:s,scale:i,gen:this.gen,ox:n,oy:r,margin:a}}newPage(t){let e=this.pageSize;for(;e<t+4;)e*=2;const s=document.createElement("canvas");s.width=s.height=e;const i=s.getContext("2d"),n=ye(s),r={surface:n,packer:new ii(e,e),ctx:i};return this.pages.push(r),this.onPage(n),r}wipe(){this.gen++;let t=0;for(let e=0;e<this.pages.length;e++){const s=this.pages[e];if(t<this.maxPages&&s.surface.source.width===this.pageSize){this.pages[t++]=s;continue}s.surface.pending=[],this.onDrop(s.surface)}this.pages.length=t;for(const e of this.pages)e.packer.reset(),e.ctx.clearRect(0,0,e.surface.source.width,e.surface.source.height),e.surface.pending=[],e.surface.pending.push([e.surface.source,0,0])}},jn=()=>globalThis.FabiPlay,ni=class{posed(t,e,s,i=!0){const n={id:t,body:e};return jn()?.smoothedBody(n,{smooth:s<1?s:!1,interpolate:i})??e}},ri=new Float64Array(1),ai=new Int32Array(ri.buffer),Bt=(t,e)=>(t=Math.imul(t^e,1540483477),t^t>>>15);function mt(t,e=2538058380){return t!==t?Bt(e,2146959360):(ri[0]=t===0?0:t,Bt(Bt(e,ai[0]),ai[1]))}function oi(t,e=2166136261){for(let s=0;s<t.length;s++)e=Math.imul(e^t.charCodeAt(s),16777619);return e}function yt(t){switch(typeof t){case"number":return mt(t);case"string":return oi(t);case"boolean":return t?1013904242:461845907;case"object":{if(t===null)return 625341585;if(Array.isArray(t)||t instanceof Float64Array){let i=1779033703^t.length;for(let n=0;n<t.length;n++){const r=t[n];i=Bt(i,typeof r=="number"?mt(r):yt(r))}return i}let e=1359893119;const s=t;for(const i in s){const n=s[i];n!==void 0&&(e=e+Bt(oi(i),yt(n))|0)}return Bt(e,2600822924)}default:return 0}}function Jt(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null)return typeof t=="number"&&typeof e=="number"&&t!==t&&e!==e;const s=Array.isArray(t)||t instanceof Float64Array;if(s!==(Array.isArray(e)||e instanceof Float64Array))return!1;if(s){const r=t,a=e;if(r.length!==a.length)return!1;for(let h=0;h<r.length;h++)if(r[h]!==a[h]&&!Jt(r[h],a[h]))return!1;return!0}const i=t,n=e;for(const r in i)if(i[r]!==void 0&&!Jt(i[r],n[r]))return!1;for(const r in n)if(n[r]!==void 0&&i[r]===void 0)return!1;return!0}function ve(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return t.map(ve);if(t instanceof Float64Array)return t.slice();const e={};for(const s in t)t[s]!==void 0&&(e[s]=ve(t[s]));return e}var hi=class{constructor(t=1/0){c(this,"max",t),c(this,"buckets",new Map),c(this,"n",0)}get size(){return this.n}get(t,e=yt(t)){const s=this.buckets.get(e);if(s){for(let i=0;i<s.length;i++)if(Jt(s[i].key,t))return s[i].value}}set(t,e,s=yt(t)){let i=this.buckets.get(s);if(i){for(const n of i)if(Jt(n.key,t)){n.value=e;return}}this.n>=this.max&&this.clear(),(!i||!this.buckets.has(s))&&this.buckets.set(s,i=[]),i.push({key:ve(t),value:e}),this.n++}clear(){this.buckets.clear(),this.n=0}},os=0,li=1,we=2,hs=3,ci=class{constructor(){c(this,"scale",1),c(this,"cOn",!1),c(this,"px0",0),c(this,"py0",0),c(this,"px1",0),c(this,"py1",0),c(this,"clipVer",0),c(this,"stack",[]),c(this,"sp",0),c(this,"real",0),c(this,"mute",0),c(this,"bnd",new Float64Array(4*(es+1))),c(this,"rx0",0),c(this,"ry0",0),c(this,"rx1",0),c(this,"ry1",0),c(this,"maxBlur",1/0),c(this,"time",0),c(this,"skipped",0),c(this,"gq",new Float64Array(4))}resetLayers(t){this.scale=t,this.sp=this.real=this.mute=0,this.skipped=0,this.cOn=!1,this.clipVer++}growQ(){const t=this.gq;this.grow(t[0],t[1],t[2],t[3])}grow(t,e,s,i){if(!this.real)return;const n=this.bnd,r=(this.real-1)*4;t<n[r]&&(n[r]=t),e<n[r+1]&&(n[r+1]=e),s>n[r+2]&&(n[r+2]=s),i>n[r+3]&&(n[r+3]=i)}area(t,e){const s=this.bnd,i=t*4,n=this.scale;return this.rx0=Math.max(Math.floor((s[i]-e)*n)-1,0),this.ry0=Math.max(Math.floor((s[i+1]-e)*n)-1,0),this.rx1=Math.min(Math.ceil((s[i+2]+e)*n)+1,this.canvas.width),this.ry1=Math.min(Math.ceil((s[i+3]+e)*n)+1,this.canvas.height),this.rx1>this.rx0&&this.ry1>this.ry0}clip(t,e,s,i){const n=this.scale,r=this.canvas.width,a=this.canvas.height,h=Math.min(Math.max(Math.round(t*n),0),r),l=Math.min(Math.max(Math.round(e*n),0),a),o=Math.min(Math.max(Math.round((t+s)*n),h),r),u=Math.min(Math.max(Math.round((e+i)*n),l),a);this.cOn&&h===this.px0&&l===this.py0&&o===this.px1&&u===this.py1||(this.cOn=!0,this.px0=h,this.py0=l,this.px1=o,this.py1=u,this.clipVer++)}unclip(){this.cOn&&(this.cOn=!1,this.clipVer++)}push(t){if(t<we&&(this.mute||this.real>=es||!this.pushLayer())&&(t+=2),t===hs)this.mute++;else if(t!==we){const e=this.real*4;this.bnd[e]=this.bnd[e+1]=1/0,this.bnd[e+2]=this.bnd[e+3]=-1/0,this.real++}return this.stack[this.sp++]=t,t<we}beginLayer(){return this.push(os)}beginMask(){this.push(this.sp&&this.stack[this.sp-1]===os?li:hs)}endLayer(t,e){if(!this.sp)return;let s=this.stack[--this.sp];if(s===hs){if(this.mute--,!this.sp)return;s=this.stack[--this.sp]}if(s===li){const i=--this.real,n=this.popLayer();this.area(i-1,0)&&this.composite(n,!0,1,null);const r=this.bnd,a=(i-1)*4,h=i*4;r[a]=Math.max(r[a],r[h]),r[a+1]=Math.max(r[a+1],r[h+1]),r[a+2]=Math.min(r[a+2],r[h+2]),r[a+3]=Math.min(r[a+3],r[h+3]),s=this.stack[--this.sp]}if(s===we)ts(e)&&(this.skipped+=e.length);else if(s===os){const i=--this.real,n=ts(e)?e:null,r=this.popLayer();if(this.area(i,n?$n(n,this.maxBlur):0)){this.composite(r,!1,t,n);const a=this.scale;this.grow(this.rx0/a,this.ry0/a,this.rx1/a,this.ry1/a)}}}closeLayers(){for(;this.sp;)this.endLayer(1)}},Vn=256,fi=8<<20,K=new Float64Array(32),Z={x:0,y:0,w:0,h:0};function Qn(t){if(typeof t.filter!="string")return!1;t.filter="blur(1px)";const e=t.filter==="blur(1px)";return t.filter="none",e}function ls(t){const e=t.getContext("2d",{alpha:!0});return e?new Kn(t,e):null}var Kn=class extends ci{constructor(t,e){super(),c(this,"canvas",t),c(this,"ctx",e),c(this,"kind","canvas2d"),c(this,"maxTextureSize",4096),c(this,"features",{}),c(this,"info",{renderer:"canvas2d"}),c(this,"support"),c(this,"lost",!1),c(this,"fxr",null),c(this,"quads",0),c(this,"stats",{drawCalls:0,quads:0,filtersSkipped:0}),c(this,"tinted",new Map),c(this,"tintedN",0),c(this,"lostListeners",[]),c(this,"restoredListeners",[]),c(this,"base"),c(this,"top"),c(this,"layers",[]),c(this,"scratch",[]),c(this,"nines",new Map),c(this,"ninePx",0),c(this,"frame",0),c(this,"hit",!1),c(this,"missed",new Map),this.support={filters:Qn(e),shaders:!1},this.base=this.top={ctx:e,clipped:!1,ver:0},t.addEventListener("contextlost",()=>{this.lost=!0,this.lostListeners.forEach(s=>s())}),t.addEventListener("contextrestored",()=>{this.lost=!1,this.tinted.clear(),this.tintedN=0,this.dropNines(),this.restoredListeners.forEach(s=>s())})}resize(t,e){this.canvas.width!==t&&(this.canvas.width=t),this.canvas.height!==e&&(this.canvas.height=e)}createTexture(t){return{id:ss(),width:t.width,height:t.height,source:t}}updateTexture(t,e,s=0,i=0){const n=e?s+e.width:1/0,r=e?i+e.height:1/0;for(const a of this.nines.values()){const h=a.key;h[0]===t.id&&h[1]<n&&h[1]+h[3]>s&&h[2]<r&&h[2]+h[4]>i&&this.dropNine(a)}for(const[a,h]of this.tinted){const l=h.filter(o=>o.id!==t.id);this.tintedN-=h.length-l.length,l.length?this.tinted.set(a,l):this.tinted.delete(a)}}destroyTexture(t){this.updateTexture(t)}begin(t,e,s){this.resetLayers(s),this.fxr?.tick(),this.frame++,this.quads=0,this.top=this.base,this.ctx=this.base.ctx;const i=this.ctx;this.base.clipped&&i.restore(),this.base.clipped=!1,this.base.ver=this.clipVer,i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.globalCompositeOperation="source-over",i.clearRect(0,0,this.canvas.width,this.canvas.height),e>0&&(i.fillStyle=Yt(t,e),i.fillRect(0,0,this.canvas.width,this.canvas.height))}quad(t,e,s,i,n,r,a,h){U[0]=i,U[1]=n,U[2]=a,this.quadQ(t,e,s,r,h)}quadQ(t,e,s,i,n){e.w<=0||e.h<=0||(i===16777215?this.blit(t.source,e.x,e.y,e.w,e.h,s,n):this.blit(this.tint(t,e,i),0,0,e.w,e.h,s,n))}blit(t,e,s,i,n,r,a){const h=U[0],l=U[1],o=U[2];if(o<=0||this.mute)return;this.sync();const u=this.ctx,f=this.scale;if(this.real){const p=r[0]*h,g=r[1]*h,d=r[2]*l,y=r[3]*l;this.grow(r[4]+Math.min(0,p,d,p+d),r[5]+Math.min(0,g,y,g+y),r[4]+Math.max(0,p,d,p+d),r[5]+Math.max(0,g,y,g+y))}u.setTransform(r[0]*f,r[1]*f,r[2]*f,r[3]*f,r[4]*f,r[5]*f),u.globalAlpha=Math.min(o,1),a==="add"&&(u.globalCompositeOperation="lighter"),u.drawImage(t,e,s,i,n,0,0,h,l),a==="add"&&(u.globalCompositeOperation="source-over"),this.quads++}nineQ(t,e,s,i,n,r,a){var h,l;const o=s[8]+s[9],u=i[8]+i[9],f=Math.ceil(o*Math.hypot(n[0],n[1])*this.scale-1e-6),p=Math.ceil(u*Math.hypot(n[2],n[3])*this.scale-1e-6);if(n[1]===0&&n[2]===0||f>4096||p>4096)return!1;if(!(f>0&&p>0&&U[2]>0)||this.mute)return!0;let g=this.kept(t,e,s,i,f,p,r);const d=(g??(g=(h=this.scratch)[l=13*Math.ceil(Math.log2(f))+Math.ceil(Math.log2(p))]??(h[l]=document.createElement("canvas").getContext("2d")))).canvas;if(d.width<f&&(d.width=f),d.height<p&&(d.height=p),!this.hit){g.clearRect(0,0,f+2,p+2);for(let y=0;y<12;y+=4){const m=Math.round(i[y]*p/u),w=Math.round((i[y]+i[y+1])*p/u);for(let x=0;x<12;x+=4){const _=Math.round(s[x]*f/o),M=Math.round((s[x]+s[x+1])*f/o);Z.x=e.x+s[x+2],Z.y=e.y+i[y+2],Z.w=s[x+3],Z.h=i[y+3],!(M<=_||w<=m||Z.w<=0||Z.h<=0)&&(r===16777215?g.drawImage(t.source,Z.x,Z.y,Z.w,Z.h,_,m,M-_,w-m):g.drawImage(this.tint(t,Z,r),0,0,Z.w,Z.h,_,m,M-_,w-m))}}}return U[0]=o,U[1]=u,this.blit(d,0,0,f,p,n,a),!0}kept(t,e,s,i,n,r,a){K[0]=t.id,K[1]=e.x,K[2]=e.y,K[3]=e.w,K[4]=e.h,K[5]=n,K[6]=r,K[7]=a,K.set(s,8),K.set(i,20);const h=yt(K),l=this.nines.get(h);if(this.hit=!1,l)return Jt(l.key,K)?(l.used=this.frame,this.hit=!0,l.ctx):null;const o=this.missed,u=o.get(h);o.size>4096&&o.clear(),o.set(h,this.frame);const f=n*r;if(u!==this.frame-1||f>fi)return null;let p;for(;this.ninePx+f>fi;){let y;for(const x of this.nines.values())x.used<this.frame-1&&!(y&&y.used<=x.used)&&(y=x);if(!y)return null;const m=y.ctx.canvas,w=!p&&m.width>=n&&m.height>=r&&m.width*m.height<=2*f;this.dropNine(y,w),w&&(p=y.ctx)}const g=p??document.createElement("canvas").getContext("2d"),d=g.canvas;return p||(d.width=n,d.height=r),this.ninePx+=d.width*d.height,this.nines.set(h,{key:ve(K),ctx:g,used:this.frame}),g}dropNine(t,e=!1){this.nines.delete(yt(t.key));const s=t.ctx.canvas;this.ninePx-=s.width*s.height,e||(s.width=0)}dropNines(){for(const t of this.nines.values())this.dropNine(t)}tint(t,e,s){const i=mt(s,mt(e.h,mt(e.w,mt(e.y,mt(e.x,mt(t.id))))));let n=this.tinted.get(i);if(n)for(let h=0;h<n.length;h++){const l=n[h];if(l.id===t.id&&l.x===e.x&&l.y===e.y&&l.w===e.w&&l.h===e.h&&l.color===s)return l.canvas}this.tintedN>=Vn&&(this.tinted.clear(),this.tintedN=0,n=void 0);const r=document.createElement("canvas");r.width=Math.ceil(e.w),r.height=Math.ceil(e.h);const a=r.getContext("2d");return a.drawImage(t.source,e.x,e.y,e.w,e.h,0,0,e.w,e.h),a.globalCompositeOperation="multiply",a.fillStyle=Yt(s),a.fillRect(0,0,e.w,e.h),a.globalCompositeOperation="destination-in",a.drawImage(t.source,e.x,e.y,e.w,e.h,0,0,e.w,e.h),n||this.tinted.set(i,n=[]),n.push({id:t.id,x:e.x,y:e.y,w:e.w,h:e.h,color:s,canvas:r}),this.tintedN++,r}paint(t,e){this.sync();const s=this.ctx,i=this.scale;return s.setTransform(i,0,0,i,0,0),s.globalAlpha=Math.min(e,1),Yt(t)}ellipse(t,e,s,i,n,r,a){if(a<=0||s<=0||i<=0||this.mute)return;const h=Math.max(s,i);this.grow(t-h,e-h,t+h,e+h);const l=this.ctx;l.fillStyle=this.paint(r,a),l.beginPath(),l.ellipse(t,e,s,i,n,0,Math.PI*2),l.fill(),this.quads++}trace(t,e,s=0){if(this.real)for(let n=0;n<e;n++)this.grow(t[n*2]-s,t[n*2+1]-s,t[n*2]+s,t[n*2+1]+s);const i=this.ctx;i.beginPath(),i.moveTo(t[0],t[1]);for(let n=1;n<e;n++)i.lineTo(t[n*2],t[n*2+1])}polygon(t,e,s,i){if(i<=0||e<3||this.mute)return;const n=this.ctx;n.fillStyle=this.paint(s,i),this.trace(t,e),n.closePath(),n.fill(),this.quads++}stroke(t,e,s,i,n,r){if(n<=0||s<=0||e<1||this.mute)return;const a=this.ctx;a.strokeStyle=this.paint(i,n),a.lineWidth=s,a.lineCap="round",a.lineJoin="round",this.trace(t,e,s/2),e===1&&a.lineTo(t[0],t[1]),r&&a.closePath(),a.stroke(),this.quads++}sync(){const t=this.top;if(t.ver===this.clipVer)return;const e=t.ctx;t.clipped&&e.restore(),t.clipped=this.cOn,t.ver=this.clipVer,this.cOn&&(e.save(),e.setTransform(1,0,0,1,0,0),e.beginPath(),e.rect(this.px0,this.py0,this.px1-this.px0,this.py1-this.py0),e.clip())}pushLayer(){const t=this.canvas.width,e=this.canvas.height;let s=this.layers[this.real];if(!s||s.ctx.canvas.width!==t||s.ctx.canvas.height!==e){const n=document.createElement("canvas");n.width=t,n.height=e;const r=n.getContext("2d");if(!r)return!1;s=this.layers[this.real]={ctx:r,clipped:!1,ver:-1}}const i=s.ctx;return s.clipped&&i.restore(),s.clipped=!1,s.ver=-1,i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.globalCompositeOperation="source-over",i.clearRect(0,0,t,e),this.top=s,this.ctx=i,!0}popLayer(){return this.top=this.real>0?this.layers[this.real-1]:this.base,this.ctx=this.top.ctx,this.layers[this.real].ctx.canvas}composite(t,e,s,i){let n=t,r="none";const a=i&&ht.c2d?this.fxr??(this.fxr=ht.c2d(this)):null;a&&(n=a.chain(t,i),r=a.css),this.sync();const h=this.ctx,l=this.rx0,o=this.ry0,u=this.rx1-l,f=this.ry1-o;h.setTransform(1,0,0,1,0,0),h.globalAlpha=Math.min(s,1),h.globalCompositeOperation=e?"destination-in":"source-over",r!=="none"&&(h.filter=r),h.drawImage(n,l,o,u,f,l,o,u,f),r!=="none"&&(h.filter="none"),h.globalCompositeOperation="source-over",this.quads++}end(){this.closeLayers();const t=this.stats;return t.drawCalls=t.quads=this.quads,t.filtersSkipped=this.skipped,t}onLost(t){this.lostListeners.push(t)}onRestored(t){this.restoredListeners.push(t)}destroy(){this.tinted.clear(),this.dropNines(),this.layers=[],this.scratch=[],this.fxr?.destroy(),this.fxr=null}},te=14,zt=6,ui=8192,Zn=class{constructor(t,e,s=ui){c(this,"instanced",t),c(this,"slots",e),c(this,"capacity",s),c(this,"f32"),c(this,"u32"),c(this,"quads",0),c(this,"textures"),c(this,"bound",0),this.textures=new Array(e).fill(null);const i=s*(t?te:zt*4),n=new ArrayBuffer(i*4);this.f32=new Float32Array(n),this.u32=new Uint32Array(n)}slot(t){const e=this.textures;for(let s=0;s<this.bound;s++)if(e[s]===t)return s;return this.bound>=this.slots?-1:(e[this.bound]=t,this.bound++)}has(t){for(let e=0;e<this.bound;e++)if(this.textures[e]===t)return!0;return!1}get full(){return this.quads>=this.capacity}get words(){return this.quads*(this.instanced?te:zt*4)}reset(){this.quads=0;for(let t=0;t<this.bound;t++)this.textures[t]=null;this.bound=0}push(t,e,s,i,n,r,a,h,l,o,u,f,p,g){const d=this.f32;if(this.instanced){let y=this.quads*te;d[y++]=t,d[y++]=e,d[y++]=s,d[y++]=i,d[y++]=n,d[y++]=r,d[y++]=a,d[y++]=h,d[y++]=l,d[y++]=o,d[y++]=u,d[y++]=f,this.u32[y++]=p,d[y]=g}else{const y=this.quads*zt*4;this.vertex(y,t,e,l,o,p,g),this.vertex(y+6,s,i,u,o,p,g),this.vertex(y+12,n,r,u,f,p,g),this.vertex(y+18,a,h,l,f,p,g)}this.quads++}pushQ(t,e){const s=this.f32;if(this.instanced){const i=this.quads*te;for(let n=0;n<12;n++)s[i+n]=t[n];this.u32[i+12]=t[12],s[i+13]=e}else{let i=this.quads*zt*4;const n=t[12];for(let r=0;r<4;r++,i+=zt)s[i]=t[r*2],s[i+1]=t[r*2+1],s[i+2]=r===1||r===2?t[10]:t[8],s[i+3]=r>=2?t[11]:t[9],this.u32[i+4]=n,s[i+5]=e}this.quads++}vertex(t,e,s,i,n,r,a){const h=this.f32;h[t]=e,h[t+1]=s,h[t+2]=i,h[t+3]=n,this.u32[t+4]=r,h[t+5]=a}};function Jn(t){const e=new Uint16Array(t*6);for(let s=0,i=0,n=0;s<t;s++,i+=6,n+=4)e[i]=n,e[i+1]=n+1,e[i+2]=n+2,e[i+3]=n,e[i+4]=n+2,e[i+5]=n+3;return e}var J={M:0,L:1,Q:2,C:3,Z:4},di=[2,2,4,6,0],tr={M:0,L:1,Q:2,C:3,Z:4};function cs(t,e){if(t.length>=e)return t;const s=new Float64Array(Math.max(e,t.length*2,16));return s.set(t),s}var xe=new Map;function er(t){if(typeof t!="string")return t;let e=xe.get(t);if(e)return e;e=[];const s=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[];let i=-1;for(let n=0;n<s.length;){const r=s[n],a=tr[r.toUpperCase()];if(a!==void 0){i=a,n++,a===J.Z&&e.push(J.Z);continue}if(i<0||i===J.Z){n++;continue}const h=di[i];e.push(i);for(let l=0;l<h;l++)e.push(Number(s[n+l]??0));n+=h,i===J.M&&(i=J.L)}return xe.size>256&&xe.clear(),xe.set(t,e),e}var vt={subs:[],count:0},fs=null,wt=null;function be(t,e){let s=wt;s||(s=vt.subs[vt.count]??null,s||vt.subs.push(s={pts:new Float64Array(64),n:0,closed:!1}),s.n=0,s.closed=!1,vt.count++,wt=s);const i=s.n*2;i+2>s.pts.length&&(s.pts=cs(s.pts,i+2));const n=fs;n?(s.pts[i]=n[0]*t+n[2]*e+n[4],s.pts[i+1]=n[1]*t+n[3]*e+n[5]):(s.pts[i]=t,s.pts[i+1]=e),s.n++}function us(t,e=null,s=1,i=6){const n=er(t);vt.count=0,wt=null,fs=e;let r=0,a=0,h=0,l=0;const o=s/i;for(let u=0;u<n.length;){const f=n[u++],p=n;if(f===J.M)wt=null,r=h=p[u],a=l=p[u+1],be(r,a);else if(f===J.L)r=p[u],a=p[u+1],be(r,a);else if(f===J.Q){const g=p[u],d=p[u+1],y=p[u+2],m=p[u+3],w=pi((ft(g-r,d-a)+ft(y-g,m-d))*o);for(let x=1;x<=w;x++){const _=x/w,M=1-_;be(M*M*r+2*M*_*g+_*_*y,M*M*a+2*M*_*d+_*_*m)}r=y,a=m}else if(f===J.C){const g=p[u],d=p[u+1],y=p[u+2],m=p[u+3],w=p[u+4],x=p[u+5],_=pi((ft(g-r,d-a)+ft(y-g,m-d)+ft(w-y,x-m))*o);for(let M=1;M<=_;M++){const k=M/_,F=1-k,R=F*F*F,N=3*F*F*k,I=3*F*k*k,D=k*k*k;be(R*r+N*g+I*y+D*w,R*a+N*d+I*m+D*x)}r=w,a=x}else if(f===J.Z){wt&&(wt.closed=!0),wt=null,r=h,a=l;continue}else break;u+=di[f]}wt=null,fs=null;for(let u=0;u<vt.count;u++){const f=vt.subs[u],p=f.n*2;f.closed&&f.n>=2&&Math.abs(f.pts[0]-f.pts[p-2])<1e-6&&Math.abs(f.pts[1]-f.pts[p-1])<1e-6&&f.n--}return vt}var ft=(t,e)=>Math.sqrt(t*t+e*e),pi=t=>Math.min(Math.max(Math.ceil(t),2),24);function sr(t,e){let s=0;for(let i=0,n=e-1;i<e;n=i++)s+=(t[n*2]-t[i*2])*(t[n*2+1]+t[i*2+1]);return s}var Me=new Int32Array(64),ke=(t,e,s,i,n)=>((t[i*2]-t[s*2])*(t[n*2+1]-t[s*2+1])-(t[i*2+1]-t[s*2+1])*(t[n*2]-t[s*2]))*e;function ir(t,e,s){if(e<3)return 0;Me.length<e&&(Me=new Int32Array(Math.max(e,Me.length*2)));const i=Me;let n=e,r=0;for(let o=0;o<e;o++)i[o]=o;const a=sr(t,e)>0?1:-1;let h=e*e+8,l=0;for(;n>3&&h-- >0;){const o=i[(l+n-1)%n],u=i[l%n],f=i[(l+1)%n];let p=ke(t,a,o,u,f)>0;if(p)for(let g=0;g<n;g++){const d=i[g];if(!(d===o||d===u||d===f)&&ke(t,a,o,u,d)>=0&&ke(t,a,u,f,d)>=0&&ke(t,a,f,o,d)>=0){p=!1;break}}p?(s[r++]=o,s[r++]=u,s[r++]=f,i.copyWithin(l%n,l%n+1,n),n--,l=Math.max(l-1,0)):l=(l+1)%n}if(n===3)s[r++]=i[0],s[r++]=i[1],s[r++]=i[2];else if(n>3)for(let o=1;o+1<n;o++)s[r++]=i[0],s[r++]=i[o],s[r++]=i[o+1];return r}var nr=.85,Ae=new Float64Array(64),gi=new Float64Array(64),mi=new Float64Array(64),yi=new Float64Array(64),vi=new Float64Array(64),wi=new Float64Array(64),xi=new Uint8Array(64),_e=new Float64Array(8);function rr(t,e,s,i,n,r){const a=_e;if(Ae.length<e){const m=Math.max(e,Ae.length*2);Ae=new Float64Array(m),gi=new Float64Array(m),mi=new Float64Array(m),yi=new Float64Array(m),vi=new Float64Array(m),wi=new Float64Array(m),xi=new Uint8Array(m)}const h=Ae,l=gi;let o=0;for(let m=0;m<e;m++){const w=t[m*2],x=t[m*2+1];!Number.isFinite(w)||!Number.isFinite(x)||o&&Math.abs(h[o-1]-w)<.001&&Math.abs(l[o-1]-x)<.001||(h[o]=w,l[o]=x,o++)}if(i&&o>2&&Math.abs(h[0]-h[o-1])<.001&&Math.abs(l[0]-l[o-1])<.001&&o--,o===0)return;if(o===1)return a[0]=h[0],a[1]=l[0],r();const u=i?o:o-1,f=mi,p=yi;for(let m=0;m<u;m++){const w=(m+1)%o,x=h[w]-h[m],_=l[w]-l[m],M=ft(x,_)||1;f[m]=-_/M,p[m]=x/M}const g=vi,d=wi,y=xi;for(let m=0;m<o;m++){const w=i?(m-1+u)%u:m-1,x=m<u?m:-1;if(y[m]=1,w<0||x<0||f[w]*f[x]+p[w]*p[x]<nr)continue;let M=f[w]+f[x],k=p[w]+p[x];const F=ft(M,k)||1;M/=F,k/=F;const R=s/Math.max(M*f[x]+k*p[x],.5);g[m]=M*R,d[m]=k*R,y[m]=0}for(let m=0;m<u;m++){const w=(m+1)%o,x=y[m]?f[m]*s:g[m],_=y[m]?p[m]*s:d[m],M=y[w]?f[m]*s:g[w],k=y[w]?p[m]*s:d[w];a[0]=h[m]+x,a[1]=l[m]+_,a[2]=h[w]+M,a[3]=l[w]+k,a[4]=h[w]-M,a[5]=l[w]-k,a[6]=h[m]-x,a[7]=l[m]-_,n()}for(let m=0;m<o;m++)y[m]&&(a[0]=h[m],a[1]=l[m],r())}function bi(t,e){let s=0,i=1/0;for(let n=0;n<e.length;n++){const r=Math.abs(Math.log(Math.max(t,.5)/e[n]));r<i&&(i=r,s=n)}return s}var et=256,ds=[{x:240,y:0,w:8,h:8,r:3},{x:224,y:0,w:16,h:16,r:7},{x:192,y:0,w:32,h:32,r:15},{x:128,y:0,w:64,h:64,r:31},{x:0,y:0,w:128,h:128,r:63}],ps=[4,8,16,32,64,128].map((t,e)=>({x:e*4,y:128,w:4,h:t,r:t/2-1})),xt={x:248,y:248,w:8,h:8},ar=ds.map(t=>t.r*2),or=ps.map(t=>t.r*2),Mi=(t,e)=>Math.min(Math.max(t+.5-e,0),1);function hr(){const t=new Uint8ClampedArray(et*et*4),e=(s,i,n)=>{const r=(i*et+s)*4;t[r]=t[r+1]=t[r+2]=255,t[r+3]=Math.round(n*255)};for(const s of ds){const i=s.w/2;for(let n=0;n<s.h;n++)for(let r=0;r<s.w;r++)e(s.x+r,s.y+n,Mi(s.r,Math.hypot(r+.5-i,n+.5-i)))}for(const s of ps){const i=s.h/2;for(let n=0;n<s.h;n++)for(let r=0;r<s.w;r++)e(s.x+r,s.y+n,Mi(s.r,Math.abs(n+.5-i)))}for(let s=0;s<xt.h;s++)for(let i=0;i<xt.w;i++)e(xt.x+i,xt.y+s,1);return t}function lr(){const t=document.createElement("canvas");return t.width=t.height=et,t.getContext("2d").putImageData(new ImageData(hr(),et,et),0,0),t}var ki=8,gs=`
|
|
1
|
+
/*! @fabi-play/engine 0.3.0 (lite: load fabi-play.js first) | Fabi Play Kit License | https://docs.fabiplay.app */(function(Ds,_t){var ce=typeof document<"u"?document.currentScript:null;typeof define=="function"&&define.amd?define([],function(){return _t(ce)}):typeof module=="object"&&module&&module.exports?module.exports=_t(ce):Ds.FabiEngine=_t(ce)})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:this,function(Ds){"use strict";var _t={exports:{}},ce=_t.exports,fe=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,gn=Object.getOwnPropertyNames,mn=Object.prototype.hasOwnProperty,yn=(t,e,s)=>e in t?fe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,vn=(t,e)=>{for(var s in e)fe(t,s,{get:e[s],enumerable:!0})},wn=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gn(e))!mn.call(t,n)&&n!==s&&fe(t,n,{get:()=>e[n],enumerable:!(i=pn(e,n))||i.enumerable});return t},xn=t=>wn(fe({},"__esModule",{value:!0}),t),c=(t,e,s)=>yn(t,typeof e!="symbol"?e+"":e,s),Bs={};vn(Bs,{AnimatedSprite:()=>St,Atlas:()=>as,AvatarPainter:()=>xs,AvatarsNode:()=>qi,BitmapFont:()=>bs,DEFAULT_FONT:()=>Ei,EASE:()=>jt,Group:()=>ns,HALO:()=>ee,MAX_LAYERS:()=>es,NameTags:()=>vs,Node:()=>Et,NodePool:()=>Zi,Particles:()=>si,STAGE_HEIGHT:()=>Y,Shape:()=>Zt,ShelfPacker:()=>ii,Sound:()=>Ii,Sprite:()=>It,TIERS:()=>ut,Text:()=>se,Timeline:()=>Xi,Tweens:()=>$i,avatarPortrait:()=>kr,blur:()=>Ta,brightness:()=>wa,colorMatrix:()=>Ea,contrast:()=>xa,createAvatarRenderer:()=>Mr,createEngine:()=>qr,createRenderer:()=>ms,dropShadow:()=>Sa,grayscale:()=>Ma,handsOf:()=>Pi,hits:()=>ks,hueRotate:()=>Aa,invert:()=>_a,nodePool:()=>Ia,packColor:()=>Lt,parseBMFont:()=>Fe,parseColor:()=>ot,pickTier:()=>Oi,playerColor:()=>Ms,rendererOrder:()=>_i,rng:()=>Ln,saturate:()=>ba,sepia:()=>ka,shader:()=>Fa,shapeBounds:()=>ws,tier:()=>Ft,tint:()=>va,touching:()=>Ni,wrists:()=>Ci}),_t.exports=xn(Bs);var bn=33,zs={nose:0,leftShoulder:11,rightShoulder:12,leftElbow:13,rightElbow:14,leftWrist:15,rightWrist:16,leftHip:23,rightHip:24,leftKnee:25,rightKnee:26,leftAnkle:27,rightAnkle:28},Mn=4,ue=["#EE6A43","#6FA0E0","#8CC9A0","#C49BE0"],kn={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},Ha=kn["6-8"],An=(t,e)=>t?{x:t.x+e.x*t.w,y:t.y+e.y*t.h}:{x:e.x,y:e.y},_n=12,En=bn*4,Tn=t=>_n+t*En,Wa=Tn(Mn),Sn=t=>t.startsWith("fabi-play.")?`fablee-play.${t.slice(10)}`:null;function Fn(t,e,s=Sn(e)){if(!(!t||!s))try{const i=t.getItem(s);if(i===null)return;t.getItem(e)===null&&t.setItem(e,i),t.removeItem(s)}catch{}}var Gs=globalThis.FabiPlay?.avatars;if(!Gs)throw new Error("[engine] fabi-play-engine.lite.js needs fabi-play.js (with FabiPlay.avatars) loaded before it");var{avatarById:de,avatarShapes:Rn,BAND_BODY:Ya,DEFAULT_AVATAR:pe,drawShapes:Xs,frameOf:Cn,iconShapes:Pn}=Gs,Nt=()=>Float64Array.of(1,0,0,1,0,0);function ct(t,e,s,i,n,r,a){const h=n?Math.cos(n):1,l=n?Math.sin(n):0,o=h*r,u=l*r,f=-l*a,p=h*a;if(!e)return t[0]=o,t[1]=u,t[2]=f,t[3]=p,t[4]=s,t[5]=i,t;const g=e[0],d=e[1],y=e[2],m=e[3];return t[0]=g*o+y*u,t[1]=d*o+m*u,t[2]=g*f+y*p,t[3]=d*f+m*p,t[4]=g*s+y*i+e[4],t[5]=d*s+m*i+e[5],t}function Nn(t,e,s){const i=t[0]*t[3]-t[1]*t[2];if(Math.abs(i)<1e-12)return null;const n=e-t[4],r=s-t[5];return[(t[3]*n-t[2]*r)/i,(-t[1]*n+t[0]*r)/i]}var $s={white:16777215,black:0,red:16711680,transparent:0},Wt=new Map;function ot(t){if(typeof t=="number")return[t&16777215,1];const e=Wt.get(t);if(e)return e;let s=[16777215,1];const i=t.trim().toLowerCase();if(i[0]==="#"){const n=i.slice(1),r=n.length<=4?[...n].map(h=>h+h).join(""):n,a=parseInt(r.slice(0,6),16);Number.isFinite(a)&&(s=[a,r.length===8?parseInt(r.slice(6,8),16)/255:1])}else if(i.startsWith("rgb")){const n=i.match(/-?\d*\.?\d+%?/g)?.map(o=>o.endsWith("%")?parseFloat(o)/100*255:parseFloat(o))??[],[r=255,a=255,h=255]=n,l=n[3]===void 0?1:i.match(/,\s*[\d.]+%\s*\)$/)?n[3]/255:n[3];s=[(We(r)<<16|We(a)<<8|We(h))>>>0,Math.min(Math.max(l,0),1)]}else if(i in $s)s=[$s[i],i==="transparent"?0:1];else if(typeof document<"u"){const n=document.createElement("canvas").getContext("2d");if(n){n.fillStyle="#ffffff",n.fillStyle=i;const r=n.fillStyle;if(r!==i)return Wt.set(t,s=ot(r)),s}}return Wt.size>512&&Wt.clear(),Wt.set(t,s),s}var We=t=>Math.min(Math.max(Math.round(t),0),255);function Lt(t,e,s=!1){const i=Math.min(Math.max(e,0),1),n=(t>>16&255)*i,r=(t>>8&255)*i,a=(t&255)*i,h=s?0:i*255;return(Math.round(h)<<24|Math.round(a)<<16|Math.round(r)<<8|Math.round(n))>>>0}var Yt=(t,e=1)=>`rgba(${t>>16&255},${t>>8&255},${t&255},${e})`;function qs(t,e){if(t===16777215)return e;if(e===16777215)return t;const s=i=>Math.round((t>>i&255)*(e>>i&255)/255);return(s(16)<<16|s(8)<<8|s(0))>>>0}var jt={linear:t=>t,quadIn:t=>t*t,quadOut:t=>t*(2-t),quadInOut:t=>t<.5?2*t*t:-1+(4-2*t)*t,cubicOut:t=>1-(1-t)**3,sineInOut:t=>-(Math.cos(Math.PI*t)-1)/2,backOut:t=>1+(1.70158+1)*(t-1)**3+1.70158*(t-1)**2,elasticOut:t=>t===0||t===1?t:2**(-10*t)*Math.sin((t*10-.75)*(2*Math.PI/3))+1,bounceOut:t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375};function Ln(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let s=e;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}var Vt=1,Hs=2,ge=0,it=1,In=4294967295,A={cap:0,epoch:0,x:new Float64Array(0),y:new Float64Array(0),rot:new Float64Array(0),sx:new Float64Array(0),sy:new Float64Array(0),alpha:new Float64Array(0),la:new Float64Array(0),lb:new Float64Array(0),lc:new Float64Array(0),ld:new Float64Array(0),world:new Float64Array(0),tint:new Uint32Array(0),flags:new Uint8Array(0),moved:new Uint8Array(0),dirty:new Uint8Array(0),gen:new Uint32Array(0),parent:new Int32Array(0),first:new Int32Array(0),next:new Int32Array(0),prev:new Int32Array(0),stamp:new Uint32Array(0),pass:0,free:new Int32Array(0),freeHead:0,freeCount:0,top:2},gt=[],On="x y rot sx sy alpha la lb lc ld world tint flags moved dirty gen parent first next prev stamp".split(" ");function Ws(t){const e=A;for(const i of On){const n=e[i],r=new n.constructor(i==="world"?t*6:t);r.set(n),e[i]=r}const s=new Int32Array(t);for(let i=0;i<A.freeCount;i++)s[i]=A.free[(A.freeHead+i)%A.cap];for(A.free=s,A.freeHead=0,A.cap=t,A.epoch++;gt.length<t;)gt.push(null)}function Ye(t){A.x[t]=A.y[t]=A.rot[t]=0,A.sx[t]=A.sy[t]=A.alpha[t]=1,A.la[t]=A.ld[t]=1,A.lb[t]=A.lc[t]=0;const e=t*6,s=A.world;s[e]=s[e+3]=1,s[e+1]=s[e+2]=s[e+4]=s[e+5]=0,A.tint[t]=16777215,A.flags[t]=Vt|Hs,A.moved[t]=1,A.dirty[t]=0,A.parent[t]=A.first[t]=A.next[t]=A.prev[t]=-1}Ws(256),Ye(ge),A.flags[ge]=0,Ye(it),A.flags[it]=0;function Un(){let t;if(A.freeCount){t=A.free[A.freeHead],A.freeHead=(A.freeHead+1)%A.cap,A.freeCount--;const e=gt[t];e&&(e._i=ge,e._g=-1,gt[t]=null)}else A.top===A.cap&&Ws(A.cap*2),t=A.top++;return Ye(t),t}function Ys(t,e){je(t);for(let i=A.first[t];i>=0;){const n=A.next[i];A.parent[i]=A.next[i]=A.prev[i]=-1,i=n}A.first[t]=-1,A.flags[t]=A.flags[t]&~Hs,A.moved[t]=0;const s=A.gen[t]+1;A.gen[t]=s,s!==In&&(e&&(gt[t]=e),A.free[(A.freeHead+A.freeCount)%A.cap]=t,A.freeCount++)}function Dn(t){for(let e=0;e<gt.length;e++){const s=gt[e];s&&t(s)&&(s._i=ge,s._g=-1,gt[e]=null)}}function Bn(t,e){je(t);const s=A.first[e];A.parent[t]=e,A.next[t]=s,A.prev[t]=-1,s>=0&&(A.prev[s]=t),A.first[e]=t,A.moved[t]=1}function je(t){const e=A.parent[t];if(e<0)return;const s=A.next[t],i=A.prev[t];i>=0?A.next[i]=s:A.first[e]=s,s>=0&&(A.prev[s]=i),A.parent[t]=A.next[t]=A.prev[t]=-1}var Qt={root:-1,gen:-1,world:new Float64Array(6)};function zn(t){const e=++A.pass,s=A.world,i=t*6,n=Qt.world;let r=Qt.root!==t||Qt.gen!==A.gen[t];for(let a=0;a<6;a++)n[a]!==s[i+a]&&(r=!0),n[a]=s[i+a];Qt.root=t,Qt.gen=A.gen[t],A.stamp[t]=r?e:e-1}function Gn(t){A.stamp[t]=A.pass}function js(t){for(let e=A.first[t];e>=0;){const s=A.next[e];js(e),e=s}Ys(t)}var Ve=typeof FinalizationRegistry=="function"?new FinalizationRegistry(t=>A.gen[t.i]===t.g&&js(t.i)):null;function Vs(t){t._reg||!Ve||(t._reg=!0,Ve.register(t,{i:t._i,g:t._g},t))}function Xn(t){t._reg&&Ve.unregister(t)}var Qe=1,Ke=2,Ze=3,Je=4;function ts(t){if(t){for(let e=0;e<t.length;e++)if(t[e].enabled)return!0}return!1}function $n(t,e){let s=0;for(let i=0;i<t.length;i++){const n=t[i];n.enabled&&n.pad&&(s+=n.pad(e))}return s}var ht={gl:null,c2d:null,live:null},U=new Float64Array(3),es=4,qn=1,ss=()=>qn++,q=Nt(),S=A,Et=class{constructor(t){c(this,"kernel",t),c(this,"_i",Un()),c(this,"_g",S.gen[this._i]),c(this,"_wv",null),c(this,"_wi",-1),c(this,"_we",-1),c(this,"blend","normal"),c(this,"_data",null),c(this,"parent",null),c(this,"hitRadius",null),c(this,"clip",null),c(this,"mask",null),c(this,"filters",null),c(this,"_z",0),c(this,"anchorX",0),c(this,"anchorY",0),c(this,"_pool",null),c(this,"_free",!1),c(this,"_reg",!1)}get x(){return S.x[this._i]}set x(t){const e=this._i||it;S.x[e]=t,S.moved[e]=1}get y(){return S.y[this._i]}set y(t){const e=this._i||it;S.y[e]=t,S.moved[e]=1}get rotation(){return S.rot[this._i]}set rotation(t){const e=this._i||it;S.rot[e]=t,S.dirty[e]=S.moved[e]=1}get scaleX(){return S.sx[this._i]}set scaleX(t){const e=this._i||it;S.sx[e]=t,S.dirty[e]=S.moved[e]=1}get scaleY(){return S.sy[this._i]}set scaleY(t){const e=this._i||it;S.sy[e]=t,S.dirty[e]=S.moved[e]=1}get alpha(){return S.alpha[this._i]}set alpha(t){const e=this._i||it;S.alpha[e]=t,S.moved[e]=1}get visible(){return(S.flags[this._i]&Vt)!==0}set visible(t){const e=this._i||it;t?S.flags[e]=S.flags[e]|Vt:S.flags[e]=S.flags[e]&~Vt,S.moved[e]=1}get destroyed(){return S.gen[this._i]!==this._g}get world(){const t=this._i||it;return(this._wi!==t||this._we!==S.epoch)&&(this._wv=S.world.subarray(t*6,t*6+6),this._wi=t,this._we=S.epoch),this._wv}get data(){return this._data??(this._data={})}set data(t){this._data=t}get scale(){return this.scaleX}set scale(t){this.scaleX=this.scaleY=t}get z(){return this._z}set z(t){t!==this._z&&(this._z=t,this.parent&&(this.parent.sortDirty=!0))}get tint(){return S.tint[this._i]}set tint(t){S.tint[this._i||it]=typeof t=="number"?t&16777215:ot(t)[0]}set anchor(t){typeof t=="number"?this.anchorX=this.anchorY=t:(this.anchorX=t.x,this.anchorY=t.y)}get width(){return 0}set width(t){}get height(){return 0}set height(t){}set(t){for(const e in t){const s=t[e];s!==void 0&&(this[e]=s)}return this}destroy(){this.destroyed||(this.visible=!1,this.parent&&(this.parent.dead=!0,this.parent=null),Ys(this._i,this),Xn(this),this.kernel.tweens.stopAll(this),this._pool?.forget(this))}updateWorld(){const t=this.parent?this.parent.updateWorld():null;return ct(this.world,t,this.x,this.y,this.rotation,this.scaleX,this.scaleY)}draw(t,e,s){}};function Hn(t){Dn(e=>e.kernel===t)}var is=!1,Qs=Object.freeze([]),ns=class dn extends Et{constructor(e){super(e),c(this,"children",Qs),c(this,"sortDirty",!1),c(this,"dead",!1),Vs(this)}add(e,...s){this.adopt(e);for(let i=0;i<s.length;i++)this.adopt(s[i]);return e}adopt(e){e.parent&&e.parent.detach(e),e.parent=this,!e.destroyed&&!this.destroyed&&Bn(e._i,this._i),this.children===Qs&&(this.children=[]),this.children.push(e),(e.z!==0||this.sortDirty)&&(this.sortDirty=!0)}remove(e){this.detach(e),e._pool||Vs(e)}detach(e){const s=this.children,i=s.indexOf(e);if(i>=0){for(let n=i+1;n<s.length;n++)s[n-1]=s[n];s.pop()}e.parent===this&&(e.parent=null,e.destroyed||je(e._i))}clear(){for(const e of this.children)e.destroy()}destroy(){for(const e of this.children)e.destroy();super.destroy()}sweep(){if(this.dead){this.dead=!1;let e=0;for(const s of this.children)s.destroyed?s.parent===this&&(s.parent=null):this.children[e++]=s;this.children.length=e}for(const e of this.children)e instanceof dn&&e.sweep()}draw(e,s,i){if(is)return S.parent[this._i]<0&&!this.destroyed&&Gn(this._i),this.drawChildren(e,s,i);is=!0;try{this.destroyed||zn(this._i),this.drawChildren(e,s,i)}finally{is=!1}}drawChildren(e,s,i){if(this.sortDirty){const h=new Map(this.children.map((l,o)=>[l,o]));this.children.sort((l,o)=>l.z-o.z||h.get(l)-h.get(o)),this.sortDirty=!1}const n=this.children,r=this._i,a=S.stamp[r]===S.pass;for(let h=0;h<n.length;h++){const l=n[h],o=l._i,u=S.alpha[o];if(S.gen[o]!==l._g||!(S.flags[o]&Vt)||u<=0)continue;if(a||S.moved[o]){S.moved[o]=0,S.stamp[o]=S.pass;let g,d,y,m;if(S.dirty[o]){S.dirty[o]=0;const D=S.rot[o],W=D?Math.cos(D):1,X=D?Math.sin(D):0,z=S.sx[o],$t=S.sy[o];S.la[o]=g=W*z,S.lb[o]=d=X*z,S.lc[o]=y=-X*$t,S.ld[o]=m=W*$t}else g=S.la[o],d=S.lb[o],y=S.lc[o],m=S.ld[o];const w=S.world,x=S.x[o],_=S.y[o],M=o*6,k=r*6,F=w[k],R=w[k+1],N=w[k+2],I=w[k+3];w[M]=F*g+N*d,w[M+1]=R*g+I*d,w[M+2]=F*y+N*m,w[M+3]=R*y+I*m,w[M+4]=F*x+N*_+w[k+4],w[M+5]=R*x+I*_+w[k+5]}const f=s*u,p=qs(i,S.tint[o]);l.clip||l.mask||l.filters?Zs(e,l,f,p):l.draw(e,f,p)}}},V=new Float64Array(128),Tt=0,rs=new Float64Array(8);function Ks(t,e,s,i){e.clip||e.mask||e.filters?Zs(t,e,s,i):e.draw(t,s,i)}function Zs(t,e,s,i){const n=t.r,r=e.world,a=e.clip;let h=!1,l=!1;if(a)if(Math.abs(r[1])<1e-9&&Math.abs(r[2])<1e-9&&Tt<32){const f=r[0]*a.x+r[4],p=r[0]*(a.x+a.width)+r[4],g=r[3]*a.y+r[5],d=r[3]*(a.y+a.height)+r[5];let y=Math.min(f,p),m=Math.max(f,p),w=Math.min(g,d),x=Math.max(g,d);if(Tt){const M=(Tt-1)*4;y=Math.max(y,V[M]),w=Math.max(w,V[M+1]),m=Math.min(m,V[M+2]),x=Math.min(x,V[M+3])}const _=Tt++*4;V[_]=y,V[_+1]=w,V[_+2]=m,V[_+3]=x,n.clip(y,w,Math.max(m-y,0),Math.max(x-w,0)),l=!0}else h=!0;const o=e.mask&&e.mask.visible?e.mask:null,u=ts(e.filters)?e.filters:null;try{if(h&&n.beginLayer(),o&&n.beginLayer(),u?(e.draw(t,n.beginLayer()?1:s,i),n.endLayer(s,u)):e.draw(t,s,i),o&&(n.beginMask(),ct(o.world,r,o.x,o.y,o.rotation,o.scaleX,o.scaleY),Ks(t,o,o.alpha,16777215),n.endLayer(1)),h&&a){n.beginMask();for(let f=0;f<4;f++){const p=f===1||f===2?a.x+a.width:a.x,g=f>1?a.y+a.height:a.y;rs[f*2]=r[0]*p+r[2]*g+r[4],rs[f*2+1]=r[1]*p+r[3]*g+r[5]}n.polygon(rs,4,16777215,1),n.endLayer(1)}}finally{if(l)if(Tt--,Tt){const f=(Tt-1)*4;n.clip(V[f],V[f+1],V[f+2]-V[f],V[f+3]-V[f+1])}else n.unclip()}}var It=class extends Et{constructor(t,e,s){super(t),c(this,"_frame",null),c(this,"_w",null),c(this,"_h",null),c(this,"slice",0),c(this,"autoAnchor",!0),c(this,"frameName",null),e&&(this.frame=e),s?.anchor===void 0&&this.useFrameAnchor(),s&&this.set(s)}get frame(){return this._frame}set frame(t){this.frameName=typeof t=="string"?t:null,this._frame=typeof t=="string"?this.kernel.frame(t):t,this.autoAnchor&&this.useFrameAnchor()}set anchor(t){this.autoAnchor=!1,super.anchor=t}get naturalWidth(){const t=this.frameNow();return t?(t.sw??t.w)/t.scale-t.margin*2:0}get naturalHeight(){const t=this.frameNow();return t?(t.sh??t.h)/t.scale-t.margin*2:0}get width(){return this._w??this.naturalWidth}set width(t){this._w=t}get height(){return this._h??this.naturalHeight}set height(t){this._h=t}sizeQ(t){Dt[0]=this._w??(t.sw??t.w)/t.scale-t.margin*2,Dt[1]=this._h??(t.sh??t.h)/t.scale-t.margin*2}frameNow(){return this.frameName&&!this.kernel.atlas.valid(this._frame)&&(this._frame=this.kernel.frame(this.frameName)),this._frame}useFrameAnchor(){const t=this._frame;if(!t)return;const e=(t.sw??t.w)/t.scale-t.margin*2,s=(t.sh??t.h)/t.scale-t.margin*2;this.anchorX=e>0?(t.ox-t.margin)/e:0,this.anchorY=s>0?(t.oy-t.margin)/s:0}draw(t,e,s){const i=this.frameNow();if(!i)return;const n=Dt;this.sizeQ(i),n[2]=this.anchorX,n[3]=this.anchorY,n[4]=e,Wn(t,i,this.world,this.slice,s,this.blend)}},Ot=new Float64Array(12),Ut=new Float64Array(12),Kt={x:0,y:0,w:0,h:0};function Js(t,e,s,i,n,r){e=Math.max(e,0),s=Math.max(s,0),i=Math.max(i,0);const a=s+i>n?s*n/(s+i):s,h=s+i>n?i*n/(s+i):i;let l=a/r,o=h/r;if(l+o>e){const u=e/(l+o);l*=u,o*=u}t[0]=0,t[1]=l,t[2]=0,t[3]=a,t[4]=l,t[5]=e-l-o,t[6]=a,t[7]=n-a-h,t[8]=e-o,t[9]=o,t[10]=n-h,t[11]=h}var Dt=new Float64Array(5);function Wn(t,e,s,i,n,r){const a=Dt,h=a[0],l=a[1],o=a[2],u=a[3],f=a[4],p=t.tex(e.surface),g=i===0?e.slice??0:i;if(g===0){const M=(e.sw??e.w)/e.scale-e.margin*2,k=(e.sh??e.h)/e.scale-e.margin*2,F=M>0?h/M:1,R=k>0?l/k:1,N=-o*h+((e.tx??0)/e.scale-e.margin)*F,I=-u*l+((e.ty??0)/e.scale-e.margin)*R;me(s,N,I),U[0]=e.w/e.scale*F,U[1]=e.h/e.scale*R,U[2]=f,t.r.quadQ(p,e,q,n,r);return}const d=e.tx??0,y=e.ty??0,m=(e.sw??e.w)-e.w-d,w=(e.sh??e.h)-e.h-y,x=-o*h-e.margin+d/e.scale,_=-u*l-e.margin+y/e.scale;if(Js(Ot,h+e.margin*2-(d+m)/e.scale,(typeof g=="number"?g:g[3])-d,(typeof g=="number"?g:g[1])-m,e.w,e.scale),Js(Ut,l+e.margin*2-(y+w)/e.scale,(typeof g=="number"?g:g[0])-y,(typeof g=="number"?g:g[2])-w,e.h,e.scale),me(s,x,_),U[2]=f,!t.r.nineQ?.(p,e,Ot,Ut,q,n,r))for(let M=0;M<12;M+=4){const k=Ut[M+1],F=Ut[M+3];if(!(k<=0||F<=0))for(let R=0;R<12;R+=4){const N=Ot[R+1],I=Ot[R+3];N<=0||I<=0||(Kt.x=e.x+Ot[R+2],Kt.y=e.y+Ut[M+2],Kt.w=I,Kt.h=F,me(s,x+Ot[R],_+Ut[M]),U[0]=N,U[1]=k,U[2]=f,t.r.quadQ(p,Kt,q,n,r))}}}function me(t,e,s){q[0]=t[0],q[1]=t[1],q[2]=t[2],q[3]=t[3],q[4]=t[0]*e+t[2]*s+t[4],q[5]=t[1]*e+t[3]*s+t[5]}var Zt=class extends It{constructor(t,e,s={}){super(t,null),c(this,"_spec"),c(this,"baked",null),c(this,"bakedEffects",!0),this._spec=e,this.bake(),s.anchor===void 0&&this.useFrameAnchor(),this.set(s)}get spec(){return this._spec}set spec(t){this._spec=t,this.baked=null,this._w=this._h=null,this.bake()}bake(){const t=this.kernel;return this.baked&&t.atlas.valid(this.baked.frame)&&this.baked.frame.scale===t.pixelScale&&this.bakedEffects===t.effects?this.baked:(this.bakedEffects=t.effects,this.baked=t.shape(this._spec),this._frame=this.baked.frame,this.slice=this.baked.slice,this.baked)}frameNow(){return this.bake().frame}sizeQ(){const t=this.bake();Dt[0]=this._w??t.w,Dt[1]=this._h??t.h}get width(){return this._w??this.bake().w}set width(t){this._w=t}get height(){return this._h??this.bake().h}set height(t){this._h=t}},ti=(t,e,s)=>t===void 0?e:typeof t=="number"?t:t[0]+(t[1]-t[0])*s(),ei=class le extends Et{constructor(e,s,i={}){super(e),c(this,"max"),c(this,"f"),c(this,"tints"),c(this,"count",0),c(this,"gravity"),c(this,"drag"),c(this,"frameRef"),c(this,"random",Math.random),this.frameRef=s,this.max=Math.max(1,Math.floor(i.max??200)),this.f=new Float32Array(this.max*le.W),this.tints=new Uint32Array(this.max),this.blend=i.blend??"normal",this.gravity=i.gravity??0,this.drag=i.drag??1}get alive(){return this.count}burst(e,s,i,n={}){const r=le.W,a=this.random,h=n.tint===void 0?16777215:ot(n.tint)[0];for(let l=0;l<i;l++){let o=this.count;if(o>=this.max){let y=0,m=1/0;for(let w=0;w<this.max;w++){const x=this.f[w*r+5]-this.f[w*r+4];x<m&&(m=x,y=w)}o=y}else this.count++;const u=(n.angle??0)+(n.spread===void 0?a()*Math.PI*2:(a()-.5)*n.spread),f=ti(n.speed,200,a),p=Array.isArray(n.scale)?n.scale[0]:n.scale??1,g=Array.isArray(n.scale)?n.scale[1]:n.scale??1,d=o*r;this.f[d]=e,this.f[d+1]=s,this.f[d+2]=Math.cos(u)*f,this.f[d+3]=Math.sin(u)*f,this.f[d+4]=0,this.f[d+5]=Math.max(ti(n.life,.8,a),.01),this.f[d+6]=a()*Math.PI*2,this.f[d+7]=(a()-.5)*2*(n.spin??0),this.f[d+8]=p,this.f[d+9]=g,this.f[d+10]=n.alpha??1,this.tints[o]=h}}update(e){const s=le.W,i=this.f,n=this.drag>=1?1:Math.pow(Math.max(this.drag,0),e);for(let r=0;r<this.count;){const a=r*s;if(i[a+4]=i[a+4]+e,i[a+4]>=i[a+5]){const h=--this.count;r!==h&&(i.copyWithin(a,h*s,h*s+s),this.tints[r]=this.tints[h]);continue}i[a+3]=(i[a+3]+this.gravity*e)*n,i[a+2]=i[a+2]*n,i[a]=i[a]+i[a+2]*e,i[a+1]=i[a+1]+i[a+3]*e,i[a+6]=i[a+6]+i[a+7]*e,r++}}clear(){this.count=0}draw(e,s,i){if(!this.count)return;const n=typeof this.frameRef=="string"?this.frameRef=this.kernel.frame(this.frameRef):this.frameRef,r=le.W,a=this.f,h=this.world,l=n.w/n.scale,o=n.h/n.scale;for(let u=0;u<this.count;u++){const f=u*r,p=a[f+4]/a[f+5],g=a[f+8]+(a[f+9]-a[f+8])*p,d=s*a[f+10]*(1-p*p),y=a[f+6],m=Math.cos(y)*g,w=Math.sin(y)*g,x=a[f],_=a[f+1],M=h[0],k=h[1],F=h[2],R=h[3],N=M*m+F*w,I=k*m+R*w,D=F*m-M*w,W=R*m-k*w;q[0]=N,q[1]=I,q[2]=D,q[3]=W,q[4]=M*x+F*_+h[4]-(N*l+D*o)/2,q[5]=k*x+R*_+h[5]-(I*l+W*o)/2,U[0]=l,U[1]=o,U[2]=d,e.r.quadQ(e.tex(n.surface),n,q,qs(i,this.tints[u]),this.blend)}}};c(ei,"W",11);var si=ei,St=class extends It{constructor(t,e,s={}){const{fps:i,loop:n,playing:r,speed:a,onComplete:h,...l}=s;if(!e.frames.length)throw new Error("[engine] an animation needs at least one frame");super(t,e.frames[0],l),c(this,"frames"),c(this,"durations"),c(this,"fps"),c(this,"loop"),c(this,"speed"),c(this,"onComplete"),c(this,"_playing"),c(this,"index",0),c(this,"t",0),this.frames=e.frames,this.durations=e.durations&&i===void 0?e.durations:null,this.fps=i??12,this.loop=n!==!1,this.speed=a??1,this.onComplete=h??null,this._playing=r!==!1,this.speed<0&&this.show(e.frames.length-1)}get frameIndex(){return this.index}get frameCount(){return this.frames.length}get playing(){return this._playing}play(){return!this.loop&&!this._playing&&this.index===(this.speed<0?0:this.frames.length-1)&&this.show(this.speed<0?this.frames.length-1:0),this._playing=!0,this}stop(){return this._playing=!1,this}gotoFrame(t){const e=this.frames.length;return this.show((Math.floor(t)%e+e)%e),this.t=0,this}gotoAndPlay(t){return this._playing=!0,this.gotoFrame(t)}gotoAndStop(t){return this._playing=!1,this.gotoFrame(t)}show(t){t===this.index&&this._frame||(this.index=t,this.frame=this.frames[t])}secondsOf(t){const e=this.durations?.[t];return e!==void 0&&e>0?e:1/Math.max(this.fps,.001)}update(t){if(!this._playing||this.destroyed||this.speed===0)return;const e=this.frames.length,s=this.speed<0;this.t+=t*Math.abs(this.speed);let i=this.index;for(let n=0;n<1e3;n++){const r=this.secondsOf(i);if(this.t<r)break;this.t-=r;const a=s?i-1:i+1;if(a<0||a>=e){if(!this.loop){this.t=0,this._playing=!1,this.show(i),this.onComplete?.();return}i=s?e-1:0}else i=a}this.show(i)}},Yn=(t,e)=>t.localeCompare(e,void 0,{numeric:!0}),ii=class{constructor(t,e,s=2){c(this,"width",t),c(this,"height",e),c(this,"padding",s),c(this,"shelves",[]),c(this,"free",[]),c(this,"bottom",0)}alloc(t,e){const s=Math.ceil(t)+this.padding*2,i=Math.ceil(e)+this.padding*2;if(s>this.width||i>this.height)return null;for(let a=0;a<this.free.length;a++){const h=this.free[a];if(h.w>=s&&h.h>=i&&h.w*h.h<=s*i*2)return this.free.splice(a,1),this.inner(h.x,h.y,t,e)}let n=null;for(const a of this.shelves)a.h>=i&&a.h<=i*1.5+8&&this.width-a.x>=s&&(!n||a.h<n.h)&&(n=a);if(!n)if(this.bottom+i>this.height){for(const a of this.shelves)a.h>=i&&this.width-a.x>=s&&(n=a);if(!n)return null}else n={y:this.bottom,h:i,x:0},this.shelves.push(n),this.bottom+=i;const r=n.x;return n.x+=s,this.inner(r,n.y,t,e)}release(t){this.free.push({x:t.x-this.padding,y:t.y-this.padding,w:Math.ceil(t.w)+this.padding*2,h:Math.ceil(t.h)+this.padding*2})}get fill(){return this.bottom/this.height}reset(){this.shelves=[],this.free=[],this.bottom=0}inner(t,e,s,i){return{x:t+this.padding,y:e+this.padding,w:s,h:i}}},ye=t=>({source:t,texture:null,pending:[]}),as=class{constructor(t=2048,e=4){c(this,"pageSize",t),c(this,"maxPages",e),c(this,"pages",[]),c(this,"gen",1),c(this,"onPage",()=>{}),c(this,"onDrop",()=>{})}valid(t){return!!t&&(t.gen===this.gen||t.gen===0)}bake(t,e,s,i=1,n=0,r=0,a=0){const h=Math.max(1,Math.ceil(t)),l=Math.max(1,Math.ceil(e)),o=document.createElement("canvas");o.width=h,o.height=l;const u=o.getContext("2d");return s(u),this.put(o,h,l,i,n,r,a)}add(t,e=1,s=0,i=0){const n=document.createElement("canvas");return n.width=Math.max(1,t.width),n.height=Math.max(1,t.height),n.getContext("2d").drawImage(t,0,0),this.put(n,n.width,n.height,e,s,i,0)}release(t){if(t.gen!==this.gen)return;this.pages.find(s=>s.surface===t.surface)?.packer.release(t)}rebake(t,e,s,i,n=t.w,r=t.h){if(!this.valid(t)||e>n||s>r)return null;const a=Math.max(1,Math.ceil(e)),h=Math.max(1,Math.ceil(s)),l=this.pages.find(u=>u.surface===t.surface);if(!l)return null;const o=document.createElement("canvas");return o.width=Math.ceil(n),o.height=Math.ceil(r),i(o.getContext("2d")),l.ctx.clearRect(t.x,t.y,o.width,o.height),l.ctx.drawImage(o,t.x,t.y),t.surface.pending.push([o,t.x,t.y]),t.w=a,t.h=h,t}put(t,e,s,i,n,r,a){let h=null,l=this.pages.find(u=>(h=u.packer.alloc(e,s))!==null);if(l||(!(Math.max(e,s)+4>this.pageSize)&&this.pages.length>=this.maxPages&&(this.wipe(),l=this.pages[0],h=l?l.packer.alloc(e,s):null),(!l||!h)&&(l=this.newPage(Math.max(e,s)),h=l.packer.alloc(e,s))),!h)throw new Error(`[engine] ${e}\xD7${s} does not fit an atlas page`);const o=h;return l.ctx.drawImage(t,o.x,o.y),l.surface.pending.push([t,o.x,o.y]),{surface:l.surface,x:o.x,y:o.y,w:e,h:s,scale:i,gen:this.gen,ox:n,oy:r,margin:a}}newPage(t){let e=this.pageSize;for(;e<t+4;)e*=2;const s=document.createElement("canvas");s.width=s.height=e;const i=s.getContext("2d"),n=ye(s),r={surface:n,packer:new ii(e,e),ctx:i};return this.pages.push(r),this.onPage(n),r}wipe(){this.gen++;let t=0;for(let e=0;e<this.pages.length;e++){const s=this.pages[e];if(t<this.maxPages&&s.surface.source.width===this.pageSize){this.pages[t++]=s;continue}s.surface.pending=[],this.onDrop(s.surface)}this.pages.length=t;for(const e of this.pages)e.packer.reset(),e.ctx.clearRect(0,0,e.surface.source.width,e.surface.source.height),e.surface.pending=[],e.surface.pending.push([e.surface.source,0,0])}},jn=()=>globalThis.FabiPlay,ni=class{posed(t,e,s,i=!0){const n={id:t,body:e};return jn()?.smoothedBody(n,{smooth:s<1?s:!1,interpolate:i})??e}},ri=new Float64Array(1),ai=new Int32Array(ri.buffer),Bt=(t,e)=>(t=Math.imul(t^e,1540483477),t^t>>>15);function mt(t,e=2538058380){return t!==t?Bt(e,2146959360):(ri[0]=t===0?0:t,Bt(Bt(e,ai[0]),ai[1]))}function oi(t,e=2166136261){for(let s=0;s<t.length;s++)e=Math.imul(e^t.charCodeAt(s),16777619);return e}function yt(t){switch(typeof t){case"number":return mt(t);case"string":return oi(t);case"boolean":return t?1013904242:461845907;case"object":{if(t===null)return 625341585;if(Array.isArray(t)||t instanceof Float64Array){let i=1779033703^t.length;for(let n=0;n<t.length;n++){const r=t[n];i=Bt(i,typeof r=="number"?mt(r):yt(r))}return i}let e=1359893119;const s=t;for(const i in s){const n=s[i];n!==void 0&&(e=e+Bt(oi(i),yt(n))|0)}return Bt(e,2600822924)}default:return 0}}function Jt(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null)return typeof t=="number"&&typeof e=="number"&&t!==t&&e!==e;const s=Array.isArray(t)||t instanceof Float64Array;if(s!==(Array.isArray(e)||e instanceof Float64Array))return!1;if(s){const r=t,a=e;if(r.length!==a.length)return!1;for(let h=0;h<r.length;h++)if(r[h]!==a[h]&&!Jt(r[h],a[h]))return!1;return!0}const i=t,n=e;for(const r in i)if(i[r]!==void 0&&!Jt(i[r],n[r]))return!1;for(const r in n)if(n[r]!==void 0&&i[r]===void 0)return!1;return!0}function ve(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return t.map(ve);if(t instanceof Float64Array)return t.slice();const e={};for(const s in t)t[s]!==void 0&&(e[s]=ve(t[s]));return e}var hi=class{constructor(t=1/0){c(this,"max",t),c(this,"buckets",new Map),c(this,"n",0)}get size(){return this.n}get(t,e=yt(t)){const s=this.buckets.get(e);if(s){for(let i=0;i<s.length;i++)if(Jt(s[i].key,t))return s[i].value}}set(t,e,s=yt(t)){let i=this.buckets.get(s);if(i){for(const n of i)if(Jt(n.key,t)){n.value=e;return}}this.n>=this.max&&this.clear(),(!i||!this.buckets.has(s))&&this.buckets.set(s,i=[]),i.push({key:ve(t),value:e}),this.n++}clear(){this.buckets.clear(),this.n=0}},os=0,li=1,we=2,hs=3,ci=class{constructor(){c(this,"scale",1),c(this,"cOn",!1),c(this,"px0",0),c(this,"py0",0),c(this,"px1",0),c(this,"py1",0),c(this,"clipVer",0),c(this,"stack",[]),c(this,"sp",0),c(this,"real",0),c(this,"mute",0),c(this,"bnd",new Float64Array(4*(es+1))),c(this,"rx0",0),c(this,"ry0",0),c(this,"rx1",0),c(this,"ry1",0),c(this,"maxBlur",1/0),c(this,"time",0),c(this,"skipped",0),c(this,"gq",new Float64Array(4))}resetLayers(t){this.scale=t,this.sp=this.real=this.mute=0,this.skipped=0,this.cOn=!1,this.clipVer++}growQ(){const t=this.gq;this.grow(t[0],t[1],t[2],t[3])}grow(t,e,s,i){if(!this.real)return;const n=this.bnd,r=(this.real-1)*4;t<n[r]&&(n[r]=t),e<n[r+1]&&(n[r+1]=e),s>n[r+2]&&(n[r+2]=s),i>n[r+3]&&(n[r+3]=i)}area(t,e){const s=this.bnd,i=t*4,n=this.scale;return this.rx0=Math.max(Math.floor((s[i]-e)*n)-1,0),this.ry0=Math.max(Math.floor((s[i+1]-e)*n)-1,0),this.rx1=Math.min(Math.ceil((s[i+2]+e)*n)+1,this.canvas.width),this.ry1=Math.min(Math.ceil((s[i+3]+e)*n)+1,this.canvas.height),this.rx1>this.rx0&&this.ry1>this.ry0}clip(t,e,s,i){const n=this.scale,r=this.canvas.width,a=this.canvas.height,h=Math.min(Math.max(Math.round(t*n),0),r),l=Math.min(Math.max(Math.round(e*n),0),a),o=Math.min(Math.max(Math.round((t+s)*n),h),r),u=Math.min(Math.max(Math.round((e+i)*n),l),a);this.cOn&&h===this.px0&&l===this.py0&&o===this.px1&&u===this.py1||(this.cOn=!0,this.px0=h,this.py0=l,this.px1=o,this.py1=u,this.clipVer++)}unclip(){this.cOn&&(this.cOn=!1,this.clipVer++)}push(t){if(t<we&&(this.mute||this.real>=es||!this.pushLayer())&&(t+=2),t===hs)this.mute++;else if(t!==we){const e=this.real*4;this.bnd[e]=this.bnd[e+1]=1/0,this.bnd[e+2]=this.bnd[e+3]=-1/0,this.real++}return this.stack[this.sp++]=t,t<we}beginLayer(){return this.push(os)}beginMask(){this.push(this.sp&&this.stack[this.sp-1]===os?li:hs)}endLayer(t,e){if(!this.sp)return;let s=this.stack[--this.sp];if(s===hs){if(this.mute--,!this.sp)return;s=this.stack[--this.sp]}if(s===li){const i=--this.real,n=this.popLayer();this.area(i-1,0)&&this.composite(n,!0,1,null);const r=this.bnd,a=(i-1)*4,h=i*4;r[a]=Math.max(r[a],r[h]),r[a+1]=Math.max(r[a+1],r[h+1]),r[a+2]=Math.min(r[a+2],r[h+2]),r[a+3]=Math.min(r[a+3],r[h+3]),s=this.stack[--this.sp]}if(s===we)ts(e)&&(this.skipped+=e.length);else if(s===os){const i=--this.real,n=ts(e)?e:null,r=this.popLayer();if(this.area(i,n?$n(n,this.maxBlur):0)){this.composite(r,!1,t,n);const a=this.scale;this.grow(this.rx0/a,this.ry0/a,this.rx1/a,this.ry1/a)}}}closeLayers(){for(;this.sp;)this.endLayer(1)}},Vn=256,fi=8<<20,K=new Float64Array(32),Z={x:0,y:0,w:0,h:0};function Qn(t){if(typeof t.filter!="string")return!1;t.filter="blur(1px)";const e=t.filter==="blur(1px)";return t.filter="none",e}function ls(t){const e=t.getContext("2d",{alpha:!0});return e?new Kn(t,e):null}var Kn=class extends ci{constructor(t,e){super(),c(this,"canvas",t),c(this,"ctx",e),c(this,"kind","canvas2d"),c(this,"maxTextureSize",4096),c(this,"features",{}),c(this,"info",{renderer:"canvas2d"}),c(this,"support"),c(this,"lost",!1),c(this,"fxr",null),c(this,"quads",0),c(this,"stats",{drawCalls:0,quads:0,filtersSkipped:0}),c(this,"tinted",new Map),c(this,"tintedN",0),c(this,"lostListeners",[]),c(this,"restoredListeners",[]),c(this,"base"),c(this,"top"),c(this,"layers",[]),c(this,"scratch",[]),c(this,"nines",new Map),c(this,"ninePx",0),c(this,"frame",0),c(this,"hit",!1),c(this,"missed",new Map),this.support={filters:Qn(e),shaders:!1},this.base=this.top={ctx:e,clipped:!1,ver:0},t.addEventListener("contextlost",()=>{this.lost=!0,this.lostListeners.forEach(s=>s())}),t.addEventListener("contextrestored",()=>{this.lost=!1,this.tinted.clear(),this.tintedN=0,this.dropNines(),this.restoredListeners.forEach(s=>s())})}resize(t,e){this.canvas.width!==t&&(this.canvas.width=t),this.canvas.height!==e&&(this.canvas.height=e)}createTexture(t){return{id:ss(),width:t.width,height:t.height,source:t}}updateTexture(t,e,s=0,i=0){const n=e?s+e.width:1/0,r=e?i+e.height:1/0;for(const a of this.nines.values()){const h=a.key;h[0]===t.id&&h[1]<n&&h[1]+h[3]>s&&h[2]<r&&h[2]+h[4]>i&&this.dropNine(a)}for(const[a,h]of this.tinted){const l=h.filter(o=>o.id!==t.id);this.tintedN-=h.length-l.length,l.length?this.tinted.set(a,l):this.tinted.delete(a)}}destroyTexture(t){this.updateTexture(t)}begin(t,e,s){this.resetLayers(s),this.fxr?.tick(),this.frame++,this.quads=0,this.top=this.base,this.ctx=this.base.ctx;const i=this.ctx;this.base.clipped&&i.restore(),this.base.clipped=!1,this.base.ver=this.clipVer,i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.globalCompositeOperation="source-over",i.clearRect(0,0,this.canvas.width,this.canvas.height),e>0&&(i.fillStyle=Yt(t,e),i.fillRect(0,0,this.canvas.width,this.canvas.height))}quad(t,e,s,i,n,r,a,h){U[0]=i,U[1]=n,U[2]=a,this.quadQ(t,e,s,r,h)}quadQ(t,e,s,i,n){e.w<=0||e.h<=0||(i===16777215?this.blit(t.source,e.x,e.y,e.w,e.h,s,n):this.blit(this.tint(t,e,i),0,0,e.w,e.h,s,n))}blit(t,e,s,i,n,r,a){const h=U[0],l=U[1],o=U[2];if(o<=0||this.mute)return;this.sync();const u=this.ctx,f=this.scale;if(this.real){const p=r[0]*h,g=r[1]*h,d=r[2]*l,y=r[3]*l;this.grow(r[4]+Math.min(0,p,d,p+d),r[5]+Math.min(0,g,y,g+y),r[4]+Math.max(0,p,d,p+d),r[5]+Math.max(0,g,y,g+y))}u.setTransform(r[0]*f,r[1]*f,r[2]*f,r[3]*f,r[4]*f,r[5]*f),u.globalAlpha=Math.min(o,1),a==="add"&&(u.globalCompositeOperation="lighter"),u.drawImage(t,e,s,i,n,0,0,h,l),a==="add"&&(u.globalCompositeOperation="source-over"),this.quads++}nineQ(t,e,s,i,n,r,a){var h,l;const o=s[8]+s[9],u=i[8]+i[9],f=Math.ceil(o*Math.hypot(n[0],n[1])*this.scale-1e-6),p=Math.ceil(u*Math.hypot(n[2],n[3])*this.scale-1e-6);if(n[1]===0&&n[2]===0||f>4096||p>4096)return!1;if(!(f>0&&p>0&&U[2]>0)||this.mute)return!0;let g=this.kept(t,e,s,i,f,p,r);const d=(g??(g=(h=this.scratch)[l=13*Math.ceil(Math.log2(f))+Math.ceil(Math.log2(p))]??(h[l]=document.createElement("canvas").getContext("2d")))).canvas;if(d.width<f&&(d.width=f),d.height<p&&(d.height=p),!this.hit){g.clearRect(0,0,f+2,p+2);for(let y=0;y<12;y+=4){const m=Math.round(i[y]*p/u),w=Math.round((i[y]+i[y+1])*p/u);for(let x=0;x<12;x+=4){const _=Math.round(s[x]*f/o),M=Math.round((s[x]+s[x+1])*f/o);Z.x=e.x+s[x+2],Z.y=e.y+i[y+2],Z.w=s[x+3],Z.h=i[y+3],!(M<=_||w<=m||Z.w<=0||Z.h<=0)&&(r===16777215?g.drawImage(t.source,Z.x,Z.y,Z.w,Z.h,_,m,M-_,w-m):g.drawImage(this.tint(t,Z,r),0,0,Z.w,Z.h,_,m,M-_,w-m))}}}return U[0]=o,U[1]=u,this.blit(d,0,0,f,p,n,a),!0}kept(t,e,s,i,n,r,a){K[0]=t.id,K[1]=e.x,K[2]=e.y,K[3]=e.w,K[4]=e.h,K[5]=n,K[6]=r,K[7]=a,K.set(s,8),K.set(i,20);const h=yt(K),l=this.nines.get(h);if(this.hit=!1,l)return Jt(l.key,K)?(l.used=this.frame,this.hit=!0,l.ctx):null;const o=this.missed,u=o.get(h);o.size>4096&&o.clear(),o.set(h,this.frame);const f=n*r;if(u!==this.frame-1||f>fi)return null;let p;for(;this.ninePx+f>fi;){let y;for(const x of this.nines.values())x.used<this.frame-1&&!(y&&y.used<=x.used)&&(y=x);if(!y)return null;const m=y.ctx.canvas,w=!p&&m.width>=n&&m.height>=r&&m.width*m.height<=2*f;this.dropNine(y,w),w&&(p=y.ctx)}const g=p??document.createElement("canvas").getContext("2d"),d=g.canvas;return p||(d.width=n,d.height=r),this.ninePx+=d.width*d.height,this.nines.set(h,{key:ve(K),ctx:g,used:this.frame}),g}dropNine(t,e=!1){this.nines.delete(yt(t.key));const s=t.ctx.canvas;this.ninePx-=s.width*s.height,e||(s.width=0)}dropNines(){for(const t of this.nines.values())this.dropNine(t)}tint(t,e,s){const i=mt(s,mt(e.h,mt(e.w,mt(e.y,mt(e.x,mt(t.id))))));let n=this.tinted.get(i);if(n)for(let h=0;h<n.length;h++){const l=n[h];if(l.id===t.id&&l.x===e.x&&l.y===e.y&&l.w===e.w&&l.h===e.h&&l.color===s)return l.canvas}this.tintedN>=Vn&&(this.tinted.clear(),this.tintedN=0,n=void 0);const r=document.createElement("canvas");r.width=Math.ceil(e.w),r.height=Math.ceil(e.h);const a=r.getContext("2d");return a.drawImage(t.source,e.x,e.y,e.w,e.h,0,0,e.w,e.h),a.globalCompositeOperation="multiply",a.fillStyle=Yt(s),a.fillRect(0,0,e.w,e.h),a.globalCompositeOperation="destination-in",a.drawImage(t.source,e.x,e.y,e.w,e.h,0,0,e.w,e.h),n||this.tinted.set(i,n=[]),n.push({id:t.id,x:e.x,y:e.y,w:e.w,h:e.h,color:s,canvas:r}),this.tintedN++,r}paint(t,e){this.sync();const s=this.ctx,i=this.scale;return s.setTransform(i,0,0,i,0,0),s.globalAlpha=Math.min(e,1),Yt(t)}ellipse(t,e,s,i,n,r,a){if(a<=0||s<=0||i<=0||this.mute)return;const h=Math.max(s,i);this.grow(t-h,e-h,t+h,e+h);const l=this.ctx;l.fillStyle=this.paint(r,a),l.beginPath(),l.ellipse(t,e,s,i,n,0,Math.PI*2),l.fill(),this.quads++}trace(t,e,s=0){if(this.real)for(let n=0;n<e;n++)this.grow(t[n*2]-s,t[n*2+1]-s,t[n*2]+s,t[n*2+1]+s);const i=this.ctx;i.beginPath(),i.moveTo(t[0],t[1]);for(let n=1;n<e;n++)i.lineTo(t[n*2],t[n*2+1])}polygon(t,e,s,i){if(i<=0||e<3||this.mute)return;const n=this.ctx;n.fillStyle=this.paint(s,i),this.trace(t,e),n.closePath(),n.fill(),this.quads++}stroke(t,e,s,i,n,r){if(n<=0||s<=0||e<1||this.mute)return;const a=this.ctx;a.strokeStyle=this.paint(i,n),a.lineWidth=s,a.lineCap="round",a.lineJoin="round",this.trace(t,e,s/2),e===1&&a.lineTo(t[0],t[1]),r&&a.closePath(),a.stroke(),this.quads++}sync(){const t=this.top;if(t.ver===this.clipVer)return;const e=t.ctx;t.clipped&&e.restore(),t.clipped=this.cOn,t.ver=this.clipVer,this.cOn&&(e.save(),e.setTransform(1,0,0,1,0,0),e.beginPath(),e.rect(this.px0,this.py0,this.px1-this.px0,this.py1-this.py0),e.clip())}pushLayer(){const t=this.canvas.width,e=this.canvas.height;let s=this.layers[this.real];if(!s||s.ctx.canvas.width!==t||s.ctx.canvas.height!==e){const n=document.createElement("canvas");n.width=t,n.height=e;const r=n.getContext("2d");if(!r)return!1;s=this.layers[this.real]={ctx:r,clipped:!1,ver:-1}}const i=s.ctx;return s.clipped&&i.restore(),s.clipped=!1,s.ver=-1,i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.globalCompositeOperation="source-over",i.clearRect(0,0,t,e),this.top=s,this.ctx=i,!0}popLayer(){return this.top=this.real>0?this.layers[this.real-1]:this.base,this.ctx=this.top.ctx,this.layers[this.real].ctx.canvas}composite(t,e,s,i){let n=t,r="none";const a=i&&ht.c2d?this.fxr??(this.fxr=ht.c2d(this)):null;a&&(n=a.chain(t,i),r=a.css),this.sync();const h=this.ctx,l=this.rx0,o=this.ry0,u=this.rx1-l,f=this.ry1-o;h.setTransform(1,0,0,1,0,0),h.globalAlpha=Math.min(s,1),h.globalCompositeOperation=e?"destination-in":"source-over",r!=="none"&&(h.filter=r),h.drawImage(n,l,o,u,f,l,o,u,f),r!=="none"&&(h.filter="none"),h.globalCompositeOperation="source-over",this.quads++}end(){this.closeLayers();const t=this.stats;return t.drawCalls=t.quads=this.quads,t.filtersSkipped=this.skipped,t}onLost(t){this.lostListeners.push(t)}onRestored(t){this.restoredListeners.push(t)}destroy(){this.tinted.clear(),this.dropNines(),this.layers=[],this.scratch=[],this.fxr?.destroy(),this.fxr=null}},te=14,zt=6,ui=8192,Zn=class{constructor(t,e,s=ui){c(this,"instanced",t),c(this,"slots",e),c(this,"capacity",s),c(this,"f32"),c(this,"u32"),c(this,"quads",0),c(this,"textures"),c(this,"bound",0),this.textures=new Array(e).fill(null);const i=s*(t?te:zt*4),n=new ArrayBuffer(i*4);this.f32=new Float32Array(n),this.u32=new Uint32Array(n)}slot(t){const e=this.textures;for(let s=0;s<this.bound;s++)if(e[s]===t)return s;return this.bound>=this.slots?-1:(e[this.bound]=t,this.bound++)}has(t){for(let e=0;e<this.bound;e++)if(this.textures[e]===t)return!0;return!1}get full(){return this.quads>=this.capacity}get words(){return this.quads*(this.instanced?te:zt*4)}reset(){this.quads=0;for(let t=0;t<this.bound;t++)this.textures[t]=null;this.bound=0}push(t,e,s,i,n,r,a,h,l,o,u,f,p,g){const d=this.f32;if(this.instanced){let y=this.quads*te;d[y++]=t,d[y++]=e,d[y++]=s,d[y++]=i,d[y++]=n,d[y++]=r,d[y++]=a,d[y++]=h,d[y++]=l,d[y++]=o,d[y++]=u,d[y++]=f,this.u32[y++]=p,d[y]=g}else{const y=this.quads*zt*4;this.vertex(y,t,e,l,o,p,g),this.vertex(y+6,s,i,u,o,p,g),this.vertex(y+12,n,r,u,f,p,g),this.vertex(y+18,a,h,l,f,p,g)}this.quads++}pushQ(t,e){const s=this.f32;if(this.instanced){const i=this.quads*te;for(let n=0;n<12;n++)s[i+n]=t[n];this.u32[i+12]=t[12],s[i+13]=e}else{let i=this.quads*zt*4;const n=t[12];for(let r=0;r<4;r++,i+=zt)s[i]=t[r*2],s[i+1]=t[r*2+1],s[i+2]=r===1||r===2?t[10]:t[8],s[i+3]=r>=2?t[11]:t[9],this.u32[i+4]=n,s[i+5]=e}this.quads++}vertex(t,e,s,i,n,r,a){const h=this.f32;h[t]=e,h[t+1]=s,h[t+2]=i,h[t+3]=n,this.u32[t+4]=r,h[t+5]=a}};function Jn(t){const e=new Uint16Array(t*6);for(let s=0,i=0,n=0;s<t;s++,i+=6,n+=4)e[i]=n,e[i+1]=n+1,e[i+2]=n+2,e[i+3]=n,e[i+4]=n+2,e[i+5]=n+3;return e}var J={M:0,L:1,Q:2,C:3,Z:4},di=[2,2,4,6,0],tr={M:0,L:1,Q:2,C:3,Z:4};function cs(t,e){if(t.length>=e)return t;const s=new Float64Array(Math.max(e,t.length*2,16));return s.set(t),s}var xe=new Map;function er(t){if(typeof t!="string")return t;let e=xe.get(t);if(e)return e;e=[];const s=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[];let i=-1;for(let n=0;n<s.length;){const r=s[n],a=tr[r.toUpperCase()];if(a!==void 0){i=a,n++,a===J.Z&&e.push(J.Z);continue}if(i<0||i===J.Z){n++;continue}const h=di[i];e.push(i);for(let l=0;l<h;l++)e.push(Number(s[n+l]??0));n+=h,i===J.M&&(i=J.L)}return xe.size>256&&xe.clear(),xe.set(t,e),e}var vt={subs:[],count:0},fs=null,wt=null;function be(t,e){let s=wt;s||(s=vt.subs[vt.count]??null,s||vt.subs.push(s={pts:new Float64Array(64),n:0,closed:!1}),s.n=0,s.closed=!1,vt.count++,wt=s);const i=s.n*2;i+2>s.pts.length&&(s.pts=cs(s.pts,i+2));const n=fs;n?(s.pts[i]=n[0]*t+n[2]*e+n[4],s.pts[i+1]=n[1]*t+n[3]*e+n[5]):(s.pts[i]=t,s.pts[i+1]=e),s.n++}function us(t,e=null,s=1,i=6){const n=er(t);vt.count=0,wt=null,fs=e;let r=0,a=0,h=0,l=0;const o=s/i;for(let u=0;u<n.length;){const f=n[u++],p=n;if(f===J.M)wt=null,r=h=p[u],a=l=p[u+1],be(r,a);else if(f===J.L)r=p[u],a=p[u+1],be(r,a);else if(f===J.Q){const g=p[u],d=p[u+1],y=p[u+2],m=p[u+3],w=pi((ft(g-r,d-a)+ft(y-g,m-d))*o);for(let x=1;x<=w;x++){const _=x/w,M=1-_;be(M*M*r+2*M*_*g+_*_*y,M*M*a+2*M*_*d+_*_*m)}r=y,a=m}else if(f===J.C){const g=p[u],d=p[u+1],y=p[u+2],m=p[u+3],w=p[u+4],x=p[u+5],_=pi((ft(g-r,d-a)+ft(y-g,m-d)+ft(w-y,x-m))*o);for(let M=1;M<=_;M++){const k=M/_,F=1-k,R=F*F*F,N=3*F*F*k,I=3*F*k*k,D=k*k*k;be(R*r+N*g+I*y+D*w,R*a+N*d+I*m+D*x)}r=w,a=x}else if(f===J.Z){wt&&(wt.closed=!0),wt=null,r=h,a=l;continue}else break;u+=di[f]}wt=null,fs=null;for(let u=0;u<vt.count;u++){const f=vt.subs[u],p=f.n*2;f.closed&&f.n>=2&&Math.abs(f.pts[0]-f.pts[p-2])<1e-6&&Math.abs(f.pts[1]-f.pts[p-1])<1e-6&&f.n--}return vt}var ft=(t,e)=>Math.sqrt(t*t+e*e),pi=t=>Math.min(Math.max(Math.ceil(t),2),24);function sr(t,e){let s=0;for(let i=0,n=e-1;i<e;n=i++)s+=(t[n*2]-t[i*2])*(t[n*2+1]+t[i*2+1]);return s}var Me=new Int32Array(64),ke=(t,e,s,i,n)=>((t[i*2]-t[s*2])*(t[n*2+1]-t[s*2+1])-(t[i*2+1]-t[s*2+1])*(t[n*2]-t[s*2]))*e;function ir(t,e,s){if(e<3)return 0;Me.length<e&&(Me=new Int32Array(Math.max(e,Me.length*2)));const i=Me;let n=e,r=0;for(let o=0;o<e;o++)i[o]=o;const a=sr(t,e)>0?1:-1;let h=e*e+8,l=0;for(;n>3&&h-- >0;){const o=i[(l+n-1)%n],u=i[l%n],f=i[(l+1)%n];let p=ke(t,a,o,u,f)>0;if(p)for(let g=0;g<n;g++){const d=i[g];if(!(d===o||d===u||d===f)&&ke(t,a,o,u,d)>=0&&ke(t,a,u,f,d)>=0&&ke(t,a,f,o,d)>=0){p=!1;break}}p?(s[r++]=o,s[r++]=u,s[r++]=f,i.copyWithin(l%n,l%n+1,n),n--,l=Math.max(l-1,0)):l=(l+1)%n}if(n===3)s[r++]=i[0],s[r++]=i[1],s[r++]=i[2];else if(n>3)for(let o=1;o+1<n;o++)s[r++]=i[0],s[r++]=i[o],s[r++]=i[o+1];return r}var nr=.85,Ae=new Float64Array(64),gi=new Float64Array(64),mi=new Float64Array(64),yi=new Float64Array(64),vi=new Float64Array(64),wi=new Float64Array(64),xi=new Uint8Array(64),_e=new Float64Array(8);function rr(t,e,s,i,n,r){const a=_e;if(Ae.length<e){const m=Math.max(e,Ae.length*2);Ae=new Float64Array(m),gi=new Float64Array(m),mi=new Float64Array(m),yi=new Float64Array(m),vi=new Float64Array(m),wi=new Float64Array(m),xi=new Uint8Array(m)}const h=Ae,l=gi;let o=0;for(let m=0;m<e;m++){const w=t[m*2],x=t[m*2+1];!Number.isFinite(w)||!Number.isFinite(x)||o&&Math.abs(h[o-1]-w)<.001&&Math.abs(l[o-1]-x)<.001||(h[o]=w,l[o]=x,o++)}if(i&&o>2&&Math.abs(h[0]-h[o-1])<.001&&Math.abs(l[0]-l[o-1])<.001&&o--,o===0)return;if(o===1)return a[0]=h[0],a[1]=l[0],r();const u=i?o:o-1,f=mi,p=yi;for(let m=0;m<u;m++){const w=(m+1)%o,x=h[w]-h[m],_=l[w]-l[m],M=ft(x,_)||1;f[m]=-_/M,p[m]=x/M}const g=vi,d=wi,y=xi;for(let m=0;m<o;m++){const w=i?(m-1+u)%u:m-1,x=m<u?m:-1;if(y[m]=1,w<0||x<0||f[w]*f[x]+p[w]*p[x]<nr)continue;let M=f[w]+f[x],k=p[w]+p[x];const F=ft(M,k)||1;M/=F,k/=F;const R=s/Math.max(M*f[x]+k*p[x],.5);g[m]=M*R,d[m]=k*R,y[m]=0}for(let m=0;m<u;m++){const w=(m+1)%o,x=y[m]?f[m]*s:g[m],_=y[m]?p[m]*s:d[m],M=y[w]?f[m]*s:g[w],k=y[w]?p[m]*s:d[w];a[0]=h[m]+x,a[1]=l[m]+_,a[2]=h[w]+M,a[3]=l[w]+k,a[4]=h[w]-M,a[5]=l[w]-k,a[6]=h[m]-x,a[7]=l[m]-_,n()}for(let m=0;m<o;m++)y[m]&&(a[0]=h[m],a[1]=l[m],r())}function bi(t,e){let s=0,i=1/0;for(let n=0;n<e.length;n++){const r=Math.abs(Math.log(Math.max(t,.5)/e[n]));r<i&&(i=r,s=n)}return s}var et=256,ds=[{x:240,y:0,w:8,h:8,r:3},{x:224,y:0,w:16,h:16,r:7},{x:192,y:0,w:32,h:32,r:15},{x:128,y:0,w:64,h:64,r:31},{x:0,y:0,w:128,h:128,r:63}],ps=[4,8,16,32,64,128].map((t,e)=>({x:e*4,y:128,w:4,h:t,r:t/2-1})),xt={x:248,y:248,w:8,h:8},ar=ds.map(t=>t.r*2),or=ps.map(t=>t.r*2),Mi=(t,e)=>Math.min(Math.max(t+.5-e,0),1);function hr(){const t=new Uint8ClampedArray(et*et*4),e=(s,i,n)=>{const r=(i*et+s)*4;t[r]=t[r+1]=t[r+2]=255,t[r+3]=Math.round(n*255)};for(const s of ds){const i=s.w/2;for(let n=0;n<s.h;n++)for(let r=0;r<s.w;r++)e(s.x+r,s.y+n,Mi(s.r,Math.hypot(r+.5-i,n+.5-i)))}for(const s of ps){const i=s.h/2;for(let n=0;n<s.h;n++)for(let r=0;r<s.w;r++)e(s.x+r,s.y+n,Mi(s.r,Math.abs(n+.5-i)))}for(let s=0;s<xt.h;s++)for(let i=0;i<xt.w;i++)e(xt.x+i,xt.y+s,1);return t}function lr(){const t=document.createElement("canvas");return t.width=t.height=et,t.getContext("2d").putImageData(new ImageData(hr(),et,et),0,0),t}var ki=8,gs=`
|
|
2
2
|
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
3
3
|
precision highp float;
|
|
4
4
|
#else
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @fabi-play/engine 0.
|
|
1
|
+
/*! @fabi-play/engine 0.3.0 (full) | Fabi Play Kit License | https://docs.fabiplay.app */
|
|
2
2
|
(function (root, factory) {
|
|
3
3
|
var script = typeof document !== 'undefined' ? document.currentScript : null;
|
|
4
4
|
if (typeof define === 'function' && define.amd) define([], function () { return factory(script); });
|
|
@@ -2066,9 +2066,11 @@ function smoothBody(prev, next, amount = 0.5) {
|
|
|
2066
2066
|
const wasSeen = pv >= 0.5;
|
|
2067
2067
|
const isSeen = nv >= 0.5;
|
|
2068
2068
|
if (wasSeen && nv >= 0.3) out[i + 2] = Math.max(nv, 0.5);
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2069
|
+
const step = Math.hypot(next[i] - prev[i], next[i + 1] - prev[i + 1]);
|
|
2070
|
+
if (wasSeen && isSeen && step < 0.15) {
|
|
2071
|
+
const k = amount * Math.min(1, STILL_SHARE + (1 - STILL_SHARE) * step / STILL_FULL);
|
|
2072
|
+
out[i] = prev[i] + (next[i] - prev[i]) * k;
|
|
2073
|
+
out[i + 1] = prev[i + 1] + (next[i + 1] - prev[i + 1]) * k;
|
|
2072
2074
|
} else if (wasSeen && !isSeen && out[i + 2] >= 0.5) {
|
|
2073
2075
|
out[i] = prev[i];
|
|
2074
2076
|
out[i + 1] = prev[i + 1];
|
|
@@ -2077,6 +2079,8 @@ function smoothBody(prev, next, amount = 0.5) {
|
|
|
2077
2079
|
smoothFace(prev, next, out, amount * FACE_SMOOTHING);
|
|
2078
2080
|
return out;
|
|
2079
2081
|
}
|
|
2082
|
+
var STILL_SHARE = 0.1;
|
|
2083
|
+
var STILL_FULL = 0.03;
|
|
2080
2084
|
var FACE_SMOOTHING = 0.35;
|
|
2081
2085
|
var FACE_POINTS = 11;
|
|
2082
2086
|
function smoothFace(prev, next, out, amount) {
|