var Yt=Object.defineProperty;var xi=Object.getOwnPropertyDescriptor;var Ui=Object.getOwnPropertyNames;var Ei=Object.prototype.hasOwnProperty;var o=(n,e)=>Yt(n,"name",{value:e,configurable:!0});var Si=(n,e)=>{for(var i in e)Yt(n,i,{get:e[i],enumerable:!0})},Ci=(n,e,i,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of Ui(e))!Ei.call(n,m)&&m!==i&&Yt(n,m,{get:()=>e[m],enumerable:!(c=xi(e,m))||c.enumerable});return n};var Ai=n=>Ci(Yt({},"__esModule",{value:!0}),n);var wr=(()=>{for(var n=new Uint8Array(128),e=0;e<64;e++)n[e<26?e+65:e<52?e+71:e<62?e-4:e*4-205]=e;return i=>{for(var c=i.length,m=new Uint8Array((c-(i[c-1]=="=")-(i[c-2]=="="))*3/4|0),p=0,P=0;p>4,m[P++]=j<<4|y>>2,m[P++]=y<<6|X}return m}})();var uo={};Si(uo,{default:()=>ao});module.exports=Ai(uo);function Ge(n){return n*Math.PI/180}o(Ge,"deg2rad");function ot(n){return n*180/Math.PI}o(ot,"rad2deg");function Le(n,e,i){return e>i?Le(n,i,e):Math.min(Math.max(n,e),i)}o(Le,"clamp");function Ve(n,e,i){if(typeof n=="number"&&typeof e=="number")return n+(e-n)*i;if(n instanceof v&&e instanceof v)return n.lerp(e,i);if(n instanceof W&&e instanceof W)return n.lerp(e,i);throw new Error(`Bad value for lerp(): ${n}, ${e}. Only number, Vec2 and Color is supported.`)}o(Ve,"lerp");function _e(n,e,i,c,m){return c+(n-e)/(i-e)*(m-c)}o(_e,"map");function vr(n,e,i,c,m){return Le(_e(n,e,i,c,m),c,m)}o(vr,"mapc");var v=class n{static{o(this,"Vec2")}x=0;y=0;constructor(e=0,i=e){this.x=e,this.y=i}static fromAngle(e){let i=Ge(e);return new n(Math.cos(i),Math.sin(i))}static LEFT=new n(-1,0);static RIGHT=new n(1,0);static UP=new n(0,-1);static DOWN=new n(0,1);clone(){return new n(this.x,this.y)}add(...e){let i=T(...e);return new n(this.x+i.x,this.y+i.y)}sub(...e){let i=T(...e);return new n(this.x-i.x,this.y-i.y)}scale(...e){let i=T(...e);return new n(this.x*i.x,this.y*i.y)}dist(...e){let i=T(...e);return this.sub(i).len()}sdist(...e){let i=T(...e);return this.sub(i).slen()}len(){return Math.sqrt(this.dot(this))}slen(){return this.dot(this)}unit(){let e=this.len();return e===0?new n(0):this.scale(1/e)}normal(){return new n(this.y,-this.x)}reflect(e){return this.sub(e.scale(2*this.dot(e)))}project(e){return e.scale(e.dot(this)/e.len())}reject(e){return this.sub(this.project(e))}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}angle(...e){let i=T(...e);return ot(Math.atan2(this.y-i.y,this.x-i.x))}angleBetween(...e){let i=T(...e);return ot(Math.atan2(this.cross(i),this.dot(i)))}lerp(e,i){return new n(Ve(this.x,e.x,i),Ve(this.y,e.y,i))}slerp(e,i){let c=this.dot(e),m=this.cross(e),p=Math.atan2(m,c);return this.scale(Math.sin((1-i)*p)).add(e.scale(Math.sin(i*p))).scale(1/m)}isZero(){return this.x===0&&this.y===0}toFixed(e){return new n(Number(this.x.toFixed(e)),Number(this.y.toFixed(e)))}transform(e){return e.multVec2(this)}eq(e){return this.x===e.x&&this.y===e.y}bbox(){return new de(this,0,0)}toString(){return`vec2(${this.x.toFixed(2)}, ${this.y.toFixed(2)})`}};function T(...n){if(n.length===1){if(n[0]instanceof v)return new v(n[0].x,n[0].y);if(Array.isArray(n[0])&&n[0].length===2)return new v(...n[0])}return new v(...n)}o(T,"vec2");var W=class n{static{o(this,"Color")}r=255;g=255;b=255;constructor(e,i,c){this.r=Le(e,0,255),this.g=Le(i,0,255),this.b=Le(c,0,255)}static fromArray(e){return new n(e[0],e[1],e[2])}static fromHex(e){if(typeof e=="number")return new n(e>>16&255,e>>8&255,e>>0&255);if(typeof e=="string"){let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return new n(parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16))}else throw new Error("Invalid hex color format")}static fromHSL(e,i,c){if(i==0)return new n(255*c,255*c,255*c);let m=o((X,S,q)=>(q<0&&(q+=1),q>1&&(q-=1),q<1/6?X+(S-X)*6*q:q<1/2?S:q<2/3?X+(S-X)*(2/3-q)*6:X),"hue2rgb"),p=c<.5?c*(1+i):c+i-c*i,P=2*c-p,I=m(P,p,e+1/3),j=m(P,p,e),y=m(P,p,e-1/3);return new n(Math.round(I*255),Math.round(j*255),Math.round(y*255))}static RED=new n(255,0,0);static GREEN=new n(0,255,0);static BLUE=new n(0,0,255);static YELLOW=new n(255,255,0);static MAGENTA=new n(255,0,255);static CYAN=new n(0,255,255);static WHITE=new n(255,255,255);static BLACK=new n(0,0,0);clone(){return new n(this.r,this.g,this.b)}lighten(e){return new n(this.r+e,this.g+e,this.b+e)}darken(e){return this.lighten(-e)}invert(){return new n(255-this.r,255-this.g,255-this.b)}mult(e){return new n(this.r*e.r/255,this.g*e.g/255,this.b*e.b/255)}lerp(e,i){return new n(Ve(this.r,e.r,i),Ve(this.g,e.g,i),Ve(this.b,e.b,i))}toHSL(){let e=this.r/255,i=this.g/255,c=this.b/255,m=Math.max(e,i,c),p=Math.min(e,i,c),P=(m+p)/2,I=P,j=P;if(m==p)P=I=0;else{let y=m-p;switch(I=j>.5?y/(2-m-p):y/(m+p),m){case e:P=(i-c)/y+(iW.fromHSL(n,e,i),"hsl2rgb"),oe=class n{static{o(this,"Quad")}x=0;y=0;w=1;h=1;constructor(e,i,c,m){this.x=e,this.y=i,this.w=c,this.h=m}scale(e){return new n(this.x+this.w*e.x,this.y+this.h*e.y,this.w*e.w,this.h*e.h)}pos(){return new v(this.x,this.y)}clone(){return new n(this.x,this.y,this.w,this.h)}eq(e){return this.x===e.x&&this.y===e.y&&this.w===e.w&&this.h===e.h}toString(){return`quad(${this.x}, ${this.y}, ${this.w}, ${this.h})`}};function ce(n,e,i,c){return new oe(n,e,i,c)}o(ce,"quad");var Ue=class n{static{o(this,"Mat4")}m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];constructor(e){e&&(this.m=e)}static translate(e){return new n([1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,0,1])}static scale(e){return new n([e.x,0,0,0,0,e.y,0,0,0,0,1,0,0,0,0,1])}static rotateX(e){e=Ge(-e);let i=Math.cos(e),c=Math.sin(e);return new n([1,0,0,0,0,i,-c,0,0,c,i,0,0,0,0,1])}static rotateY(e){e=Ge(-e);let i=Math.cos(e),c=Math.sin(e);return new n([i,0,c,0,0,1,0,0,-c,0,i,0,0,0,0,1])}static rotateZ(e){e=Ge(-e);let i=Math.cos(e),c=Math.sin(e);return new n([i,-c,0,0,c,i,0,0,0,0,1,0,0,0,0,1])}translate(e){return this.m[12]+=this.m[0]*e.x+this.m[4]*e.y,this.m[13]+=this.m[1]*e.x+this.m[5]*e.y,this.m[14]+=this.m[2]*e.x+this.m[6]*e.y,this.m[15]+=this.m[3]*e.x+this.m[7]*e.y,this}scale(e){return this.m[0]*=e.x,this.m[4]*=e.y,this.m[1]*=e.x,this.m[5]*=e.y,this.m[2]*=e.x,this.m[6]*=e.y,this.m[3]*=e.x,this.m[7]*=e.y,this}rotate(e){e=Ge(-e);let i=Math.cos(e),c=Math.sin(e),m=this.m[0],p=this.m[1],P=this.m[4],I=this.m[5];return this.m[0]=m*i+p*c,this.m[1]=-m*c+p*i,this.m[4]=P*i+I*c,this.m[5]=-P*c+I*i,this}mult(e){let i=[];for(let c=0;c<4;c++)for(let m=0;m<4;m++)i[c*4+m]=this.m[0*4+m]*e.m[c*4+0]+this.m[1*4+m]*e.m[c*4+1]+this.m[2*4+m]*e.m[c*4+2]+this.m[3*4+m]*e.m[c*4+3];return new n(i)}multVec2(e){return new v(e.x*this.m[0]+e.y*this.m[4]+this.m[12],e.x*this.m[1]+e.y*this.m[5]+this.m[13])}getTranslation(){return new v(this.m[12],this.m[13])}getScale(){if(this.m[0]!=0||this.m[1]!=0){let e=this.m[0]*this.m[5]-this.m[1]*this.m[4],i=Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]);return new v(i,e/i)}else if(this.m[4]!=0||this.m[5]!=0){let e=this.m[0]*this.m[5]-this.m[1]*this.m[4],i=Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]);return new v(e/i,i)}else return new v(0,0)}getRotation(){if(this.m[0]!=0||this.m[1]!=0){let e=Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]);return ot(this.m[1]>0?Math.acos(this.m[0]/e):-Math.acos(this.m[0]/e))}else if(this.m[4]!=0||this.m[5]!=0){let e=Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]);return ot(Math.PI/2-(this.m[5]>0?Math.acos(-this.m[4]/e):-Math.acos(this.m[4]/e)))}else return 0}getSkew(){if(this.m[0]!=0||this.m[1]!=0){let e=Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]);return new v(Math.atan(this.m[0]*this.m[4]+this.m[1]*this.m[5])/(e*e),0)}else if(this.m[4]!=0||this.m[5]!=0){let e=Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]);return new v(0,Math.atan(this.m[0]*this.m[4]+this.m[1]*this.m[5])/(e*e))}else return new v(0,0)}invert(){let e=[],i=this.m[10]*this.m[15]-this.m[14]*this.m[11],c=this.m[9]*this.m[15]-this.m[13]*this.m[11],m=this.m[9]*this.m[14]-this.m[13]*this.m[10],p=this.m[8]*this.m[15]-this.m[12]*this.m[11],P=this.m[8]*this.m[14]-this.m[12]*this.m[10],I=this.m[8]*this.m[13]-this.m[12]*this.m[9],j=this.m[6]*this.m[15]-this.m[14]*this.m[7],y=this.m[5]*this.m[15]-this.m[13]*this.m[7],X=this.m[5]*this.m[14]-this.m[13]*this.m[6],S=this.m[4]*this.m[15]-this.m[12]*this.m[7],q=this.m[4]*this.m[14]-this.m[12]*this.m[6],E=this.m[5]*this.m[15]-this.m[13]*this.m[7],K=this.m[4]*this.m[13]-this.m[12]*this.m[5],Q=this.m[6]*this.m[11]-this.m[10]*this.m[7],te=this.m[5]*this.m[11]-this.m[9]*this.m[7],k=this.m[5]*this.m[10]-this.m[9]*this.m[6],pe=this.m[4]*this.m[11]-this.m[8]*this.m[7],C=this.m[4]*this.m[10]-this.m[8]*this.m[6],Ae=this.m[4]*this.m[9]-this.m[8]*this.m[5];e[0]=this.m[5]*i-this.m[6]*c+this.m[7]*m,e[4]=-(this.m[4]*i-this.m[6]*p+this.m[7]*P),e[8]=this.m[4]*c-this.m[5]*p+this.m[7]*I,e[12]=-(this.m[4]*m-this.m[5]*P+this.m[6]*I),e[1]=-(this.m[1]*i-this.m[2]*c+this.m[3]*m),e[5]=this.m[0]*i-this.m[2]*p+this.m[3]*P,e[9]=-(this.m[0]*c-this.m[1]*p+this.m[3]*I),e[13]=this.m[0]*m-this.m[1]*P+this.m[2]*I,e[2]=this.m[1]*j-this.m[2]*y+this.m[3]*X,e[6]=-(this.m[0]*j-this.m[2]*S+this.m[3]*q),e[10]=this.m[0]*E-this.m[1]*S+this.m[3]*K,e[14]=-(this.m[0]*X-this.m[1]*q+this.m[2]*K),e[3]=-(this.m[1]*Q-this.m[2]*te+this.m[3]*k),e[7]=this.m[0]*Q-this.m[2]*pe+this.m[3]*C,e[11]=-(this.m[0]*te-this.m[1]*pe+this.m[3]*Ae),e[15]=this.m[0]*k-this.m[1]*C+this.m[2]*Ae;let $=this.m[0]*e[0]+this.m[1]*e[4]+this.m[2]*e[8]+this.m[3]*e[12];for(let Te=0;Te<4;Te++)for(let ye=0;ye<4;ye++)e[Te*4+ye]*=1/$;return new n(e)}clone(){return new n([...this.m])}toString(){return this.m.toString()}};function Ln(n,e,i,c=m=>-Math.cos(m)){return n+(c(i)+1)/2*(e-n)}o(Ln,"wave");var Ti=1103515245,Oi=12345,br=2147483648,bt=class{static{o(this,"RNG")}seed;constructor(e){this.seed=e}gen(){return this.seed=(Ti*this.seed+Oi)%br,this.seed/br}genNumber(e,i){return e+this.gen()*(i-e)}genVec2(e,i){return new v(this.genNumber(e.x,i.x),this.genNumber(e.y,i.y))}genColor(e,i){return new W(this.genNumber(e.r,i.r),this.genNumber(e.g,i.g),this.genNumber(e.b,i.b))}genAny(...e){if(e.length===0)return this.gen();if(e.length===1){if(typeof e[0]=="number")return this.genNumber(0,e[0]);if(e[0]instanceof v)return this.genVec2(T(0,0),e[0]);if(e[0]instanceof W)return this.genColor(J(0,0,0),e[0])}else if(e.length===2){if(typeof e[0]=="number"&&typeof e[1]=="number")return this.genNumber(e[0],e[1]);if(e[0]instanceof v&&e[1]instanceof v)return this.genVec2(e[0],e[1]);if(e[0]instanceof W&&e[1]instanceof W)return this.genColor(e[0],e[1])}}},Fn=new bt(Date.now());function xr(n){return n!=null&&(Fn.seed=n),Fn.seed}o(xr,"randSeed");function xt(...n){return Fn.genAny(...n)}o(xt,"rand");function Vn(...n){return Math.floor(xt(...n))}o(Vn,"randi");function Ur(n){return xt()<=n}o(Ur,"chance");function Er(n){return n[Vn(n.length)]}o(Er,"choose");function Sr(n,e){return n.pos.x+n.width>e.pos.x&&n.pos.xe.pos.y&&n.pos.y1||m<0||m>1?null:c}o(Ri,"testLineLineT");function it(n,e){let i=Ri(n,e);return i?T(n.p1.x+i*(n.p2.x-n.p1.x),n.p1.y+i*(n.p2.y-n.p1.y)):null}o(it,"testLineLine");function Cr(n,e){if(vt(n,e.p1)||vt(n,e.p2))return!0;let i=n.points();return!!it(e,new Ie(i[0],i[1]))||!!it(e,new Ie(i[1],i[2]))||!!it(e,new Ie(i[2],i[3]))||!!it(e,new Ie(i[3],i[0]))}o(Cr,"testRectLine");function vt(n,e){return e.x>n.pos.x&&e.xn.pos.y&&e.yNumber.EPSILON)return!1;let m=i.dot(c)/c.dot(c);return m>=0&&m<=1}o(Ar,"testLinePoint");function _n(n,e){let i=n.p2.sub(n.p1),c=i.dot(i),m=n.p1.sub(e.center),p=2*i.dot(m),P=m.dot(m)-e.radius*e.radius,I=p*p-4*c*P;if(c<=Number.EPSILON||I<0)return!1;if(I==0){let j=-p/(2*c);if(j>=0&&j<=1)return!0}else{let j=(-p+Math.sqrt(I))/(2*c),y=(-p-Math.sqrt(I))/(2*c);if(j>=0&&j<=1||y>=0&&y<=1)return!0}return Tr(e,n.p1)}o(_n,"testLineCircle");function Tr(n,e){return n.center.sdist(e)e.y!=c[p].y>e.y&&e.x<(c[p].x-c[m].x)*(e.y-c[m].y)/(c[p].y-c[m].y)+c[m].x&&(i=!i);return i}o(kn,"testPolygonPoint");var Ie=class n{static{o(this,"Line")}p1;p2;constructor(e,i){this.p1=e.clone(),this.p2=i.clone()}transform(e){return new n(e.multVec2(this.p1),e.multVec2(this.p2))}bbox(){return de.fromPoints(this.p1,this.p2)}area(){return this.p1.dist(this.p2)}clone(){return new n(this.p1,this.p2)}},de=class n{static{o(this,"Rect")}pos;width;height;constructor(e,i,c){this.pos=e.clone(),this.width=i,this.height=c}static fromPoints(e,i){return new n(e.clone(),i.x-e.x,i.y-e.y)}center(){return new v(this.pos.x+this.width/2,this.pos.y+this.height/2)}points(){return[this.pos,this.pos.add(this.width,0),this.pos.add(this.width,this.height),this.pos.add(0,this.height)]}transform(e){return new Ke(this.points().map(i=>e.multVec2(i)))}bbox(){return this.clone()}area(){return this.width*this.height}clone(){return new n(this.pos.clone(),this.width,this.height)}distToPoint(e){return Math.sqrt(this.sdistToPoint(e))}sdistToPoint(e){let i=this.pos,c=this.pos.add(this.width,this.height),m=Math.max(i.x-e.x,0,e.x-c.x),p=Math.max(i.y-e.y,0,e.y-c.y);return m*m+p*p}},yt=class n{static{o(this,"Circle")}center;radius;constructor(e,i){this.center=e.clone(),this.radius=i}transform(e){return new In(this.center,this.radius,this.radius).transform(e)}bbox(){return de.fromPoints(this.center.sub(T(this.radius)),this.center.add(T(this.radius)))}area(){return this.radius*this.radius*Math.PI}clone(){return new n(this.center,this.radius)}},In=class n{static{o(this,"Ellipse")}center;radiusX;radiusY;constructor(e,i,c){this.center=e.clone(),this.radiusX=i,this.radiusY=c}transform(e){return new n(e.multVec2(this.center),e.m[0]*this.radiusX,e.m[5]*this.radiusY)}bbox(){return de.fromPoints(this.center.sub(T(this.radiusX,this.radiusY)),this.center.add(T(this.radiusX,this.radiusY)))}area(){return this.radiusX*this.radiusY*Math.PI}clone(){return new n(this.center,this.radiusX,this.radiusY)}},Ke=class n{static{o(this,"Polygon")}pts;constructor(e){if(e.length<3)throw new Error("Polygons should have at least 3 vertices");this.pts=e}transform(e){return new n(this.pts.map(i=>e.multVec2(i)))}bbox(){let e=T(Number.MAX_VALUE),i=T(-Number.MAX_VALUE);for(let c of this.pts)e.x=Math.min(e.x,c.x),i.x=Math.max(i.x,c.x),e.y=Math.min(e.y,c.y),i.y=Math.max(i.y,c.y);return de.fromPoints(e,i)}area(){let e=0,i=this.pts.length;for(let c=0;ce.clone()))}};function Rr(n,e){let i=Number.MAX_VALUE,c=T(0);for(let m of[n,e])for(let p=0;pthis.delete(i)}},ke=class n{static{o(this,"EventController")}paused=!1;cancel;constructor(e){this.cancel=e}static join(e){let i=new n(()=>e.forEach(c=>c.cancel()));return Object.defineProperty(i,"paused",{get:()=>e[0].paused,set:c=>e.forEach(m=>m.paused=c)}),i.paused=!1,i}},be=class{static{o(this,"Event")}handlers=new Ut;add(e){let i=this.handlers.pushd((...m)=>{c.paused||e(...m)}),c=new ke(i);return c}addOnce(e){let i=this.add((...c)=>{i.cancel(),e(...c)});return i}next(){return new Promise(e=>this.addOnce(e))}trigger(...e){this.handlers.forEach(i=>i(...e))}numListeners(){return this.handlers.size}clear(){this.handlers.clear()}},Ne=class{static{o(this,"EventHandler")}handlers={};on(e,i){return this.handlers[e]||(this.handlers[e]=new be),this.handlers[e].add(i)}onOnce(e,i){let c=this.on(e,(...m)=>{c.cancel(),i(...m)});return c}next(e){return new Promise(i=>{this.onOnce(e,(...c)=>i(c[0]))})}trigger(e,...i){this.handlers[e]&&this.handlers[e].trigger(...i)}remove(e){delete this.handlers[e]}clear(){this.handlers={}}numListeners(e){return this.handlers[e]?.numListeners()??0}};function Xt(n,e){if(n===e)return!0;let i=typeof n,c=typeof e;if(i!==c)return!1;if(i==="object"&&c==="object"&&n!==null&&e!==null){if(Array.isArray(n)!==Array.isArray(e))return!1;let m=Object.keys(n),p=Object.keys(e);if(m.length!==p.length)return!1;for(let P of m){let I=n[P],j=e[P];if(!Xt(I,j))return!1}return!0}return!1}o(Xt,"deepEq");function Pi(n){let e=window.atob(n),i=e.length,c=new Uint8Array(i);for(let m=0;mn.match(/^data:\w+\/\w+;base64,.+/),"isDataURL");var Gr=o(n=>n.split(".").slice(0,-1).join("."),"getFileName");function Ee(n,e){return(...i)=>{let c=i.length;if(c===n.length)return n(...i);if(c===e.length)return e(...i)}}o(Ee,"overload2");var Br=(()=>{let n=0;return()=>n++})(),Fr=o(n=>n instanceof Error?n.message:String(n),"getErrorMessage");var Wt=class{static{o(this,"BinaryHeap")}_items;_compareFn;constructor(e=(i,c)=>i0;){let i=Math.floor((e-1)/2);if(!this._compareFn(this._items[e],this._items[i])&&this._items[e]>=this._items[i])break;this.swap(e,i),e=i}}moveDown(e){for(;e=e&&n<=i}o(tt,"betweenInclusive");var $n={"Joy-Con L+R (STANDARD GAMEPAD Vendor: 057e Product: 200e)":{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","6":"ltrigger","7":"rtrigger","8":"select","9":"start","10":"lstick","11":"rstick","12":"dpad-up","13":"dpad-down","14":"dpad-left","15":"dpad-right","16":"home","17":"capture"},sticks:{left:{x:0,y:1},right:{x:2,y:3}}},"Joy-Con (L) (STANDARD GAMEPAD Vendor: 057e Product: 2006)":{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","9":"select","10":"lstick","16":"start"},sticks:{left:{x:0,y:1}}},"Joy-Con (R) (STANDARD GAMEPAD Vendor: 057e Product: 2007)":{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","9":"start","10":"lstick","16":"select"},sticks:{left:{x:0,y:1}}},"Pro Controller (STANDARD GAMEPAD Vendor: 057e Product: 2009)":{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","6":"ltrigger","7":"rtrigger","8":"select","9":"start","10":"lstick","11":"rstick","12":"dpad-up","13":"dpad-down","14":"dpad-left","15":"dpad-right","16":"home","17":"capture"},sticks:{left:{x:0,y:1},right:{x:2,y:3}}},default:{buttons:{"0":"south","1":"east","2":"west","3":"north","4":"lshoulder","5":"rshoulder","6":"ltrigger","7":"rtrigger","8":"select","9":"start","10":"lstick","11":"rstick","12":"dpad-up","13":"dpad-down","14":"dpad-left","15":"dpad-right","16":"home"},sticks:{left:{x:0,y:1},right:{x:2,y:3}}}};var at=class{static{o(this,"ButtonState")}pressed=new Set([]);pressedRepeat=new Set([]);released=new Set([]);down=new Set([]);update(){this.pressed.clear(),this.released.clear(),this.pressedRepeat.clear()}press(e){this.pressed.add(e),this.pressedRepeat.add(e),this.down.add(e)}pressRepeat(e){this.pressedRepeat.add(e)}release(e){this.down.delete(e),this.pressed.delete(e),this.released.add(e)}},zn=class{static{o(this,"GamepadState")}buttonState=new at;stickState=new Map},Kn=class{static{o(this,"FPSCounter")}dts=[];timer=0;fps=0;tick(e){this.dts.push(e),this.timer+=e,this.timer>=1&&(this.timer=0,this.fps=Math.round(1/(this.dts.reduce((i,c)=>i+c)/this.dts.length)),this.dts=[])}},Lr=o(n=>{if(!n.canvas)throw new Error("Please provide a canvas");let e={canvas:n.canvas,loopID:null,stopped:!1,dt:0,time:0,realTime:0,fpsCounter:new Kn,timeScale:1,skipTime:!1,numFrames:0,mousePos:new v(0),mouseDeltaPos:new v(0),keyState:new at,mouseState:new at,mergedGamepadState:new zn,gamepadStates:new Map,gamepads:[],charInputted:[],isMouseMoved:!1,lastWidth:n.canvas.offsetWidth,lastHeight:n.canvas.offsetHeight,events:new Ne};function i(){return e.dt*e.timeScale}o(i,"dt");function c(){return e.time}o(c,"time");function m(){return e.fpsCounter.fps}o(m,"fps");function p(){return e.numFrames}o(p,"numFrames");function P(){return e.canvas.toDataURL()}o(P,"screenshot");function I(l){e.canvas.style.cursor=l}o(I,"setCursor");function j(){return e.canvas.style.cursor}o(j,"getCursor");function y(l){if(l)try{let x=e.canvas.requestPointerLock();x.catch&&x.catch(R=>console.error(R))}catch(x){console.error(x)}else document.exitPointerLock()}o(y,"setCursorLocked");function X(){return!!document.pointerLockElement}o(X,"isCursorLocked");function S(l){l.requestFullscreen?l.requestFullscreen():l.webkitRequestFullscreen&&l.webkitRequestFullscreen()}o(S,"enterFullscreen");function q(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullScreen&&document.webkitExitFullScreen()}o(q,"exitFullscreen");function E(){return document.fullscreenElement||document.webkitFullscreenElement}o(E,"getFullscreenElement");function K(l=!0){l?S(e.canvas):q()}o(K,"setFullscreen");function Q(){return!!E()}o(Q,"isFullscreen");function te(){e.stopped=!0;for(let l in se)e.canvas.removeEventListener(l,se[l]);for(let l in le)document.removeEventListener(l,le[l]);for(let l in ae)window.removeEventListener(l,ae[l]);ge.disconnect()}o(te,"quit");function k(l){e.loopID!==null&&cancelAnimationFrame(e.loopID);let x=0,R=o(L=>{if(e.stopped)return;if(document.visibilityState!=="visible"){e.loopID=requestAnimationFrame(R);return}let he=L/1e3,z=he-e.realTime,Oe=n.maxFPS?1/n.maxFPS:0;e.realTime=he,x+=z,x>Oe&&(e.skipTime||(e.dt=x,e.time+=i(),e.fpsCounter.tick(e.dt)),x=0,e.skipTime=!1,e.numFrames++,ft(),l(),yn()),e.loopID=requestAnimationFrame(R)},"frame");R(0)}o(k,"run");function pe(){return"ontouchstart"in window||navigator.maxTouchPoints>0}o(pe,"isTouchscreen");function C(){return e.mousePos.clone()}o(C,"mousePos");function Ae(){return e.mouseDeltaPos.clone()}o(Ae,"mouseDeltaPos");function $(l="left"){return e.mouseState.pressed.has(l)}o($,"isMousePressed");function Te(l="left"){return e.mouseState.down.has(l)}o(Te,"isMouseDown");function ye(l="left"){return e.mouseState.released.has(l)}o(ye,"isMouseReleased");function Se(){return e.isMouseMoved}o(Se,"isMouseMoved");function st(l){return l===void 0?e.keyState.pressed.size>0:e.keyState.pressed.has(l)}o(st,"isKeyPressed");function an(l){return l===void 0?e.keyState.pressedRepeat.size>0:e.keyState.pressedRepeat.has(l)}o(an,"isKeyPressedRepeat");function Tt(l){return l===void 0?e.keyState.down.size>0:e.keyState.down.has(l)}o(Tt,"isKeyDown");function Ot(l){return l===void 0?e.keyState.released.size>0:e.keyState.released.has(l)}o(Ot,"isKeyReleased");function Rt(l){return l===void 0?e.mergedGamepadState.buttonState.pressed.size>0:e.mergedGamepadState.buttonState.pressed.has(l)}o(Rt,"isGamepadButtonPressed");function Ye(l){return l===void 0?e.mergedGamepadState.buttonState.down.size>0:e.mergedGamepadState.buttonState.down.has(l)}o(Ye,"isGamepadButtonDown");function un(l){return l===void 0?e.mergedGamepadState.buttonState.released.size>0:e.mergedGamepadState.buttonState.released.has(l)}o(un,"isGamepadButtonReleased");function cn(l){return e.events.on("resize",l)}o(cn,"onResize");let hn=Ee(l=>e.events.on("keyDown",l),(l,x)=>e.events.on("keyDown",R=>R===l&&x(l))),ln=Ee(l=>e.events.on("keyPress",l),(l,x)=>e.events.on("keyPress",R=>R===l&&x(l))),dn=Ee(l=>e.events.on("keyPressRepeat",l),(l,x)=>e.events.on("keyPressRepeat",R=>R===l&&x(l))),fn=Ee(l=>e.events.on("keyRelease",l),(l,x)=>e.events.on("keyRelease",R=>R===l&&x(l))),Pt=Ee(l=>e.events.on("mouseDown",x=>l(x)),(l,x)=>e.events.on("mouseDown",R=>R===l&&x(R))),Dt=Ee(l=>e.events.on("mousePress",x=>l(x)),(l,x)=>e.events.on("mousePress",R=>R===l&&x(R))),Mt=Ee(l=>e.events.on("mouseRelease",x=>l(x)),(l,x)=>e.events.on("mouseRelease",R=>R===l&&x(R)));function Gt(l){return e.events.on("mouseMove",()=>l(C(),Ae()))}o(Gt,"onMouseMove");function Bt(l){return e.events.on("charInput",l)}o(Bt,"onCharInput");function mn(l){return e.events.on("touchStart",l)}o(mn,"onTouchStart");function ct(l){return e.events.on("touchMove",l)}o(ct,"onTouchMove");function pn(l){return e.events.on("touchEnd",l)}o(pn,"onTouchEnd");function gn(l){return e.events.on("scroll",l)}o(gn,"onScroll");function Ft(l){return e.events.on("hide",l)}o(Ft,"onHide");function wn(l){return e.events.on("show",l)}o(wn,"onShow");function It(l,x){if(typeof l=="function")return e.events.on("gamepadButtonDown",l);if(typeof l=="string"&&typeof x=="function")return e.events.on("gamepadButtonDown",R=>R===l&&x(l))}o(It,"onGamepadButtonDown");function Lt(l,x){if(typeof l=="function")return e.events.on("gamepadButtonPress",l);if(typeof l=="string"&&typeof x=="function")return e.events.on("gamepadButtonPress",R=>R===l&&x(l))}o(Lt,"onGamepadButtonPress");function bn(l,x){if(typeof l=="function")return e.events.on("gamepadButtonRelease",l);if(typeof l=="string"&&typeof x=="function")return e.events.on("gamepadButtonRelease",R=>R===l&&x(l))}o(bn,"onGamepadButtonRelease");function ht(l,x){return e.events.on("gamepadStick",(R,L)=>R===l&&x(L))}o(ht,"onGamepadStick");function vn(l){e.events.on("gamepadConnect",l)}o(vn,"onGamepadConnect");function lt(l){e.events.on("gamepadDisconnect",l)}o(lt,"onGamepadDisconnect");function Pe(l){return e.mergedGamepadState.stickState.get(l)||new v(0)}o(Pe,"getGamepadStick");function dt(){return[...e.charInputted]}o(dt,"charInputted");function Vt(){return[...e.gamepads]}o(Vt,"getGamepads");function ft(){e.events.trigger("input"),e.keyState.down.forEach(l=>e.events.trigger("keyDown",l)),e.mouseState.down.forEach(l=>e.events.trigger("mouseDown",l)),He()}o(ft,"processInput");function yn(){e.keyState.update(),e.mouseState.update(),e.mergedGamepadState.buttonState.update(),e.mergedGamepadState.stickState.forEach((l,x)=>{e.mergedGamepadState.stickState.set(x,new v(0))}),e.charInputted=[],e.isMouseMoved=!1,e.gamepadStates.forEach(l=>{l.buttonState.update(),l.stickState.forEach((x,R)=>{l.stickState.set(R,new v(0))})})}o(yn,"resetInput");function _t(l){let x={index:l.index,isPressed:R=>e.gamepadStates.get(l.index).buttonState.pressed.has(R),isDown:R=>e.gamepadStates.get(l.index).buttonState.down.has(R),isReleased:R=>e.gamepadStates.get(l.index).buttonState.released.has(R),getStick:R=>e.gamepadStates.get(l.index).stickState.get(R)};return e.gamepads.push(x),e.gamepadStates.set(l.index,{buttonState:new at,stickState:new Map([["left",new v(0)],["right",new v(0)]])}),x}o(_t,"registerGamepad");function ne(l){e.gamepads=e.gamepads.filter(x=>x.index!==l.index),e.gamepadStates.delete(l.index)}o(ne,"removeGamepad");function He(){for(let l of navigator.getGamepads())l&&!e.gamepadStates.has(l.index)&&_t(l);for(let l of e.gamepads){let x=navigator.getGamepads()[l.index],L=(n.gamepads??{})[x.id]??$n[x.id]??$n.default,he=e.gamepadStates.get(l.index);for(let z=0;z{let x=new v(l.offsetX,l.offsetY),R=new v(l.movementX,l.movementY);if(Q()){let L=e.canvas.width/Be,he=e.canvas.height/Be,z=window.innerWidth,Oe=window.innerHeight,$e=z/Oe,kt=L/he;if($e>kt){let De=Oe/he,Ce=(z-L*De)/2;x.x=_e(l.offsetX-Ce,0,L*De,0,L),x.y=_e(l.offsetY,0,he*De,0,he)}else{let De=z/L,Ce=(Oe-he*De)/2;x.x=_e(l.offsetX,0,L*De,0,L),x.y=_e(l.offsetY-Ce,0,he*De,0,he)}}e.events.onOnce("input",()=>{e.isMouseMoved=!0,e.mousePos=x,e.mouseDeltaPos=R,e.events.trigger("mouseMove")})};let We=["left","middle","right","back","forward"];se.mousedown=l=>{e.events.onOnce("input",()=>{let x=We[l.button];x&&(e.mouseState.press(x),e.events.trigger("mousePress",x))})},se.mouseup=l=>{e.events.onOnce("input",()=>{let x=We[l.button];x&&(e.mouseState.release(x),e.events.trigger("mouseRelease",x))})};let xn=new Set([" ","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab"]),qe={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down"," ":"space"};se.keydown=l=>{xn.has(l.key)&&l.preventDefault(),e.events.onOnce("input",()=>{let x=qe[l.key]||l.key.toLowerCase();x.length===1?(e.events.trigger("charInput",x),e.charInputted.push(x)):x==="space"&&(e.events.trigger("charInput"," "),e.charInputted.push(" ")),l.repeat?(e.keyState.pressRepeat(x),e.events.trigger("keyPressRepeat",x)):(e.keyState.press(x),e.events.trigger("keyPressRepeat",x),e.events.trigger("keyPress",x))})},se.keyup=l=>{e.events.onOnce("input",()=>{let x=qe[l.key]||l.key.toLowerCase();e.keyState.release(x),e.events.trigger("keyRelease",x)})},se.touchstart=l=>{l.preventDefault(),e.events.onOnce("input",()=>{let x=[...l.changedTouches],R=e.canvas.getBoundingClientRect();n.touchToMouse!==!1&&(e.mousePos=new v(x[0].clientX-R.x,x[0].clientY-R.y),e.mouseState.press("left"),e.events.trigger("mousePress","left")),x.forEach(L=>{e.events.trigger("touchStart",new v(L.clientX-R.x,L.clientY-R.y),L)})})},se.touchmove=l=>{l.preventDefault(),e.events.onOnce("input",()=>{let x=[...l.changedTouches],R=e.canvas.getBoundingClientRect();n.touchToMouse!==!1&&(e.mousePos=new v(x[0].clientX-R.x,x[0].clientY-R.y),e.events.trigger("mouseMove")),x.forEach(L=>{e.events.trigger("touchMove",new v(L.clientX-R.x,L.clientY-R.y),L)})})},se.touchend=l=>{e.events.onOnce("input",()=>{let x=[...l.changedTouches],R=e.canvas.getBoundingClientRect();n.touchToMouse!==!1&&(e.mousePos=new v(x[0].clientX-R.x,x[0].clientY-R.y),e.mouseState.release("left"),e.events.trigger("mouseRelease","left")),x.forEach(L=>{e.events.trigger("touchEnd",new v(L.clientX-R.x,L.clientY-R.y),L)})})},se.touchcancel=l=>{e.events.onOnce("input",()=>{let x=[...l.changedTouches],R=e.canvas.getBoundingClientRect();n.touchToMouse!==!1&&(e.mousePos=new v(x[0].clientX-R.x,x[0].clientY-R.y),e.mouseState.release("left"),e.events.trigger("mouseRelease","left")),x.forEach(L=>{e.events.trigger("touchEnd",new v(L.clientX-R.x,L.clientY-R.y),L)})})},se.wheel=l=>{l.preventDefault(),e.events.onOnce("input",()=>{e.events.trigger("scroll",new v(l.deltaX,l.deltaY))})},se.contextmenu=l=>l.preventDefault(),le.visibilitychange=()=>{document.visibilityState==="visible"?(e.skipTime=!0,e.events.trigger("show")):e.events.trigger("hide")},ae.gamepadconnected=l=>{let x=_t(l.gamepad);e.events.onOnce("input",()=>{e.events.trigger("gamepadConnect",x)})},ae.gamepaddisconnected=l=>{let x=Vt().filter(R=>R.index===l.gamepad.index)[0];ne(l.gamepad),e.events.onOnce("input",()=>{e.events.trigger("gamepadDisconnect",x)})};for(let l in se)e.canvas.addEventListener(l,se[l]);for(let l in le)document.addEventListener(l,le[l]);for(let l in ae)window.addEventListener(l,ae[l]);let ge=new ResizeObserver(l=>{for(let x of l)if(x.target===e.canvas){if(e.lastWidth===e.canvas.offsetWidth&&e.lastHeight===e.canvas.offsetHeight)return;e.lastWidth=e.canvas.offsetWidth,e.lastHeight=e.canvas.offsetHeight,e.events.onOnce("input",()=>{e.events.trigger("resize")})}});return ge.observe(e.canvas),{dt:i,time:c,run:k,canvas:e.canvas,fps:m,numFrames:p,quit:te,setFullscreen:K,isFullscreen:Q,setCursor:I,screenshot:P,getGamepads:Vt,getCursor:j,setCursorLocked:y,isCursorLocked:X,isTouchscreen:pe,mousePos:C,mouseDeltaPos:Ae,isKeyDown:Tt,isKeyPressed:st,isKeyPressedRepeat:an,isKeyReleased:Ot,isMouseDown:Te,isMousePressed:$,isMouseReleased:ye,isMouseMoved:Se,isGamepadButtonPressed:Rt,isGamepadButtonDown:Ye,isGamepadButtonReleased:un,getGamepadStick:Pe,charInputted:dt,onResize:cn,onKeyDown:hn,onKeyPress:ln,onKeyPressRepeat:dn,onKeyRelease:fn,onMouseDown:Pt,onMousePress:Dt,onMouseRelease:Mt,onMouseMove:Gt,onCharInput:Bt,onTouchStart:mn,onTouchMove:ct,onTouchEnd:pn,onScroll:gn,onHide:Ft,onShow:wn,onGamepadButtonDown:It,onGamepadButtonPress:Lt,onGamepadButtonRelease:bn,onGamepadStick:ht,onGamepadConnect:vn,onGamepadDisconnect:lt,events:e.events}},"default");var Re=class n{static{o(this,"Texture")}ctx;src=null;glTex;width;height;constructor(e,i,c,m={}){this.ctx=e;let p=e.gl;this.glTex=e.gl.createTexture(),e.onDestroy(()=>this.free()),this.width=i,this.height=c;let P={linear:p.LINEAR,nearest:p.NEAREST}[m.filter??e.opts.texFilter]??p.NEAREST,I={repeat:p.REPEAT,clampToEadge:p.CLAMP_TO_EDGE}[m.wrap]??p.CLAMP_TO_EDGE;this.bind(),i&&c&&p.texImage2D(p.TEXTURE_2D,0,p.RGBA,i,c,0,p.RGBA,p.UNSIGNED_BYTE,null),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,P),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,P),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,I),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,I),this.unbind()}static fromImage(e,i,c={}){let m=new n(e,i.width,i.height,c);return m.update(i),m.src=i,m}update(e,i=0,c=0){let m=this.ctx.gl;this.bind(),m.texSubImage2D(m.TEXTURE_2D,0,i,c,m.RGBA,m.UNSIGNED_BYTE,e),this.unbind()}bind(){this.ctx.pushTexture2D(this.glTex)}unbind(){this.ctx.popTexture2D()}free(){this.ctx.gl.deleteTexture(this.glTex)}},rt=class{static{o(this,"FrameBuffer")}ctx;tex;glFramebuffer;glRenderbuffer;constructor(e,i,c,m={}){this.ctx=e;let p=e.gl;e.onDestroy(()=>this.free()),this.tex=new Re(e,i,c,m),this.glFramebuffer=p.createFramebuffer(),this.glRenderbuffer=p.createRenderbuffer(),this.bind(),p.renderbufferStorage(p.RENDERBUFFER,p.DEPTH_STENCIL,i,c),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,this.tex.glTex,0),p.framebufferRenderbuffer(p.FRAMEBUFFER,p.DEPTH_STENCIL_ATTACHMENT,p.RENDERBUFFER,this.glRenderbuffer),this.unbind()}get width(){return this.tex.width}get height(){return this.tex.height}toImageData(){let e=this.ctx.gl,i=new Uint8ClampedArray(this.width*this.height*4);this.bind(),e.readPixels(0,0,this.width,this.height,e.RGBA,e.UNSIGNED_BYTE,i),this.unbind();let c=this.width*4,m=new Uint8Array(c);for(let p=0;p<(this.height/2|0);p++){let P=p*c,I=(this.height-p-1)*c;m.set(i.subarray(P,P+c)),i.copyWithin(P,I,I+c),i.set(m,I)}return new ImageData(i,this.width,this.height)}toDataURL(){let e=document.createElement("canvas"),i=e.getContext("2d");return e.width=this.width,e.height=this.height,i.putImageData(this.toImageData(),0,0),e.toDataURL()}draw(e){this.bind(),e(),this.unbind()}bind(){this.ctx.pushFramebuffer(this.glFramebuffer),this.ctx.pushRenderbuffer(this.glRenderbuffer),this.ctx.pushViewport({x:0,y:0,w:this.width,h:this.height})}unbind(){this.ctx.popFramebuffer(),this.ctx.popRenderbuffer(),this.ctx.popViewport()}free(){let e=this.ctx.gl;e.deleteFramebuffer(this.glFramebuffer),e.deleteRenderbuffer(this.glRenderbuffer),this.tex.free()}},Qt=class{static{o(this,"Shader")}ctx;glProgram;constructor(e,i,c,m){this.ctx=e,e.onDestroy(()=>this.free());let p=e.gl,P=p.createShader(p.VERTEX_SHADER),I=p.createShader(p.FRAGMENT_SHADER);p.shaderSource(P,i),p.shaderSource(I,c),p.compileShader(P),p.compileShader(I);let j=p.createProgram();if(this.glProgram=j,p.attachShader(j,P),p.attachShader(j,I),m.forEach((y,X)=>p.bindAttribLocation(j,X,y)),p.linkProgram(j),!p.getProgramParameter(j,p.LINK_STATUS)){let y=p.getShaderInfoLog(P);if(y)throw new Error("VERTEX SHADER "+y);let X=p.getShaderInfoLog(I);if(X)throw new Error("FRAGMENT SHADER "+X)}p.deleteShader(P),p.deleteShader(I)}bind(){this.ctx.pushProgram(this.glProgram)}unbind(){this.ctx.popProgram()}send(e){let i=this.ctx.gl;for(let c in e){let m=e[c],p=i.getUniformLocation(this.glProgram,c);typeof m=="number"?i.uniform1f(p,m):m instanceof Ue?i.uniformMatrix4fv(p,!1,new Float32Array(m.m)):m instanceof W?i.uniform3f(p,m.r,m.g,m.b):m instanceof v&&i.uniform2f(p,m.x,m.y)}}free(){this.ctx.gl.deleteProgram(this.glProgram)}},Zt=class{static{o(this,"BatchRenderer")}ctx;glVBuf;glIBuf;vqueue=[];iqueue=[];stride;maxVertices;maxIndices;vertexFormat;numDraws=0;curPrimitive=null;curTex=null;curShader=null;curUniform={};constructor(e,i,c,m){let p=e.gl;this.vertexFormat=i,this.ctx=e,this.stride=i.reduce((P,I)=>P+I.size,0),this.maxVertices=c,this.maxIndices=m,this.glVBuf=p.createBuffer(),e.pushArrayBuffer(this.glVBuf),p.bufferData(p.ARRAY_BUFFER,c*4,p.DYNAMIC_DRAW),e.popArrayBuffer(),this.glIBuf=p.createBuffer(),e.pushElementArrayBuffer(this.glIBuf),p.bufferData(p.ELEMENT_ARRAY_BUFFER,m*4,p.DYNAMIC_DRAW),e.popElementArrayBuffer()}push(e,i,c,m,p=null,P={}){(e!==this.curPrimitive||p!==this.curTex||m!==this.curShader||!Xt(this.curUniform,P)||this.vqueue.length+i.length*this.stride>this.maxVertices||this.iqueue.length+c.length>this.maxIndices)&&this.flush();let I=this.vqueue.length/this.stride;for(let j of i)this.vqueue.push(j);for(let j of c)this.iqueue.push(j+I);this.curPrimitive=e,this.curShader=m,this.curTex=p,this.curUniform=P}flush(){if(!this.curPrimitive||!this.curShader||this.vqueue.length===0||this.iqueue.length===0)return;let e=this.ctx.gl;this.ctx.pushArrayBuffer(this.glVBuf),e.bufferSubData(e.ARRAY_BUFFER,0,new Float32Array(this.vqueue)),this.ctx.pushElementArrayBuffer(this.glIBuf),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,new Uint16Array(this.iqueue)),this.ctx.setVertexFormat(this.vertexFormat),this.curShader.bind(),this.curShader.send(this.curUniform),this.curTex?.bind(),e.drawElements(this.curPrimitive,this.iqueue.length,e.UNSIGNED_SHORT,0),this.curTex?.unbind(),this.curShader.unbind(),this.ctx.popArrayBuffer(),this.ctx.popElementArrayBuffer(),this.vqueue=[],this.iqueue=[],this.numDraws++}free(){let e=this.ctx.gl;e.deleteBuffer(this.glVBuf),e.deleteBuffer(this.glIBuf)}};function nt(n){let e=[],i=o(p=>{e.push(p),n(p)},"push"),c=o(()=>{e.pop(),n(m()??null)},"pop"),m=o(()=>e[e.length-1],"cur");return[i,c,m]}o(nt,"genStack");function Yn(n,e={}){let i=[];function c($){i.push($)}o(c,"onDestroy");function m(){i.forEach($=>$()),n.getExtension("WEBGL_lose_context").loseContext()}o(m,"destroy");let p=null;function P($){if(Xt($,p))return;p=$;let Te=$.reduce((ye,Se)=>ye+Se.size,0);$.reduce((ye,Se,st)=>(n.vertexAttribPointer(st,Se.size,n.FLOAT,!1,Te*4,ye),n.enableVertexAttribArray(st),ye+Se.size*4),0)}o(P,"setVertexFormat");let[I,j]=nt($=>n.bindTexture(n.TEXTURE_2D,$)),[y,X]=nt($=>n.bindBuffer(n.ARRAY_BUFFER,$)),[S,q]=nt($=>n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,$)),[E,K]=nt($=>n.bindFramebuffer(n.FRAMEBUFFER,$)),[Q,te]=nt($=>n.bindRenderbuffer(n.RENDERBUFFER,$)),[k,pe]=nt(({x:$,y:Te,w:ye,h:Se})=>{n.viewport($,Te,ye,Se)}),[C,Ae]=nt($=>n.useProgram($));return k({x:0,y:0,w:n.drawingBufferWidth,h:n.drawingBufferHeight}),{gl:n,opts:e,onDestroy:c,destroy:m,pushTexture2D:I,popTexture2D:j,pushArrayBuffer:y,popArrayBuffer:X,pushElementArrayBuffer:S,popElementArrayBuffer:q,pushFramebuffer:E,popFramebuffer:K,pushRenderbuffer:Q,popRenderbuffer:te,pushViewport:k,popViewport:pe,pushProgram:C,popProgram:Ae,setVertexFormat:P}}o(Yn,"initGfx");var ve=class n{static{o(this,"Asset")}loaded=!1;data=null;error=null;onLoadEvents=new be;onErrorEvents=new be;onFinishEvents=new be;constructor(e){e.then(i=>{this.data=i,this.onLoadEvents.trigger(i)}).catch(i=>{if(this.error=i,this.onErrorEvents.numListeners()>0)this.onErrorEvents.trigger(i);else throw i}).finally(()=>{this.onFinishEvents.trigger(),this.loaded=!0})}static loaded(e){let i=new n(Promise.resolve(e));return i.data=e,i.loaded=!0,i}onLoad(e){return this.loaded&&this.data?e(this.data):this.onLoadEvents.add(e),this}onError(e){return this.loaded&&this.error?e(this.error):this.onErrorEvents.add(e),this}onFinish(e){return this.loaded?e():this.onFinishEvents.add(e),this}then(e){return this.onLoad(e)}catch(e){return this.onError(e)}finally(e){return this.onFinish(e)}},je=class{static{o(this,"AssetBucket")}assets=new Map;lastUID=0;add(e,i){let c=e??this.lastUID+++"",m=new ve(i);return this.assets.set(c,m),m}addLoaded(e,i){let c=e??this.lastUID+++"",m=ve.loaded(i);return this.assets.set(c,m),m}get(e){return this.assets.get(e)}progress(){if(this.assets.size===0)return 1;let e=0;return this.assets.forEach(i=>{i.loaded&&e++}),e/this.assets.size}};function Wn(n){return fetch(n).then(e=>{if(!e.ok)throw new Error(`Failed to fetch "${n}"`);return e})}o(Wn,"fetchURL");function Et(n){return Wn(n).then(e=>e.json())}o(Et,"fetchJSON");function Vr(n){return Wn(n).then(e=>e.text())}o(Vr,"fetchText");function _r(n){return Wn(n).then(e=>e.arrayBuffer())}o(_r,"fetchArrayBuffer");function St(n){let e=new Image;return e.crossOrigin="anonymous",e.src=n,new Promise((i,c)=>{e.onload=()=>i(e),e.onerror=()=>c(new Error(`Failed to load image from "${n}"`))})}o(St,"loadImg");var en=2.5949095,kr=1.70158+1,Nr=2*Math.PI/3,jr=2*Math.PI/4.5,tn={linear:n=>n,easeInSine:n=>1-Math.cos(n*Math.PI/2),easeOutSine:n=>Math.sin(n*Math.PI/2),easeInOutSine:n=>-(Math.cos(Math.PI*n)-1)/2,easeInQuad:n=>n*n,easeOutQuad:n=>1-(1-n)*(1-n),easeInOutQuad:n=>n<.5?2*n*n:1-Math.pow(-2*n+2,2)/2,easeInCubic:n=>n*n*n,easeOutCubic:n=>1-Math.pow(1-n,3),easeInOutCubic:n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,easeInQuart:n=>n*n*n*n,easeOutQuart:n=>1-Math.pow(1-n,4),easeInOutQuart:n=>n<.5?8*n*n*n*n:1-Math.pow(-2*n+2,4)/2,easeInQuint:n=>n*n*n*n*n,easeOutQuint:n=>1-Math.pow(1-n,5),easeInOutQuint:n=>n<.5?16*n*n*n*n*n:1-Math.pow(-2*n+2,5)/2,easeInExpo:n=>n===0?0:Math.pow(2,10*n-10),easeOutExpo:n=>n===1?1:1-Math.pow(2,-10*n),easeInOutExpo:n=>n===0?0:n===1?1:n<.5?Math.pow(2,20*n-10)/2:(2-Math.pow(2,-20*n+10))/2,easeInCirc:n=>1-Math.sqrt(1-Math.pow(n,2)),easeOutCirc:n=>Math.sqrt(1-Math.pow(n-1,2)),easeInOutCirc:n=>n<.5?(1-Math.sqrt(1-Math.pow(2*n,2)))/2:(Math.sqrt(1-Math.pow(-2*n+2,2))+1)/2,easeInBack:n=>kr*n*n*n-1.70158*n*n,easeOutBack:n=>1+kr*Math.pow(n-1,3)+1.70158*Math.pow(n-1,2),easeInOutBack:n=>n<.5?Math.pow(2*n,2)*((en+1)*2*n-en)/2:(Math.pow(2*n-2,2)*((en+1)*(n*2-2)+en)+2)/2,easeInElastic:n=>n===0?0:n===1?1:-Math.pow(2,10*n-10)*Math.sin((n*10-10.75)*Nr),easeOutElastic:n=>n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n*10-.75)*Nr)+1,easeInOutElastic:n=>n===0?0:n===1?1:n<.5?-(Math.pow(2,20*n-10)*Math.sin((20*n-11.125)*jr))/2:Math.pow(2,-20*n+10)*Math.sin((20*n-11.125)*jr)/2+1,easeInBounce:n=>1-tn.easeOutBounce(1-n),easeOutBounce:n=>n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375,easeInOutBounce:n=>n<.5?(1-tn.easeOutBounce(1-2*n))/2:(1+tn.easeOutBounce(2*n-1))/2},Ct=tn;var At=class{static{o(this,"TexPacker")}textures=[];canvas;c2d;x=0;y=0;curHeight=0;gfx;constructor(e,i,c){this.gfx=e,this.canvas=document.createElement("canvas"),this.canvas.width=i,this.canvas.height=c,this.textures=[Re.fromImage(e,this.canvas)],this.c2d=this.canvas.getContext("2d")}add(e){if(e.width>this.canvas.width||e.height>this.canvas.height)throw new Error(`Texture size (${e.width} x ${e.height}) exceeds limit (${this.canvas.width} x ${this.canvas.height})`);this.x+e.width>this.canvas.width&&(this.x=0,this.y+=this.curHeight,this.curHeight=0),this.y+e.height>this.canvas.height&&(this.c2d.clearRect(0,0,this.canvas.width,this.canvas.height),this.textures.push(Re.fromImage(this.gfx,this.canvas)),this.x=0,this.y=0,this.curHeight=0);let i=this.textures[this.textures.length-1],c=new v(this.x,this.y);return this.x+=e.width,e.height>this.curHeight&&(this.curHeight=e.height),e instanceof ImageData?this.c2d.putImageData(e,c.x,c.y):this.c2d.drawImage(e,c.x,c.y),i.update(this.canvas),[i,new oe(c.x/this.canvas.width,c.y/this.canvas.height,e.width/this.canvas.width,e.height/this.canvas.height)]}free(){for(let e of this.textures)e.free()}};var Hr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD0AAAA1CAYAAADyMeOEAAAAAXNSR0IArs4c6QAAAoVJREFUaIHdm7txwkAQhheGAqACiCHzOKQDQrqgILpwSAeEDBnEUAF0gCMxZ7G72qce/mec2Lpf9+3unaS78wgSNZ8uX5729+d1FNWXUuGmXlBOUUEIMckEpeQJgBu6C+BSFngztBR2vd+ovY+7g+p6LbgaWgJrAeUkDYIUXgXdBB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Gl51ZTHCnFv5bqNnFGjZvRtEFUEHSHmI1ZHWgVBXZ5+sxvX7ANlPChpjKsknSllKaPlRU4nZo0Yjq6wiIJGFPMML2mj3M8ZRRe4QkzF6FhCJEFbBn4i0iKswn11yenZiLLKeMRqQdWiZSmlkqrcV9d0gPfksAcqBW+2ZqAoq5gZGSrnTtGwlVmCIqUepxWxerj7iIyNZ7SgiKmJhJw7NJpRgiKmLuHl3KnReA4UIaU+y+WkcbzHQ1DEzMGQ9aJH0BDK6RE0y9wlTDp2HuppERQxc0FFBaZGUMTMB5UlQG/fHyk1odJEaBUUMXWh4oSoFRQxtaHyxMi2uBseQwUKciUoYuaAShTlkaCImQcqUph7QREzF/8DSS/2GZ2/N/sAAAAASUVORK5CYII=";var zi="3000.1.17",Kr=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",nn="topleft",Yr=64,Ki="monospace",rn="monospace",Yi=36,sn=64,on=256,Wr=2048,Xr=2048,Jr=2048,Qr=2048,Zr=.1,Wi=64,Xn="linear",Xi=8,Ji=4,Zn=[{name:"a_pos",size:2},{name:"a_uv",size:2},{name:"a_color",size:4}],Qi=Zn.reduce((n,e)=>n+e.size,0),es=2048,Zi=es*4*Qi,eo=es*6,to=` attribute vec2 a_pos; attribute vec2 a_uv; attribute vec4 a_color; varying vec2 v_pos; varying vec2 v_uv; varying vec4 v_color; vec4 def_vert() { return vec4(a_pos, 0.0, 1.0); } {{user}} void main() { vec4 pos = vert(a_pos, a_uv, a_color); v_pos = a_pos; v_uv = a_uv; v_color = a_color; gl_Position = pos; } `,no=` precision mediump float; varying vec2 v_pos; varying vec2 v_uv; varying vec4 v_color; uniform sampler2D u_tex; vec4 def_frag() { return v_color * texture2D(u_tex, v_uv); } {{user}} void main() { gl_FragColor = frag(v_pos, v_uv, v_color, u_tex); if (gl_FragColor.a == 0.0) { discard; } } `,Jn=` vec4 vert(vec2 pos, vec2 uv, vec4 color) { return def_vert(); } `,Qn=` vec4 frag(vec2 pos, vec2 uv, vec4 color, sampler2D tex) { return def_frag(); } `,ro=new Set(["id","require"]),so=new Set(["add","update","draw","destroy","inspect","drawInspect"]);function ut(n){switch(n){case"topleft":return new v(-1,-1);case"top":return new v(0,-1);case"topright":return new v(1,-1);case"left":return new v(-1,0);case"center":return new v(0,0);case"right":return new v(1,0);case"botleft":return new v(-1,1);case"bot":return new v(0,1);case"botright":return new v(1,1);default:return n}}o(ut,"anchorPt");function io(n){switch(n){case"left":return 0;case"center":return .5;case"right":return 1;default:return 0}}o(io,"alignPt");function oo(n){return n.createBuffer(1,1,44100)}o(oo,"createEmptyAudioBuffer");var ao=o((n={})=>{let e=n.root??document.body;e===document.body&&(document.body.style.width="100%",document.body.style.height="100%",document.body.style.margin="0px",document.documentElement.style.width="100%",document.documentElement.style.height="100%");let i=n.canvas??(()=>{let t=document.createElement("canvas");return e.appendChild(t),t})(),c=n.scale??1,m=n.width&&n.height&&!n.stretch&&!n.letterbox;m?(i.width=n.width*c,i.height=n.height*c):(i.width=i.parentElement.offsetWidth,i.height=i.parentElement.offsetHeight);let p=["outline: none","cursor: default"];if(m){let t=i.width,r=i.height;p.push(`width: ${t}px`),p.push(`height: ${r}px`)}else p.push("width: 100%"),p.push("height: 100%");n.crisp&&(p.push("image-rendering: pixelated"),p.push("image-rendering: crisp-edges")),i.style.cssText=p.join(";");let P=n.pixelDensity||window.devicePixelRatio;i.width*=P,i.height*=P,i.tabIndex=0;let I=document.createElement("canvas");I.width=on,I.height=on;let j=I.getContext("2d",{willReadFrequently:!0}),y=Lr({canvas:i,touchToMouse:n.touchToMouse,gamepads:n.gamepads,pixelDensity:n.pixelDensity,maxFPS:n.maxFPS}),X=[],S=y.canvas.getContext("webgl",{antialias:!0,depth:!0,stencil:!0,alpha:!0,preserveDrawingBuffer:!0}),q=Yn(S,{texFilter:n.texFilter}),E=(()=>{let t=ht(Jn,Qn),r=Re.fromImage(q,new ImageData(new Uint8ClampedArray([255,255,255,255]),1,1)),s=n.width&&n.height?new rt(q,n.width*P*c,n.height*P*c):new rt(q,S.drawingBufferWidth,S.drawingBufferHeight),u=null,a=1;n.background&&(u=J(n.background),a=Array.isArray(n.background)?n.background[3]:1,S.clearColor(u.r/255,u.g/255,u.b/255,a??1)),S.enable(S.BLEND),S.blendFuncSeparate(S.SRC_ALPHA,S.ONE_MINUS_SRC_ALPHA,S.ONE,S.ONE_MINUS_SRC_ALPHA);let h=new Zt(q,Zn,Zi,eo),f=Re.fromImage(q,new ImageData(new Uint8ClampedArray([128,128,128,255,190,190,190,255,190,190,190,255,128,128,128,255]),2,2),{wrap:"repeat",filter:"nearest"});return{lastDrawCalls:0,defShader:t,defTex:r,frameBuffer:s,postShader:null,postShaderUniform:null,renderer:h,transform:new Ue,transformStack:[],bgTex:f,bgColor:u,bgAlpha:a,width:n.width??S.drawingBufferWidth/P/c,height:n.height??S.drawingBufferHeight/P/c,viewport:{x:0,y:0,width:S.drawingBufferWidth,height:S.drawingBufferHeight},fixed:!1}})();class K{static{o(this,"SpriteData")}tex;frames=[new oe(0,0,1,1)];anims={};slice9=null;constructor(r,s,u={},a=null){this.tex=r,s&&(this.frames=s),this.anims=u,this.slice9=a}get width(){return this.tex.width*this.frames[0].w}get height(){return this.tex.height*this.frames[0].h}static from(r,s={}){return typeof r=="string"?K.fromURL(r,s):Promise.resolve(K.fromImage(r,s))}static fromImage(r,s={}){let[u,a]=k.packer.add(r),h=s.frames?s.frames.map(f=>new oe(a.x+f.x*a.w,a.y+f.y*a.h,f.w*a.w,f.h*a.h)):Tt(s.sliceX||1,s.sliceY||1,a.x,a.y,a.w,a.h);return new K(u,h,s.anims,s.slice9)}static fromURL(r,s={}){return St(r).then(u=>K.fromImage(u,s))}}class Q{static{o(this,"SoundData")}buf;constructor(r){this.buf=r}static fromArrayBuffer(r){return new Promise((s,u)=>te.ctx.decodeAudioData(r,s,u)).then(s=>new Q(s))}static fromURL(r){return Hn(r)?Q.fromArrayBuffer(Dr(r)):_r(r).then(s=>Q.fromArrayBuffer(s))}}let te=(()=>{let t=new(window.AudioContext||window.webkitAudioContext),r=t.createGain();r.connect(t.destination);let s=new Q(oo(t));return t.decodeAudioData(qr.buffer.slice(0)).then(u=>{s.buf=u}).catch(u=>{console.error("Failed to load burp: ",u)}),{ctx:t,masterNode:r,burpSnd:s}})(),k={urlPrefix:"",sprites:new je,fonts:new je,bitmapFonts:new je,sounds:new je,shaders:new je,custom:new je,packer:new At(q,Jr,Qr),loaded:!1};function pe(t){return typeof t!="string"||Hn(t)?t:k.urlPrefix+t}o(pe,"fixURL");let C={events:new Ne,objEvents:new Ne,root:En([]),gravity:0,scenes:{},logs:[],cam:{pos:null,scale:new v(1),angle:0,shake:0,transform:new Ue}};C.root.use(Tn());function Ae(t){return k.custom.add(null,t)}o(Ae,"load");function $(){let t=[k.sprites,k.sounds,k.shaders,k.fonts,k.bitmapFonts,k.custom];return t.reduce((r,s)=>r+s.progress(),0)/t.length}o($,"loadProgress");function Te(t){return t!==void 0&&(k.urlPrefix=t),k.urlPrefix}o(Te,"loadRoot");function ye(t,r){return k.custom.add(t,Et(r))}o(ye,"loadJSON");class Se{static{o(this,"FontData")}fontface;filter=Xn;outline=null;size=sn;constructor(r,s={}){if(this.fontface=r,this.filter=s.filter??Xn,this.size=s.size??sn,this.size>on)throw new Error(`Max font size: ${on}`);s.outline&&(this.outline={width:1,color:J(0,0,0)},typeof s.outline=="number"?this.outline.width=s.outline:typeof s.outline=="object"&&(s.outline.width&&(this.outline.width=s.outline.width),s.outline.color&&(this.outline.color=s.outline.color)))}}function st(t,r,s={}){let u=new FontFace(t,typeof r=="string"?`url(${r})`:r);return document.fonts.add(u),k.fonts.add(t,u.load().catch(a=>{throw new Error(`Failed to load font from "${r}": ${a}`)}).then(a=>new Se(a,s)))}o(st,"loadFont");function an(t,r,s,u,a={}){return k.bitmapFonts.add(t,St(r).then(h=>vn(Re.fromImage(q,h,a),s,u,a.chars??Kr)))}o(an,"loadBitmapFont");function Tt(t=1,r=1,s=0,u=0,a=1,h=1){let f=[],b=a/t,g=h/r;for(let d=0;d{Et(r).then(a=>{Ot(t,a).then(s).catch(u)})}):K.from(t).then(s=>{let u={};for(let a in r){let h=r[a],f=s.frames[0],b=Jr*f.w,g=Qr*f.h,d=h.frames?h.frames.map(A=>new oe(f.x+(h.x+A.x)/b*f.w,f.y+(h.y+A.y)/g*f.h,A.w/b*f.w,A.h/g*f.h)):Tt(h.sliceX||1,h.sliceY||1,f.x+h.x/b*f.w,f.y+h.y/g*f.h,h.width/b*f.w,h.height/g*f.h),w=new K(s.tex,d,h.anims);k.sprites.addLoaded(a,w),u[a]=w}return u}))}o(Ot,"loadSpriteAtlas");function Rt(t,r={}){let s=document.createElement("canvas"),u=t[0].width,a=t[0].height;s.width=u*t.length,s.height=a;let h=s.getContext("2d");t.forEach((b,g)=>{b instanceof ImageData?h.putImageData(b,g*u,0):h.drawImage(b,g*u,0)});let f=h.getImageData(0,0,t.length*u,a);return K.fromImage(f,{...r,sliceX:t.length,sliceY:1})}o(Rt,"createSpriteSheet");function Ye(t,r,s={sliceX:1,sliceY:1,anims:{}}){return r=pe(r),Array.isArray(r)?r.some(u=>typeof u=="string")?k.sprites.add(t,Promise.all(r.map(u=>typeof u=="string"?St(u):Promise.resolve(u))).then(u=>Rt(u,s))):k.sprites.addLoaded(t,Rt(r,s)):typeof r=="string"?k.sprites.add(t,K.from(r,s)):k.sprites.addLoaded(t,K.fromImage(r,s))}o(Ye,"loadSprite");function un(t,r){return r=pe(r),k.sprites.add(t,new Promise(async s=>{let u=typeof r=="string"?await Et(r):r,a=await Promise.all(u.frames.map(St)),h=document.createElement("canvas");h.width=u.width,h.height=u.height*u.frames.length;let f=h.getContext("2d");a.forEach((g,d)=>{f.drawImage(g,0,d*u.height)});let b=await Ye(null,h,{sliceY:u.frames.length,anims:u.anims});s(b)}))}o(un,"loadPedit");function cn(t,r,s){r=pe(r),s=pe(s),typeof r=="string"&&!s&&(s=Gr(r)+".json");let u=typeof s=="string"?Et(s):Promise.resolve(s);return k.sprites.add(t,u.then(a=>{let h=a.meta.size,f=a.frames.map(g=>new oe(g.frame.x/h.w,g.frame.y/h.h,g.frame.w/h.w,g.frame.h/h.h)),b={};for(let g of a.meta.frameTags)g.from===g.to?b[g.name]=g.from:b[g.name]={from:g.from,to:g.to,speed:10,loop:!0,pingpong:g.direction==="pingpong"};return K.from(r,{frames:f,anims:b})}))}o(cn,"loadAseprite");function hn(t,r,s){return k.shaders.addLoaded(t,ht(r,s))}o(hn,"loadShader");function ln(t,r,s){r=pe(r),s=pe(s);let u=o(h=>h?Vr(h):Promise.resolve(null),"resolveUrl"),a=Promise.all([u(r),u(s)]).then(([h,f])=>ht(h,f));return k.shaders.add(t,a)}o(ln,"loadShaderURL");function dn(t,r){return r=pe(r),k.sounds.add(t,typeof r=="string"?Q.fromURL(r):Q.fromArrayBuffer(r))}o(dn,"loadSound");function fn(t="bean"){return Ye(t,Hr)}o(fn,"loadBean");function Pt(t){return k.sprites.get(t)}o(Pt,"getSprite");function Dt(t){return k.sounds.get(t)}o(Dt,"getSound");function Mt(t){return k.fonts.get(t)}o(Mt,"getFont");function Gt(t){return k.bitmapFonts.get(t)}o(Gt,"getBitmapFont");function Bt(t){return k.shaders.get(t)}o(Bt,"getShader");function mn(t){return k.custom.get(t)}o(mn,"getAsset");function ct(t){if(typeof t=="string"){let r=Pt(t);if(r)return r;if($()<1)return null;throw new Error(`Sprite not found: ${t}`)}else{if(t instanceof K)return ve.loaded(t);if(t instanceof ve)return t;throw new Error(`Invalid sprite: ${t}`)}}o(ct,"resolveSprite");function pn(t){if(typeof t=="string"){let r=Dt(t);if(r)return r;if($()<1)return null;throw new Error(`Sound not found: ${t}`)}else{if(t instanceof Q)return ve.loaded(t);if(t instanceof ve)return t;throw new Error(`Invalid sound: ${t}`)}}o(pn,"resolveSound");function gn(t){if(!t)return E.defShader;if(typeof t=="string"){let r=Bt(t);if(r)return r.data??r;if($()<1)return null;throw new Error(`Shader not found: ${t}`)}else if(t instanceof ve)return t.data?t.data:t;return t}o(gn,"resolveShader");function Ft(t){if(!t)return Ft(n.font??Ki);if(typeof t=="string"){let r=Gt(t),s=Mt(t);if(r)return r.data??r;if(s)return s.data??s;if(document.fonts.check(`${sn}px ${t}`))return t;if($()<1)return null;throw new Error(`Font not found: ${t}`)}else if(t instanceof ve)return t.data?t.data:t;return t}o(Ft,"resolveFont");function wn(t){return t!==void 0&&(te.masterNode.gain.value=t),te.masterNode.gain.value}o(wn,"volume");function It(t,r={}){let s=te.ctx,u=r.paused??!1,a=s.createBufferSource(),h=new be,f=s.createGain(),b=r.seek??0,g=0,d=0,w=!1;a.loop=!!r.loop,a.detune.value=r.detune??0,a.playbackRate.value=r.speed??1,a.connect(f),a.onended=()=>{N()>=a.buffer?.duration&&h.trigger()},f.connect(te.masterNode),f.gain.value=r.volume??1;let A=o(M=>{a.buffer=M.buf,u||(g=s.currentTime,a.start(0,b),w=!0)},"start"),D=pn(t);D instanceof ve&&D.onLoad(A);let N=o(()=>{if(!a.buffer)return 0;let M=u?d-g:s.currentTime-g,O=a.buffer.duration;return a.loop?M%O:Math.min(M,O)},"getTime"),_=o(M=>{let O=s.createBufferSource();return O.buffer=M.buffer,O.loop=M.loop,O.playbackRate.value=M.playbackRate.value,O.detune.value=M.detune.value,O.onended=M.onended,O.connect(f),O},"cloneNode");return{stop(){this.paused=!0,this.seek(0)},set paused(M){if(u!==M)if(u=M,M)w&&(a.stop(),w=!1),d=s.currentTime;else{a=_(a);let O=d-g;a.start(0,O),w=!0,g=s.currentTime-O,d=0}},get paused(){return u},play(M=0){this.seek(M),this.paused=!1},seek(M){a.buffer?.duration&&(M>a.buffer.duration||(u?(a=_(a),g=d-M):(a.stop(),a=_(a),g=s.currentTime-M,a.start(0,M),w=!0,d=0)))},set speed(M){a.playbackRate.value=M},get speed(){return a.playbackRate.value},set detune(M){a.detune.value=M},get detune(){return a.detune.value},set volume(M){f.gain.value=Math.max(M,0)},get volume(){return f.gain.value},set loop(M){a.loop=M},get loop(){return a.loop},duration(){return a.buffer?.duration??0},time(){return N()%this.duration()},onEnd(M){return h.add(M)},then(M){return this.onEnd(M)}}}o(It,"play");function Lt(t){return It(te.burpSnd,t)}o(Lt,"burp");function bn(t,r){return new rt(q,t,r)}o(bn,"makeCanvas");function ht(t=Jn,r=Qn){let s=to.replace("{{user}}",t??Jn),u=no.replace("{{user}}",r??Qn);try{return new Qt(q,s,u,Zn.map(a=>a.name))}catch(a){let f=/(?^\w+) SHADER ERROR: 0:(?\d+): (?.+)/,b=Fr(a).match(f),g=Number(b.groups.line)-14,d=b.groups.msg.trim(),w=b.groups.type.toLowerCase();throw new Error(`${w} shader line ${g}: ${d}`)}}o(ht,"makeShader");function vn(t,r,s,u){let a=t.width/r,h={},f=u.split("").entries();for(let[b,g]of f)h[g]=new oe(b%a*r,Math.floor(b/a)*s,r,s);return{tex:t,map:h,size:s}}o(vn,"makeFont");function lt(t,r,s,u=E.defTex,a=E.defShader,h={}){let f=gn(a);if(!f||f instanceof ve)return;let b=E.fixed||s?E.transform:C.cam.transform.mult(E.transform),g=[];for(let d of t){let w=yn(b.multVec2(d.pos));g.push(w.x,w.y,d.uv.x,d.uv.y,d.color.r/255,d.color.g/255,d.color.b/255,d.opacity)}E.renderer.push(S.TRIANGLES,g,r,f,u,h)}o(lt,"drawRaw");function Pe(){E.renderer.flush()}o(Pe,"flush");function dt(){S.clear(S.COLOR_BUFFER_BIT),E.frameBuffer.bind(),S.clear(S.COLOR_BUFFER_BIT),E.bgColor||Ce(()=>{Be({width:we(),height:xe(),quad:new oe(0,0,we()/Yr,xe()/Yr),tex:E.bgTex,fixed:!0})}),E.renderer.numDraws=0,E.fixed=!1,E.transformStack.length=0,E.transform=new Ue}o(dt,"frameStart");function Vt(t,r){E.postShader=t,E.postShaderUniform=r??null}o(Vt,"usePostEffect");function ft(){Pe(),E.lastDrawCalls=E.renderer.numDraws,E.frameBuffer.unbind(),S.viewport(0,0,S.drawingBufferWidth,S.drawingBufferHeight);let t=E.width,r=E.height;E.width=S.drawingBufferWidth/P,E.height=S.drawingBufferHeight/P,We({flipY:!0,tex:E.frameBuffer.tex,pos:new v(E.viewport.x,E.viewport.y),width:E.viewport.width,height:E.viewport.height,shader:E.postShader,uniform:typeof E.postShaderUniform=="function"?E.postShaderUniform():E.postShaderUniform,fixed:!0}),Pe(),E.width=t,E.height=r}o(ft,"frameEnd");function yn(t){return new v(t.x/we()*2-1,-t.y/xe()*2+1)}o(yn,"screen2ndc");function _t(t){E.transform=t.clone()}o(_t,"pushMatrix");function ne(...t){if(t[0]===void 0)return;let r=T(...t);r.x===0&&r.y===0||E.transform.translate(r)}o(ne,"pushTranslate");function He(...t){if(t[0]===void 0)return;let r=T(...t);r.x===1&&r.y===1||E.transform.scale(r)}o(He,"pushScale");function se(t){t&&E.transform.rotate(t)}o(se,"pushRotate");function le(){E.transformStack.push(E.transform.clone())}o(le,"pushTransform");function ae(){E.transformStack.length>0&&(E.transform=E.transformStack.pop())}o(ae,"popTransform");function Be(t){if(t.width===void 0||t.height===void 0)throw new Error('drawUVQuad() requires property "width" and "height".');if(t.width<=0||t.height<=0)return;let r=t.width,s=t.height,a=ut(t.anchor||nn).scale(new v(r,s).scale(-.5)),h=t.quad||new oe(0,0,1,1),f=t.color||J(255,255,255),b=t.opacity??1,g=t.tex?Zr/t.tex.width:0,d=t.tex?Zr/t.tex.height:0,w=h.x+g,A=h.y+d,D=h.w-g*2,N=h.h-d*2;le(),ne(t.pos),se(t.angle),He(t.scale),ne(a),lt([{pos:new v(-r/2,s/2),uv:new v(t.flipX?w+D:w,t.flipY?A:A+N),color:f,opacity:b},{pos:new v(-r/2,-s/2),uv:new v(t.flipX?w+D:w,t.flipY?A+N:A),color:f,opacity:b},{pos:new v(r/2,-s/2),uv:new v(t.flipX?w:w+D,t.flipY?A+N:A),color:f,opacity:b},{pos:new v(r/2,s/2),uv:new v(t.flipX?w:w+D,t.flipY?A:A+N),color:f,opacity:b}],[0,1,3,1,2,3],t.fixed,t.tex,t.shader,t.uniform),ae()}o(Be,"drawUVQuad");function We(t){if(!t.tex)throw new Error('drawTexture() requires property "tex".');let r=t.quad??new oe(0,0,1,1),s=t.tex.width*r.w,u=t.tex.height*r.h,a=new v(1);if(t.tiled){let h=Math.ceil((t.width||s)/s),f=Math.ceil((t.height||u)/u),g=ut(t.anchor||nn).add(new v(1,1)).scale(.5).scale(h*s,f*u);for(let d=0;d({pos:new v(f.x,f.y),uv:new v(0),color:t.color??W.WHITE,opacity:t.opacity??1}));lt(h,[0,1,3,1,2,3],t.fixed,E.defTex,t.shader,t.uniform)}o(l,"drawLine");function x(t){let r=t.pts;if(!r)throw new Error('drawLines() requires property "pts".');if(!(r.length<2))if(t.radius&&r.length>=3){let s=r[0].sdist(r[1]);for(let a=1;a=360&&t.outline){t.fill!==!1&&z(Object.assign(h,{outline:null})),z(Object.assign(h,{pts:a.slice(1),fill:!1}));return}z(h)}o(he,"drawEllipse");function z(t){if(!t.pts)throw new Error('drawPolygon() requires property "pts".');let r=t.pts.length;if(!(r<3)){if(le(),ne(t.pos),He(t.scale),se(t.angle),ne(t.offset),t.fill!==!1){let s=t.color??W.WHITE,u=t.pts.map((h,f)=>({pos:new v(h.x,h.y),uv:new v(0,0),color:t.colors&&t.colors[f]?t.colors[f].mult(s):s,opacity:t.opacity??1})),a=[...Array(r-2).keys()].map(h=>[0,h+1,h+2]).flat();lt(u,t.indices??a,t.fixed,E.defTex,t.shader,t.uniform)}t.outline&&x({pts:[...t.pts,t.pts[0]],radius:t.radius,width:t.outline.width,color:t.outline.color,join:t.outline.join,uniform:t.uniform,fixed:t.fixed,opacity:t.opacity}),ae()}}o(z,"drawPolygon");function Oe(t,r,s){Pe(),S.clear(S.STENCIL_BUFFER_BIT),S.enable(S.STENCIL_TEST),S.stencilFunc(S.NEVER,1,255),S.stencilOp(S.REPLACE,S.REPLACE,S.REPLACE),r(),Pe(),S.stencilFunc(s,1,255),S.stencilOp(S.KEEP,S.KEEP,S.KEEP),t(),Pe(),S.disable(S.STENCIL_TEST)}o(Oe,"drawStenciled");function $e(t,r){Oe(t,r,S.EQUAL)}o($e,"drawMasked");function kt(t,r){Oe(t,r,S.NOTEQUAL)}o(kt,"drawSubtracted");function De(){return(E.viewport.width+E.viewport.height)/(E.width+E.height)}o(De,"getViewportScale");function Ce(t){Pe();let r=E.width,s=E.height;E.width=E.viewport.width,E.height=E.viewport.height,t(),Pe(),E.width=r,E.height=s}o(Ce,"drawUnscaled");function er(t,r){r.pos&&(t.pos=t.pos.add(r.pos)),r.scale&&(t.scale=t.scale.scale(T(r.scale))),r.angle&&(t.angle+=r.angle),r.color&&t.ch.length===1&&(t.color=t.color.mult(r.color)),r.opacity&&(t.opacity*=r.opacity)}o(er,"applyCharTransform");let tr=/\[(?