evotars 0.0.13 → 0.0.15
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/{CanvasPool-323z5Bgc.js → CanvasPool-DFeTH3RJ.js} +1 -1
- package/dist/{SharedSystems-CpNLwPlr.js → SharedSystems-zObTVAWO.js} +2 -2
- package/dist/{WebGLRenderer-8_UYFwzF.js → WebGLRenderer-DdYX4Qpw.js} +4 -4
- package/dist/{WebGPURenderer-D3yK12c3.js → WebGPURenderer-B713L7ek.js} +4 -4
- package/dist/{browserAll--tlJ0wmH.js → browserAll-CctCOtCx.js} +2 -2
- package/dist/{colorToUniform-ZnVvWd8z.js → colorToUniform-BdoeDvkl.js} +1 -1
- package/dist/evotars.js +1 -1
- package/dist/evotars.umd.cjs +1 -1
- package/dist/{getBatchSamplersUniformGroup-DIigPB-W.js → getBatchSamplersUniformGroup-Nw3bkDeI.js} +1 -1
- package/dist/{index-RgERw5ms.js → index-CNgGuUdP.js} +416 -421
- package/dist/index.d.ts +10 -14
- package/dist/{webworkerAll-DxpydbmF.js → webworkerAll-B33vuHnD.js} +4 -4
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as Re, M as g, o as Be, p as Ue, E as u, q as b, s as Ae, t as q, F as K, v as Ie, j as m, S as p, d as B, w as Y, x as Fe, b as H, B as k, h as U, u as C, i as _, R as w, y as Ee, a as De, C as S, z as Oe, G as ze, H as He, I as J, e as X, J as Le, P as We, c as Ve, D as Q, K as je, L as $e } from "./index-
|
|
2
|
-
import { b as Ne, S as Z, G as ee, f as te, U as re, T as L, h as W, B as qe, i as Ke, R as se } from "./colorToUniform-
|
|
1
|
+
import { l as Re, M as g, o as Be, p as Ue, E as u, q as b, s as Ae, t as q, F as K, v as Ie, j as m, S as p, d as B, w as Y, x as Fe, b as H, B as k, h as U, u as C, i as _, R as w, y as Ee, a as De, C as S, z as Oe, G as ze, H as He, I as J, e as X, J as Le, P as We, c as Ve, D as Q, K as je, L as $e } from "./index-CNgGuUdP.js";
|
|
2
|
+
import { b as Ne, S as Z, G as ee, f as te, U as re, T as L, h as W, B as qe, i as Ke, R as se } from "./colorToUniform-BdoeDvkl.js";
|
|
3
3
|
const ae = class A extends Ne {
|
|
4
4
|
/**
|
|
5
5
|
* @param options - The optional parameters of this filter.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { m as $, E as l, B as A, D as G, w as b, N as Be, j as S, i as z, S as g, R as w, d as B, M as Y, e as v, A as Ne } from "./index-
|
|
2
|
-
import { S as U, j as O, k as q, m as Z, n as P, b as x, h as Q, f as Ie, U as F, o as J, R as De } from "./colorToUniform-
|
|
3
|
-
import { g as ee } from "./getBatchSamplersUniformGroup-
|
|
4
|
-
import { e as ye, G as Ce, c as Ge, b as Ue, U as Oe, R as Pe, B as te, d as N, f as Fe, S as Me, a as Le } from "./SharedSystems-
|
|
1
|
+
import { m as $, E as l, B as A, D as G, w as b, N as Be, j as S, i as z, S as g, R as w, d as B, M as Y, e as v, A as Ne } from "./index-CNgGuUdP.js";
|
|
2
|
+
import { S as U, j as O, k as q, m as Z, n as P, b as x, h as Q, f as Ie, U as F, o as J, R as De } from "./colorToUniform-BdoeDvkl.js";
|
|
3
|
+
import { g as ee } from "./getBatchSamplersUniformGroup-Nw3bkDeI.js";
|
|
4
|
+
import { e as ye, G as Ce, c as Ge, b as Ue, U as Oe, R as Pe, B as te, d as N, f as Fe, S as Me, a as Le } from "./SharedSystems-zObTVAWO.js";
|
|
5
5
|
class re {
|
|
6
6
|
constructor() {
|
|
7
7
|
this._didUpload = !1, this._tempState = U.for2d();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { m as R, g as E, E as l, f as ie, S as P, B as S, b as ne, c as A, d as b, h as oe, i as ae, D as ue, M as k, j as M, w as ce, e as G, A as de } from "./index-
|
|
2
|
-
import { S as D, c as T, a as z, g as L, r as C, b as v, d as he, U as pe, l as le, e as fe, R as ge } from "./colorToUniform-
|
|
3
|
-
import { c as me, u as _e, U as be, B as ye, G as xe, e as Ge, R as Be, t as Se, S as Pe, a as Te } from "./SharedSystems-
|
|
4
|
-
import { C as w } from "./CanvasPool-
|
|
1
|
+
import { m as R, g as E, E as l, f as ie, S as P, B as S, b as ne, c as A, d as b, h as oe, i as ae, D as ue, M as k, j as M, w as ce, e as G, A as de } from "./index-CNgGuUdP.js";
|
|
2
|
+
import { S as D, c as T, a as z, g as L, r as C, b as v, d as he, U as pe, l as le, e as fe, R as ge } from "./colorToUniform-BdoeDvkl.js";
|
|
3
|
+
import { c as me, u as _e, U as be, B as ye, G as xe, e as Ge, R as Be, t as Se, S as Pe, a as Te } from "./SharedSystems-zObTVAWO.js";
|
|
4
|
+
import { C as w } from "./CanvasPool-DFeTH3RJ.js";
|
|
5
5
|
const y = D.for2d();
|
|
6
6
|
class O {
|
|
7
7
|
init() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as m, r as J, E as w, T as L, U as Q, a as ee, w as y, e as z, C as Z } from "./index-
|
|
2
|
-
import "./webworkerAll-
|
|
1
|
+
import { P as m, r as J, E as w, T as L, U as Q, a as ee, w as y, e as z, C as Z } from "./index-CNgGuUdP.js";
|
|
2
|
+
import "./webworkerAll-B33vuHnD.js";
|
|
3
3
|
class M {
|
|
4
4
|
/**
|
|
5
5
|
* @param manager - The event boundary which manages this event. Propagation can only occur
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as mt, u as K, a as dt, c as T, i as ht, j as pt, n as X, w as gt, m as N } from "./index-
|
|
1
|
+
import { k as mt, u as K, a as dt, c as T, i as ht, j as pt, n as X, w as gt, m as N } from "./index-CNgGuUdP.js";
|
|
2
2
|
const C = /* @__PURE__ */ Object.create(null), Y = /* @__PURE__ */ Object.create(null);
|
|
3
3
|
function W(o, t) {
|
|
4
4
|
let e = Y[o];
|
package/dist/evotars.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a7 as i, ad as a, a9 as r, ab as n, aa as o, a8 as e, ae as c, ac as A } from "./index-
|
|
1
|
+
import { a7 as i, ad as a, a9 as r, ab as n, aa as o, a8 as e, ae as c, ac as A } from "./index-CNgGuUdP.js";
|
|
2
2
|
export {
|
|
3
3
|
i as Evotars,
|
|
4
4
|
a as isAddJumpHitsUserActionEntity,
|
package/dist/evotars.umd.cjs
CHANGED
|
@@ -977,4 +977,4 @@ ${r.join(`
|
|
|
977
977
|
font-weight: ${s.fontWeight};
|
|
978
978
|
font-style: ${s.fontStyle};
|
|
979
979
|
}`}const hi=new Map;async function $g(s,t,e){const i=s.filter(r=>K.has(`${r}-and-url`)).map((r,n)=>{if(!hi.has(r)){const{url:a}=K.get(`${r}-and-url`);n===0?hi.set(r,Ic(t,a)):hi.set(r,Ic({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:r},a))}return hi.get(r)});return(await Promise.all(i)).join(`
|
|
980
|
-
`)}function Xg(s,t,e,i,r){const{domElement:n,styleElement:a,svgRoot:o}=r;n.innerHTML=`<style>${t.cssStyle}</style><div>${s}</div>`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),a.textContent=i;const{width:h,height:c}=r.image;return o.setAttribute("width",h.toString()),o.setAttribute("height",c.toString()),new XMLSerializer().serializeToString(o)}function Yg(s,t){const e=qt.getOptimalCanvasAndContext(s.width,s.height,t),{context:i}=e;return i.clearRect(0,0,s.width,s.height),i.drawImage(s,0,0),qt.returnCanvasAndContext(e),e.canvas}function Kg(s,t,e){return new Promise(async i=>{e&&await new Promise(r=>setTimeout(r,100)),s.onload=()=>{i()},s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,s.crossOrigin="anonymous"})}class dn{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===Lt.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,i,r){if(this._activeTextures[r])return this._increaseReferenceCount(r),this._activeTextures[r].promise;const n=this._buildTexturePromise(t,e,i).then(a=>(this._activeTextures[r].texture=a,a));return this._activeTextures[r]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(t,e,i){const r=$.get(Lo),n=Vg(t,i),a=await $g(n,i,Gr.defaultTextStyle),o=Ap(t,i,a,r),h=Math.ceil(Math.ceil(Math.max(1,o.width)+i.padding*2)*e),c=Math.ceil(Math.ceil(Math.max(1,o.height)+i.padding*2)*e),l=r.image;l.width=h|0,l.height=c|0;const u=Xg(t,i,e,a,r);await Kg(l,u,zg()&&n.length>0);let d=l;this._createCanvas&&(d=Yg(l,e));const f=kc(d,l.width,l.height,e);return this._createCanvas&&this._renderer.texture.initSource(f.source),$.return(r),f}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e):e.promise.then(i=>{e.texture=i,this._cleanUp(e)}).catch(()=>{D("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[t]=null))}_cleanUp(t){Pt.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}dn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"htmlText"},dn.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"};class Fc{constructor(t){this._gpuText=Object.create(null),this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t._getKey();if(e.currentKey!==i){const r=t.resolution??this._renderer.resolution,{width:n,height:a}=this._renderer.canvasText.getTextureSize(t.text,r,t._style);return!(this._renderer.canvasText.getReferenceCount(e.currentKey)===1&&n===e.texture._source.width&&a===e.texture._source.height)}return!1}addRenderable(t,e){const r=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(r)}updateRenderable(t){const i=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),i.batcher.updateElement(i)}destroyRenderable(t){this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.canvasText.decreaseReferenceCount(e.currentKey),$.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),i=this._getGpuText(t),r=i.batchableSprite;i.currentKey!==e&&this._updateGpuText(t),t._didTextUpdate=!1;const n=t._style.padding;Cs(r.bounds,t._anchor,r.texture,n)}_updateGpuText(t){const e=this._getGpuText(t),i=e.batchableSprite;e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),e.texture=i.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t._getKey(),i.texture=e.texture}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:null,currentKey:"--",batchableSprite:$.get(Qr)};return e.batchableSprite.renderable=t,e.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},e.batchableSprite.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,this._updateText(t),t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Fc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"text"};function Gc(s,t,e){for(let i=0,r=4*e*t;i<t;++i,r+=4)if(s[r+3]!==0)return!1;return!0}function Uc(s,t,e,i,r){const n=4*t;for(let a=i,o=i*n+4*e;a<=r;++a,o+=n)if(s[o+3]!==0)return!1;return!0}function qg(s,t=1){const{width:e,height:i}=s,r=s.getContext("2d",{willReadFrequently:!0});if(r===null)throw new TypeError("Failed to get canvas 2D context");const a=r.getImageData(0,0,e,i).data;let o=0,h=0,c=e-1,l=i-1;for(;h<i&&Gc(a,e,h);)++h;if(h===i)return Y.EMPTY;for(;Gc(a,e,l);)--l;for(;Uc(a,e,o,h,l);)++o;for(;Uc(a,e,c,h,l);)--c;return++c,++l,new Y(o/t,h/t,(c-o)/t,(l-h)/t)}class Dc{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,i){const r=Gt.measureText(t||" ",i);let n=Math.ceil(Math.ceil(Math.max(1,r.width)+i.padding*2)*e),a=Math.ceil(Math.ceil(Math.max(1,r.height)+i.padding*2)*e);return n=Math.ceil(n-1e-6),a=Math.ceil(a-1e-6),n=Te(n),a=Te(a),{width:n,height:a}}getTexture(t,e,i,r){typeof t=="string"&&(N("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof me||(t.style=new me(t.style));const{texture:n,canvasAndContext:a}=this.createTextureAndCanvas(t);return this._renderer.texture.initSource(n._source),qt.returnCanvasAndContext(a),n}createTextureAndCanvas(t){const{text:e,style:i}=t,r=t.resolution??this._renderer.resolution,n=Gt.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,n.width)+i.padding*2)*r),o=Math.ceil(Math.ceil(Math.max(1,n.height)+i.padding*2)*r),h=qt.getOptimalCanvasAndContext(a,o),{canvas:c}=h;this.renderTextToCanvas(e,i,r,h);const l=kc(c,a,o,r);if(i.trim){const u=qg(c,r);l.frame.copyFrom(u),l.updateUvs()}return{texture:l,canvasAndContext:h}}getManagedTexture(t){const e=t._getKey();if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const{texture:i,canvasAndContext:r}=this.createTextureAndCanvas(t);return this._activeTextures[e]={canvasAndContext:r,texture:i,usageCount:1},i}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];if(e.usageCount--,e.usageCount===0){qt.returnCanvasAndContext(e.canvasAndContext),Pt.returnTexture(e.texture);const i=e.texture.source;i.resource=null,i.uploadMethodId="unknown",i.alphaMode="no-premultiply-alpha",this._activeTextures[t]=null}}getReferenceCount(t){return this._activeTextures[t].usageCount}renderTextToCanvas(t,e,i,r){var y,v,w,E,C;const{canvas:n,context:a}=r,o=Zs(e),h=Gt.measureText(t||" ",e),c=h.lines,l=h.lineHeight,u=h.lineWidths,d=h.maxLineWidth,f=h.fontProperties,p=n.height;a.resetTransform(),a.scale(i,i);const g=e.padding*2;if(a.clearRect(0,0,h.width+4+g,h.height+4+g),(y=e._stroke)!=null&&y.width){const P=e._stroke;a.lineWidth=P.width,a.miterLimit=P.miterLimit,a.lineJoin=P.join,a.lineCap=P.cap}a.font=o;let m,_;const x=e.dropShadow?2:1;for(let P=0;P<x;++P){const S=e.dropShadow&&P===0,A=S?Math.ceil(Math.max(1,p)+e.padding*2):0,Q=A*i;if(S){a.fillStyle="black",a.strokeStyle="black";const B=e.dropShadow,q=B.color,it=B.alpha;a.shadowColor=j.shared.setValue(q).setAlpha(it).toRgbaString();const vt=B.blur*i,_s=B.distance*i;a.shadowBlur=vt,a.shadowOffsetX=Math.cos(B.angle)*_s,a.shadowOffsetY=Math.sin(B.angle)*_s+Q}else a.globalAlpha=((v=e._fill)==null?void 0:v.alpha)??1,a.fillStyle=e._fill?Qs(e._fill,a):null,(w=e._stroke)!=null&&w.width&&(a.strokeStyle=Qs(e._stroke,a)),a.shadowColor="black";let Mt=(l-f.fontSize)/2;l-f.fontSize<0&&(Mt=0);const F=((E=e._stroke)==null?void 0:E.width)??0;for(let B=0;B<c.length;B++)m=F/2,_=F/2+B*l+f.ascent+Mt,e.align==="right"?m+=d-u[B]:e.align==="center"&&(m+=(d-u[B])/2),(C=e._stroke)!=null&&C.width&&this._drawLetterSpacing(c[B],e,r,m+e.padding,_+e.padding-A,!0),e._fill!==void 0&&this._drawLetterSpacing(c[B],e,r,m+e.padding,_+e.padding-A)}}_drawLetterSpacing(t,e,i,r,n,a=!1){const{context:o}=i,h=e.letterSpacing;let c=!1;if(Gt.experimentalLetterSpacingSupported&&(Gt.experimentalLetterSpacing?(o.letterSpacing=`${h}px`,o.textLetterSpacing=`${h}px`,c=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),h===0||c){a?o.strokeText(t,r,n):o.fillText(t,r,n);return}let l=r;const u=Gt.graphemeSegmenter(t);let d=o.measureText(t).width,f=0;for(let p=0;p<u.length;++p){const g=u[p];a?o.strokeText(g,l,n):o.fillText(g,l,n);let m="";for(let _=p+1;_<u.length;++_)m+=u[_];f=o.measureText(m).width,l+=d-f+h,d=f}}destroy(){this._activeTextures=null}}Dc.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"canvasText"},O.add(Ml,Bl);const ae=.02*1e3;class Zt{constructor(t=0,e){T(this,"isCompleted",!1);this.current=t,this.onComplete=e}tick(t=ae){this.isCompleted||(this.current-=t,this.current<0&&this.complete())}complete(){var t;this.isCompleted=!0,(t=this.onComplete)==null||t.call(this)}}class Zg{constructor(){T(this,"timers",[])}add(t,e){this.timers.push(new Zt(t,e))}tick(t=ae){const e=[];for(const i of this.timers)i.isCompleted||(i.tick(t),e.push(i));this.timers=e}}const fn=new Zg,Oc=s=>s.name=="jump",Lc=s=>s.name=="color",Hc=s=>s.name=="grow",Nc=s=>s.name=="dash",zc=s=>s.name=="sprite",Wc=s=>s.name=="add_jump_hits",Vc=s=>s.name=="resurrect";function ci(s){"@babel/helpers - typeof";return ci=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ci(s)}var Jg=/^\s+/,Qg=/\s+$/;function k(s,t){if(s=s||"",t=t||{},s instanceof k)return s;if(!(this instanceof k))return new k(s,t);var e=t_(s);this._originalInput=s,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||e.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}k.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),e,i,r,n,a,o;return e=t.r/255,i=t.g/255,r=t.b/255,e<=.03928?n=e/12.92:n=Math.pow((e+.055)/1.055,2.4),i<=.03928?a=i/12.92:a=Math.pow((i+.055)/1.055,2.4),r<=.03928?o=r/12.92:o=Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*a+.0722*o},setAlpha:function(t){return this._a=qc(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=$c(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=$c(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),r=Math.round(t.v*100);return this._a==1?"hsv("+e+", "+i+"%, "+r+"%)":"hsva("+e+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=jc(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=jc(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),r=Math.round(t.l*100);return this._a==1?"hsl("+e+", "+i+"%, "+r+"%)":"hsla("+e+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return Xc(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return r_(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(J(this._r,255)*100)+"%",g:Math.round(J(this._g,255)*100)+"%",b:Math.round(J(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(J(this._r,255)*100)+"%, "+Math.round(J(this._g,255)*100)+"%, "+Math.round(J(this._b,255)*100)+"%)":"rgba("+Math.round(J(this._r,255)*100)+"%, "+Math.round(J(this._g,255)*100)+"%, "+Math.round(J(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:g_[Xc(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+Yc(this._r,this._g,this._b,this._a),i=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var n=k(t);i="#"+Yc(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+i+")"},toString:function(t){var e=!!t;t=t||this._format;var i=!1,r=this._a<1&&this._a>=0,n=!e&&r&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(i=this.toRgbString()),t==="prgb"&&(i=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(i=this.toHexString()),t==="hex3"&&(i=this.toHexString(!0)),t==="hex4"&&(i=this.toHex8String(!0)),t==="hex8"&&(i=this.toHex8String()),t==="name"&&(i=this.toName()),t==="hsl"&&(i=this.toHslString()),t==="hsv"&&(i=this.toHsvString()),i||this.toHexString())},clone:function(){return k(this.toString())},_applyModification:function(t,e){var i=t.apply(null,[this].concat([].slice.call(e)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(h_,arguments)},brighten:function(){return this._applyModification(c_,arguments)},darken:function(){return this._applyModification(l_,arguments)},desaturate:function(){return this._applyModification(n_,arguments)},saturate:function(){return this._applyModification(a_,arguments)},greyscale:function(){return this._applyModification(o_,arguments)},spin:function(){return this._applyModification(u_,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(p_,arguments)},complement:function(){return this._applyCombination(d_,arguments)},monochromatic:function(){return this._applyCombination(m_,arguments)},splitcomplement:function(){return this._applyCombination(f_,arguments)},triad:function(){return this._applyCombination(Kc,[3])},tetrad:function(){return this._applyCombination(Kc,[4])}},k.fromRatio=function(s,t){if(ci(s)=="object"){var e={};for(var i in s)s.hasOwnProperty(i)&&(i==="a"?e[i]=s[i]:e[i]=fs(s[i]));s=e}return k(s,t)};function t_(s){var t={r:0,g:0,b:0},e=1,i=null,r=null,n=null,a=!1,o=!1;return typeof s=="string"&&(s=b_(s)),ci(s)=="object"&&(Jt(s.r)&&Jt(s.g)&&Jt(s.b)?(t=e_(s.r,s.g,s.b),a=!0,o=String(s.r).substr(-1)==="%"?"prgb":"rgb"):Jt(s.h)&&Jt(s.s)&&Jt(s.v)?(i=fs(s.s),r=fs(s.v),t=i_(s.h,i,r),a=!0,o="hsv"):Jt(s.h)&&Jt(s.s)&&Jt(s.l)&&(i=fs(s.s),n=fs(s.l),t=s_(s.h,i,n),a=!0,o="hsl"),s.hasOwnProperty("a")&&(e=s.a)),e=qc(e),{ok:a,format:s.format||o,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:e}}function e_(s,t,e){return{r:J(s,255)*255,g:J(t,255)*255,b:J(e,255)*255}}function jc(s,t,e){s=J(s,255),t=J(t,255),e=J(e,255);var i=Math.max(s,t,e),r=Math.min(s,t,e),n,a,o=(i+r)/2;if(i==r)n=a=0;else{var h=i-r;switch(a=o>.5?h/(2-i-r):h/(i+r),i){case s:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-s)/h+2;break;case e:n=(s-t)/h+4;break}n/=6}return{h:n,s:a,l:o}}function s_(s,t,e){var i,r,n;s=J(s,360),t=J(t,100),e=J(e,100);function a(c,l,u){return u<0&&(u+=1),u>1&&(u-=1),u<1/6?c+(l-c)*6*u:u<1/2?l:u<2/3?c+(l-c)*(2/3-u)*6:c}if(t===0)i=r=n=e;else{var o=e<.5?e*(1+t):e+t-e*t,h=2*e-o;i=a(h,o,s+1/3),r=a(h,o,s),n=a(h,o,s-1/3)}return{r:i*255,g:r*255,b:n*255}}function $c(s,t,e){s=J(s,255),t=J(t,255),e=J(e,255);var i=Math.max(s,t,e),r=Math.min(s,t,e),n,a,o=i,h=i-r;if(a=i===0?0:h/i,i==r)n=0;else{switch(i){case s:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-s)/h+2;break;case e:n=(s-t)/h+4;break}n/=6}return{h:n,s:a,v:o}}function i_(s,t,e){s=J(s,360)*6,t=J(t,100),e=J(e,100);var i=Math.floor(s),r=s-i,n=e*(1-t),a=e*(1-r*t),o=e*(1-(1-r)*t),h=i%6,c=[e,a,n,n,o,e][h],l=[o,e,e,a,n,n][h],u=[n,n,o,e,e,a][h];return{r:c*255,g:l*255,b:u*255}}function Xc(s,t,e,i){var r=[Ut(Math.round(s).toString(16)),Ut(Math.round(t).toString(16)),Ut(Math.round(e).toString(16))];return i&&r[0].charAt(0)==r[0].charAt(1)&&r[1].charAt(0)==r[1].charAt(1)&&r[2].charAt(0)==r[2].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")}function r_(s,t,e,i,r){var n=[Ut(Math.round(s).toString(16)),Ut(Math.round(t).toString(16)),Ut(Math.round(e).toString(16)),Ut(Zc(i))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function Yc(s,t,e,i){var r=[Ut(Zc(i)),Ut(Math.round(s).toString(16)),Ut(Math.round(t).toString(16)),Ut(Math.round(e).toString(16))];return r.join("")}k.equals=function(s,t){return!s||!t?!1:k(s).toRgbString()==k(t).toRgbString()},k.random=function(){return k.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function n_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.s-=t/100,e.s=li(e.s),k(e)}function a_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.s+=t/100,e.s=li(e.s),k(e)}function o_(s){return k(s).desaturate(100)}function h_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.l+=t/100,e.l=li(e.l),k(e)}function c_(s,t){t=t===0?0:t||10;var e=k(s).toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(255*-(t/100)))),e.g=Math.max(0,Math.min(255,e.g-Math.round(255*-(t/100)))),e.b=Math.max(0,Math.min(255,e.b-Math.round(255*-(t/100)))),k(e)}function l_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.l-=t/100,e.l=li(e.l),k(e)}function u_(s,t){var e=k(s).toHsl(),i=(e.h+t)%360;return e.h=i<0?360+i:i,k(e)}function d_(s){var t=k(s).toHsl();return t.h=(t.h+180)%360,k(t)}function Kc(s,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var e=k(s).toHsl(),i=[k(s)],r=360/t,n=1;n<t;n++)i.push(k({h:(e.h+n*r)%360,s:e.s,l:e.l}));return i}function f_(s){var t=k(s).toHsl(),e=t.h;return[k(s),k({h:(e+72)%360,s:t.s,l:t.l}),k({h:(e+216)%360,s:t.s,l:t.l})]}function p_(s,t,e){t=t||6,e=e||30;var i=k(s).toHsl(),r=360/e,n=[k(s)];for(i.h=(i.h-(r*t>>1)+720)%360;--t;)i.h=(i.h+r)%360,n.push(k(i));return n}function m_(s,t){t=t||6;for(var e=k(s).toHsv(),i=e.h,r=e.s,n=e.v,a=[],o=1/t;t--;)a.push(k({h:i,s:r,v:n})),n=(n+o)%1;return a}k.mix=function(s,t,e){e=e===0?0:e||50;var i=k(s).toRgb(),r=k(t).toRgb(),n=e/100,a={r:(r.r-i.r)*n+i.r,g:(r.g-i.g)*n+i.g,b:(r.b-i.b)*n+i.b,a:(r.a-i.a)*n+i.a};return k(a)},k.readability=function(s,t){var e=k(s),i=k(t);return(Math.max(e.getLuminance(),i.getLuminance())+.05)/(Math.min(e.getLuminance(),i.getLuminance())+.05)},k.isReadable=function(s,t,e){var i=k.readability(s,t),r,n;switch(n=!1,r=v_(e),r.level+r.size){case"AAsmall":case"AAAlarge":n=i>=4.5;break;case"AAlarge":n=i>=3;break;case"AAAsmall":n=i>=7;break}return n},k.mostReadable=function(s,t,e){var i=null,r=0,n,a,o,h;e=e||{},a=e.includeFallbackColors,o=e.level,h=e.size;for(var c=0;c<t.length;c++)n=k.readability(s,t[c]),n>r&&(r=n,i=k(t[c]));return k.isReadable(s,i,{level:o,size:h})||!a?i:(e.includeFallbackColors=!1,k.mostReadable(s,["#fff","#000"],e))};var pn=k.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},g_=k.hexNames=__(pn);function __(s){var t={};for(var e in s)s.hasOwnProperty(e)&&(t[s[e]]=e);return t}function qc(s){return s=parseFloat(s),(isNaN(s)||s<0||s>1)&&(s=1),s}function J(s,t){x_(s)&&(s="100%");var e=y_(s);return s=Math.min(t,Math.max(0,parseFloat(s))),e&&(s=parseInt(s*t,10)/100),Math.abs(s-t)<1e-6?1:s%t/parseFloat(t)}function li(s){return Math.min(1,Math.max(0,s))}function bt(s){return parseInt(s,16)}function x_(s){return typeof s=="string"&&s.indexOf(".")!=-1&&parseFloat(s)===1}function y_(s){return typeof s=="string"&&s.indexOf("%")!=-1}function Ut(s){return s.length==1?"0"+s:""+s}function fs(s){return s<=1&&(s=s*100+"%"),s}function Zc(s){return Math.round(parseFloat(s)*255).toString(16)}function Jc(s){return bt(s)/255}var Dt=function(){var s="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",e="(?:"+t+")|(?:"+s+")",i="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+i),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+i),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+i),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Jt(s){return!!Dt.CSS_UNIT.exec(s)}function b_(s){s=s.replace(Jg,"").replace(Qg,"").toLowerCase();var t=!1;if(pn[s])s=pn[s],t=!0;else if(s=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=Dt.rgb.exec(s))?{r:e[1],g:e[2],b:e[3]}:(e=Dt.rgba.exec(s))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=Dt.hsl.exec(s))?{h:e[1],s:e[2],l:e[3]}:(e=Dt.hsla.exec(s))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=Dt.hsv.exec(s))?{h:e[1],s:e[2],v:e[3]}:(e=Dt.hsva.exec(s))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=Dt.hex8.exec(s))?{r:bt(e[1]),g:bt(e[2]),b:bt(e[3]),a:Jc(e[4]),format:t?"name":"hex8"}:(e=Dt.hex6.exec(s))?{r:bt(e[1]),g:bt(e[2]),b:bt(e[3]),format:t?"name":"hex"}:(e=Dt.hex4.exec(s))?{r:bt(e[1]+""+e[1]),g:bt(e[2]+""+e[2]),b:bt(e[3]+""+e[3]),a:Jc(e[4]+""+e[4]),format:t?"name":"hex8"}:(e=Dt.hex3.exec(s))?{r:bt(e[1]+""+e[1]),g:bt(e[2]+""+e[2]),b:bt(e[3]+""+e[3]),format:t?"name":"hex"}:!1}function v_(s){var t,e;return s=s||{level:"AA",size:"small"},t=(s.level||"AA").toUpperCase(),e=(s.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:t,size:e}}var ps=Object.freeze({Linear:Object.freeze({None:function(s){return s},In:function(s){return s},Out:function(s){return s},InOut:function(s){return s}}),Quadratic:Object.freeze({In:function(s){return s*s},Out:function(s){return s*(2-s)},InOut:function(s){return(s*=2)<1?.5*s*s:-.5*(--s*(s-2)-1)}}),Cubic:Object.freeze({In:function(s){return s*s*s},Out:function(s){return--s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s:.5*((s-=2)*s*s+2)}}),Quartic:Object.freeze({In:function(s){return s*s*s*s},Out:function(s){return 1- --s*s*s*s},InOut:function(s){return(s*=2)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2)}}),Quintic:Object.freeze({In:function(s){return s*s*s*s*s},Out:function(s){return--s*s*s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2)}}),Sinusoidal:Object.freeze({In:function(s){return 1-Math.sin((1-s)*Math.PI/2)},Out:function(s){return Math.sin(s*Math.PI/2)},InOut:function(s){return .5*(1-Math.sin(Math.PI*(.5-s)))}}),Exponential:Object.freeze({In:function(s){return s===0?0:Math.pow(1024,s-1)},Out:function(s){return s===1?1:1-Math.pow(2,-10*s)},InOut:function(s){return s===0?0:s===1?1:(s*=2)<1?.5*Math.pow(1024,s-1):.5*(-Math.pow(2,-10*(s-1))+2)}}),Circular:Object.freeze({In:function(s){return 1-Math.sqrt(1-s*s)},Out:function(s){return Math.sqrt(1- --s*s)},InOut:function(s){return(s*=2)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1)}}),Elastic:Object.freeze({In:function(s){return s===0?0:s===1?1:-Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI)},Out:function(s){return s===0?0:s===1?1:Math.pow(2,-10*s)*Math.sin((s-.1)*5*Math.PI)+1},InOut:function(s){return s===0?0:s===1?1:(s*=2,s<1?-.5*Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI):.5*Math.pow(2,-10*(s-1))*Math.sin((s-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(s){var t=1.70158;return s===1?1:s*s*((t+1)*s-t)},Out:function(s){var t=1.70158;return s===0?0:--s*s*((t+1)*s+t)+1},InOut:function(s){var t=2.5949095;return(s*=2)<1?.5*(s*s*((t+1)*s-t)):.5*((s-=2)*s*((t+1)*s+t)+2)}}),Bounce:Object.freeze({In:function(s){return 1-ps.Bounce.Out(1-s)},Out:function(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},InOut:function(s){return s<.5?ps.Bounce.In(s*2)*.5:ps.Bounce.Out(s*2-1)*.5+.5}}),generatePow:function(s){return s===void 0&&(s=4),s=s<Number.EPSILON?Number.EPSILON:s,s=s>1e4?1e4:s,{In:function(t){return Math.pow(t,s)},Out:function(t){return 1-Math.pow(1-t,s)},InOut:function(t){return t<.5?Math.pow(t*2,s)/2:(1-Math.pow(2-t*2,s))/2+.5}}}}),ms=function(){return performance.now()},S_=function(){function s(){this._tweens={},this._tweensAddedDuringUpdate={}}return s.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},s.prototype.removeAll=function(){this._tweens={}},s.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},s.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},s.prototype.update=function(t,e){t===void 0&&(t=ms()),e===void 0&&(e=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<i.length;r++){var n=this._tweens[i[r]],a=!e;n&&n.update(t,a)===!1&&!e&&delete this._tweens[i[r]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},s}(),He={Linear:function(s,t){var e=s.length-1,i=e*t,r=Math.floor(i),n=He.Utils.Linear;return t<0?n(s[0],s[1],i):t>1?n(s[e],s[e-1],e-i):n(s[r],s[r+1>e?e:r+1],i-r)},Bezier:function(s,t){for(var e=0,i=s.length-1,r=Math.pow,n=He.Utils.Bernstein,a=0;a<=i;a++)e+=r(1-t,i-a)*r(t,a)*s[a]*n(i,a);return e},CatmullRom:function(s,t){var e=s.length-1,i=e*t,r=Math.floor(i),n=He.Utils.CatmullRom;return s[0]===s[e]?(t<0&&(r=Math.floor(i=e*(1+t))),n(s[(r-1+e)%e],s[r],s[(r+1)%e],s[(r+2)%e],i-r)):t<0?s[0]-(n(s[0],s[0],s[1],s[1],-i)-s[0]):t>1?s[e]-(n(s[e],s[e],s[e-1],s[e-1],i-e)-s[e]):n(s[r?r-1:0],s[r],s[e<r+1?e:r+1],s[e<r+2?e:r+2],i-r)},Utils:{Linear:function(s,t,e){return(t-s)*e+s},Bernstein:function(s,t){var e=He.Utils.Factorial;return e(s)/e(t)/e(s-t)},Factorial:function(){var s=[1];return function(t){var e=1;if(s[t])return s[t];for(var i=t;i>1;i--)e*=i;return s[t]=e,e}}(),CatmullRom:function(s,t,e,i,r){var n=(e-s)*.5,a=(i-t)*.5,o=r*r,h=r*o;return(2*t-2*e+n+a)*h+(-3*t+3*e-2*n-a)*o+n*r+t}}},w_=function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s}(),mn=new S_,xe=function(){function s(t,e){e===void 0&&(e=mn),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=ps.Linear.None,this._interpolationFunction=He.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=w_.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return s.prototype.getId=function(){return this._id},s.prototype.isPlaying=function(){return this._isPlaying},s.prototype.isPaused=function(){return this._isPaused},s.prototype.getDuration=function(){return this._duration},s.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},s.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t<0?0:t,this},s.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},s.prototype.start=function(t,e){if(t===void 0&&(t=ms()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var n in this._valuesEnd)r[n]=this._valuesEnd[n];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},s.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},s.prototype._setupProperties=function(t,e,i,r,n){for(var a in i){var o=t[a],h=Array.isArray(o),c=h?"array":typeof o,l=!h&&Array.isArray(i[a]);if(!(c==="undefined"||c==="function")){if(l){var u=i[a];if(u.length===0)continue;for(var d=[o],f=0,p=u.length;f<p;f+=1){var g=this._handleRelativeValue(o,u[f]);if(isNaN(g)){l=!1,console.warn("Found invalid interpolation list. Skipping.");break}d.push(g)}l&&(i[a]=d)}if((c==="object"||h)&&o&&!l){e[a]=h?[]:{};var m=o;for(var _ in m)e[a][_]=m[_];r[a]=h?[]:{};var u=i[a];if(!this._isDynamic){var x={};for(var _ in u)x[_]=u[_];i[a]=u=x}this._setupProperties(m,e[a],u,r[a],n)}else(typeof e[a]>"u"||n)&&(e[a]=o),h||(e[a]*=1),l?r[a]=i[a].slice().reverse():r[a]=e[a]||0}}},s.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},s.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},s.prototype.pause=function(t){return t===void 0&&(t=ms()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},s.prototype.resume=function(t){return t===void 0&&(t=ms()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},s.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},s.prototype.group=function(t){return t===void 0&&(t=mn),this._group=t,this},s.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},s.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},s.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},s.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},s.prototype.easing=function(t){return t===void 0&&(t=ps.Linear.None),this._easingFunction=t,this},s.prototype.interpolation=function(t){return t===void 0&&(t=He.Linear),this._interpolationFunction=t,this},s.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},s.prototype.onStart=function(t){return this._onStartCallback=t,this},s.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},s.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},s.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},s.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},s.prototype.onStop=function(t){return this._onStopCallback=t,this},s.prototype.update=function(t,e){var i;if(t===void 0&&(t=ms()),e===void 0&&(e=!0),this._isPaused)return!0;var r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>r)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var n=t-this._startTime,a=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),o=this._duration+this._repeat*a,h=this._calculateElapsedPortion(n,a,o),c=this._easingFunction(h),l=this._calculateCompletionStatus(n,a);if(l==="repeat"&&this._processRepetition(n,a),this._updateProperties(this._object,this._valuesStart,this._valuesEnd,c),l==="about-to-repeat"&&this._processRepetition(n,a),this._onUpdateCallback&&this._onUpdateCallback(this._object,h),l==="repeat"||l==="about-to-repeat")this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1;else if(l==="completed"){this._isPlaying=!1,this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var u=0,d=this._chainedTweens.length;u<d;u++)this._chainedTweens[u].start(this._startTime+this._duration,!1)}return l!=="completed"},s.prototype._calculateElapsedPortion=function(t,e,i){if(this._duration===0||t>i)return 1;var r=t%e,n=Math.min(r/this._duration,1);return n===0&&t!==0&&t%this._duration===0?1:n},s.prototype._calculateCompletionStatus=function(t,e){return this._duration!==0&&t<this._duration?"playing":this._repeat<=0?"completed":t===this._duration?"about-to-repeat":"repeat"},s.prototype._processRepetition=function(t,e){var i=Math.min(Math.trunc((t-this._duration)/e)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=i);for(var r in this._valuesStartRepeat){var n=this._valuesEnd[r];!this._yoyo&&typeof n=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(n)),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}this._yoyo&&(this._reversed=!this._reversed),this._startTime+=e*i},s.prototype._updateProperties=function(t,e,i,r){for(var n in i)if(e[n]!==void 0){var a=e[n]||0,o=i[n],h=Array.isArray(t[n]),c=Array.isArray(o),l=!h&&c;l?t[n]=this._interpolationFunction(o,r):typeof o=="object"&&o?this._updateProperties(t[n],a,o,r):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(t[n]=a+(o-a)*r))}},s.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},s.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];typeof i=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(i):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},s}(),Nt=mn;Nt.getAll.bind(Nt),Nt.removeAll.bind(Nt),Nt.add.bind(Nt),Nt.remove.bind(Nt),Nt.update.bind(Nt);class T_{constructor(){T(this,"assets",{})}async initialize(t){this.assets=Object.fromEntries(Array.from(Object.entries(t??{})).map(([e,i])=>[e,new Audio(i.src)]))}play(t){const e=this.assets[t];e&&(e.volume=.3,e.pause(),e.currentTime=0,e.play())}}const Qc=new T_;var dt=(s=>(s.Idle="Idle",s.Jump="Jump",s.Fall="Fall",s.Land="Land",s.Run="Run",s.Die="Die",s))(dt||{});class A_{constructor(){T(this,"spriteLoaderFn");T(this,"sprites",{})}initialize(t){this.spriteLoaderFn=t}async getSpriteData(t){const e=await this.spriteLoaderFn(t);if(!e)return;if(this.sprites[t])return this.sprites[t];const i=await ft.load(e.image),r=new Ni(i,e.sprite);return await r.parse(),this.sprites[t]={sheet:r,data:{...e.data,scale:e.data.scale??1}},this.sprites[t]}createAnimatedSprite(t,e){for(const i of e.data.meta.frameTags??[]){const r=[];for(let a=i.from;a<=i.to;a++){const o=a.toString(),h=t+"_"+o,c=e.textures[h],l=e.data.frames[h].duration;r.push({texture:c,time:l})}const n=new ns(r);return n.texture.source.scaleMode="nearest",n}}getAnimatedSprites(t){if(!t)throw Error("Sheet is not defined");if(!this.sprites[t])throw Error("Sprite is not loaded");const e=this.sprites[t].data,i=this.sprites[t].sheet,r={};for(const n of i.data.meta.frameTags??[]){if(!i.data.meta.layers)throw Error("Layers are not defined");const a={};for(const o of i.data.meta.layers){const h=[];for(let l=n.from;l<=n.to;l++){const u=l.toString(),d=e.name+"_"+o.name+"_"+u,f=i.textures[d],p=i.data.frames[d].duration;h.push({texture:f,time:p})}const c=new ns(h);c.texture.source.scaleMode="nearest",a[o.name]=c}n.name&&(r[n.name]=a)}return r}}const ui=new A_;var ye={},tl={},Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.loop=Qt.conditional=Qt.parse=void 0;var P_=function s(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;if(Array.isArray(e))e.forEach(function(a){return s(t,a,i,r)});else if(typeof e=="function")e(t,i,r,s);else{var n=Object.keys(e)[0];Array.isArray(e[n])?(r[n]={},s(t,e[n],i,r[n])):r[n]=e[n](t,i,r,s)}return i};Qt.parse=P_;var C_=function(t,e){return function(i,r,n,a){e(i,r,n)&&a(i,t,r,n)}};Qt.conditional=C_;var E_=function(t,e){return function(i,r,n,a){for(var o=[],h=i.pos;e(i,r,n);){var c={};if(a(i,t,r,c),i.pos===h)break;h=i.pos,o.push(c)}return o}};Qt.loop=E_;var rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.readBits=rt.readArray=rt.readUnsigned=rt.readString=rt.peekBytes=rt.readBytes=rt.peekByte=rt.readByte=rt.buildStream=void 0;var M_=function(t){return{data:t,pos:0}};rt.buildStream=M_;var el=function(){return function(t){return t.data[t.pos++]}};rt.readByte=el;var B_=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(e){return e.data[e.pos+t]}};rt.peekByte=B_;var di=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};rt.readBytes=di;var R_=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}};rt.peekBytes=R_;var k_=function(t){return function(e){return Array.from(di(t)(e)).map(function(i){return String.fromCharCode(i)}).join("")}};rt.readString=k_;var I_=function(t){return function(e){var i=di(2)(e);return t?(i[1]<<8)+i[0]:(i[0]<<8)+i[1]}};rt.readUnsigned=I_;var F_=function(t,e){return function(i,r,n){for(var a=typeof e=="function"?e(i,r,n):e,o=di(t),h=new Array(a),c=0;c<a;c++)h[c]=o(i);return h}};rt.readArray=F_;var G_=function(t,e,i){for(var r=0,n=0;n<i;n++)r+=t[e+n]&&Math.pow(2,i-n-1);return r},U_=function(t){return function(e){for(var i=el()(e),r=new Array(8),n=0;n<8;n++)r[7-n]=!!(i&1<<n);return Object.keys(t).reduce(function(a,o){var h=t[o];return h.length?a[o]=G_(r,h.index,h.length):a[o]=r[h.index],a},{})}};rt.readBits=U_,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var t=Qt,e=rt,i={blocks:function(d){for(var f=0,p=[],g=d.data.length,m=0,_=(0,e.readByte)()(d);_!==f&&_;_=(0,e.readByte)()(d)){if(d.pos+_>=g){var x=g-d.pos;p.push((0,e.readBytes)(x)(d)),m+=x;break}p.push((0,e.readBytes)(_)(d)),m+=_}for(var y=new Uint8Array(m),v=0,w=0;w<p.length;w++)y.set(p[w],v),v+=p[w].length;return y}},r=(0,t.conditional)({gce:[{codes:(0,e.readBytes)(2)},{byteSize:(0,e.readByte)()},{extras:(0,e.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,e.readUnsigned)(!0)},{transparentColorIndex:(0,e.readByte)()},{terminator:(0,e.readByte)()}]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===249}),n=(0,t.conditional)({image:[{code:(0,e.readByte)()},{descriptor:[{left:(0,e.readUnsigned)(!0)},{top:(0,e.readUnsigned)(!0)},{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{lct:(0,e.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,t.conditional)({lct:(0,e.readArray)(3,function(u,d,f){return Math.pow(2,f.descriptor.lct.size+1)})},function(u,d,f){return f.descriptor.lct.exists}),{data:[{minCodeSize:(0,e.readByte)()},i]}]},function(u){return(0,e.peekByte)()(u)===44}),a=(0,t.conditional)({text:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{preData:function(d,f,p){return(0,e.readBytes)(p.text.blockSize)(d)}},i]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===1}),o=(0,t.conditional)({application:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{id:function(d,f,p){return(0,e.readString)(p.blockSize)(d)}},i]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===255}),h=(0,t.conditional)({comment:[{codes:(0,e.readBytes)(2)},i]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===254}),c=[{header:[{signature:(0,e.readString)(3)},{version:(0,e.readString)(3)}]},{lsd:[{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{gct:(0,e.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,e.readByte)()},{pixelAspectRatio:(0,e.readByte)()}]},(0,t.conditional)({gct:(0,e.readArray)(3,function(u,d){return Math.pow(2,d.lsd.gct.size+1)})},function(u,d){return d.lsd.gct.exists}),{frames:(0,t.loop)([r,o,h,n,a],function(u){var d=(0,e.peekByte)()(u);return d===33||d===44})}],l=c;s.default=l}(tl);var fi={};Object.defineProperty(fi,"__esModule",{value:!0}),fi.deinterlace=void 0;var D_=function(t,e){for(var i=new Array(t.length),r=t.length/e,n=function(d,f){var p=t.slice(f*e,(f+1)*e);i.splice.apply(i,[d*e,e].concat(p))},a=[0,4,2,1],o=[8,8,4,2],h=0,c=0;c<4;c++)for(var l=a[c];l<r;l+=o[c])n(l,h),h++;return i};fi.deinterlace=D_;var pi={};Object.defineProperty(pi,"__esModule",{value:!0}),pi.lzw=void 0;var O_=function(t,e,i){var r=4096,n=-1,a=i,o,h,c,l,u,d,f,E,p,g,w,m,C,P,A,S,_=new Array(i),x=new Array(r),y=new Array(r),v=new Array(r+1);for(m=t,h=1<<m,u=h+1,o=h+2,f=n,l=m+1,c=(1<<l)-1,p=0;p<h;p++)x[p]=0,y[p]=p;var w,E,C,P,S,A;for(w=E=C=P=S=A=0,g=0;g<a;){if(P===0){if(E<l){w+=e[A]<<E,E+=8,A++;continue}if(p=w&c,w>>=l,E-=l,p>o||p==u)break;if(p==h){l=m+1,c=(1<<l)-1,o=h+2,f=n;continue}if(f==n){v[P++]=y[p],f=p,C=p;continue}for(d=p,p==o&&(v[P++]=C,p=f);p>h;)v[P++]=y[p],p=x[p];C=y[p]&255,v[P++]=C,o<r&&(x[o]=f,y[o]=C,o++,!(o&c)&&o<r&&(l++,c+=o)),f=d}P--,_[S++]=v[P],g++}for(g=S;g<a;g++)_[g]=0;return _};pi.lzw=O_,Object.defineProperty(ye,"__esModule",{value:!0});var sl=ye.decompressFrames=ye.decompressFrame=il=ye.parseGIF=void 0,L_=V_(tl),H_=Qt,N_=rt,z_=fi,W_=pi;function V_(s){return s&&s.__esModule?s:{default:s}}var j_=function(t){var e=new Uint8Array(t);return(0,H_.parse)((0,N_.buildStream)(e),L_.default)},il=ye.parseGIF=j_,$_=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(e*4),r=0;r<e;r++){var n=r*4,a=t.pixels[r],o=t.colorTable[a]||[0,0,0];i[n]=o[0],i[n+1]=o[1],i[n+2]=o[2],i[n+3]=a!==t.transparentIndex?255:0}return i},rl=function(t,e,i){if(!t.image){console.warn("gif frame does not have associated image.");return}var r=t.image,n=r.descriptor.width*r.descriptor.height,a=(0,W_.lzw)(r.data.minCodeSize,r.data.blocks,n);r.descriptor.lct.interlaced&&(a=(0,z_.deinterlace)(a,r.descriptor.width));var o={pixels:a,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return r.descriptor.lct&&r.descriptor.lct.exists?o.colorTable=r.lct:o.colorTable=e,t.gce&&(o.delay=(t.gce.delay||10)*10,o.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(o.transparentIndex=t.gce.transparentColorIndex)),i&&(o.patch=$_(o)),o};ye.decompressFrame=rl;var X_=function(t,e){return t.frames.filter(function(i){return i.image}).map(function(i){return rl(i,t.gct,e)})};sl=ye.decompressFrames=X_;const gs=class extends Tt{constructor(s,t){super(M.EMPTY),this.animationSpeed=1,this.loop=!0,this.duration=0,this.autoPlay=!0,this.dirty=!1,this._currentFrame=0,this._autoUpdate=!1,this._isConnectedToTicker=!1,this._playing=!1,this._currentTime=0,this.onRender=()=>this.updateFrame();const{scaleMode:e,width:i,height:r,...n}=Object.assign({},gs.defaultOptions,t),a=L.get().createCanvas(i,r),o=a.getContext("2d");this.texture=M.from(a),this.texture.source.scaleMode=e,this.duration=s[s.length-1].end,this._frames=s,this._context=o,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,n),this.currentFrame=0,n.autoPlay&&this.play()}static fromBuffer(s,t){if(!s||s.byteLength===0)throw new Error("Invalid buffer");const e=m=>{let _=null;for(const x of m.frames)_=x.gce??_,"image"in x&&!("gce"in x)&&(x.gce=_)},i=il(s);e(i);const r=sl(i,!0),n=[],a=L.get().createCanvas(i.lsd.width,i.lsd.height),o=a.getContext("2d",{willReadFrequently:!0}),h=L.get().createCanvas(),c=h.getContext("2d");let l=0,u=null;const{fps:d}=Object.assign({},gs.defaultOptions,t),f=1e3/d;for(let m=0;m<r.length;m++){const{disposalType:_=2,delay:x=f,patch:y,dims:{width:v,height:w,left:E,top:C}}=r[m];h.width=v,h.height=w,c.clearRect(0,0,v,w);const P=c.createImageData(v,w);P.data.set(y),c.putImageData(P,0,0),_===3&&(u=o.getImageData(0,0,a.width,a.height)),o.drawImage(h,E,C);const S=o.getImageData(0,0,a.width,a.height);_===2?o.clearRect(0,0,a.width,a.height):_===3&&o.putImageData(u,0,0),n.push({start:l,end:l+x,imageData:S}),l+=x}a.width=a.height=0,h.width=h.height=0;const{width:p,height:g}=i.lsd;return new gs(n,{width:p,height:g,...t})}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ot.shared.add(this.update,this,de.HIGH),this._isConnectedToTicker=!0),!this.loop&&this.currentFrame===this._frames.length-1&&(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(s){var n,a;if(!this._playing)return;const t=this.animationSpeed*s.deltaTime/ot.targetFPMS,e=this._currentTime+t,i=e%this.duration,r=this._frames.findIndex(o=>o.start<=i&&o.end>i);e>=this.duration?this.loop?(this._currentTime=i,this.updateFrameIndex(r),(n=this.onLoop)==null||n.call(this)):(this._currentTime=this.duration,this.updateFrameIndex(this._frames.length-1),(a=this.onComplete)==null||a.call(this),this.stop()):(this._currentTime=i,this.updateFrameIndex(r))}updateFrame(){if(!this.dirty)return;const{imageData:s}=this._frames[this._currentFrame];this._context.putImageData(s,0,0),this._context.fillStyle="transparent",this._context.fillRect(0,0,0,1),this.texture.source.update(),this.dirty=!1}get autoUpdate(){return this._autoUpdate}set autoUpdate(s){s!==this._autoUpdate&&(this._autoUpdate=s,!this._autoUpdate&&this._isConnectedToTicker?(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ot.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(s){this.updateFrameIndex(s),this._currentTime=this._frames[s].start}updateFrameIndex(s){var t;if(s<0||s>=this._frames.length)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${s}`);this._currentFrame!==s&&(this._currentFrame=s,this.dirty=!0,(t=this.onFrameChange)==null||t.call(this,s))}get totalFrames(){return this._frames.length}destroy(){this.stop(),super.destroy(!0);const s=null;this._context=s,this._frames=s,this.onComplete=s,this.onFrameChange=s,this.onLoop=s}clone(){const s=new gs([...this._frames],{autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,scaleMode:this.texture.source.scaleMode,animationSpeed:this.animationSpeed,width:this._context.canvas.width,height:this._context.canvas.height,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return s.dirty=!0,s}};let gn=gs;gn.defaultOptions={scaleMode:"linear",fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};const Y_={extension:b.Asset,detection:{test:async()=>!0,add:async s=>[...s,"gif"],remove:async s=>s.filter(t=>t!=="gif")},loader:{name:"gifLoader",test:s=>gt.extname(s)===".gif",load:async(s,t)=>{const i=await(await L.get().fetch(s)).arrayBuffer();return gn.fromBuffer(i,t==null?void 0:t.data)},unload:async s=>{s.destroy()}}};O.add(Y_);const nl={};class K_{constructor(){T(this,"container",new z);T(this,"emotes",[]);T(this,"moveSpeed",50);T(this,"alphaSpeed",1);T(this,"scaleSpeed",.5);T(this,"timer")}async add(t){const e=nl[t];let i;if(e)i=e.clone();else{const r=await fetch(t),n=r.headers.get("content-type");switch(n){case"image/gif":{const a=await r.arrayBuffer();i=gn.fromBuffer(a),nl[t]=i;break}case"image/png":{i=Tt.from(t);break}default:{console.warn("Unsupported content type: ",n);return}}}i&&(i.anchor.set(.5,.5),i.scale.set(0,0),this.emotes.push(i))}isAnimatedGIF(t){return t.currentFrame}update(t){var e;(e=this.timer)==null||e.tick(),(!this.timer||this.timer.isCompleted)&&this.emotes.length>0&&(this.timer=new Zt(2e3,()=>{const i=this.emotes.shift();i&&(this.isAnimatedGIF(i)&&(i.currentFrame=0),this.container.addChild(i))})),this.container.position.x=t.position.x??this.container.position.x,this.container.position.y=t.position.y??this.container.position.y;for(const i of this.container.children)i.position.y-=ae*this.moveSpeed/1e3,i.scale.x+=ae*this.scaleSpeed/1e3,i.scale.y+=ae*this.scaleSpeed/1e3,i.scale.x>1&&(i.alpha-=ae*this.alphaSpeed/1e3),i.alpha<=0&&this.container.removeChild(i)}}class q_{constructor(t){T(this,"container",new z);T(this,"animated",new z);T(this,"text",new Js({text:void 0,style:{fontFamily:"Custom Font",fontSize:20,fill:2236962,align:"left",breakWords:!0,wordWrap:!0,wordWrapWidth:200}}));T(this,"padding",10);T(this,"borderRadius",10);T(this,"boxColor",15658734);T(this,"boxBorderColor",2236962);T(this,"fadeShift",10);T(this,"isChecking",!0);T(this,"messageQueue",[]);T(this,"showTween");T(this,"hideTween");T(this,"timer");this.beforeShow=t,this.container.addChild(this.animated),this.text.anchor.set(.5,1),this.text.position.set(0,-this.padding)}trim(t){const e=Gt.measureText(t.text,t.style);return e.lines.length>4?e.lines.slice(0,4).join(" ").slice(0,-3)+"...":t.text}update(t){var i,r,n,a,o;if((i=this.timer)==null||i.tick(),(r=this.showTween)==null||r.update(),(n=this.hideTween)==null||n.update(),this.isChecking&&this.messageQueue.length>0){this.isChecking=!1;const h=this.messageQueue.shift();h&&(this.beforeShow(),this.show(h))}this.container.position.x=t.position.x??this.container.position.x,this.container.position.y=t.position.y??this.container.position.y;const e=((a=this.showTween)==null?void 0:a.isPlaying())||((o=this.hideTween)==null?void 0:o.isPlaying());!this.isChecking&&!e&&this.timer&&(this.animated.position.y=Math.sin(this.timer.current*.0025)*4-2)}add(t){this.messageQueue.push(t)}drawBox(t){const e={x:t.x-this.padding-t.width*t.anchor.x,y:t.y-this.padding-t.height*t.anchor.y,w:t.width+this.padding*2,h:t.height+this.padding*2},i=20,r=5,n=new rs;return n.moveTo(e.x+this.borderRadius,e.y),n.quadraticCurveTo(e.x,e.y,e.x,e.y+this.borderRadius,5),n.lineTo(e.x,e.y+e.h-this.borderRadius),n.quadraticCurveTo(e.x,e.y+e.h,e.x+this.borderRadius,e.y+e.h,5),n.lineTo(e.x+e.w/2-i/2,e.y+e.h),n.lineTo(e.x+e.w/2,e.y+e.h+r),n.lineTo(e.x+e.w/2+i/2,e.y+e.h),n.lineTo(e.x+e.w-this.borderRadius,e.y+e.h),n.quadraticCurveTo(e.x+e.w,e.y+e.h,e.x+e.w,e.y+e.h-this.borderRadius,5),n.lineTo(e.x+e.w,e.y+this.borderRadius),n.quadraticCurveTo(e.x+e.w,e.y,e.x+e.w-this.borderRadius,e.y,5),n.lineTo(e.x+this.borderRadius,e.y),n.fill({color:this.boxColor}),n.stroke({color:this.boxBorderColor,width:2}),n}show(t){this.text.text=t,this.text.text=this.trim(this.text),this.animated.alpha=0,this.animated.position.y=this.fadeShift;const e=this.drawBox(this.text);this.animated.removeChildren(),this.animated.addChild(e,this.text);const i={alpha:1,y:this.animated.y-this.fadeShift},r={alpha:0,y:this.animated.y+this.fadeShift};this.hideTween=new xe(this.animated).to(r,500).onComplete(()=>{this.isChecking=!0}),this.showTween=new xe(this.animated).to(i,500).onComplete(()=>{this.timer=new Zt(1e4,()=>{var n;(n=this.hideTween)==null||n.start()})}),this.showTween.start()}}class Z_{constructor(){T(this,"text",new Js({text:void 0,style:{fontFamily:"Custom Font",fontSize:18,fill:16777215,align:"center",stroke:{width:4,color:"black",join:"round"}}}));this.text.anchor.set(.5,1),this.text.zIndex=100}update(t){this.text.text=t.name??"",this.text.visible=t.isVisible,this.text.position.x=t.position.x??this.text.position.x,this.text.position.y=t.position.y??this.text.position.y}}class J_{constructor(t,e){T(this,"container",new z);T(this,"currentTag",dt.Idle);this.sprites=t,this.data=e,this.container.pivot.set(0,e.collider.y+e.collider.h),this.container.sortableChildren=!0;let i=0;for(const r in this.sprites){const n=this.sprites[r];for(const a in n){const o=n[a];o.zIndex=++i,o.anchor.set(.5,0),o.autoUpdate=!1,o.play()}}}getLayersByTag(t){return this.sprites[t]}setTag(t=dt.Idle){this.currentTag!=t&&this.container.removeChildren(),this.currentTag=t;const e=this.sprites[this.currentTag];for(const i in e){const r=e[i];this.container.addChild(r)}}update(t){const e=this.sprites[this.currentTag];for(const i in e){const r=e[i];if(t.play&&r.update(lt.ticker),t.color){for(const n in t.color)if(n==i){const a=t.color[n];a&&(r.alpha=a.alpha,r.tint=a)}}t.scale.x&&(r.animationSpeed=4/Math.abs(t.scale.x))}this.container.scale.set(t.scale.x,t.scale.y)}}class Q_{constructor(){T(this,"container",new z);T(this,"timer");T(this,"sprite");T(this,"opacityStep",.1);T(this,"shadowStep",50);lt.stage.addChild(this.container),this.container.zIndex=-100}setSprite(t){this.sprite=t}update(t){for(const e of this.container.children)e.alpha>0&&(e.alpha=e.alpha-this.opacityStep);if(this.timer&&!this.timer.isCompleted)this.timer.tick();else if(t.play){this.timer=new Zt(this.shadowStep);const e=new z;if(this.sprite){const i=this.sprite.getLayersByTag(dt.Idle);for(const r in i){const n=i[r],a=n.texture,o=new Tt(a);o.anchor.set(.5,0),o.alpha=n.alpha,o.tint=n.tint,e.addChild(o),e.scale.set(this.sprite.container.scale.x,this.sprite.container.scale.y),e.pivot.set(this.sprite.container.pivot.x,this.sprite.container.pivot.y);const h=this.sprite.container.getGlobalPosition();e.position.set(h.x,h.y)}}this.container.addChild(e)}}}const tx=async s=>{await new Promise(t=>setTimeout(()=>{t(void 0)},s))},al={fontFamily:"Custom Font",fontSize:14,fill:"white",align:"center",stroke:{width:4,color:"black",join:"round"}};class ex{constructor(){T(this,"containter",new z);T(this,"killText",new Js({text:void 0,style:al}));T(this,"killSprite");T(this,"jumpText",new Js({text:void 0,style:al}));T(this,"jumpSprite");T(this,"kills",0);T(this,"jumps",0);this.containter.zIndex=100,this.killSprite=this.createSprite("skull"),this.killText.anchor.set(0,.5),this.jumpSprite=this.createSprite("weight"),this.jumpText.anchor.set(0,.5)}addJumps(t){this.jumps+=t,this.draw()}addKill(){this.kills+=1,this.draw()}useJump(){this.jumps-=1,this.draw()}createSprite(t){const e=ft.get(t),i=Tt.from(e);return i.anchor.set(0,.5),i.scale.set(2,2),i.texture.source.scaleMode="nearest",i}draw(){const t=[];this.kills>0&&(t.push(this.killSprite),t.push(this.killText),this.killText.text=this.kills),this.jumps>0&&(t.push(this.jumpSprite),t.push(this.jumpText),this.jumpText.text=this.jumps);const e=4;let r=-(t.reduce((n,a)=>n+a.width,0)+e*(t.length-1))/2;this.containter.removeChildren();for(const n of t)n.position.set(r,0),r+=n.width+e,this.containter.addChild(n)}update(t){this.containter.position.x=t.position.x??this.containter.position.x,this.containter.position.y=t.position.y??this.containter.position.y}}const sx=(s,t)=>s.x<t.x+t.w&&s.x+s.w>t.x&&s.y<t.y+t.h&&s.y+s.h>t.y,ix=(s,t,e)=>{const i={...s,x:s.x+(e.x??0),y:s.y+(e.y??0)};return sx(i,t)?s.y+s.h<t.y&&i.y+i.h>=t.y:!1};class Ne{constructor(){T(this,"container",new z);T(this,"userState",{});T(this,"state",{name:"",sprite:"",color:new j("#969696"),direction:1,scale:1,isAnonymous:!1,isImmortal:!1,zIndex:0});T(this,"animationState",dt.Idle);T(this,"sprite");T(this,"trail",new Q_);T(this,"name",new Z_);T(this,"info",new ex);T(this,"message",new q_(()=>{this.state.zIndex=Et.zIndexEvotarMax(this.container.zIndex)}));T(this,"emoteSpitter",new K_);T(this,"velocity",{x:0,y:0});T(this,"runSpeed",.05);T(this,"gravity",.2);T(this,"dashAcc",3);T(this,"isJumping",!1);T(this,"isHitJumping",!1);T(this,"isDashing",!1);T(this,"isDespawned",!1);T(this,"isDead",!1);T(this,"deathTimer");T(this,"landTimer");T(this,"stateTimer");T(this,"scaleTimer");T(this,"spawnTween");T(this,"fadeTween");T(this,"scaleTween");T(this,"offset",0);T(this,"screenBounds",{left:this.offset,right:lt.renderer.width-this.offset});this.container.addChild(this.name.text),this.container.addChild(this.info.containter),this.container.addChild(this.emoteSpitter.container),this.container.addChild(this.message.container),this.container.sortableChildren=!0}getCenterOffsetY(){return this.sprite?this.sprite.data.collider.h/2*this.getScale():0}getCenterPosition(){return{x:this.container.position.x,y:this.container.position.y-this.getCenterOffsetY()}}setPosition(t){this.container.position=t}getScale(){return this.sprite?this.state.scale*this.sprite.data.scale:this.state.scale}getCollider(){if(this.sprite){const t=this.sprite.data.collider.x*this.getScale(),e=this.sprite.data.collider.h*this.getScale();return{x:this.container.position.x-t,y:this.container.position.y-e,w:this.sprite.data.collider.w*this.getScale(),h:this.sprite.data.collider.h*this.getScale()}}return{x:0,y:0,w:0,h:0}}async resurrect(){this.deathTimer&&this.deathTimer.complete()}async die(){this.state.isImmortal||(this.isDead=!0,this.container.visible=!1,Et.kill(this),this.deathTimer=new Zt(1e3*60*1,()=>{!this.isDespawned&&this.isDead&&(this.isDead=!1,this.container.visible=!0,this.state.scale=1,Et.resurrect(this))}))}spawn(t={isFalling:!1}){if(!this.sprite)return;const e=this.sprite.data.collider,i=this.sprite.data.size,r=-(e.y+e.h-i.h/2),n=t.isFalling?r:lt.renderer.height,a=i.w*this.getScale(),o=t.positionX!=null?t.positionX*this.screenBounds.right:Math.random()*(this.screenBounds.right-a)+a/2,h=n*this.getScale();if(this.container.x=o,this.container.y=h,this.state.direction=Math.random()>.5?1:-1,!t.isFalling){const c=Et.zIndexEvotarMin(this.container.zIndex);this.state.zIndex=c,this.container.alpha=0,this.spawnTween=new xe(this.container).to({alpha:1},500).onComplete(t.onComplete).start()}this.stateTimer=new Zt(5e3,()=>{!this.isJumping&&!this.isDead&&this.setAnimationState(dt.Run)})}despawn(t={}){this.fadeTween&&this.fadeTween.isPlaying()||(this.fadeTween=new xe(this.container).to({alpha:0},1e3).onComplete(()=>{this.isDespawned=!0,t.onComplete&&t.onComplete()}).start())}scale(t){this.scaleTween&&this.scaleTween.isPlaying()||this.scaleTimer&&!this.scaleTimer.isCompleted||(this.scaleTween=new xe(this).to({state:{scale:t.value??2}},2e3).onComplete(()=>{this.scaleTimer=new Zt((t.duration??10)*1e3,()=>{this.scaleTween=new xe(this).to({state:{scale:1}},2e3).start()})}).start())}addJumpHit(t){this.info.addJumps(t)}async jump(t){this.isDespawned||this.isJumping||(this.isJumping=!0,Qc.play("jump"),await tx(300),this.velocity.x=this.state.direction*((t==null?void 0:t.velocityX)??3.5),this.velocity.y=(t==null?void 0:t.velocityY)??-8,this.setAnimationState(dt.Jump),this.info.jumps>0&&(this.info.useJump(),this.isHitJumping=!0))}dash(t){this.isDespawned||this.isDashing||(this.isDashing=!0,this.velocity.x=this.state.direction*(t.force??14))}async setSprite(t){if(t&&t!=this.state.sprite){const e=await ui.getSpriteData(t);if(!e)return;this.sprite&&this.container.removeChild(this.sprite.container),this.state.sprite=t;const i=ui.getAnimatedSprites(t);this.sprite=new J_(i,e.data),this.container.addChild(this.sprite.container),this.trail.setSprite(this.sprite),this.setAnimationState(this.animationState,!0)}}async setProps(t){t.sprite&&await this.setSprite(t.sprite),this.state={...this.state,...t}}setUserProps(t){this.userState={...this.userState,...t}}move(){var i;if(!this.sprite)return;const t=this.sprite.data.collider,e={x:this.container.position.x,y:this.container.position.y};if(this.isDashing){const r=Math.sign(this.velocity.x);this.velocity.x=this.velocity.x-r*this.dashAcc/Math.abs(this.velocity.x),r!=Math.sign(this.velocity.x)?(this.isDashing=!1,this.velocity.x=0):e.x+=this.velocity.x}else{if((i=this.stateTimer)!=null&&i.isCompleted&&(this.stateTimer=new Zt(Math.random()*5e3,()=>{this.animationState==dt.Idle?this.setAnimationState(dt.Run):this.animationState==dt.Run&&this.setAnimationState(dt.Idle)})),this.animationState==dt.Run){const r=this.runSpeed*this.state.direction;this.velocity.x=r*ae}this.velocity.y=this.velocity.y+this.gravity,e.x+=this.velocity.x,e.y+=this.velocity.y,this.isOnGround(e.y)&&(this.velocity.y=0,this.velocity.x=0,e.y=lt.renderer.height,this.animationState==dt.Fall&&(this.setAnimationState(dt.Land),this.landTimer=new Zt(200,()=>{this.setAnimationState(dt.Idle),this.isJumping=!1,this.isHitJumping=!1}))),this.velocity.y>0&&this.setAnimationState(dt.Fall)}if(this.animationState!=dt.Idle||this.isDashing){const r=t.w/2*this.getScale(),n=this.container.x-r<this.screenBounds.left,a=this.container.x+r>this.screenBounds.right;(n||a)&&(this.state.direction=-this.state.direction,this.velocity.x=-this.velocity.x,n&&(e.x=this.screenBounds.left+r),a&&(e.x=this.screenBounds.right-r))}this.container.position.set(e.x,e.y),this.isHitJumping&&this.jumpHit()}jumpHit(){const t=Et.getViewerEvotars();for(const e in t){const i=t[e];if(i){const r=this.getCollider(),n=i.getCollider();i!=this&&ix(r,n,{x:this.velocity.x,y:this.velocity.y})&&!i.isDead&&!i.state.isImmortal&&(i.die(),this.info.addKill())}}}update(){var r,n,a,o,h,c,l;if(this.isDespawned||!this.sprite)return;(r=this.landTimer)==null||r.tick(),(n=this.stateTimer)==null||n.tick(),(a=this.scaleTimer)==null||a.tick(),(o=this.fadeTween)==null||o.update(),(h=this.spawnTween)==null||h.update(),(c=this.scaleTween)==null||c.update(),(l=this.deathTimer)==null||l.tick(),this.container.zIndex=this.state.zIndex;const t=this.sprite.data.collider;this.name.update({name:this.state.name,isVisible:!this.state.isAnonymous,position:{y:-t.h*this.getScale()}}),this.info.update({position:{y:this.name.text.position.y-this.name.text.height-6}}),this.message.update({position:{y:this.info.containter.position.y-this.info.containter.height-6}}),this.emoteSpitter.update({position:{y:this.message.container.position.y-this.message.container.height}}),this.isDead||this.move();const e=Object.fromEntries(this.sprite.data.colored.map(u=>[u,this.userState.color?this.userState.color:this.state.color])),i=this.sprite.data.flip?this.state.direction:1;this.sprite.update({color:e,scale:{x:i*this.getScale(),y:this.getScale()},play:!this.isDashing}),this.trail.update({play:this.isDashing})}isOnGround(t){return t>lt.renderer.height}addMessage(t){var e;this.message.add(t),this.state.isAnonymous=!1,(e=this.fadeTween)==null||e.stop(),this.fadeTween=void 0,this.container.alpha=1}async spitEmotes(t){for(const e of t)await this.emoteSpitter.add(e)}async setAnimationState(t,e=!1){this.animationState==t&&!e||(this.animationState=t,this.sprite&&this.sprite.setTag(t))}}class rx{play(t,e,i){const r=ft.get(t),n=ui.createAnimatedSprite(t,r);n&&(lt.stage.addChild(n),n.zIndex=1e3,n.scale.set(i,i),n.position.set(e.x,e.y),n.anchor.set(.5,.5),n.loop=!1,n.texture.source.scaleMode="nearest",n.play(),n.onComplete=()=>{lt.stage.removeChild(n)})}}const ol=new rx,nx=4;class ax{constructor(t){T(this,"container",new z);T(this,"sprite");T(this,"gravity",.2);T(this,"velocity",{x:0,y:0});T(this,"fadeTween");this.id=t;const e=Math.random()>.5?"rip1":"rip2",i=ft.get(e);this.sprite=Tt.from(i)}isOnGround(t){return t>lt.renderer.height}update(){const t={x:this.container.position.x,y:this.container.position.y};this.velocity.y=this.velocity.y+this.gravity,t.x+=this.velocity.x,t.y+=this.velocity.y,this.isOnGround(t.y)&&(this.velocity.y=0,this.velocity.x=0,t.y=lt.renderer.height),this.container.position.set(t.x,t.y)}despawn(t=!1,e=()=>{}){if(t)this.fadeTween=new xe(this.container).to({alpha:0},1e3).onComplete(e).start();else{const i={x:this.container.position.x,y:this.container.position.y-8*this.container.scale.x};ol.play("poof",i,this.container.scale.x),e()}}spawn(t){this.container.removeChildren(),this.container.addChild(this.sprite),this.container.position.set(t.position.x,(t.position.y??0)+this.sprite.height/2*t.scale),this.container.scale.set(nx),this.sprite.anchor.set(.5,1),this.sprite.texture.source.scaleMode="nearest",ol.play("poof",{x:t.position.x,y:t.position.y},t.scale)}}const ox=1e3*60*5;class hx{constructor(){T(this,"viewers",{});T(this,"tombstones",[]);T(this,"raiders",[]);T(this,"recentEvotarActivity",{});T(this,"subscriptions",[]);T(this,"hasActivity",t=>!!this.recentEvotarActivity[t])}subscribe(t){this.subscriptions.push(t)}update(){for(const t in this.viewers){const e=this.viewers[t];e&&e.update()}for(const t of this.raiders)t.update();for(const t of this.tombstones)t.update()}getViewerEvotars(){return this.viewers}getViewerEvotar(t){return this.viewers[t]}async spawnViewerEvotar(t,e,i){const r=new Ne;return this.addViewer(t,r),await r.setProps(e),r.spawn(i),this.recentEvotarActivity[t]=performance.now(),r}processRaid(t){if(!lt.settings.fallingRaiders)return;const e=1/t.viewers.count*5e3;for(let a=0;a<t.viewers.count;a++){const o=new Ne;o.setProps({isAnonymous:!0,zIndex:-1,sprite:t.viewers.sprite,color:new j(t.broadcaster.info.color)}),fn.add(e*a,()=>{this.addRaider(o),o.spawn({isFalling:!0})}),fn.add(a*e+6e4,()=>{o.despawn({onComplete:()=>{this.deleteRaider(o)}})})}const i=this.viewers[t.broadcaster.id],r={...this.prepareEvotarProps(t.broadcaster.info.displayName,t.broadcaster.info.color,t.broadcaster.info.sprite),scale:2,isImmortal:!0},n=()=>{const a=new Ne;a.setProps(r),this.addViewer(t.broadcaster.id,a),a.spawn({isFalling:!0,positionX:.5})};this.recentEvotarActivity[t.broadcaster.id]=performance.now(),i?i.despawn({onComplete:()=>{n()}}):n()}despawnEvotar(t,e){e.despawn({onComplete:()=>{this.deleteViewer(t,e)}});const i=this.tombstones.find(r=>r.id==t);i&&i.despawn(!0,()=>{this.deleteTombStone(i)})}async processChatters(t){for(const e in this.viewers){const i=this.recentEvotarActivity[e],r=!!i&&performance.now()-i<ox;if(t.every(n=>n.userId!=e)&&!r){const n=this.viewers[e];n&&this.despawnEvotar(e,n)}}if(lt.settings.showAnonymousEvotars){for(const e of t)if(!this.viewers[e.userId]){const r={name:e.name,isAnonymous:!this.hasActivity(e.userId)},n=new Ne;await n.setProps(r),n.spawn(),this.addViewer(e.userId,n)}}}doAction(t,e){if(Oc(t)&&e.jump({velocityX:t.data.velocityX,velocityY:t.data.velocityY}),Nc(t)&&e.dash({force:t.data.force}),Lc(t)){const i=k(t.data.color);i&&i.isValid()&&e.setUserProps({color:new j(t.data.color)})}Hc(t)&&e.scale({value:t.data.scale,duration:t.data.duration}),zc(t)&&e.setSprite(t.data.sprite),Wc(t)&&e.addJumpHit(t.data.count),Vc(t)&&e.resurrect()}prepareEvotarProps(t,e,i){const r={name:t,isAnonymous:!1};if(i&&(r.sprite=i),e)try{r.color=new j(e)}catch{}return r}async processAction(t){const e=this.viewers[t.userId],i=this.prepareEvotarProps(t.info.displayName,t.info.color,t.info.sprite);if(e)await e.setProps(i),this.doAction(t,e);else{const r=new Ne;this.addViewer(t.userId,r),await r.setProps(i),r.spawn({onComplete:()=>{const n=this.viewers[t.userId];n&&this.doAction(t,n)}})}}async processMessage(t){const e=this.prepareEvotarProps(t.info.displayName,t.info.color,t.info.sprite);let i=this.viewers[t.userId];if(i)i.setProps(e);else{const r=lt.settings.fallingEvotars?!this.hasActivity(t.userId):!1;i=new Ne,this.addViewer(t.userId,i),await i.setProps(e),i.spawn({isFalling:r})}this.recentEvotarActivity[t.userId]=performance.now(),t.message&&i.addMessage(t.message),t.emotes.length>0&&i.spitEmotes(t.emotes)}getViewerId(t){for(const e in this.viewers)if(this.viewers[e]==t)return e}resurrect(t){const e=this.getViewerId(t);if(e){const i=this.tombstones.find(r=>r.id==e);i&&(t.setPosition(i.container.position),i.despawn(),this.deleteTombStone(i))}}kill(t){const e=this.getViewerId(t);if(e){const i=new ax(e),r=t.getCenterPosition();this.addTombStone(i),i.spawn({position:r,scale:t.getScale()})}}addTombStone(t){lt.stage.addChild(t.container),this.tombstones.push(t)}deleteTombStone(t){lt.stage.removeChild(t.container),this.tombstones=this.tombstones.filter(e=>e!=t)}addViewer(t,e){this.subscriptions.forEach(i=>i.onAdd(e)),this.viewers[t]=e}deleteViewer(t,e){this.subscriptions.forEach(i=>i.onDelete(e)),delete this.viewers[t]}addRaider(t){this.subscriptions.forEach(e=>e.onAdd(t)),this.raiders.push(t)}deleteRaider(t){this.subscriptions.forEach(e=>e.onDelete(t)),this.raiders=this.raiders.filter(e=>e!=t)}zIndexEvotarMax(t){return Object.values(this.viewers).reduce((e,i)=>i&&e<=i.container.zIndex?i.container.zIndex+1:e,t)}zIndexEvotarMin(t){return Object.values(this.viewers).reduce((e,i)=>i&&e>=i.container.zIndex?i.container.zIndex-1:e,t)}}const Et=new hx;class cx{constructor(){T(this,"stage",new z);T(this,"evotars",{});T(this,"chatterIds",[]);T(this,"settings",{});T(this,"renderer");T(this,"ticker")}async initialize(t,e){ui.initialize(e.spriteLoaderFn),Qc.initialize(e.sounds),e.font&&await ft.load({src:e.font,data:{family:"Custom Font"}}),ft.add({alias:"poof",src:"/client/poof.json"}),ft.add({alias:"rip1",src:"/client/rip1.png"}),ft.add({alias:"rip2",src:"/client/rip2.png"}),ft.add({alias:"skull",src:"/client/skull.png"}),ft.add({alias:"weight",src:"/client/weight.png"}),await ft.load(["skull","weight","poof","rip1","rip2"]),this.ticker=new ot,this.ticker.deltaTime=ae*.06,this.renderer=await md({preference:"webgl"}),await this.renderer.init({width:t.clientWidth,height:t.clientHeight,backgroundAlpha:0}),t.appendChild(this.renderer.canvas),window.onresize=()=>{this.renderer.resize(t.clientWidth,t.clientHeight)},this.stage.sortableChildren=!0,Et.subscribe({onAdd:i=>this.stage.addChild(i.container),onDelete:i=>{this.stage.removeChild(i.container),this.stage.removeChild(i.trail.container)}})}updateSettings(t){this.settings=t}update(){fn.tick(),Et.update(),this.renderer.render(this.stage)}}const lt=new cx;class lx{constructor(t,e){T(this,"isRendered",!1);T(this,"processMessage",t=>Et.processMessage(t));T(this,"processAction",t=>Et.processAction(t));T(this,"processChatters",t=>Et.processChatters(t));T(this,"processRaid",t=>Et.processRaid(t));this.root=t,this.options=e}get manager(){return Et}updateSettings(t){lt.updateSettings(t)}async run(){if(this.isRendered)return;this.isRendered=!0,await(async()=>{await lt.initialize(this.root,this.options),performance.now();let e=-1;const r=1e3/60;requestAnimationFrame(n);function n(a=performance.now()){const o=a-e|0;o>r&&(e=a-o%r,lt.update()),requestAnimationFrame(n)}})()}}O.add(Ta),z.mixin(Bu),O.add(Ha),O.add(Na),O.add(bo),z.mixin(ip),O.add(bc),O.add(yr),O.add(Sc),O.add(Dc),O.add(Fc),O.add(Mc,Ug,Gg),O.add(dn),O.add(Rc),O.add(Ac),O.add(Tc),O.add(wo),O.add(vo);const ux=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),dx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));nt.Evotars=lx,nt.isAddJumpHitsUserActionEntity=Wc,nt.isColorUserActionEntity=Lc,nt.isDashUserActionEntity=Nc,nt.isGrowUserActionEntity=Hc,nt.isJumpUserActionEntity=Oc,nt.isResurrectUserActionEntity=Vc,nt.isSpriteUserActionEntity=zc,Object.defineProperty(nt,Symbol.toStringTag,{value:"Module"})});
|
|
980
|
+
`)}function Xg(s,t,e,i,r){const{domElement:n,styleElement:a,svgRoot:o}=r;n.innerHTML=`<style>${t.cssStyle}</style><div>${s}</div>`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),a.textContent=i;const{width:h,height:c}=r.image;return o.setAttribute("width",h.toString()),o.setAttribute("height",c.toString()),new XMLSerializer().serializeToString(o)}function Yg(s,t){const e=qt.getOptimalCanvasAndContext(s.width,s.height,t),{context:i}=e;return i.clearRect(0,0,s.width,s.height),i.drawImage(s,0,0),qt.returnCanvasAndContext(e),e.canvas}function Kg(s,t,e){return new Promise(async i=>{e&&await new Promise(r=>setTimeout(r,100)),s.onload=()=>{i()},s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,s.crossOrigin="anonymous"})}class dn{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===Lt.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,i,r){if(this._activeTextures[r])return this._increaseReferenceCount(r),this._activeTextures[r].promise;const n=this._buildTexturePromise(t,e,i).then(a=>(this._activeTextures[r].texture=a,a));return this._activeTextures[r]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(t,e,i){const r=$.get(Lo),n=Vg(t,i),a=await $g(n,i,Gr.defaultTextStyle),o=Ap(t,i,a,r),h=Math.ceil(Math.ceil(Math.max(1,o.width)+i.padding*2)*e),c=Math.ceil(Math.ceil(Math.max(1,o.height)+i.padding*2)*e),l=r.image;l.width=h|0,l.height=c|0;const u=Xg(t,i,e,a,r);await Kg(l,u,zg()&&n.length>0);let d=l;this._createCanvas&&(d=Yg(l,e));const f=kc(d,l.width,l.height,e);return this._createCanvas&&this._renderer.texture.initSource(f.source),$.return(r),f}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e):e.promise.then(i=>{e.texture=i,this._cleanUp(e)}).catch(()=>{D("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[t]=null))}_cleanUp(t){Pt.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}dn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"htmlText"},dn.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"};class Fc{constructor(t){this._gpuText=Object.create(null),this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t._getKey();if(e.currentKey!==i){const r=t.resolution??this._renderer.resolution,{width:n,height:a}=this._renderer.canvasText.getTextureSize(t.text,r,t._style);return!(this._renderer.canvasText.getReferenceCount(e.currentKey)===1&&n===e.texture._source.width&&a===e.texture._source.height)}return!1}addRenderable(t,e){const r=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(r)}updateRenderable(t){const i=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),i.batcher.updateElement(i)}destroyRenderable(t){this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.canvasText.decreaseReferenceCount(e.currentKey),$.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),i=this._getGpuText(t),r=i.batchableSprite;i.currentKey!==e&&this._updateGpuText(t),t._didTextUpdate=!1;const n=t._style.padding;Cs(r.bounds,t._anchor,r.texture,n)}_updateGpuText(t){const e=this._getGpuText(t),i=e.batchableSprite;e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),e.texture=i.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t._getKey(),i.texture=e.texture}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:null,currentKey:"--",batchableSprite:$.get(Qr)};return e.batchableSprite.renderable=t,e.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},e.batchableSprite.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,this._updateText(t),t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Fc.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"text"};function Gc(s,t,e){for(let i=0,r=4*e*t;i<t;++i,r+=4)if(s[r+3]!==0)return!1;return!0}function Uc(s,t,e,i,r){const n=4*t;for(let a=i,o=i*n+4*e;a<=r;++a,o+=n)if(s[o+3]!==0)return!1;return!0}function qg(s,t=1){const{width:e,height:i}=s,r=s.getContext("2d",{willReadFrequently:!0});if(r===null)throw new TypeError("Failed to get canvas 2D context");const a=r.getImageData(0,0,e,i).data;let o=0,h=0,c=e-1,l=i-1;for(;h<i&&Gc(a,e,h);)++h;if(h===i)return Y.EMPTY;for(;Gc(a,e,l);)--l;for(;Uc(a,e,o,h,l);)++o;for(;Uc(a,e,c,h,l);)--c;return++c,++l,new Y(o/t,h/t,(c-o)/t,(l-h)/t)}class Dc{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,i){const r=Gt.measureText(t||" ",i);let n=Math.ceil(Math.ceil(Math.max(1,r.width)+i.padding*2)*e),a=Math.ceil(Math.ceil(Math.max(1,r.height)+i.padding*2)*e);return n=Math.ceil(n-1e-6),a=Math.ceil(a-1e-6),n=Te(n),a=Te(a),{width:n,height:a}}getTexture(t,e,i,r){typeof t=="string"&&(N("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof me||(t.style=new me(t.style));const{texture:n,canvasAndContext:a}=this.createTextureAndCanvas(t);return this._renderer.texture.initSource(n._source),qt.returnCanvasAndContext(a),n}createTextureAndCanvas(t){const{text:e,style:i}=t,r=t.resolution??this._renderer.resolution,n=Gt.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,n.width)+i.padding*2)*r),o=Math.ceil(Math.ceil(Math.max(1,n.height)+i.padding*2)*r),h=qt.getOptimalCanvasAndContext(a,o),{canvas:c}=h;this.renderTextToCanvas(e,i,r,h);const l=kc(c,a,o,r);if(i.trim){const u=qg(c,r);l.frame.copyFrom(u),l.updateUvs()}return{texture:l,canvasAndContext:h}}getManagedTexture(t){const e=t._getKey();if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const{texture:i,canvasAndContext:r}=this.createTextureAndCanvas(t);return this._activeTextures[e]={canvasAndContext:r,texture:i,usageCount:1},i}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];if(e.usageCount--,e.usageCount===0){qt.returnCanvasAndContext(e.canvasAndContext),Pt.returnTexture(e.texture);const i=e.texture.source;i.resource=null,i.uploadMethodId="unknown",i.alphaMode="no-premultiply-alpha",this._activeTextures[t]=null}}getReferenceCount(t){return this._activeTextures[t].usageCount}renderTextToCanvas(t,e,i,r){var y,v,w,E,C;const{canvas:n,context:a}=r,o=Zs(e),h=Gt.measureText(t||" ",e),c=h.lines,l=h.lineHeight,u=h.lineWidths,d=h.maxLineWidth,f=h.fontProperties,p=n.height;a.resetTransform(),a.scale(i,i);const g=e.padding*2;if(a.clearRect(0,0,h.width+4+g,h.height+4+g),(y=e._stroke)!=null&&y.width){const P=e._stroke;a.lineWidth=P.width,a.miterLimit=P.miterLimit,a.lineJoin=P.join,a.lineCap=P.cap}a.font=o;let m,_;const x=e.dropShadow?2:1;for(let P=0;P<x;++P){const S=e.dropShadow&&P===0,A=S?Math.ceil(Math.max(1,p)+e.padding*2):0,Q=A*i;if(S){a.fillStyle="black",a.strokeStyle="black";const B=e.dropShadow,q=B.color,it=B.alpha;a.shadowColor=j.shared.setValue(q).setAlpha(it).toRgbaString();const vt=B.blur*i,_s=B.distance*i;a.shadowBlur=vt,a.shadowOffsetX=Math.cos(B.angle)*_s,a.shadowOffsetY=Math.sin(B.angle)*_s+Q}else a.globalAlpha=((v=e._fill)==null?void 0:v.alpha)??1,a.fillStyle=e._fill?Qs(e._fill,a):null,(w=e._stroke)!=null&&w.width&&(a.strokeStyle=Qs(e._stroke,a)),a.shadowColor="black";let Mt=(l-f.fontSize)/2;l-f.fontSize<0&&(Mt=0);const F=((E=e._stroke)==null?void 0:E.width)??0;for(let B=0;B<c.length;B++)m=F/2,_=F/2+B*l+f.ascent+Mt,e.align==="right"?m+=d-u[B]:e.align==="center"&&(m+=(d-u[B])/2),(C=e._stroke)!=null&&C.width&&this._drawLetterSpacing(c[B],e,r,m+e.padding,_+e.padding-A,!0),e._fill!==void 0&&this._drawLetterSpacing(c[B],e,r,m+e.padding,_+e.padding-A)}}_drawLetterSpacing(t,e,i,r,n,a=!1){const{context:o}=i,h=e.letterSpacing;let c=!1;if(Gt.experimentalLetterSpacingSupported&&(Gt.experimentalLetterSpacing?(o.letterSpacing=`${h}px`,o.textLetterSpacing=`${h}px`,c=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),h===0||c){a?o.strokeText(t,r,n):o.fillText(t,r,n);return}let l=r;const u=Gt.graphemeSegmenter(t);let d=o.measureText(t).width,f=0;for(let p=0;p<u.length;++p){const g=u[p];a?o.strokeText(g,l,n):o.fillText(g,l,n);let m="";for(let _=p+1;_<u.length;++_)m+=u[_];f=o.measureText(m).width,l+=d-f+h,d=f}}destroy(){this._activeTextures=null}}Dc.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"canvasText"},O.add(Ml,Bl);const ae=.02*1e3;class Zt{constructor(t=0,e){T(this,"isCompleted",!1);this.current=t,this.onComplete=e}tick(t=ae){this.isCompleted||(this.current-=t,this.current<0&&this.complete())}complete(){var t;this.isCompleted=!0,(t=this.onComplete)==null||t.call(this)}}class Zg{constructor(){T(this,"timers",[])}add(t,e){this.timers.push(new Zt(t,e))}tick(t=ae){const e=[];for(const i of this.timers)i.isCompleted||(i.tick(t),e.push(i));this.timers=e}}const fn=new Zg,Oc=s=>s.name=="jump",Lc=s=>s.name=="color",Hc=s=>s.name=="grow",Nc=s=>s.name=="dash",zc=s=>s.name=="sprite",Wc=s=>s.name=="add_jump_hits",Vc=s=>s.name=="resurrect";function ci(s){"@babel/helpers - typeof";return ci=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ci(s)}var Jg=/^\s+/,Qg=/\s+$/;function k(s,t){if(s=s||"",t=t||{},s instanceof k)return s;if(!(this instanceof k))return new k(s,t);var e=t_(s);this._originalInput=s,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||e.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}k.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),e,i,r,n,a,o;return e=t.r/255,i=t.g/255,r=t.b/255,e<=.03928?n=e/12.92:n=Math.pow((e+.055)/1.055,2.4),i<=.03928?a=i/12.92:a=Math.pow((i+.055)/1.055,2.4),r<=.03928?o=r/12.92:o=Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*a+.0722*o},setAlpha:function(t){return this._a=qc(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=$c(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=$c(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),r=Math.round(t.v*100);return this._a==1?"hsv("+e+", "+i+"%, "+r+"%)":"hsva("+e+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=jc(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=jc(this._r,this._g,this._b),e=Math.round(t.h*360),i=Math.round(t.s*100),r=Math.round(t.l*100);return this._a==1?"hsl("+e+", "+i+"%, "+r+"%)":"hsla("+e+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return Xc(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return r_(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(J(this._r,255)*100)+"%",g:Math.round(J(this._g,255)*100)+"%",b:Math.round(J(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(J(this._r,255)*100)+"%, "+Math.round(J(this._g,255)*100)+"%, "+Math.round(J(this._b,255)*100)+"%)":"rgba("+Math.round(J(this._r,255)*100)+"%, "+Math.round(J(this._g,255)*100)+"%, "+Math.round(J(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:g_[Xc(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+Yc(this._r,this._g,this._b,this._a),i=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var n=k(t);i="#"+Yc(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+i+")"},toString:function(t){var e=!!t;t=t||this._format;var i=!1,r=this._a<1&&this._a>=0,n=!e&&r&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(i=this.toRgbString()),t==="prgb"&&(i=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(i=this.toHexString()),t==="hex3"&&(i=this.toHexString(!0)),t==="hex4"&&(i=this.toHex8String(!0)),t==="hex8"&&(i=this.toHex8String()),t==="name"&&(i=this.toName()),t==="hsl"&&(i=this.toHslString()),t==="hsv"&&(i=this.toHsvString()),i||this.toHexString())},clone:function(){return k(this.toString())},_applyModification:function(t,e){var i=t.apply(null,[this].concat([].slice.call(e)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(h_,arguments)},brighten:function(){return this._applyModification(c_,arguments)},darken:function(){return this._applyModification(l_,arguments)},desaturate:function(){return this._applyModification(n_,arguments)},saturate:function(){return this._applyModification(a_,arguments)},greyscale:function(){return this._applyModification(o_,arguments)},spin:function(){return this._applyModification(u_,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(p_,arguments)},complement:function(){return this._applyCombination(d_,arguments)},monochromatic:function(){return this._applyCombination(m_,arguments)},splitcomplement:function(){return this._applyCombination(f_,arguments)},triad:function(){return this._applyCombination(Kc,[3])},tetrad:function(){return this._applyCombination(Kc,[4])}},k.fromRatio=function(s,t){if(ci(s)=="object"){var e={};for(var i in s)s.hasOwnProperty(i)&&(i==="a"?e[i]=s[i]:e[i]=fs(s[i]));s=e}return k(s,t)};function t_(s){var t={r:0,g:0,b:0},e=1,i=null,r=null,n=null,a=!1,o=!1;return typeof s=="string"&&(s=b_(s)),ci(s)=="object"&&(Jt(s.r)&&Jt(s.g)&&Jt(s.b)?(t=e_(s.r,s.g,s.b),a=!0,o=String(s.r).substr(-1)==="%"?"prgb":"rgb"):Jt(s.h)&&Jt(s.s)&&Jt(s.v)?(i=fs(s.s),r=fs(s.v),t=i_(s.h,i,r),a=!0,o="hsv"):Jt(s.h)&&Jt(s.s)&&Jt(s.l)&&(i=fs(s.s),n=fs(s.l),t=s_(s.h,i,n),a=!0,o="hsl"),s.hasOwnProperty("a")&&(e=s.a)),e=qc(e),{ok:a,format:s.format||o,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:e}}function e_(s,t,e){return{r:J(s,255)*255,g:J(t,255)*255,b:J(e,255)*255}}function jc(s,t,e){s=J(s,255),t=J(t,255),e=J(e,255);var i=Math.max(s,t,e),r=Math.min(s,t,e),n,a,o=(i+r)/2;if(i==r)n=a=0;else{var h=i-r;switch(a=o>.5?h/(2-i-r):h/(i+r),i){case s:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-s)/h+2;break;case e:n=(s-t)/h+4;break}n/=6}return{h:n,s:a,l:o}}function s_(s,t,e){var i,r,n;s=J(s,360),t=J(t,100),e=J(e,100);function a(c,l,u){return u<0&&(u+=1),u>1&&(u-=1),u<1/6?c+(l-c)*6*u:u<1/2?l:u<2/3?c+(l-c)*(2/3-u)*6:c}if(t===0)i=r=n=e;else{var o=e<.5?e*(1+t):e+t-e*t,h=2*e-o;i=a(h,o,s+1/3),r=a(h,o,s),n=a(h,o,s-1/3)}return{r:i*255,g:r*255,b:n*255}}function $c(s,t,e){s=J(s,255),t=J(t,255),e=J(e,255);var i=Math.max(s,t,e),r=Math.min(s,t,e),n,a,o=i,h=i-r;if(a=i===0?0:h/i,i==r)n=0;else{switch(i){case s:n=(t-e)/h+(t<e?6:0);break;case t:n=(e-s)/h+2;break;case e:n=(s-t)/h+4;break}n/=6}return{h:n,s:a,v:o}}function i_(s,t,e){s=J(s,360)*6,t=J(t,100),e=J(e,100);var i=Math.floor(s),r=s-i,n=e*(1-t),a=e*(1-r*t),o=e*(1-(1-r)*t),h=i%6,c=[e,a,n,n,o,e][h],l=[o,e,e,a,n,n][h],u=[n,n,o,e,e,a][h];return{r:c*255,g:l*255,b:u*255}}function Xc(s,t,e,i){var r=[Ut(Math.round(s).toString(16)),Ut(Math.round(t).toString(16)),Ut(Math.round(e).toString(16))];return i&&r[0].charAt(0)==r[0].charAt(1)&&r[1].charAt(0)==r[1].charAt(1)&&r[2].charAt(0)==r[2].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")}function r_(s,t,e,i,r){var n=[Ut(Math.round(s).toString(16)),Ut(Math.round(t).toString(16)),Ut(Math.round(e).toString(16)),Ut(Zc(i))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function Yc(s,t,e,i){var r=[Ut(Zc(i)),Ut(Math.round(s).toString(16)),Ut(Math.round(t).toString(16)),Ut(Math.round(e).toString(16))];return r.join("")}k.equals=function(s,t){return!s||!t?!1:k(s).toRgbString()==k(t).toRgbString()},k.random=function(){return k.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function n_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.s-=t/100,e.s=li(e.s),k(e)}function a_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.s+=t/100,e.s=li(e.s),k(e)}function o_(s){return k(s).desaturate(100)}function h_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.l+=t/100,e.l=li(e.l),k(e)}function c_(s,t){t=t===0?0:t||10;var e=k(s).toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(255*-(t/100)))),e.g=Math.max(0,Math.min(255,e.g-Math.round(255*-(t/100)))),e.b=Math.max(0,Math.min(255,e.b-Math.round(255*-(t/100)))),k(e)}function l_(s,t){t=t===0?0:t||10;var e=k(s).toHsl();return e.l-=t/100,e.l=li(e.l),k(e)}function u_(s,t){var e=k(s).toHsl(),i=(e.h+t)%360;return e.h=i<0?360+i:i,k(e)}function d_(s){var t=k(s).toHsl();return t.h=(t.h+180)%360,k(t)}function Kc(s,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var e=k(s).toHsl(),i=[k(s)],r=360/t,n=1;n<t;n++)i.push(k({h:(e.h+n*r)%360,s:e.s,l:e.l}));return i}function f_(s){var t=k(s).toHsl(),e=t.h;return[k(s),k({h:(e+72)%360,s:t.s,l:t.l}),k({h:(e+216)%360,s:t.s,l:t.l})]}function p_(s,t,e){t=t||6,e=e||30;var i=k(s).toHsl(),r=360/e,n=[k(s)];for(i.h=(i.h-(r*t>>1)+720)%360;--t;)i.h=(i.h+r)%360,n.push(k(i));return n}function m_(s,t){t=t||6;for(var e=k(s).toHsv(),i=e.h,r=e.s,n=e.v,a=[],o=1/t;t--;)a.push(k({h:i,s:r,v:n})),n=(n+o)%1;return a}k.mix=function(s,t,e){e=e===0?0:e||50;var i=k(s).toRgb(),r=k(t).toRgb(),n=e/100,a={r:(r.r-i.r)*n+i.r,g:(r.g-i.g)*n+i.g,b:(r.b-i.b)*n+i.b,a:(r.a-i.a)*n+i.a};return k(a)},k.readability=function(s,t){var e=k(s),i=k(t);return(Math.max(e.getLuminance(),i.getLuminance())+.05)/(Math.min(e.getLuminance(),i.getLuminance())+.05)},k.isReadable=function(s,t,e){var i=k.readability(s,t),r,n;switch(n=!1,r=v_(e),r.level+r.size){case"AAsmall":case"AAAlarge":n=i>=4.5;break;case"AAlarge":n=i>=3;break;case"AAAsmall":n=i>=7;break}return n},k.mostReadable=function(s,t,e){var i=null,r=0,n,a,o,h;e=e||{},a=e.includeFallbackColors,o=e.level,h=e.size;for(var c=0;c<t.length;c++)n=k.readability(s,t[c]),n>r&&(r=n,i=k(t[c]));return k.isReadable(s,i,{level:o,size:h})||!a?i:(e.includeFallbackColors=!1,k.mostReadable(s,["#fff","#000"],e))};var pn=k.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},g_=k.hexNames=__(pn);function __(s){var t={};for(var e in s)s.hasOwnProperty(e)&&(t[s[e]]=e);return t}function qc(s){return s=parseFloat(s),(isNaN(s)||s<0||s>1)&&(s=1),s}function J(s,t){x_(s)&&(s="100%");var e=y_(s);return s=Math.min(t,Math.max(0,parseFloat(s))),e&&(s=parseInt(s*t,10)/100),Math.abs(s-t)<1e-6?1:s%t/parseFloat(t)}function li(s){return Math.min(1,Math.max(0,s))}function bt(s){return parseInt(s,16)}function x_(s){return typeof s=="string"&&s.indexOf(".")!=-1&&parseFloat(s)===1}function y_(s){return typeof s=="string"&&s.indexOf("%")!=-1}function Ut(s){return s.length==1?"0"+s:""+s}function fs(s){return s<=1&&(s=s*100+"%"),s}function Zc(s){return Math.round(parseFloat(s)*255).toString(16)}function Jc(s){return bt(s)/255}var Dt=function(){var s="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",e="(?:"+t+")|(?:"+s+")",i="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",r="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+i),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+i),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+i),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Jt(s){return!!Dt.CSS_UNIT.exec(s)}function b_(s){s=s.replace(Jg,"").replace(Qg,"").toLowerCase();var t=!1;if(pn[s])s=pn[s],t=!0;else if(s=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var e;return(e=Dt.rgb.exec(s))?{r:e[1],g:e[2],b:e[3]}:(e=Dt.rgba.exec(s))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=Dt.hsl.exec(s))?{h:e[1],s:e[2],l:e[3]}:(e=Dt.hsla.exec(s))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=Dt.hsv.exec(s))?{h:e[1],s:e[2],v:e[3]}:(e=Dt.hsva.exec(s))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=Dt.hex8.exec(s))?{r:bt(e[1]),g:bt(e[2]),b:bt(e[3]),a:Jc(e[4]),format:t?"name":"hex8"}:(e=Dt.hex6.exec(s))?{r:bt(e[1]),g:bt(e[2]),b:bt(e[3]),format:t?"name":"hex"}:(e=Dt.hex4.exec(s))?{r:bt(e[1]+""+e[1]),g:bt(e[2]+""+e[2]),b:bt(e[3]+""+e[3]),a:Jc(e[4]+""+e[4]),format:t?"name":"hex8"}:(e=Dt.hex3.exec(s))?{r:bt(e[1]+""+e[1]),g:bt(e[2]+""+e[2]),b:bt(e[3]+""+e[3]),format:t?"name":"hex"}:!1}function v_(s){var t,e;return s=s||{level:"AA",size:"small"},t=(s.level||"AA").toUpperCase(),e=(s.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),e!=="small"&&e!=="large"&&(e="small"),{level:t,size:e}}var ps=Object.freeze({Linear:Object.freeze({None:function(s){return s},In:function(s){return s},Out:function(s){return s},InOut:function(s){return s}}),Quadratic:Object.freeze({In:function(s){return s*s},Out:function(s){return s*(2-s)},InOut:function(s){return(s*=2)<1?.5*s*s:-.5*(--s*(s-2)-1)}}),Cubic:Object.freeze({In:function(s){return s*s*s},Out:function(s){return--s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s:.5*((s-=2)*s*s+2)}}),Quartic:Object.freeze({In:function(s){return s*s*s*s},Out:function(s){return 1- --s*s*s*s},InOut:function(s){return(s*=2)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2)}}),Quintic:Object.freeze({In:function(s){return s*s*s*s*s},Out:function(s){return--s*s*s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2)}}),Sinusoidal:Object.freeze({In:function(s){return 1-Math.sin((1-s)*Math.PI/2)},Out:function(s){return Math.sin(s*Math.PI/2)},InOut:function(s){return .5*(1-Math.sin(Math.PI*(.5-s)))}}),Exponential:Object.freeze({In:function(s){return s===0?0:Math.pow(1024,s-1)},Out:function(s){return s===1?1:1-Math.pow(2,-10*s)},InOut:function(s){return s===0?0:s===1?1:(s*=2)<1?.5*Math.pow(1024,s-1):.5*(-Math.pow(2,-10*(s-1))+2)}}),Circular:Object.freeze({In:function(s){return 1-Math.sqrt(1-s*s)},Out:function(s){return Math.sqrt(1- --s*s)},InOut:function(s){return(s*=2)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1)}}),Elastic:Object.freeze({In:function(s){return s===0?0:s===1?1:-Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI)},Out:function(s){return s===0?0:s===1?1:Math.pow(2,-10*s)*Math.sin((s-.1)*5*Math.PI)+1},InOut:function(s){return s===0?0:s===1?1:(s*=2,s<1?-.5*Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI):.5*Math.pow(2,-10*(s-1))*Math.sin((s-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(s){var t=1.70158;return s===1?1:s*s*((t+1)*s-t)},Out:function(s){var t=1.70158;return s===0?0:--s*s*((t+1)*s+t)+1},InOut:function(s){var t=2.5949095;return(s*=2)<1?.5*(s*s*((t+1)*s-t)):.5*((s-=2)*s*((t+1)*s+t)+2)}}),Bounce:Object.freeze({In:function(s){return 1-ps.Bounce.Out(1-s)},Out:function(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},InOut:function(s){return s<.5?ps.Bounce.In(s*2)*.5:ps.Bounce.Out(s*2-1)*.5+.5}}),generatePow:function(s){return s===void 0&&(s=4),s=s<Number.EPSILON?Number.EPSILON:s,s=s>1e4?1e4:s,{In:function(t){return Math.pow(t,s)},Out:function(t){return 1-Math.pow(1-t,s)},InOut:function(t){return t<.5?Math.pow(t*2,s)/2:(1-Math.pow(2-t*2,s))/2+.5}}}}),ms=function(){return performance.now()},S_=function(){function s(){this._tweens={},this._tweensAddedDuringUpdate={}}return s.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},s.prototype.removeAll=function(){this._tweens={}},s.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},s.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},s.prototype.update=function(t,e){t===void 0&&(t=ms()),e===void 0&&(e=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<i.length;r++){var n=this._tweens[i[r]],a=!e;n&&n.update(t,a)===!1&&!e&&delete this._tweens[i[r]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},s}(),He={Linear:function(s,t){var e=s.length-1,i=e*t,r=Math.floor(i),n=He.Utils.Linear;return t<0?n(s[0],s[1],i):t>1?n(s[e],s[e-1],e-i):n(s[r],s[r+1>e?e:r+1],i-r)},Bezier:function(s,t){for(var e=0,i=s.length-1,r=Math.pow,n=He.Utils.Bernstein,a=0;a<=i;a++)e+=r(1-t,i-a)*r(t,a)*s[a]*n(i,a);return e},CatmullRom:function(s,t){var e=s.length-1,i=e*t,r=Math.floor(i),n=He.Utils.CatmullRom;return s[0]===s[e]?(t<0&&(r=Math.floor(i=e*(1+t))),n(s[(r-1+e)%e],s[r],s[(r+1)%e],s[(r+2)%e],i-r)):t<0?s[0]-(n(s[0],s[0],s[1],s[1],-i)-s[0]):t>1?s[e]-(n(s[e],s[e],s[e-1],s[e-1],i-e)-s[e]):n(s[r?r-1:0],s[r],s[e<r+1?e:r+1],s[e<r+2?e:r+2],i-r)},Utils:{Linear:function(s,t,e){return(t-s)*e+s},Bernstein:function(s,t){var e=He.Utils.Factorial;return e(s)/e(t)/e(s-t)},Factorial:function(){var s=[1];return function(t){var e=1;if(s[t])return s[t];for(var i=t;i>1;i--)e*=i;return s[t]=e,e}}(),CatmullRom:function(s,t,e,i,r){var n=(e-s)*.5,a=(i-t)*.5,o=r*r,h=r*o;return(2*t-2*e+n+a)*h+(-3*t+3*e-2*n-a)*o+n*r+t}}},w_=function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s}(),mn=new S_,xe=function(){function s(t,e){e===void 0&&(e=mn),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=ps.Linear.None,this._interpolationFunction=He.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=w_.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return s.prototype.getId=function(){return this._id},s.prototype.isPlaying=function(){return this._isPlaying},s.prototype.isPaused=function(){return this._isPaused},s.prototype.getDuration=function(){return this._duration},s.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},s.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t<0?0:t,this},s.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},s.prototype.start=function(t,e){if(t===void 0&&(t=ms()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var n in this._valuesEnd)r[n]=this._valuesEnd[n];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},s.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},s.prototype._setupProperties=function(t,e,i,r,n){for(var a in i){var o=t[a],h=Array.isArray(o),c=h?"array":typeof o,l=!h&&Array.isArray(i[a]);if(!(c==="undefined"||c==="function")){if(l){var u=i[a];if(u.length===0)continue;for(var d=[o],f=0,p=u.length;f<p;f+=1){var g=this._handleRelativeValue(o,u[f]);if(isNaN(g)){l=!1,console.warn("Found invalid interpolation list. Skipping.");break}d.push(g)}l&&(i[a]=d)}if((c==="object"||h)&&o&&!l){e[a]=h?[]:{};var m=o;for(var _ in m)e[a][_]=m[_];r[a]=h?[]:{};var u=i[a];if(!this._isDynamic){var x={};for(var _ in u)x[_]=u[_];i[a]=u=x}this._setupProperties(m,e[a],u,r[a],n)}else(typeof e[a]>"u"||n)&&(e[a]=o),h||(e[a]*=1),l?r[a]=i[a].slice().reverse():r[a]=e[a]||0}}},s.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},s.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},s.prototype.pause=function(t){return t===void 0&&(t=ms()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},s.prototype.resume=function(t){return t===void 0&&(t=ms()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},s.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},s.prototype.group=function(t){return t===void 0&&(t=mn),this._group=t,this},s.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},s.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},s.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},s.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},s.prototype.easing=function(t){return t===void 0&&(t=ps.Linear.None),this._easingFunction=t,this},s.prototype.interpolation=function(t){return t===void 0&&(t=He.Linear),this._interpolationFunction=t,this},s.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},s.prototype.onStart=function(t){return this._onStartCallback=t,this},s.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},s.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},s.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},s.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},s.prototype.onStop=function(t){return this._onStopCallback=t,this},s.prototype.update=function(t,e){var i;if(t===void 0&&(t=ms()),e===void 0&&(e=!0),this._isPaused)return!0;var r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>r)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var n=t-this._startTime,a=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),o=this._duration+this._repeat*a,h=this._calculateElapsedPortion(n,a,o),c=this._easingFunction(h),l=this._calculateCompletionStatus(n,a);if(l==="repeat"&&this._processRepetition(n,a),this._updateProperties(this._object,this._valuesStart,this._valuesEnd,c),l==="about-to-repeat"&&this._processRepetition(n,a),this._onUpdateCallback&&this._onUpdateCallback(this._object,h),l==="repeat"||l==="about-to-repeat")this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1;else if(l==="completed"){this._isPlaying=!1,this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var u=0,d=this._chainedTweens.length;u<d;u++)this._chainedTweens[u].start(this._startTime+this._duration,!1)}return l!=="completed"},s.prototype._calculateElapsedPortion=function(t,e,i){if(this._duration===0||t>i)return 1;var r=t%e,n=Math.min(r/this._duration,1);return n===0&&t!==0&&t%this._duration===0?1:n},s.prototype._calculateCompletionStatus=function(t,e){return this._duration!==0&&t<this._duration?"playing":this._repeat<=0?"completed":t===this._duration?"about-to-repeat":"repeat"},s.prototype._processRepetition=function(t,e){var i=Math.min(Math.trunc((t-this._duration)/e)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=i);for(var r in this._valuesStartRepeat){var n=this._valuesEnd[r];!this._yoyo&&typeof n=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(n)),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}this._yoyo&&(this._reversed=!this._reversed),this._startTime+=e*i},s.prototype._updateProperties=function(t,e,i,r){for(var n in i)if(e[n]!==void 0){var a=e[n]||0,o=i[n],h=Array.isArray(t[n]),c=Array.isArray(o),l=!h&&c;l?t[n]=this._interpolationFunction(o,r):typeof o=="object"&&o?this._updateProperties(t[n],a,o,r):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(t[n]=a+(o-a)*r))}},s.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},s.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],i=this._valuesEnd[t];typeof i=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(i):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},s}(),Nt=mn;Nt.getAll.bind(Nt),Nt.removeAll.bind(Nt),Nt.add.bind(Nt),Nt.remove.bind(Nt),Nt.update.bind(Nt);class T_{constructor(){T(this,"assets",{})}async initialize(t){this.assets=Object.fromEntries(Array.from(Object.entries(t??{})).map(([e,i])=>[e,new Audio(i.src)]))}play(t){const e=this.assets[t];e&&(e.volume=.3,e.pause(),e.currentTime=0,e.play())}}const Qc=new T_;var dt=(s=>(s.Idle="Idle",s.Jump="Jump",s.Fall="Fall",s.Land="Land",s.Run="Run",s.Die="Die",s))(dt||{});class A_{constructor(){T(this,"spriteLoaderFn");T(this,"sprites",{})}initialize(t){this.spriteLoaderFn=t}async getSpriteData(t){const e=await this.spriteLoaderFn(t);if(!e)return;if(this.sprites[t])return this.sprites[t];const i=await ft.load(e.image),r=new Ni(i,e.sprite);return await r.parse(),this.sprites[t]={sheet:r,data:{...e.data,scale:e.data.scale??1}},this.sprites[t]}createAnimatedSprite(t,e){for(const i of e.data.meta.frameTags??[]){const r=[];for(let a=i.from;a<=i.to;a++){const o=a.toString(),h=t+"_"+o,c=e.textures[h],l=e.data.frames[h].duration;r.push({texture:c,time:l})}const n=new ns(r);return n.texture.source.scaleMode="nearest",n}}getAnimatedSprites(t){if(!t)throw Error("Sheet is not defined");if(!this.sprites[t])throw Error("Sprite is not loaded");const e=this.sprites[t].data,i=this.sprites[t].sheet,r={};for(const n of i.data.meta.frameTags??[]){if(!i.data.meta.layers)throw Error("Layers are not defined");const a={};for(const o of i.data.meta.layers){const h=[];for(let l=n.from;l<=n.to;l++){const u=l.toString(),d=e.name+"_"+o.name+"_"+u,f=i.textures[d],p=i.data.frames[d].duration;h.push({texture:f,time:p})}const c=new ns(h);c.texture.source.scaleMode="nearest",a[o.name]=c}n.name&&(r[n.name]=a)}return r}}const ui=new A_;var ye={},tl={},Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.loop=Qt.conditional=Qt.parse=void 0;var P_=function s(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;if(Array.isArray(e))e.forEach(function(a){return s(t,a,i,r)});else if(typeof e=="function")e(t,i,r,s);else{var n=Object.keys(e)[0];Array.isArray(e[n])?(r[n]={},s(t,e[n],i,r[n])):r[n]=e[n](t,i,r,s)}return i};Qt.parse=P_;var C_=function(t,e){return function(i,r,n,a){e(i,r,n)&&a(i,t,r,n)}};Qt.conditional=C_;var E_=function(t,e){return function(i,r,n,a){for(var o=[],h=i.pos;e(i,r,n);){var c={};if(a(i,t,r,c),i.pos===h)break;h=i.pos,o.push(c)}return o}};Qt.loop=E_;var rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.readBits=rt.readArray=rt.readUnsigned=rt.readString=rt.peekBytes=rt.readBytes=rt.peekByte=rt.readByte=rt.buildStream=void 0;var M_=function(t){return{data:t,pos:0}};rt.buildStream=M_;var el=function(){return function(t){return t.data[t.pos++]}};rt.readByte=el;var B_=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(e){return e.data[e.pos+t]}};rt.peekByte=B_;var di=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};rt.readBytes=di;var R_=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}};rt.peekBytes=R_;var k_=function(t){return function(e){return Array.from(di(t)(e)).map(function(i){return String.fromCharCode(i)}).join("")}};rt.readString=k_;var I_=function(t){return function(e){var i=di(2)(e);return t?(i[1]<<8)+i[0]:(i[0]<<8)+i[1]}};rt.readUnsigned=I_;var F_=function(t,e){return function(i,r,n){for(var a=typeof e=="function"?e(i,r,n):e,o=di(t),h=new Array(a),c=0;c<a;c++)h[c]=o(i);return h}};rt.readArray=F_;var G_=function(t,e,i){for(var r=0,n=0;n<i;n++)r+=t[e+n]&&Math.pow(2,i-n-1);return r},U_=function(t){return function(e){for(var i=el()(e),r=new Array(8),n=0;n<8;n++)r[7-n]=!!(i&1<<n);return Object.keys(t).reduce(function(a,o){var h=t[o];return h.length?a[o]=G_(r,h.index,h.length):a[o]=r[h.index],a},{})}};rt.readBits=U_,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var t=Qt,e=rt,i={blocks:function(d){for(var f=0,p=[],g=d.data.length,m=0,_=(0,e.readByte)()(d);_!==f&&_;_=(0,e.readByte)()(d)){if(d.pos+_>=g){var x=g-d.pos;p.push((0,e.readBytes)(x)(d)),m+=x;break}p.push((0,e.readBytes)(_)(d)),m+=_}for(var y=new Uint8Array(m),v=0,w=0;w<p.length;w++)y.set(p[w],v),v+=p[w].length;return y}},r=(0,t.conditional)({gce:[{codes:(0,e.readBytes)(2)},{byteSize:(0,e.readByte)()},{extras:(0,e.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,e.readUnsigned)(!0)},{transparentColorIndex:(0,e.readByte)()},{terminator:(0,e.readByte)()}]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===249}),n=(0,t.conditional)({image:[{code:(0,e.readByte)()},{descriptor:[{left:(0,e.readUnsigned)(!0)},{top:(0,e.readUnsigned)(!0)},{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{lct:(0,e.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,t.conditional)({lct:(0,e.readArray)(3,function(u,d,f){return Math.pow(2,f.descriptor.lct.size+1)})},function(u,d,f){return f.descriptor.lct.exists}),{data:[{minCodeSize:(0,e.readByte)()},i]}]},function(u){return(0,e.peekByte)()(u)===44}),a=(0,t.conditional)({text:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{preData:function(d,f,p){return(0,e.readBytes)(p.text.blockSize)(d)}},i]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===1}),o=(0,t.conditional)({application:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{id:function(d,f,p){return(0,e.readString)(p.blockSize)(d)}},i]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===255}),h=(0,t.conditional)({comment:[{codes:(0,e.readBytes)(2)},i]},function(u){var d=(0,e.peekBytes)(2)(u);return d[0]===33&&d[1]===254}),c=[{header:[{signature:(0,e.readString)(3)},{version:(0,e.readString)(3)}]},{lsd:[{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{gct:(0,e.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,e.readByte)()},{pixelAspectRatio:(0,e.readByte)()}]},(0,t.conditional)({gct:(0,e.readArray)(3,function(u,d){return Math.pow(2,d.lsd.gct.size+1)})},function(u,d){return d.lsd.gct.exists}),{frames:(0,t.loop)([r,o,h,n,a],function(u){var d=(0,e.peekByte)()(u);return d===33||d===44})}],l=c;s.default=l}(tl);var fi={};Object.defineProperty(fi,"__esModule",{value:!0}),fi.deinterlace=void 0;var D_=function(t,e){for(var i=new Array(t.length),r=t.length/e,n=function(d,f){var p=t.slice(f*e,(f+1)*e);i.splice.apply(i,[d*e,e].concat(p))},a=[0,4,2,1],o=[8,8,4,2],h=0,c=0;c<4;c++)for(var l=a[c];l<r;l+=o[c])n(l,h),h++;return i};fi.deinterlace=D_;var pi={};Object.defineProperty(pi,"__esModule",{value:!0}),pi.lzw=void 0;var O_=function(t,e,i){var r=4096,n=-1,a=i,o,h,c,l,u,d,f,E,p,g,w,m,C,P,A,S,_=new Array(i),x=new Array(r),y=new Array(r),v=new Array(r+1);for(m=t,h=1<<m,u=h+1,o=h+2,f=n,l=m+1,c=(1<<l)-1,p=0;p<h;p++)x[p]=0,y[p]=p;var w,E,C,P,S,A;for(w=E=C=P=S=A=0,g=0;g<a;){if(P===0){if(E<l){w+=e[A]<<E,E+=8,A++;continue}if(p=w&c,w>>=l,E-=l,p>o||p==u)break;if(p==h){l=m+1,c=(1<<l)-1,o=h+2,f=n;continue}if(f==n){v[P++]=y[p],f=p,C=p;continue}for(d=p,p==o&&(v[P++]=C,p=f);p>h;)v[P++]=y[p],p=x[p];C=y[p]&255,v[P++]=C,o<r&&(x[o]=f,y[o]=C,o++,!(o&c)&&o<r&&(l++,c+=o)),f=d}P--,_[S++]=v[P],g++}for(g=S;g<a;g++)_[g]=0;return _};pi.lzw=O_,Object.defineProperty(ye,"__esModule",{value:!0});var sl=ye.decompressFrames=ye.decompressFrame=il=ye.parseGIF=void 0,L_=V_(tl),H_=Qt,N_=rt,z_=fi,W_=pi;function V_(s){return s&&s.__esModule?s:{default:s}}var j_=function(t){var e=new Uint8Array(t);return(0,H_.parse)((0,N_.buildStream)(e),L_.default)},il=ye.parseGIF=j_,$_=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(e*4),r=0;r<e;r++){var n=r*4,a=t.pixels[r],o=t.colorTable[a]||[0,0,0];i[n]=o[0],i[n+1]=o[1],i[n+2]=o[2],i[n+3]=a!==t.transparentIndex?255:0}return i},rl=function(t,e,i){if(!t.image){console.warn("gif frame does not have associated image.");return}var r=t.image,n=r.descriptor.width*r.descriptor.height,a=(0,W_.lzw)(r.data.minCodeSize,r.data.blocks,n);r.descriptor.lct.interlaced&&(a=(0,z_.deinterlace)(a,r.descriptor.width));var o={pixels:a,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return r.descriptor.lct&&r.descriptor.lct.exists?o.colorTable=r.lct:o.colorTable=e,t.gce&&(o.delay=(t.gce.delay||10)*10,o.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(o.transparentIndex=t.gce.transparentColorIndex)),i&&(o.patch=$_(o)),o};ye.decompressFrame=rl;var X_=function(t,e){return t.frames.filter(function(i){return i.image}).map(function(i){return rl(i,t.gct,e)})};sl=ye.decompressFrames=X_;const gs=class extends Tt{constructor(s,t){super(M.EMPTY),this.animationSpeed=1,this.loop=!0,this.duration=0,this.autoPlay=!0,this.dirty=!1,this._currentFrame=0,this._autoUpdate=!1,this._isConnectedToTicker=!1,this._playing=!1,this._currentTime=0,this.onRender=()=>this.updateFrame();const{scaleMode:e,width:i,height:r,...n}=Object.assign({},gs.defaultOptions,t),a=L.get().createCanvas(i,r),o=a.getContext("2d");this.texture=M.from(a),this.texture.source.scaleMode=e,this.duration=s[s.length-1].end,this._frames=s,this._context=o,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,n),this.currentFrame=0,n.autoPlay&&this.play()}static fromBuffer(s,t){if(!s||s.byteLength===0)throw new Error("Invalid buffer");const e=m=>{let _=null;for(const x of m.frames)_=x.gce??_,"image"in x&&!("gce"in x)&&(x.gce=_)},i=il(s);e(i);const r=sl(i,!0),n=[],a=L.get().createCanvas(i.lsd.width,i.lsd.height),o=a.getContext("2d",{willReadFrequently:!0}),h=L.get().createCanvas(),c=h.getContext("2d");let l=0,u=null;const{fps:d}=Object.assign({},gs.defaultOptions,t),f=1e3/d;for(let m=0;m<r.length;m++){const{disposalType:_=2,delay:x=f,patch:y,dims:{width:v,height:w,left:E,top:C}}=r[m];h.width=v,h.height=w,c.clearRect(0,0,v,w);const P=c.createImageData(v,w);P.data.set(y),c.putImageData(P,0,0),_===3&&(u=o.getImageData(0,0,a.width,a.height)),o.drawImage(h,E,C);const S=o.getImageData(0,0,a.width,a.height);_===2?o.clearRect(0,0,a.width,a.height):_===3&&o.putImageData(u,0,0),n.push({start:l,end:l+x,imageData:S}),l+=x}a.width=a.height=0,h.width=h.height=0;const{width:p,height:g}=i.lsd;return new gs(n,{width:p,height:g,...t})}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ot.shared.add(this.update,this,de.HIGH),this._isConnectedToTicker=!0),!this.loop&&this.currentFrame===this._frames.length-1&&(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(s){var n,a;if(!this._playing)return;const t=this.animationSpeed*s.deltaTime/ot.targetFPMS,e=this._currentTime+t,i=e%this.duration,r=this._frames.findIndex(o=>o.start<=i&&o.end>i);e>=this.duration?this.loop?(this._currentTime=i,this.updateFrameIndex(r),(n=this.onLoop)==null||n.call(this)):(this._currentTime=this.duration,this.updateFrameIndex(this._frames.length-1),(a=this.onComplete)==null||a.call(this),this.stop()):(this._currentTime=i,this.updateFrameIndex(r))}updateFrame(){if(!this.dirty)return;const{imageData:s}=this._frames[this._currentFrame];this._context.putImageData(s,0,0),this._context.fillStyle="transparent",this._context.fillRect(0,0,0,1),this.texture.source.update(),this.dirty=!1}get autoUpdate(){return this._autoUpdate}set autoUpdate(s){s!==this._autoUpdate&&(this._autoUpdate=s,!this._autoUpdate&&this._isConnectedToTicker?(ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ot.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(s){this.updateFrameIndex(s),this._currentTime=this._frames[s].start}updateFrameIndex(s){var t;if(s<0||s>=this._frames.length)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${s}`);this._currentFrame!==s&&(this._currentFrame=s,this.dirty=!0,(t=this.onFrameChange)==null||t.call(this,s))}get totalFrames(){return this._frames.length}destroy(){this.stop(),super.destroy(!0);const s=null;this._context=s,this._frames=s,this.onComplete=s,this.onFrameChange=s,this.onLoop=s}clone(){const s=new gs([...this._frames],{autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,scaleMode:this.texture.source.scaleMode,animationSpeed:this.animationSpeed,width:this._context.canvas.width,height:this._context.canvas.height,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return s.dirty=!0,s}};let gn=gs;gn.defaultOptions={scaleMode:"linear",fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};const Y_={extension:b.Asset,detection:{test:async()=>!0,add:async s=>[...s,"gif"],remove:async s=>s.filter(t=>t!=="gif")},loader:{name:"gifLoader",test:s=>gt.extname(s)===".gif",load:async(s,t)=>{const i=await(await L.get().fetch(s)).arrayBuffer();return gn.fromBuffer(i,t==null?void 0:t.data)},unload:async s=>{s.destroy()}}};O.add(Y_);const nl={};class K_{constructor(){T(this,"container",new z);T(this,"emotes",[]);T(this,"moveSpeed",50);T(this,"alphaSpeed",1);T(this,"scaleSpeed",.5);T(this,"timer")}async add(t){const e=nl[t];let i;if(e)i=e.clone();else{const r=await fetch(t),n=r.headers.get("content-type");switch(n){case"image/gif":{const a=await r.arrayBuffer();i=gn.fromBuffer(a),nl[t]=i;break}case"image/png":{i=Tt.from(t);break}default:{console.warn("Unsupported content type: ",n);return}}}i&&(i.anchor.set(.5,.5),i.scale.set(0,0),this.emotes.push(i))}isAnimatedGIF(t){return t.currentFrame}update(t){var e;(e=this.timer)==null||e.tick(),(!this.timer||this.timer.isCompleted)&&this.emotes.length>0&&(this.timer=new Zt(2e3,()=>{const i=this.emotes.shift();i&&(this.isAnimatedGIF(i)&&(i.currentFrame=0),this.container.addChild(i))})),this.container.position.x=t.position.x??this.container.position.x,this.container.position.y=t.position.y??this.container.position.y;for(const i of this.container.children)i.position.y-=ae*this.moveSpeed/1e3,i.scale.x+=ae*this.scaleSpeed/1e3,i.scale.y+=ae*this.scaleSpeed/1e3,i.scale.x>1&&(i.alpha-=ae*this.alphaSpeed/1e3),i.alpha<=0&&this.container.removeChild(i)}}class q_{constructor(t){T(this,"container",new z);T(this,"animated",new z);T(this,"text",new Js({text:void 0,style:{fontFamily:"Custom Font",fontSize:20,fill:2236962,align:"left",breakWords:!0,wordWrap:!0,wordWrapWidth:200}}));T(this,"padding",10);T(this,"borderRadius",10);T(this,"boxColor",15658734);T(this,"boxBorderColor",2236962);T(this,"fadeShift",10);T(this,"isChecking",!0);T(this,"messageQueue",[]);T(this,"showTween");T(this,"hideTween");T(this,"timer");this.beforeShow=t,this.container.addChild(this.animated),this.text.anchor.set(.5,1),this.text.position.set(0,-this.padding)}trim(t){const e=Gt.measureText(t.text,t.style);return e.lines.length>4?e.lines.slice(0,4).join(" ").slice(0,-3)+"...":t.text}update(t){var i,r,n,a,o;if((i=this.timer)==null||i.tick(),(r=this.showTween)==null||r.update(),(n=this.hideTween)==null||n.update(),this.isChecking&&this.messageQueue.length>0){this.isChecking=!1;const h=this.messageQueue.shift();h&&(this.beforeShow(),this.show(h))}this.container.position.x=t.position.x??this.container.position.x,this.container.position.y=t.position.y??this.container.position.y;const e=((a=this.showTween)==null?void 0:a.isPlaying())||((o=this.hideTween)==null?void 0:o.isPlaying());!this.isChecking&&!e&&this.timer&&(this.animated.position.y=Math.sin(this.timer.current*.0025)*4-2)}add(t){this.messageQueue.push(t)}drawBox(t){const e={x:t.x-this.padding-t.width*t.anchor.x,y:t.y-this.padding-t.height*t.anchor.y,w:t.width+this.padding*2,h:t.height+this.padding*2},i=20,r=5,n=new rs;return n.moveTo(e.x+this.borderRadius,e.y),n.quadraticCurveTo(e.x,e.y,e.x,e.y+this.borderRadius,5),n.lineTo(e.x,e.y+e.h-this.borderRadius),n.quadraticCurveTo(e.x,e.y+e.h,e.x+this.borderRadius,e.y+e.h,5),n.lineTo(e.x+e.w/2-i/2,e.y+e.h),n.lineTo(e.x+e.w/2,e.y+e.h+r),n.lineTo(e.x+e.w/2+i/2,e.y+e.h),n.lineTo(e.x+e.w-this.borderRadius,e.y+e.h),n.quadraticCurveTo(e.x+e.w,e.y+e.h,e.x+e.w,e.y+e.h-this.borderRadius,5),n.lineTo(e.x+e.w,e.y+this.borderRadius),n.quadraticCurveTo(e.x+e.w,e.y,e.x+e.w-this.borderRadius,e.y,5),n.lineTo(e.x+this.borderRadius,e.y),n.fill({color:this.boxColor}),n.stroke({color:this.boxBorderColor,width:2}),n}show(t){this.text.text=t,this.text.text=this.trim(this.text),this.animated.alpha=0,this.animated.position.y=this.fadeShift;const e=this.drawBox(this.text);this.animated.removeChildren(),this.animated.addChild(e,this.text);const i={alpha:1,y:this.animated.y-this.fadeShift},r={alpha:0,y:this.animated.y+this.fadeShift};this.hideTween=new xe(this.animated).to(r,500).onComplete(()=>{this.isChecking=!0}),this.showTween=new xe(this.animated).to(i,500).onComplete(()=>{this.timer=new Zt(1e4,()=>{var n;(n=this.hideTween)==null||n.start()})}),this.showTween.start()}}class Z_{constructor(){T(this,"text",new Js({text:void 0,style:{fontFamily:"Custom Font",fontSize:18,fill:16777215,align:"center",stroke:{width:4,color:"black",join:"round"}}}));this.text.anchor.set(.5,1),this.text.zIndex=100}update(t){this.text.text=t.name??"",this.text.visible=t.isVisible,this.text.position.x=t.position.x??this.text.position.x,this.text.position.y=t.position.y??this.text.position.y}}class J_{constructor(t,e){T(this,"container",new z);T(this,"currentTag",dt.Idle);this.sprites=t,this.data=e,this.container.pivot.set(0,e.collider.y+e.collider.h),this.container.sortableChildren=!0;let i=0;for(const r in this.sprites){const n=this.sprites[r];for(const a in n){const o=n[a];o.zIndex=++i,o.anchor.set(.5,0),o.autoUpdate=!1,o.play()}}}getLayersByTag(t){return this.sprites[t]}setTag(t=dt.Idle){this.currentTag!=t&&this.container.removeChildren(),this.currentTag=t;const e=this.sprites[this.currentTag];for(const i in e){const r=e[i];this.container.addChild(r)}}update(t){const e=this.sprites[this.currentTag];for(const i in e){const r=e[i];if(t.play&&r.update(lt.ticker),t.color){for(const n in t.color)if(n==i){const a=t.color[n];a&&(r.alpha=a.alpha,r.tint=a)}}t.scale.x&&(r.animationSpeed=4/Math.abs(t.scale.x))}this.container.scale.set(t.scale.x,t.scale.y)}}class Q_{constructor(){T(this,"container",new z);T(this,"timer");T(this,"sprite");T(this,"opacityStep",.1);T(this,"shadowStep",50);lt.stage.addChild(this.container),this.container.zIndex=-100}setSprite(t){this.sprite=t}update(t){for(const e of this.container.children)e.alpha>0&&(e.alpha=e.alpha-this.opacityStep);if(this.timer&&!this.timer.isCompleted)this.timer.tick();else if(t.play){this.timer=new Zt(this.shadowStep);const e=new z;if(this.sprite){const i=this.sprite.getLayersByTag(dt.Idle);for(const r in i){const n=i[r],a=n.texture,o=new Tt(a);o.anchor.set(.5,0),o.alpha=n.alpha,o.tint=n.tint,e.addChild(o),e.scale.set(this.sprite.container.scale.x,this.sprite.container.scale.y),e.pivot.set(this.sprite.container.pivot.x,this.sprite.container.pivot.y);const h=this.sprite.container.getGlobalPosition();e.position.set(h.x,h.y)}}this.container.addChild(e)}}}const tx=async s=>{await new Promise(t=>setTimeout(()=>{t(void 0)},s))},al={fontFamily:"Custom Font",fontSize:14,fill:"white",align:"center",stroke:{width:4,color:"black",join:"round"}};class ex{constructor(){T(this,"containter",new z);T(this,"killText",new Js({text:void 0,style:al}));T(this,"killSprite");T(this,"jumpText",new Js({text:void 0,style:al}));T(this,"jumpSprite");T(this,"kills",0);T(this,"jumps",0);this.containter.zIndex=100,this.killSprite=this.createSprite("skull"),this.killText.anchor.set(0,.5),this.jumpSprite=this.createSprite("weight"),this.jumpText.anchor.set(0,.5)}addJumps(t){this.jumps+=t,this.draw()}addKill(){this.kills+=1,this.draw()}useJump(){this.jumps-=1,this.draw()}createSprite(t){const e=ft.get(t),i=Tt.from(e);return i.anchor.set(0,.5),i.scale.set(2,2),i.texture.source.scaleMode="nearest",i}draw(){const t=[];this.kills>0&&(t.push(this.killSprite),t.push(this.killText),this.killText.text=this.kills),this.jumps>0&&(t.push(this.jumpSprite),t.push(this.jumpText),this.jumpText.text=this.jumps);const e=4;let r=-(t.reduce((n,a)=>n+a.width,0)+e*(t.length-1))/2;this.containter.removeChildren();for(const n of t)n.position.set(r,0),r+=n.width+e,this.containter.addChild(n)}update(t){this.containter.position.x=t.position.x??this.containter.position.x,this.containter.position.y=t.position.y??this.containter.position.y}}const sx=(s,t)=>s.x<t.x+t.w&&s.x+s.w>t.x&&s.y<t.y+t.h&&s.y+s.h>t.y,ix=(s,t,e)=>{const i={...s,x:s.x+(e.x??0),y:s.y+(e.y??0)};return sx(i,t)?s.y+s.h<t.y&&i.y+i.h>=t.y:!1};class Ne{constructor(){T(this,"container",new z);T(this,"userState",{});T(this,"state",{name:"",sprite:"",color:new j("#969696"),direction:1,scale:1,isAnonymous:!1,isImmortal:!1,zIndex:0});T(this,"animationState",dt.Idle);T(this,"sprite");T(this,"trail",new Q_);T(this,"name",new Z_);T(this,"info",new ex);T(this,"message",new q_(()=>{this.state.zIndex=Et.zIndexEvotarMax(this.container.zIndex)}));T(this,"emoteSpitter",new K_);T(this,"velocity",{x:0,y:0});T(this,"runSpeed",.05);T(this,"gravity",.2);T(this,"dashAcc",3);T(this,"isJumping",!1);T(this,"isHitJumping",!1);T(this,"isDashing",!1);T(this,"isDespawned",!1);T(this,"isDead",!1);T(this,"deathTimer");T(this,"landTimer");T(this,"stateTimer");T(this,"scaleTimer");T(this,"spawnTween");T(this,"fadeTween");T(this,"scaleTween");T(this,"offset",0);T(this,"screenBounds",{left:this.offset,right:lt.renderer.width-this.offset});this.container.addChild(this.name.text),this.container.addChild(this.info.containter),this.container.addChild(this.emoteSpitter.container),this.container.addChild(this.message.container),this.container.sortableChildren=!0}getCenterOffsetY(){return this.sprite?this.sprite.data.collider.h/2*this.getScale():0}getCenterPosition(){return{x:this.container.position.x,y:this.container.position.y-this.getCenterOffsetY()}}setPosition(t){this.container.position=t}getScale(){return this.sprite?this.state.scale*this.sprite.data.scale:this.state.scale}getCollider(){if(this.sprite){const t=this.sprite.data.collider.x*this.getScale(),e=this.sprite.data.collider.h*this.getScale();return{x:this.container.position.x-t,y:this.container.position.y-e,w:this.sprite.data.collider.w*this.getScale(),h:this.sprite.data.collider.h*this.getScale()}}return{x:0,y:0,w:0,h:0}}async resurrect(){this.deathTimer&&this.deathTimer.complete()}async die(){this.state.isImmortal||(this.isDead=!0,this.container.visible=!1,Et.kill(this),this.deathTimer=new Zt(1e3*60*1,()=>{!this.isDespawned&&this.isDead&&(this.isDead=!1,this.container.visible=!0,this.state.scale=1,Et.resurrect(this))}))}spawn(t={isFalling:!1}){if(!this.sprite)return;const e=this.sprite.data.collider,i=this.sprite.data.size,r=-(e.y+e.h-i.h/2),n=t.isFalling?r:lt.renderer.height,a=i.w*this.getScale(),o=t.positionX!=null?t.positionX*this.screenBounds.right:Math.random()*(this.screenBounds.right-a)+a/2,h=n*this.getScale();if(this.container.x=o,this.container.y=h,this.state.direction=Math.random()>.5?1:-1,!t.isFalling){const c=Et.zIndexEvotarMin(this.container.zIndex);this.state.zIndex=c,this.container.alpha=0,this.spawnTween=new xe(this.container).to({alpha:1},500).onComplete(t.onComplete).start()}this.stateTimer=new Zt(5e3,()=>{this.isJumping||this.setAnimationState(dt.Run)})}despawn(t={}){this.fadeTween&&this.fadeTween.isPlaying()||(this.fadeTween=new xe(this.container).to({alpha:0},1e3).onComplete(()=>{this.isDespawned=!0,t.onComplete&&t.onComplete()}).start())}scale(t){this.scaleTween&&this.scaleTween.isPlaying()||this.scaleTimer&&!this.scaleTimer.isCompleted||(this.scaleTween=new xe(this).to({state:{scale:t.value??2}},2e3).onComplete(()=>{this.scaleTimer=new Zt((t.duration??10)*1e3,()=>{this.scaleTween=new xe(this).to({state:{scale:1}},2e3).start()})}).start())}addJumpHit(t){this.info.addJumps(t)}canDoAction(){return!this.isDespawned&&!this.isDead}async jump(t){this.canDoAction()&&(this.isJumping||(this.isJumping=!0,Qc.play("jump"),await tx(300),this.velocity.x=this.state.direction*((t==null?void 0:t.velocityX)??3.5),this.velocity.y=(t==null?void 0:t.velocityY)??-8,this.setAnimationState(dt.Jump),this.info.jumps>0&&(this.info.useJump(),this.isHitJumping=!0)))}dash(t){this.canDoAction()&&(this.isDashing||(this.isDashing=!0,this.velocity.x=this.state.direction*(t.force??14)))}async setSprite(t){if(t&&t!=this.state.sprite){const e=await ui.getSpriteData(t);if(!e)return;this.sprite&&this.container.removeChild(this.sprite.container),this.state.sprite=t;const i=ui.getAnimatedSprites(t);this.sprite=new J_(i,e.data),this.container.addChild(this.sprite.container),this.trail.setSprite(this.sprite),this.setAnimationState(this.animationState,!0)}}async setProps(t){t.sprite&&await this.setSprite(t.sprite),this.state={...this.state,...t}}setUserProps(t){this.userState={...this.userState,...t}}move(){var i;if(!this.sprite)return;const t=this.sprite.data.collider,e={x:this.container.position.x,y:this.container.position.y};if(this.isDashing){const r=Math.sign(this.velocity.x);this.velocity.x=this.velocity.x-r*this.dashAcc/Math.abs(this.velocity.x),r!=Math.sign(this.velocity.x)?(this.isDashing=!1,this.velocity.x=0):e.x+=this.velocity.x}else{if((i=this.stateTimer)!=null&&i.isCompleted&&(this.stateTimer=new Zt(Math.random()*5e3,()=>{this.animationState==dt.Idle?this.setAnimationState(dt.Run):this.animationState==dt.Run&&this.setAnimationState(dt.Idle)})),this.animationState==dt.Run){const r=this.runSpeed*this.state.direction;this.velocity.x=r*ae}this.velocity.y=this.velocity.y+this.gravity,e.x+=this.velocity.x,e.y+=this.velocity.y,this.isOnGround(e.y)&&(this.velocity.y=0,this.velocity.x=0,e.y=lt.renderer.height,this.animationState==dt.Fall&&(this.setAnimationState(dt.Land),this.landTimer=new Zt(200,()=>{this.setAnimationState(dt.Idle),this.isJumping=!1,this.isHitJumping=!1}))),this.velocity.y>0&&this.setAnimationState(dt.Fall)}if(this.animationState!=dt.Idle||this.isDashing){const r=t.w/2*this.getScale(),n=this.container.x-r<this.screenBounds.left,a=this.container.x+r>this.screenBounds.right;(n||a)&&(this.state.direction=-this.state.direction,this.velocity.x=-this.velocity.x,n&&(e.x=this.screenBounds.left+r),a&&(e.x=this.screenBounds.right-r))}this.container.position.set(e.x,e.y),this.isHitJumping&&this.jumpHit()}jumpHit(){const t=Et.getEvotars();for(const e in t){const i=t[e];if(i){const r=this.getCollider(),n=i.getCollider();i!=this&&ix(r,n,{x:this.velocity.x,y:this.velocity.y})&&!i.isDead&&!i.state.isImmortal&&(i.die(),this.info.addKill())}}}update(){var r,n,a,o,h,c,l;if(this.isDespawned||!this.sprite)return;(r=this.landTimer)==null||r.tick(),(n=this.stateTimer)==null||n.tick(),(a=this.scaleTimer)==null||a.tick(),(o=this.fadeTween)==null||o.update(),(h=this.spawnTween)==null||h.update(),(c=this.scaleTween)==null||c.update(),(l=this.deathTimer)==null||l.tick(),this.container.zIndex=this.state.zIndex;const t=this.sprite.data.collider;this.name.update({name:this.state.name,isVisible:!this.state.isAnonymous,position:{y:-t.h*this.getScale()}}),this.info.update({position:{y:this.name.text.position.y-this.name.text.height-6}}),this.message.update({position:{y:this.info.containter.position.y-this.info.containter.height-6}}),this.emoteSpitter.update({position:{y:this.message.container.position.y-this.message.container.height}}),this.isDead||this.move();const e=Object.fromEntries(this.sprite.data.colored.map(u=>[u,this.userState.color?this.userState.color:this.state.color])),i=this.sprite.data.flip?this.state.direction:1;this.sprite.update({color:e,scale:{x:i*this.getScale(),y:this.getScale()},play:!this.isDashing}),this.trail.update({play:this.isDashing})}isOnGround(t){return t>lt.renderer.height}addMessage(t){var e;this.message.add(t),this.state.isAnonymous=!1,(e=this.fadeTween)==null||e.stop(),this.fadeTween=void 0,this.container.alpha=1}async spitEmotes(t){for(const e of t)await this.emoteSpitter.add(e)}async setAnimationState(t,e=!1){this.animationState==t&&!e||(this.animationState=t,this.sprite&&this.sprite.setTag(t))}}class rx{play(t,e,i){const r=ft.get(t),n=ui.createAnimatedSprite(t,r);n&&(lt.stage.addChild(n),n.zIndex=1e3,n.scale.set(i,i),n.position.set(e.x,e.y),n.anchor.set(.5,.5),n.loop=!1,n.texture.source.scaleMode="nearest",n.play(),n.onComplete=()=>{lt.stage.removeChild(n)})}}const ol=new rx,nx=4;class ax{constructor(t){T(this,"container",new z);T(this,"sprite");T(this,"gravity",.2);T(this,"velocity",{x:0,y:0});T(this,"fadeTween");this.evotar=t;const e=Math.random()>.5?"rip1":"rip2",i=ft.get(e);this.sprite=Tt.from(i)}isOnGround(t){return t>lt.renderer.height}update(){var e;(e=this.fadeTween)==null||e.update();const t={x:this.container.position.x,y:this.container.position.y};this.velocity.y=this.velocity.y+this.gravity,t.x+=this.velocity.x,t.y+=this.velocity.y,this.isOnGround(t.y)&&(this.velocity.y=0,this.velocity.x=0,t.y=lt.renderer.height),this.container.position.set(t.x,t.y)}despawn(t=!1,e=()=>{}){if(t)this.fadeTween=new xe(this.container).to({alpha:0},1e3).onComplete(e).start();else{const i={x:this.container.position.x,y:this.container.position.y-8*this.container.scale.x};ol.play("poof",i,this.container.scale.x),e()}}spawn(){const t=this.evotar.getCenterPosition(),e=this.evotar.getScale();this.container.removeChildren(),this.container.addChild(this.sprite),this.container.position.set(t.x,(t.y??0)+this.sprite.height/2*e),this.container.scale.set(nx),this.sprite.anchor.set(.5,1),this.sprite.texture.source.scaleMode="nearest",ol.play("poof",{x:t.x,y:t.y},e)}}const ox=1e3*60*5;class hx{constructor(){T(this,"viewers",{});T(this,"tombstones",[]);T(this,"raiders",[]);T(this,"recentEvotarActivity",{});T(this,"subscriptions",[]);T(this,"hasActivity",t=>!!this.recentEvotarActivity[t])}subscribe(t){this.subscriptions.push(t)}update(){for(const t in this.viewers){const e=this.viewers[t];e&&e.update()}for(const t of this.raiders)t.update();for(const t of this.tombstones)t.update()}getEvotars(){return Object.values(this.viewers).concat(this.raiders)}async spawnViewerEvotar(t,e,i){const r=new Ne;return this.addViewer(t,r),await r.setProps(e),r.spawn(i),this.recentEvotarActivity[t]=performance.now(),r}async processRaid(t){if(!lt.settings.fallingRaiders)return;const e=1/t.viewers.count*5e3;for(let a=0;a<t.viewers.count;a++){const o=new Ne;await o.setProps({isAnonymous:!0,zIndex:-1,sprite:t.viewers.sprite,color:new j(t.broadcaster.info.color)}),fn.add(e*a,()=>{this.addRaider(o),o.spawn({isFalling:!0})}),fn.add(a*e+6e4,()=>{this.despawnRaider(o)})}const i=this.viewers[t.broadcaster.id],r={...this.prepareEvotarProps(t.broadcaster.info.displayName,t.broadcaster.info.color,t.broadcaster.info.sprite),scale:2,isImmortal:!0},n=async()=>{const a=new Ne;await a.setProps(r),this.addViewer(t.broadcaster.id,a),a.spawn({isFalling:!0,positionX:.5})};this.recentEvotarActivity[t.broadcaster.id]=performance.now(),i?i.despawn({onComplete:()=>{n()}}):n()}despawnTombStone(t){const e=this.tombstones.find(i=>i.evotar==t);e&&e.despawn(!0,()=>{this.deleteTombStone(e)})}despawnRaider(t){t.despawn({onComplete:()=>{this.deleteRaider(t)}}),this.despawnTombStone(t)}despawnViewer(t,e){e.despawn({onComplete:()=>{this.deleteViewer(t,e)}}),this.despawnTombStone(e)}async processChatters(t){for(const e in this.viewers){const i=this.recentEvotarActivity[e],r=!!i&&performance.now()-i<ox;if(t.every(n=>n.userId!=e)&&!r){const n=this.viewers[e];n&&this.despawnViewer(e,n)}}if(lt.settings.showAnonymousEvotars){for(const e of t)if(!this.viewers[e.userId]){const r={name:e.name,isAnonymous:!this.hasActivity(e.userId),sprite:"default"},n=new Ne;this.addViewer(e.userId,n),await n.setProps(r),n.spawn()}}}doAction(t,e){if(Oc(t)&&e.jump({velocityX:t.data.velocityX,velocityY:t.data.velocityY}),Nc(t)&&e.dash({force:t.data.force}),Lc(t)){const i=k(t.data.color);i&&i.isValid()&&e.setUserProps({color:new j(t.data.color)})}Hc(t)&&e.scale({value:t.data.scale,duration:t.data.duration}),zc(t)&&e.setSprite(t.data.sprite),Wc(t)&&e.addJumpHit(t.data.count),Vc(t)&&e.resurrect()}prepareEvotarProps(t,e,i){const r={name:t,isAnonymous:!1};if(i&&(r.sprite=i),e)try{r.color=new j(e)}catch{}return r}async processAction(t){const e=this.viewers[t.userId],i=this.prepareEvotarProps(t.info.displayName,t.info.color,t.info.sprite);if(e)await e.setProps(i),this.doAction(t,e);else{const r=new Ne;this.addViewer(t.userId,r),await r.setProps(i),r.spawn({onComplete:()=>{const n=this.viewers[t.userId];n&&this.doAction(t,n)}})}}async processMessage(t){const e=this.prepareEvotarProps(t.info.displayName,t.info.color,t.info.sprite);let i=this.viewers[t.userId];if(i)i.setProps(e);else{const r=lt.settings.fallingEvotars?!this.hasActivity(t.userId):!1;i=new Ne,this.addViewer(t.userId,i),await i.setProps(e),i.spawn({isFalling:r})}this.recentEvotarActivity[t.userId]=performance.now(),t.message&&i.addMessage(t.message),t.emotes.length>0&&i.spitEmotes(t.emotes)}resurrect(t){const e=this.tombstones.find(i=>i.evotar==t);e&&(t.setPosition(e.container.position),e.despawn(),this.deleteTombStone(e))}kill(t){const e=new ax(t);this.addTombStone(e),e.spawn()}addTombStone(t){lt.stage.addChild(t.container),this.tombstones.push(t)}deleteTombStone(t){lt.stage.removeChild(t.container),this.tombstones=this.tombstones.filter(e=>e!=t)}addViewer(t,e){this.subscriptions.forEach(i=>i.onAdd(e)),this.viewers[t]=e}deleteViewer(t,e){this.subscriptions.forEach(i=>i.onDelete(e)),delete this.viewers[t]}addRaider(t){this.subscriptions.forEach(e=>e.onAdd(t)),this.raiders.push(t)}deleteRaider(t){this.subscriptions.forEach(e=>e.onDelete(t)),this.raiders=this.raiders.filter(e=>e!=t)}zIndexEvotarMax(t){return Object.values(this.viewers).reduce((e,i)=>i&&e<=i.container.zIndex?i.container.zIndex+1:e,t)}zIndexEvotarMin(t){return Object.values(this.viewers).reduce((e,i)=>i&&e>=i.container.zIndex?i.container.zIndex-1:e,t)}}const Et=new hx;class cx{constructor(){T(this,"stage",new z);T(this,"evotars",{});T(this,"chatterIds",[]);T(this,"settings",{});T(this,"renderer");T(this,"ticker")}async initialize(t,e){ui.initialize(e.spriteLoaderFn),Qc.initialize(e.sounds),e.font&&await ft.load({src:e.font,data:{family:"Custom Font"}}),ft.add({alias:"poof",src:"/client/poof.json"}),ft.add({alias:"rip1",src:"/client/rip1.png"}),ft.add({alias:"rip2",src:"/client/rip2.png"}),ft.add({alias:"skull",src:"/client/skull.png"}),ft.add({alias:"weight",src:"/client/weight.png"}),await ft.load(["skull","weight","poof","rip1","rip2"]),this.ticker=new ot,this.ticker.deltaTime=ae*.06,this.renderer=await md({preference:"webgl"}),await this.renderer.init({width:t.clientWidth,height:t.clientHeight,backgroundAlpha:0}),t.appendChild(this.renderer.canvas),window.onresize=()=>{this.renderer.resize(t.clientWidth,t.clientHeight)},this.stage.sortableChildren=!0,Et.subscribe({onAdd:i=>this.stage.addChild(i.container),onDelete:i=>{this.stage.removeChild(i.container),this.stage.removeChild(i.trail.container)}})}updateSettings(t){this.settings=t}update(){fn.tick(),Et.update(),this.renderer.render(this.stage)}}const lt=new cx;class lx{constructor(t,e){T(this,"isRendered",!1);T(this,"processMessage",t=>Et.processMessage(t));T(this,"processAction",t=>Et.processAction(t));T(this,"processChatters",t=>Et.processChatters(t));T(this,"processRaid",t=>Et.processRaid(t));this.root=t,this.options=e}get manager(){return Et}updateSettings(t){lt.updateSettings(t)}async run(){if(this.isRendered)return;this.isRendered=!0,await(async()=>{await lt.initialize(this.root,this.options),performance.now();let e=-1;const r=1e3/60;requestAnimationFrame(n);function n(a=performance.now()){const o=a-e|0;o>r&&(e=a-o%r,lt.update()),requestAnimationFrame(n)}})()}}O.add(Ta),z.mixin(Bu),O.add(Ha),O.add(Na),O.add(bo),z.mixin(ip),O.add(bc),O.add(yr),O.add(Sc),O.add(Dc),O.add(Fc),O.add(Mc,Ug,Gg),O.add(dn),O.add(Rc),O.add(Ac),O.add(Tc),O.add(wo),O.add(vo);const ux=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),dx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));nt.Evotars=lx,nt.isAddJumpHitsUserActionEntity=Wc,nt.isColorUserActionEntity=Lc,nt.isDashUserActionEntity=Nc,nt.isGrowUserActionEntity=Hc,nt.isJumpUserActionEntity=Oc,nt.isResurrectUserActionEntity=Vc,nt.isSpriteUserActionEntity=zc,Object.defineProperty(nt,Symbol.toStringTag,{value:"Module"})});
|